Exemplo n.º 1
0
        public static void SaveHouseMap(MySql database, string mapID, HouseMap map)
        {
            bool localTransaction = false;

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

            SaveMapDump(database, mapID, map);

            // Save extra data associated with instanced maps
            database.UpdateOrInsert("map_house_data", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "Owner", map.Owner),
                database.CreateColumn(false, "Room", map.Room.ToString()),
                database.CreateColumn(false, "StartX", map.StartX.ToString()),
                database.CreateColumn(false, "StartY", map.StartY.ToString())
            });

            if (localTransaction)
            {
                database.EndTransaction();
            }
        }
Exemplo n.º 2
0
        public static HouseMap LoadHouseMap(MySql database, string mapID)
        {
            if (IsMapIDInUse(database, mapID))
            {
                HouseMap map = new HouseMap(mapID);
                LoadMapDump(database, mapID, map);

                string query             = "SELECT map_house_data.Owner, map_house_data.Room, map_house_data.StartX, map_house_data.StartY FROM map_house_data WHERE map_house_data.MapID = \'" + database.VerifyValueString(mapID) + "\'";
                DataColumnCollection row = database.RetrieveRow(query);
                if (row != null)
                {
                    int counter = 0;
                    map.Owner  = row[counter++].ValueString;
                    map.Room   = Convert.ToInt32(row[counter++].Value);
                    map.StartX = Convert.ToInt32(row[counter++].Value);
                    map.StartY = Convert.ToInt32(row[counter++].Value);
                }
                else
                {
                    throw new Exception("House map data not found");
                }

                return(map);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public static House LoadHouseMap(DatabaseConnection dbConnection, string mapID)
        {
            DataManager.Maps.HouseMap loadedMap = MapDataManager.LoadHouseMap(dbConnection.Database, mapID);
            if (loadedMap != null)
            {
                House map = new House(loadedMap);

                return(map);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public static HouseMap LoadHouseMap(MySql database, string mapID)
        {
            if (IsMapIDInUse(database, mapID)) {
                HouseMap map = new HouseMap(mapID);
                LoadMapDump(database, mapID, map);

                string query = "SELECT map_house_data.Owner, map_house_data.Room, map_house_data.StartX, map_house_data.StartY FROM map_house_data WHERE map_house_data.MapID = \'" + database.VerifyValueString(mapID) + "\'";
                DataColumnCollection row = database.RetrieveRow(query);
                if (row != null) {
                    int counter = 0;
                    map.Owner = row[counter++].ValueString;
                    map.Room = Convert.ToInt32(row[counter++].Value);
                    map.StartX = Convert.ToInt32(row[counter++].Value);
                    map.StartY = Convert.ToInt32(row[counter++].Value);
                } else {
                    throw new Exception("House map data not found");
                }

                return map;
            } else {
                return null;
            }
        }
Exemplo n.º 5
0
        public static void SaveHouseMap(MySql database, string mapID, HouseMap map)
        {
            bool localTransaction = false;
            if (database.IsTransactionActive == false) {
                database.BeginTransaction();
                localTransaction = true;
            }

            SaveMapDump(database, mapID, map);

            // Save extra data associated with instanced maps
            database.UpdateOrInsert("map_house_data", new IDataColumn[] {
                database.CreateColumn(false, "MapID", mapID),
                database.CreateColumn(false, "Owner", map.Owner),
                database.CreateColumn(false, "Room", map.Room.ToString()),
                database.CreateColumn(false, "StartX", map.StartX.ToString()),
                database.CreateColumn(false, "StartY", map.StartY.ToString())
            });

            if (localTransaction) {
                database.EndTransaction();
            }
        }