예제 #1
0
        public MapBase(RawMap rawMap)
        {
            this.rawMap = rawMap;

            Tile = new TileCollection(rawMap);
            Npc = new MapNpcPresetCollection(rawMap);
        }
예제 #2
0
        public MapBase(string mapID)
        {
            rawMap = new RawMap(mapID);

            rawMap.MaxX = 19;
            rawMap.MaxY = 14;
            rawMap.Tile = new DataManager.Maps.Tile[rawMap.MaxX + 1, rawMap.MaxY + 1];
        }
예제 #3
0
        public TileCollection(RawMap rawMap)
        {
            this.rawMap = rawMap;
            tiles = new Tile[rawMap.MaxX + 1, rawMap.MaxY + 1];

            if (rawMap.Tile != null) {
                for (int x = 0; x <= MaxX; x++) {
                    for (int y = 0; y <= MaxY; y++) {
                        if (rawMap.Tile[x, y] == null) {
                            rawMap.Tile[x, y] = new DataManager.Maps.Tile();
                        }
                        tiles[x, y] = new Tile(rawMap.Tile[x, y]);
                    }
                }
            }
        }
예제 #4
0
        public TileCollection(RawMap rawMap, int maxX, int maxY)
        {
            this.rawMap = rawMap;
            rawMap.MaxX = maxX;
            rawMap.MaxY = maxY;

            rawMap.Tile = new DataManager.Maps.Tile[MaxX + 1, MaxY + 1];
            tiles = new Tile[MaxX + 1, MaxY + 1];

            for (int x = 0; x <= MaxX; x++) {
                for (int y = 0; y <= MaxY; y++) {
                    if (rawMap.Tile[x, y] == null) {
                        rawMap.Tile[x, y] = new DataManager.Maps.Tile();
                    }
                    tiles[x, y] = new Tile(rawMap.Tile[x, y]);
                }
            }
        }
예제 #5
0
        public static void SaveRawMap(MySql database, string mapID, RawMap rawMap)
        {
            bool localTransaction = false;

            if (database.IsTransactionActive == false)
            {
                database.BeginTransaction();
                localTransaction = true;
            }

            // Delete old map, if it exists
            DeleteMap(database, mapID);

            // Save map general information
            database.UpdateOrInsert("map_general", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "Revision", rawMap.Revision.ToString()),
                database.CreateColumn(false, "MaxX", rawMap.MaxX.ToString()),
                database.CreateColumn(false, "MaxY", rawMap.MaxY.ToString())
            });

            // Save map data
            database.UpdateOrInsert("map_data", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "Name", rawMap.Name),
                database.CreateColumn(false, "Moral", rawMap.Moral.ToString()),
                database.CreateColumn(false, "Music", rawMap.Music),
                database.CreateColumn(false, "Indoors", rawMap.Indoors.ToIntString()),
                database.CreateColumn(false, "Weather", rawMap.Weather.ToString()),
                database.CreateColumn(false, "Darkness", rawMap.Darkness.ToString()),
                database.CreateColumn(false, "HungerEnabled", rawMap.HungerEnabled.ToIntString()),
                database.CreateColumn(false, "RecruitmentEnabled", rawMap.RecruitEnabled.ToIntString()),
                database.CreateColumn(false, "ExpEnabled", rawMap.ExpEnabled.ToIntString()),
                database.CreateColumn(false, "TimeLimit", rawMap.TimeLimit.ToString()),
                database.CreateColumn(false, "MinNpcs", rawMap.MinNpcs.ToString()),
                database.CreateColumn(false, "MaxNpcs", rawMap.MaxNpcs.ToString()),
                database.CreateColumn(false, "NpcSpawnTime", rawMap.NpcSpawnTime.ToString())
            });

            // Save map switchovers
            database.UpdateOrInsert("map_switchovers", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "UpMap", rawMap.Up.ToString()),
                database.CreateColumn(false, "DownMap", rawMap.Down.ToString()),
                database.CreateColumn(false, "LeftMap", rawMap.Left.ToString()),
                database.CreateColumn(false, "RightMap", rawMap.Right.ToString())
            });

            // Save map npc presets
            MultiRowInsert multiRowInsert = new MultiRowInsert(database, "map_npcs", "MapID", "Slot", "Number", "SpawnX",
                                                               "SpawnY", "MinLevel", "MaxLevel", "AppearanceRate", "StartStatus", "StartStatusCounter", "StartStatusChance");

            if (rawMap.Npc.Count > 0)
            {
                for (int i = 0; i < rawMap.Npc.Count; i++)
                {
                    multiRowInsert.AddRowOpening();

                    multiRowInsert.AddColumnData(mapID);
                    multiRowInsert.AddColumnData(i, rawMap.Npc[i].NpcNum, rawMap.Npc[i].SpawnX, rawMap.Npc[i].SpawnY, rawMap.Npc[i].MinLevel,
                                                 rawMap.Npc[i].MaxLevel, rawMap.Npc[i].AppearanceRate, rawMap.Npc[i].StartStatus, rawMap.Npc[i].StartStatusCounter,
                                                 rawMap.Npc[i].StartStatusChance);

                    multiRowInsert.AddRowClosing();
                }
                database.ExecuteNonQuery(multiRowInsert.GetSqlQuery());
            }

            // Save map tiles
            multiRowInsert.UpdateParameters("map_tiles", new string[] { "MapID", "X", "Y", "Ground", "GroundAnim", "Mask",
                                                                        "MaskAnim", "Mask2", "Mask2Anim", "Fringe", "FringeAnim", "Fringe2", "Fringe2Anim", "Type", "Data1", "Data2", "Data3", "String1",
                                                                        "String2", "String3", "Light", "GroundTileset", "GroundAnimTileset", "MaskTileset", "MaskAnimTileset",
                                                                        "Mask2Tileset", "Mask2AnimTileset", "FringeTileset", "FringeAnimTileset", "Fringe2Tileset", "Fringe2AnimTileset" });

            for (int x = 0; x <= rawMap.MaxX; x++)
            {
                for (int y = 0; y <= rawMap.MaxY; y++)
                {
                    if (rawMap.Tile[x, y] == null)
                    {
                        rawMap.Tile[x, y] = new Tile();
                    }

                    multiRowInsert.AddRowOpening();
                    multiRowInsert.AddColumnData(mapID);
                    multiRowInsert.AddColumnData(x, y);

                    Tile tile = rawMap.Tile[x, y];

                    multiRowInsert.AddColumnData(tile.Ground, tile.GroundAnim, tile.Mask, tile.Anim, tile.Mask2, tile.M2Anim,
                                                 tile.Fringe, tile.FAnim, tile.Fringe2, tile.F2Anim, tile.Type, tile.Data1, tile.Data2, tile.Data3);
                    multiRowInsert.AddColumnData(tile.String1, tile.String2, tile.String3);
                    multiRowInsert.AddColumnData(tile.RDungeonMapValue, tile.GroundSet, tile.GroundAnimSet, tile.MaskSet, tile.AnimSet,
                                                 tile.Mask2Set, tile.M2AnimSet, tile.FringeSet, tile.FAnimSet, tile.Fringe2Set, tile.F2AnimSet);

                    multiRowInsert.AddRowClosing();
                }
            }

            database.ExecuteNonQuery(multiRowInsert.GetSqlQuery());

            if (localTransaction)
            {
                database.EndTransaction();
            }
        }
예제 #6
0
        public static void LoadRawMap(MySql database, string mapID, RawMap rawMap)
        {
            string query = "SELECT map_general.Revision, map_general.MaxX, map_general.MaxY, " +
                           "map_switchovers.UpMap, map_switchovers.DownMap, map_switchovers.LeftMap, map_switchovers.RightMap, " +
                           "map_data.Name, map_data.Moral, map_data.Music, map_data.Indoors, map_data.Weather, " +
                           "map_data.Darkness, map_data.HungerEnabled, map_data.RecruitmentEnabled, map_data.ExpEnabled, map_data.TimeLimit, " +
                           "map_data.MinNpcs, map_data.MaxNpcs, map_data.NpcSpawnTime " +
                           "FROM map_data " +
                           "JOIN map_general ON map_general.MapID = map_data.MapID " +
                           "JOIN map_switchovers ON map_switchovers.MapID = map_data.MapID " +
                           "WHERE map_data.MapID = \'" + database.VerifyValueString(mapID) + "\'";

            {
                // Load general data + switchovers
                DataColumnCollection row = database.RetrieveRow(query);
                if (row != null)
                {
                    int counter = 0;
                    rawMap.Revision       = Convert.ToInt32(row[counter++].Value);
                    rawMap.MaxX           = Convert.ToInt32(row[counter++].Value);
                    rawMap.MaxY           = Convert.ToInt32(row[counter++].Value);
                    rawMap.Up             = Convert.ToInt32(row[counter++].Value);
                    rawMap.Down           = Convert.ToInt32(row[counter++].Value);
                    rawMap.Left           = Convert.ToInt32(row[counter++].Value);
                    rawMap.Right          = Convert.ToInt32(row[counter++].Value);
                    rawMap.Name           = row[counter++].ValueString;
                    rawMap.Moral          = Convert.ToByte(row[counter++].Value);
                    rawMap.Music          = row[counter++].ValueString;
                    rawMap.Indoors        = row[counter++].ValueString.ToBool();
                    rawMap.Weather        = Convert.ToByte(row[counter++].Value);
                    rawMap.Darkness       = Convert.ToInt32(row[counter++].Value);
                    rawMap.HungerEnabled  = row[counter++].ValueString.ToBool();
                    rawMap.RecruitEnabled = row[counter++].ValueString.ToBool();
                    rawMap.ExpEnabled     = row[counter++].ValueString.ToBool();
                    rawMap.TimeLimit      = Convert.ToInt32(row[counter++].Value);
                    rawMap.MinNpcs        = Convert.ToInt32(row[counter++].Value);
                    rawMap.MaxNpcs        = Convert.ToInt32(row[counter++].Value);
                    rawMap.NpcSpawnTime   = Convert.ToInt32(row[counter++].Value);

                    rawMap.Tile = new Tile[rawMap.MaxX + 1, rawMap.MaxY + 1];
                }
                else
                {
                    throw new Exception("Raw map data not found.");
                }
            }

            // Load map npc presets
            query = "SELECT map_npcs.Number, map_npcs.SpawnX, map_npcs.SpawnY, map_npcs.MinLevel, map_npcs.MaxLevel, " +
                    "map_npcs.AppearanceRate, map_npcs.StartStatus, map_npcs.StartStatusCounter, map_npcs.StartStatusChance " +
                    "FROM map_npcs WHERE map_npcs.MapID = \'" + database.VerifyValueString(mapID) + "\' ORDER BY map_npcs.Slot";
            foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query))
            {
                MapNpcPreset mapNpc  = new MapNpcPreset();
                int          counter = 0;
                mapNpc.NpcNum             = Convert.ToInt32(row[counter++].Value);
                mapNpc.SpawnX             = Convert.ToInt32(row[counter++].Value);
                mapNpc.SpawnY             = Convert.ToInt32(row[counter++].Value);
                mapNpc.MinLevel           = Convert.ToInt32(row[counter++].Value);
                mapNpc.MaxLevel           = Convert.ToInt32(row[counter++].Value);
                mapNpc.AppearanceRate     = Convert.ToInt32(row[counter++].Value);
                mapNpc.StartStatus        = Convert.ToInt32(row[counter++].Value);
                mapNpc.StartStatusCounter = Convert.ToInt32(row[counter++].Value);
                mapNpc.StartStatusChance  = Convert.ToInt32(row[counter++].Value);

                rawMap.Npc.Add(mapNpc);
            }

            // Load map tiles
            query = "SELECT map_tiles.X, map_tiles.Y, map_tiles.Ground, map_tiles.GroundAnim, map_tiles.Mask, map_tiles.MaskAnim, " +
                    "map_tiles.Mask2, map_tiles.Mask2Anim, map_tiles.Fringe, map_tiles.FringeAnim, map_tiles.Fringe2, " +
                    "map_tiles.Fringe2Anim, map_tiles.Type, map_tiles.Data1, map_tiles.Data2, map_tiles.Data3, map_tiles.String1, " +
                    "map_tiles.String2, map_tiles.String3, map_tiles.Light, map_tiles.GroundTileset, map_tiles.GroundAnimTileset, " +
                    "map_tiles.MaskTileset, map_tiles.MaskAnimTileset, map_tiles.Mask2Tileset, map_tiles.Mask2AnimTileset, " +
                    "map_tiles.FringeTileset, map_tiles.FringeAnimTileset, map_tiles.Fringe2Tileset, map_tiles.Fringe2AnimTileset " +
                    "FROM map_tiles WHERE map_tiles.MapID = \'" + database.VerifyValueString(mapID) + "\'";
            foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query))
            {
                Tile tile    = new Tile();
                int  counter = 0;
                int  x       = Convert.ToInt32(row[counter++].Value);
                int  y       = Convert.ToInt32(row[counter++].Value);
                tile.Ground           = Convert.ToInt32(row[counter++].Value);
                tile.GroundAnim       = Convert.ToInt32(row[counter++].Value);
                tile.Mask             = Convert.ToInt32(row[counter++].Value);
                tile.Anim             = Convert.ToInt32(row[counter++].Value);
                tile.Mask2            = Convert.ToInt32(row[counter++].Value);
                tile.M2Anim           = Convert.ToInt32(row[counter++].Value);
                tile.Fringe           = Convert.ToInt32(row[counter++].Value);
                tile.FAnim            = Convert.ToInt32(row[counter++].Value);
                tile.Fringe2          = Convert.ToInt32(row[counter++].Value);
                tile.F2Anim           = Convert.ToInt32(row[counter++].Value);
                tile.Type             = Convert.ToInt32(row[counter++].Value);
                tile.Data1            = Convert.ToInt32(row[counter++].Value);
                tile.Data2            = Convert.ToInt32(row[counter++].Value);
                tile.Data3            = Convert.ToInt32(row[counter++].Value);
                tile.String1          = row[counter++].ValueString;
                tile.String2          = row[counter++].ValueString;
                tile.String3          = row[counter++].ValueString;
                tile.RDungeonMapValue = Convert.ToInt32(row[counter++].Value);
                tile.GroundSet        = Convert.ToInt32(row[counter++].Value);
                tile.GroundAnimSet    = Convert.ToInt32(row[counter++].Value);
                tile.MaskSet          = Convert.ToInt32(row[counter++].Value);
                tile.AnimSet          = Convert.ToInt32(row[counter++].Value);
                tile.Mask2Set         = Convert.ToInt32(row[counter++].Value);
                tile.M2AnimSet        = Convert.ToInt32(row[counter++].Value);
                tile.FringeSet        = Convert.ToInt32(row[counter++].Value);
                tile.FAnimSet         = Convert.ToInt32(row[counter++].Value);
                tile.Fringe2Set       = Convert.ToInt32(row[counter++].Value);
                tile.F2AnimSet        = Convert.ToInt32(row[counter++].Value);

                rawMap.Tile[x, y] = tile;
            }

            rawMap.MapID = mapID;
        }
예제 #7
0
        public static void SaveRawMap(MySql database, string mapID, RawMap rawMap)
        {
            bool localTransaction = false;
            if (database.IsTransactionActive == false) {
                database.BeginTransaction();
                localTransaction = true;
            }

            // Delete old map, if it exists
            DeleteMap(database, mapID);

            // Save map general information
            database.UpdateOrInsert("map_general", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "Revision", rawMap.Revision.ToString()),
                database.CreateColumn(false, "MaxX", rawMap.MaxX.ToString()),
                database.CreateColumn(false, "MaxY", rawMap.MaxY.ToString())
            });

            // Save map data
            database.UpdateOrInsert("map_data", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "Name", rawMap.Name),
                database.CreateColumn(false, "Moral", rawMap.Moral.ToString()),
                database.CreateColumn(false, "Music", rawMap.Music),
                database.CreateColumn(false, "Indoors", rawMap.Indoors.ToIntString()),
                database.CreateColumn(false, "Weather", rawMap.Weather.ToString()),
                database.CreateColumn(false, "Darkness", rawMap.Darkness.ToString()),
                database.CreateColumn(false, "HungerEnabled", rawMap.HungerEnabled.ToIntString()),
                database.CreateColumn(false, "RecruitmentEnabled", rawMap.RecruitEnabled.ToIntString()),
                database.CreateColumn(false, "ExpEnabled", rawMap.ExpEnabled.ToIntString()),
                database.CreateColumn(false, "TimeLimit", rawMap.TimeLimit.ToString()),
                database.CreateColumn(false, "MinNpcs", rawMap.MinNpcs.ToString()),
                database.CreateColumn(false, "MaxNpcs", rawMap.MaxNpcs.ToString()),
                database.CreateColumn(false, "NpcSpawnTime", rawMap.NpcSpawnTime.ToString())
            });

            // Save map switchovers
            database.UpdateOrInsert("map_switchovers", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "UpMap", rawMap.Up.ToString()),
                database.CreateColumn(false, "DownMap", rawMap.Down.ToString()),
                database.CreateColumn(false, "LeftMap", rawMap.Left.ToString()),
                database.CreateColumn(false, "RightMap", rawMap.Right.ToString())
            });

            // Save map npc presets
            MultiRowInsert multiRowInsert = new MultiRowInsert(database, "map_npcs", "MapID", "Slot", "Number", "SpawnX",
                "SpawnY", "MinLevel", "MaxLevel", "AppearanceRate", "StartStatus", "StartStatusCounter", "StartStatusChance");

            if (rawMap.Npc.Count > 0) {
                for (int i = 0; i < rawMap.Npc.Count; i++) {
                    multiRowInsert.AddRowOpening();

                    multiRowInsert.AddColumnData(mapID);
                    multiRowInsert.AddColumnData(i, rawMap.Npc[i].NpcNum, rawMap.Npc[i].SpawnX, rawMap.Npc[i].SpawnY, rawMap.Npc[i].MinLevel,
                        rawMap.Npc[i].MaxLevel, rawMap.Npc[i].AppearanceRate, rawMap.Npc[i].StartStatus, rawMap.Npc[i].StartStatusCounter,
                        rawMap.Npc[i].StartStatusChance);

                    multiRowInsert.AddRowClosing();
                }
                database.ExecuteNonQuery(multiRowInsert.GetSqlQuery());
            }

            // Save map tiles
            multiRowInsert.UpdateParameters("map_tiles", new string[] {"MapID", "X", "Y", "Ground", "GroundAnim", "Mask",
                "MaskAnim", "Mask2", "Mask2Anim", "Fringe", "FringeAnim", "Fringe2", "Fringe2Anim", "Type", "Data1", "Data2", "Data3", "String1",
                "String2", "String3", "Light", "GroundTileset", "GroundAnimTileset", "MaskTileset", "MaskAnimTileset",
                "Mask2Tileset", "Mask2AnimTileset", "FringeTileset", "FringeAnimTileset", "Fringe2Tileset", "Fringe2AnimTileset" });

            for (int x = 0; x <= rawMap.MaxX; x++) {
                for (int y = 0; y <= rawMap.MaxY; y++) {
                    if (rawMap.Tile[x, y] == null) {
                        rawMap.Tile[x, y] = new Tile();
                    }

                    multiRowInsert.AddRowOpening();
                    multiRowInsert.AddColumnData(mapID);
                    multiRowInsert.AddColumnData(x, y);

                    Tile tile = rawMap.Tile[x, y];

                    multiRowInsert.AddColumnData(tile.Ground, tile.GroundAnim, tile.Mask, tile.Anim, tile.Mask2, tile.M2Anim,
                        tile.Fringe, tile.FAnim, tile.Fringe2, tile.F2Anim, tile.Type, tile.Data1, tile.Data2, tile.Data3);
                    multiRowInsert.AddColumnData(tile.String1, tile.String2, tile.String3);
                    multiRowInsert.AddColumnData(tile.RDungeonMapValue, tile.GroundSet, tile.GroundAnimSet, tile.MaskSet, tile.AnimSet,
                        tile.Mask2Set, tile.M2AnimSet, tile.FringeSet, tile.FAnimSet, tile.Fringe2Set, tile.F2AnimSet);

                    multiRowInsert.AddRowClosing();
                }
            }

            database.ExecuteNonQuery(multiRowInsert.GetSqlQuery());

            if (localTransaction) {
                database.EndTransaction();
            }
        }
예제 #8
0
        public static void LoadRawMap(MySql database, string mapID, RawMap rawMap)
        {
            string query = "SELECT map_general.Revision, map_general.MaxX, map_general.MaxY, " +
                "map_switchovers.UpMap, map_switchovers.DownMap, map_switchovers.LeftMap, map_switchovers.RightMap, " +
                "map_data.Name, map_data.Moral, map_data.Music, map_data.Indoors, map_data.Weather, " +
                "map_data.Darkness, map_data.HungerEnabled, map_data.RecruitmentEnabled, map_data.ExpEnabled, map_data.TimeLimit, " +
                "map_data.MinNpcs, map_data.MaxNpcs, map_data.NpcSpawnTime " +
                "FROM map_data " +
                "JOIN map_general ON map_general.MapID = map_data.MapID " +
                "JOIN map_switchovers ON map_switchovers.MapID = map_data.MapID " +
                "WHERE map_data.MapID = \'" + database.VerifyValueString(mapID) + "\'";

            {
                // Load general data + switchovers
                DataColumnCollection row = database.RetrieveRow(query);
                if (row != null) {
                    int counter = 0;
                    rawMap.Revision = Convert.ToInt32(row[counter++].Value);
                    rawMap.MaxX = Convert.ToInt32(row[counter++].Value);
                    rawMap.MaxY = Convert.ToInt32(row[counter++].Value);
                    rawMap.Up = Convert.ToInt32(row[counter++].Value);
                    rawMap.Down = Convert.ToInt32(row[counter++].Value);
                    rawMap.Left = Convert.ToInt32(row[counter++].Value);
                    rawMap.Right = Convert.ToInt32(row[counter++].Value);
                    rawMap.Name = row[counter++].ValueString;
                    rawMap.Moral = Convert.ToByte(row[counter++].Value);
                    rawMap.Music = row[counter++].ValueString;
                    rawMap.Indoors = row[counter++].ValueString.ToBool();
                    rawMap.Weather = Convert.ToByte(row[counter++].Value);
                    rawMap.Darkness = Convert.ToInt32(row[counter++].Value);
                    rawMap.HungerEnabled = row[counter++].ValueString.ToBool();
                    rawMap.RecruitEnabled = row[counter++].ValueString.ToBool();
                    rawMap.ExpEnabled = row[counter++].ValueString.ToBool();
                    rawMap.TimeLimit = Convert.ToInt32(row[counter++].Value);
                    rawMap.MinNpcs = Convert.ToInt32(row[counter++].Value);
                    rawMap.MaxNpcs = Convert.ToInt32(row[counter++].Value);
                    rawMap.NpcSpawnTime = Convert.ToInt32(row[counter++].Value);

                    rawMap.Tile = new Tile[rawMap.MaxX + 1, rawMap.MaxY + 1];
                } else {
                    throw new Exception("Raw map data not found.");
                }
            }

            // Load map npc presets
            query = "SELECT map_npcs.Number, map_npcs.SpawnX, map_npcs.SpawnY, map_npcs.MinLevel, map_npcs.MaxLevel, " +
                "map_npcs.AppearanceRate, map_npcs.StartStatus, map_npcs.StartStatusCounter, map_npcs.StartStatusChance " +
                "FROM map_npcs WHERE map_npcs.MapID = \'" + database.VerifyValueString(mapID) + "\' ORDER BY map_npcs.Slot";
            foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) {
                MapNpcPreset mapNpc = new MapNpcPreset();
                int counter = 0;
                mapNpc.NpcNum = Convert.ToInt32(row[counter++].Value);
                mapNpc.SpawnX = Convert.ToInt32(row[counter++].Value);
                mapNpc.SpawnY = Convert.ToInt32(row[counter++].Value);
                mapNpc.MinLevel = Convert.ToInt32(row[counter++].Value);
                mapNpc.MaxLevel = Convert.ToInt32(row[counter++].Value);
                mapNpc.AppearanceRate = Convert.ToInt32(row[counter++].Value);
                mapNpc.StartStatus = Convert.ToInt32(row[counter++].Value);
                mapNpc.StartStatusCounter = Convert.ToInt32(row[counter++].Value);
                mapNpc.StartStatusChance = Convert.ToInt32(row[counter++].Value);

                rawMap.Npc.Add(mapNpc);
            }

            // Load map tiles
            query = "SELECT map_tiles.X, map_tiles.Y, map_tiles.Ground, map_tiles.GroundAnim, map_tiles.Mask, map_tiles.MaskAnim, " +
                "map_tiles.Mask2, map_tiles.Mask2Anim, map_tiles.Fringe, map_tiles.FringeAnim, map_tiles.Fringe2, " +
                "map_tiles.Fringe2Anim, map_tiles.Type, map_tiles.Data1, map_tiles.Data2, map_tiles.Data3, map_tiles.String1, " +
                "map_tiles.String2, map_tiles.String3, map_tiles.Light, map_tiles.GroundTileset, map_tiles.GroundAnimTileset, " +
                "map_tiles.MaskTileset, map_tiles.MaskAnimTileset, map_tiles.Mask2Tileset, map_tiles.Mask2AnimTileset, " +
                "map_tiles.FringeTileset, map_tiles.FringeAnimTileset, map_tiles.Fringe2Tileset, map_tiles.Fringe2AnimTileset " +
                "FROM map_tiles WHERE map_tiles.MapID = \'" + database.VerifyValueString(mapID) + "\'";
            foreach (DataColumnCollection row in database.RetrieveRowsEnumerable(query)) {
                Tile tile = new Tile();
                int counter = 0;
                int x = Convert.ToInt32(row[counter++].Value);
                int y = Convert.ToInt32(row[counter++].Value);
                tile.Ground = Convert.ToInt32(row[counter++].Value);
                tile.GroundAnim = Convert.ToInt32(row[counter++].Value);
                tile.Mask = Convert.ToInt32(row[counter++].Value);
                tile.Anim = Convert.ToInt32(row[counter++].Value);
                tile.Mask2 = Convert.ToInt32(row[counter++].Value);
                tile.M2Anim = Convert.ToInt32(row[counter++].Value);
                tile.Fringe = Convert.ToInt32(row[counter++].Value);
                tile.FAnim = Convert.ToInt32(row[counter++].Value);
                tile.Fringe2 = Convert.ToInt32(row[counter++].Value);
                tile.F2Anim = Convert.ToInt32(row[counter++].Value);
                tile.Type = Convert.ToInt32(row[counter++].Value);
                tile.Data1 = Convert.ToInt32(row[counter++].Value);
                tile.Data2 = Convert.ToInt32(row[counter++].Value);
                tile.Data3 = Convert.ToInt32(row[counter++].Value);
                tile.String1 = row[counter++].ValueString;
                tile.String2 = row[counter++].ValueString;
                tile.String3 = row[counter++].ValueString;
                tile.RDungeonMapValue = Convert.ToInt32(row[counter++].Value);
                tile.GroundSet = Convert.ToInt32(row[counter++].Value);
                tile.GroundAnimSet = Convert.ToInt32(row[counter++].Value);
                tile.MaskSet = Convert.ToInt32(row[counter++].Value);
                tile.AnimSet = Convert.ToInt32(row[counter++].Value);
                tile.Mask2Set = Convert.ToInt32(row[counter++].Value);
                tile.M2AnimSet = Convert.ToInt32(row[counter++].Value);
                tile.FringeSet = Convert.ToInt32(row[counter++].Value);
                tile.FAnimSet = Convert.ToInt32(row[counter++].Value);
                tile.Fringe2Set = Convert.ToInt32(row[counter++].Value);
                tile.F2AnimSet = Convert.ToInt32(row[counter++].Value);

                rawMap.Tile[x, y] = tile;
            }

            rawMap.MapID = mapID;
        }