/// <summary> /// Create a new game map with the specified information. /// </summary> /// <param name="aMapId">The unique ID of the map</param> /// <param name="aInfo">The object containing the info</param> /// <returns>True on success, false otherwise</returns> public static bool CreateMap(UInt32 aMapId, GameMap.Info aInfo) { bool success = true; lock (sGameMaps) { if (!sGameMaps.ContainsKey(aMapId)) { if (sMaps.ContainsKey(aInfo.DocId)) { GameMap map = new GameMap(aMapId, aInfo, sMaps[aInfo.DocId]); sGameMaps.Add(aMapId, map); sLogger.Info("Created game map {0} with data of {1}.", map.Id, map.DocId); } else { sLogger.Error("Missing map data for doc ID {0}. The map {1} won't be created.", aInfo.DocId, aMapId); success = false; } } else { sLogger.Error("Duplicated map {0}.", aMapId); success = false; } } return(success); }
public static void GetAllMaps() { sLogger.Info("Loading all maps in memory..."); using (var connection = sDefaultPool.GetConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = "SELECT `id`, `doc_id`, `type`, `weather`, `portal_x`, `portal_y`, `reborn_map`, `reborn_portal`, `light` FROM `map`"; command.Prepare(); sLogger.Debug("Executing SQL: {0}", GetSqlCommand(command)); using (var reader = command.ExecuteReader()) { while (reader.Read()) { UInt32 mapId = reader.GetUInt32("id"); GameMap.Info info = new GameMap.Info { DocId = reader.GetUInt16("doc_id"), Type = reader.GetUInt32("type"), Weather = (WeatherType)reader.GetUInt32("weather"), PortalX = reader.GetUInt16("portal_x"), PortalY = reader.GetUInt16("portal_y"), RebornMap = reader.GetUInt32("reborn_map"), Light = reader.GetUInt32("light") }; if (!MapManager.CreateMap(mapId, info)) { sLogger.Error("Failed to create map {0}.", mapId); } } } } } }
public GameMap(UInt32 aMapId, GameMap.Info aInfo, MapData aData) { mId = aMapId; mInfo = aInfo; mData = aData; }