/// <summary> /// Creates a new piece of crime data. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> /// <param name="type"></param> /// <returns></returns> static Crime CreateCrime(CharData ch, CharData victim, int type) { Log.Trace("Create crime called."); Crime crime = new Crime(); Database.CrimeList.Add(crime); crime.Criminal = ch.Name; crime.Victim = victim.Name; crime.Time = Database.SystemData.CurrentTime; crime.CrimeType = type; crime.Zone = ch.InRoom.Area.Filename; return(crime); }
/// <summary> /// Creates a new piece of crime data. /// </summary> /// <param name="ch"></param> /// <param name="victim"></param> /// <param name="type"></param> /// <returns></returns> static Crime CreateCrime( CharData ch, CharData victim, int type ) { Log.Trace( "Create crime called." ); Crime crime = new Crime(); Database.CrimeList.Add( crime ); crime.Criminal = ch.Name; crime.Victim = victim.Name; crime.Time = Database.SystemData.CurrentTime; crime.CrimeType = type; crime.Zone = ch.InRoom.Area.Filename; return crime; }
/// <summary> /// Loads the entire MUD database including all classes, races, areas, helps, sytem data, etc. /// </summary> public void LoadDatabase() { DatabaseIsBooting = true; Log.Trace(DateTime.Now.ToShortDateString() + " BOOT: -------------------------[ Boot Log ]-------------------------"); Log.Trace("Validating that player directories exist."); for (Char letter = 'a'; letter <= 'z'; letter++) { String directory = FileLocation.PlayerDirectory + letter; if (!Directory.Exists(directory)) { Log.Trace("Creating directory: " + directory + "."); Directory.CreateDirectory(directory); } } Log.Trace("Player directories validated."); Log.Trace("Loading Database.SystemData."); Sysdata.Load(); SystemData.CurrentTime = DateTime.Now; SystemData.GameBootTime = SystemData.CurrentTime; // Set time and weather. Log.Trace("Setting time and weather."); SystemData.SetWeather(); Log.Trace("Loading static rooms."); StaticRooms.Load(); Log.Trace("Loaded " + StaticRooms.Count + " static rooms."); Log.Trace("Loading spells."); Spell.LoadSpells(); Log.Trace("Loaded " + Spell.SpellList.Count + " spells."); Log.Trace("Loading skills."); Skill.LoadSkills(); Log.Trace("Loaded " + Skill.SkillList.Count + " skills."); Log.Trace("Loading races."); Race.LoadRaces(); Log.Trace("Loaded " + Race.Count + " races."); Log.Trace("Initializing skill Levels."); { int cclass; foreach (KeyValuePair <String, Skill> kvp in Skill.SkillList) { for (cclass = 0; cclass < CharClass.ClassList.Length; cclass++) { kvp.Value.ClassAvailability[cclass] = Limits.LEVEL_LESSER_GOD; } } foreach (KeyValuePair <String, Spell> kvp in Spell.SpellList) { for (cclass = 0; cclass < CharClass.ClassList.Length; cclass++) { kvp.Value.SpellCircle[cclass] = Limits.MAX_CIRCLE + 3; } } } Log.Trace("Loading classes."); CharClass.LoadClasses(true); Log.Trace("Loaded " + CharClass.Count + " classes."); Log.Trace("Assigning spell circles."); AssignSpellCircles(); Log.Trace("Assigned spell circles."); Log.Trace("Loading socials."); SocialList = Socials.Load(); Log.Trace("Loaded " + Social.Count + " socials."); Log.Trace("Loading bans."); LoadBans(); Log.Trace("Loaded " + BanList.Count + " bans."); Log.Trace("Loading help entries."); HelpList = Help.Load(FileLocation.SystemDirectory + FileLocation.HelpFile); Log.Trace("Loaded " + Help.Count + " help entries."); Log.Trace("Loading screens."); Screen.Load(FileLocation.SystemDirectory + FileLocation.ScreenFile, FileLocation.BlankSystemFileDirectory + FileLocation.ScreenFile); Log.Trace("Loaded " + Screen.Count + " screens."); // Chatbots have to be loaded before mobs. Log.Trace("Loading chatbots."); ChatterBot.Load(); Log.Trace("Loaded " + ChatterBot.Count + " chatbots."); // Read in all the area files. Log.Trace("Reading in area files..."); LoadAreaFiles(); Log.Trace("Loaded " + Area.Count + " areas."); string buf = String.Format("Loaded {0} mobs, {1} objects, {2} rooms, {3} shops, {4} helps, {5} resets, and {6} quests.", MobTemplate.Count, ObjTemplate.Count, Room.Count, Shop.Count, Help.Count, Reset.Count, QuestData.Count); Log.Trace(buf); Log.Trace("Loading guilds."); Guild.LoadGuilds(); Log.Trace("Loaded " + Guild.Count + " guilds."); Log.Trace("Loading corpses."); CorpseList = CorpseData.Load(); Log.Trace("Loaded " + CorpseData.Count + " corpses."); Log.Trace("Loading crimes."); Crime.Load(); Log.Trace("Loaded " + Crime.Count + " crimes."); Log.Trace("Loading fraglist."); FraglistData.Fraglist.Load(); Log.Trace("Loading issues."); Issue.Load(); Log.Trace("Loaded " + Issue.Count + " issues."); Log.Trace("Loading bounties."); Bounty.Load(); Log.Trace("Loaded " + Bounty.Count + " bounties."); Log.Trace("Initializing movement parameters."); Movement.Initialize(); Log.Trace("Movement parameters initialized."); // Only compile spells that have attached code. Otherwise use default handlers. Log.Trace("Compiling spells."); int good = 0; int bad = 0; foreach (KeyValuePair <String, Spell> kvp in Spell.SpellList) { if (!String.IsNullOrEmpty(kvp.Value.Code)) { if (!SpellFunction.CompileSpell(kvp.Value)) { ++bad; } else { ++good; } } } Log.Trace("Done compiling spells. " + good + " were successful, " + bad + " failed."); // Links up exits and makes rooms runtime-ready so we can access them. Log.Trace("Linking exits."); LinkExits(); // This has to be after LinkExits(). Log.Trace("Loading zone connections."); ZoneConnectionList = ZoneConnection.Load(); // Link zones together based on file. foreach (ZoneConnection connection in ZoneConnectionList) { RoomTemplate room1 = Room.GetRoom(connection.FirstRoomNumber); RoomTemplate room2 = Room.GetRoom(connection.SecondRoomNumber); Exit.Direction direction = connection.FirstToSecondDirection; if (room1 != null && room2 != null && direction != Exit.Direction.invalid) { Exit exit = new Exit(); exit.TargetRoom = room2; exit.IndexNumber = connection.SecondRoomNumber; room1.ExitData[(int)direction] = exit; exit = new Exit(); exit.TargetRoom = room1; exit.IndexNumber = connection.FirstRoomNumber; room2.ExitData[(int)Exit.ReverseDirection(direction)] = exit; Log.Trace("Connected " + room1.Area.Name + " to " + room2.Area.Name + " at " + room1.IndexNumber); } else { Log.Error("Unable to connect room " + connection.FirstRoomNumber + " to " + connection.SecondRoomNumber + " in direction " + connection.FirstToSecondDirection); } } Log.Trace("Loaded " + ZoneConnectionList.Count + " zone connections."); DatabaseIsBooting = false; Log.Trace("Resetting areas."); AreaUpdate(); Log.Trace("Creating events."); Event.CreateEvent(Event.EventType.save_corpses, Event.TICK_SAVE_CORPSES, null, null, null); Event.CreateEvent(Event.EventType.save_sysdata, Event.TICK_SAVE_SYSDATA, null, null, null); Event.CreateEvent(Event.EventType.violence_update, Event.TICK_COMBAT_UPDATE, null, null, null); Event.CreateEvent(Event.EventType.area_update, Event.TICK_AREA, null, null, null); Event.CreateEvent(Event.EventType.room_update, Event.TICK_ROOM, null, null, null); Event.CreateEvent(Event.EventType.object_special, Event.TICK_OBJECT, null, null, null); Event.CreateEvent(Event.EventType.mobile_update, Event.TICK_MOBILE, null, null, null); Event.CreateEvent(Event.EventType.weather_update, Event.TICK_WEATHER, null, null, null); Event.CreateEvent(Event.EventType.char_update, Event.TICK_CHAR_UPDATE, null, null, null); Event.CreateEvent(Event.EventType.object_update, Event.TICK_OBJ_UPDATE, null, null, null); Event.CreateEvent(Event.EventType.aggression_update, Event.TICK_AGGRESS, null, null, null); Event.CreateEvent(Event.EventType.memorize_update, Event.TICK_MEMORIZE, null, null, null); Event.CreateEvent(Event.EventType.hit_gain, Event.TICK_HITGAIN, null, null, null); Event.CreateEvent(Event.EventType.mana_gain, Event.TICK_MANAGAIN, null, null, null); Event.CreateEvent(Event.EventType.move_gain, Event.TICK_MOVEGAIN, null, null, null); Event.CreateEvent(Event.EventType.heartbeat, Event.TICK_WEATHER, null, null, null); return; }