public static void LoadMapDump(MySql database, string mapID, MapDump mapDump) { // First, load the raw map data LoadRawMap(database, mapID, mapDump); mapID = database.VerifyValueString(mapID); // Load map state data string query = "SELECT mapstate_data.ActivationTime, mapstate_data.ProcessingPaused, mapstate_data.SpawnMarker, " + "mapstate_data.NpcSpawnWait, mapstate_data.TempChange, mapstate_data.CurrentWeather " + "FROM mapstate_data WHERE mapstate_data.MapID = \'" + mapID + "\'"; ; { DataColumnCollection row = database.RetrieveRow(query); if (row != null) { int counter = 0; mapDump.ActivationTime = Convert.ToInt32(row[counter++].Value); mapDump.ProcessingPaused = row[counter++].ValueString.ToBool(); mapDump.SpawnMarker = Convert.ToInt32(row[counter++].Value); mapDump.NpcSpawnWait = Convert.ToInt32(row[counter++].Value); mapDump.TempChange = row[counter++].ValueString.ToBool(); mapDump.CurrentWeather = Convert.ToByte(row[counter++].Value); } else { throw new Exception("Map state data not found"); } } { // Load map active items query = "SELECT mapstate_activeitem.Slot, mapstate_activeitem.Number, mapstate_activeitem.Value, mapstate_activeitem.Sticky, " + "mapstate_activeitem.Tag, mapstate_activeitem.Hidden, mapstate_activeitem.X, mapstate_activeitem.Y, " + "mapstate_activeitem.TimeRemaining, mapstate_activeitem.ItemOwner " + "FROM mapstate_activeitem WHERE mapstate_activeitem.MapID = \'" + mapID + "\'"; foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { MapItem mapItem = new MapItem(); int counter = 0; int slot = Convert.ToInt32(row[counter++].Value); mapItem.Num = Convert.ToInt32(row[counter++].Value); mapItem.Value = Convert.ToInt32(row[counter++].Value); mapItem.Sticky = row[counter++].ValueString.ToBool(); mapItem.Tag = row[counter++].ValueString; mapItem.Hidden = row[counter++].ValueString.ToBool(); mapItem.X = Convert.ToInt32(row[counter++].Value); mapItem.Y = Convert.ToInt32(row[counter++].Value); mapItem.TimeRemaining = Convert.ToInt32(row[counter++].Value); mapItem.PlayerFor = row[counter++].ValueString; mapDump.ActiveItem[slot] = mapItem; } } { // Load map active npcs query = "SELECT mapstate_activenpc_data.MapNpcSlot, mapstate_activenpc_data.Name, mapstate_activenpc_data.Shiny, mapstate_activenpc_data.Form, " + "mapstate_activenpc_data.Level, mapstate_activenpc_data.NpcNumber, mapstate_activenpc_data.Sex, " + "mapstate_activenpc_data.AttackTimer, mapstate_activenpc_data.PauseTimer, mapstate_activenpc_data.StatusAilment, " + "mapstate_activenpc_data.StatusAilmentCounter, mapstate_activenpc_data.HPStepCounter, " + "mapstate_activenpc_data.Target, " + "mapstate_activenpc_location.X, mapstate_activenpc_location.Y, mapstate_activenpc_location.Direction, " + "mapstate_activenpc_stats.IQ, mapstate_activenpc_stats.HP, mapstate_activenpc_stats.HPRemainder, " + "mapstate_activenpc_stats.MaxHPBonus, mapstate_activenpc_stats.AtkBonus, mapstate_activenpc_stats.DefBonus, " + "mapstate_activenpc_stats.SpdBonus, mapstate_activenpc_stats.SpclAtkBonus, mapstate_activenpc_stats.SpclDefBonus, " + "mapstate_activenpc_stats.AttackBuff, " + "mapstate_activenpc_stats.DefenseBuff, mapstate_activenpc_stats.SpAtkBuff, mapstate_activenpc_stats.SpDefBuff, mapstate_activenpc_stats.SpeedBuff, " + "mapstate_activenpc_stats.AccuracyBuff, mapstate_activenpc_stats.EvasionBuff " + "FROM mapstate_activenpc_data " + "LEFT OUTER JOIN mapstate_activenpc_location ON mapstate_activenpc_data.MapID = mapstate_activenpc_location.MapID AND mapstate_activenpc_data.MapNpcSlot = mapstate_activenpc_location.MapNpcSlot " + "JOIN mapstate_activenpc_stats ON mapstate_activenpc_data.MapID = mapstate_activenpc_stats.MapID AND mapstate_activenpc_data.MapNpcSlot = mapstate_activenpc_stats.MapNpcSlot " + "WHERE mapstate_activenpc_data.MapID = \'" + mapID + "\'"; foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { int counter = 0; int slot = Convert.ToInt32(row[counter++].Value); MapNpc npc = new MapNpc(slot); npc.Name = row[counter++].ValueString; npc.Shiny = Convert.ToByte(row[counter++].Value); npc.Form = Convert.ToInt32(row[counter++].Value); npc.Level = Convert.ToInt32(row[counter++].Value); npc.Num = Convert.ToInt32(row[counter++].Value); //npc.Sprite = Convert.ToInt32(row[counter++].Value); npc.Sex = Convert.ToByte(row[counter++].Value); //npc.Type1 = Convert.ToByte(row[counter++].Value); //npc.Type2 = Convert.ToByte(row[counter++].Value); //npc.Ability1 = row[counter++].ValueString; //npc.Ability2 = row[counter++].ValueString; //npc.Ability3 = row[counter++].ValueString; //npc.TimeMultiplier = Convert.ToInt32(row[counter++].Value); npc.AttackTimer = Convert.ToInt32(row[counter++].Value); npc.PauseTimer = Convert.ToInt32(row[counter++].Value); npc.StatusAilment = Convert.ToByte(row[counter++].Value); npc.StatusAilmentCounter = Convert.ToInt32(row[counter++].Value); npc.HPStepCounter = Convert.ToInt32(row[counter++].Value); //npc.ConfusionStepCounter = Convert.ToInt32(row[counter++].Value); //npc.SpeedLimit = Convert.ToByte(row[counter++].Value); npc.Target = row[counter++].ValueString; //npc.ItemActive = row[counter++].ValueString.ToBool(); // Load location data npc.X = Convert.ToInt32(row[counter++].Value); npc.Y = Convert.ToInt32(row[counter++].Value); npc.Direction = Convert.ToByte(row[counter++].Value); // Load stat data npc.IQ = Convert.ToInt32(row[counter++].Value); npc.HP = Convert.ToInt32(row[counter++].Value); npc.HPRemainder = Convert.ToInt32(row[counter++].Value); //npc.BaseMaxHP = Convert.ToInt32(row[counter++].Value); //npc.BaseAtk = Convert.ToInt32(row[counter++].Value); //npc.BaseDef = Convert.ToInt32(row[counter++].Value); //npc.BaseSpd = Convert.ToInt32(row[counter++].Value); //npc.BaseSpclAtk = Convert.ToInt32(row[counter++].Value); //npc.BaseSpclDef = Convert.ToInt32(row[counter++].Value); //npc.MaxHPBonus = Convert.ToInt32(row[counter++].Value); npc.AtkBonus = Convert.ToInt32(row[counter++].Value); npc.DefBonus = Convert.ToInt32(row[counter++].Value); npc.SpdBonus = Convert.ToInt32(row[counter++].Value); npc.SpclAtkBonus = Convert.ToInt32(row[counter++].Value); npc.SpclDefBonus = Convert.ToInt32(row[counter++].Value); //npc.MaxHPBoost = Convert.ToInt32(row[counter++].Value); //npc.AtkBoost = Convert.ToInt32(row[counter++].Value); //npc.DefBoost = Convert.ToInt32(row[counter++].Value); //npc.SpdBoost = Convert.ToInt32(row[counter++].Value); //npc.SpclAtkBoost = Convert.ToInt32(row[counter++].Value); //npc.SpclDefBoost = Convert.ToInt32(row[counter++].Value); npc.AttackBuff = Convert.ToInt32(row[counter++].Value); npc.DefenseBuff = Convert.ToInt32(row[counter++].Value); npc.SpAtkBuff = Convert.ToInt32(row[counter++].Value); npc.SpDefBuff = Convert.ToInt32(row[counter++].Value); npc.SpeedBuff = Convert.ToInt32(row[counter++].Value); npc.AccuracyBuff = Convert.ToInt32(row[counter++].Value); npc.EvasionBuff = Convert.ToInt32(row[counter++].Value); mapDump.ActiveNpc[slot] = npc; } query = "SELECT mapstate_activenpc_helditem.MapNpcSlot, mapstate_activenpc_helditem.ItemNumber, mapstate_activenpc_helditem.Amount, " + "mapstate_activenpc_helditem.Sticky, mapstate_activenpc_helditem.Tag " + "FROM mapstate_activenpc_helditem " + "WHERE mapstate_activenpc_helditem.MapID = \'" + mapID + "\'"; foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { int counter = 0; int slot = Convert.ToInt32(row[counter++].Value); MapNpc npc = new MapNpc(slot); // Load held item { int heldItemNum = Convert.ToInt32(row[counter++].Value); if (heldItemNum > 0) { // The npc has a held item! Continue loading it npc.HeldItem = new Characters.InventoryItem(); npc.HeldItem.Num = heldItemNum; npc.HeldItem.Amount = Convert.ToInt32(row[counter++].Value); npc.HeldItem.Sticky = row[counter++].ValueString.ToBool(); npc.HeldItem.Tag = row[counter++].ValueString; } else { // No held item - skip loading the other values npc.HeldItem = new Characters.InventoryItem(); counter += 3; } } mapDump.ActiveNpc[slot] = npc; } query = "SELECT mapstate_activenpc_moves.MapNpcSlot, mapstate_activenpc_moves.MoveSlot, mapstate_activenpc_moves.CurrentPP, " + "mapstate_activenpc_moves.MaxPP, mapstate_activenpc_moves.MoveNum " + "FROM mapstate_activenpc_moves WHERE mapstate_activenpc_moves.MapID = \'" + mapID + "\'"; foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { int counter = 0; int slot = Convert.ToInt32(row[counter++].Value); int moveSlot = Convert.ToInt32(row[counter++].Value); Characters.Move move = new Characters.Move(); move.CurrentPP = Convert.ToInt32(row[counter++].Value); move.MaxPP = Convert.ToInt32(row[counter++].Value); move.MoveNum = Convert.ToInt32(row[counter++].Value); //move.Sealed = row[counter++].ValueString.ToBool(); mapDump.ActiveNpc[slot].Moves[moveSlot] = move; } //query = "SELECT mapstate_activenpc_mobility.MapNpcSlot, mapstate_activenpc_mobility.MobilitySlot, mapstate_activenpc_mobility.Mobile " + // "FROM mapstate_activenpc_mobility WHERE mapstate_activenpc_mobility.MapID = \'" + mapID + "\'"; //foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { // int counter = 0; // int slot = Convert.ToInt32(row[counter++].Value); // int mobilitySlot = Convert.ToInt32(row[counter++].Value); // mapDump.ActiveNpc[slot].Mobility[mobilitySlot] = row[counter++].ValueString.ToBool(); //} query = "SELECT mapstate_activenpc_volatilestatus.MapNpcSlot, mapstate_activenpc_volatilestatus.Name, " + "mapstate_activenpc_volatilestatus.Emoticon, mapstate_activenpc_volatilestatus.Counter, mapstate_activenpc_volatilestatus.Tag " + "FROM mapstate_activenpc_volatilestatus WHERE mapstate_activenpc_volatilestatus.MapID = \'" + mapID + "\' ORDER BY mapstate_activenpc_volatilestatus.StatusIndex"; foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { int counter = 0; int slot = Convert.ToInt32(row[counter++].Value); Characters.VolatileStatus status = new Characters.VolatileStatus(); status.Name = row[counter++].ValueString; status.Emoticon = Convert.ToInt32(row[counter++].Value); status.Counter = Convert.ToInt32(row[counter++].ValueString); status.Tag = row[counter++].ValueString; mapDump.ActiveNpc[slot].VolatileStatus.Add(status); } } // Load map status query = "SELECT mapstate_mapstatus.StatusIndex, mapstate_mapstatus.Name, mapstate_mapstatus.Tag, mapstate_mapstatus.GraphicEffect, mapstate_mapstatus.Tag, mapstate_mapstatus.Counter " + "FROM mapstate_mapstatus WHERE mapstate_mapstatus.MapID = \'" + mapID + "\' ORDER BY mapstate_mapstatus.StatusIndex"; foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) { MapStatus status = new MapStatus(); int counter = 1; status.Name = row[counter++].ValueString; status.Tag = row[counter++].ValueString; status.GraphicEffect = Convert.ToInt32(row[counter++].ValueString); status.Counter = Convert.ToInt32(row.FindByName("Counter").Value); mapDump.TempStatus.Add(status); } }