public static Map GetActiveMap(int pMapIdentifier) { Map map = sActiveMaps.GetOrDefault(pMapIdentifier, null); if (map == null) { MapData mapData = GetMapData(pMapIdentifier); if (mapData != null) { map = new Map(mapData); sActiveMaps.Add(pMapIdentifier, map); } } return map; }
public Player(Client pClient, DatabaseQuery pQuery) { mClient = pClient; mRandom = new Random(); mIdentifier = (int)pQuery["identifier"]; mName = (string)pQuery["name"]; mGender = (byte)pQuery["gender"]; mSkin = (byte)pQuery["skin"]; mEyesIdentifier = (int)pQuery["eyes_identifier"]; mHairIdentifier = (int)pQuery["hair_identifier"]; mLevel = (byte)pQuery["level"]; mJob = (ushort)pQuery["job"]; mStrength = (ushort)pQuery["strength"]; mDexterity = (ushort)pQuery["dexterity"]; mIntellect = (ushort)pQuery["intellect"]; mLuck = (ushort)pQuery["luck"]; mHealth = (ushort)pQuery["health"]; mMaxHealth = (ushort)pQuery["max_health"]; mMana = (ushort)pQuery["mana"]; mMaxMana = (ushort)pQuery["max_mana"]; mAbilityPoints = (ushort)pQuery["ability_points"]; mSkillPoints = (ushort)pQuery["skill_points"]; mExperience = (int)pQuery["experience"]; mFame = (ushort)pQuery["fame"]; int mapIdentifier = (int)pQuery["map_identifier"]; MapData mapData = Server.GetMapData(mapIdentifier); byte spawn = (byte)pQuery["map_spawn"]; if (mapData.ForcedReturnMapIdentifier != MapData.INVALID_MAP_IDENTIFIER) { mapData = Server.GetMapData(mapData.ForcedReturnMapIdentifier); spawn = 0; if (mHealth == 0) mHealth = 50; } else if (mHealth == 0) { mapData = Server.GetMapData(mapData.ReturnMapIdentifier); spawn = 0; mHealth = 50; } mMap = Server.GetActiveMap(mapData.Identifier); mSpawn = spawn; mPosition = new Coordinates(mapData.Portals[spawn].X, mapData.Portals[spawn].Y); using (DatabaseQuery query = Database.Query("SELECT * FROM player_item WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { byte[] slots = new byte[(byte)EInventoryType.Count]; slots[(byte)EInventoryType.Equipment] = (byte)pQuery["equipment_slots"]; slots[(byte)EInventoryType.Use] = (byte)pQuery["use_slots"]; slots[(byte)EInventoryType.Setup] = (byte)pQuery["setup_slots"]; slots[(byte)EInventoryType.Etc] = (byte)pQuery["etc_slots"]; slots[(byte)EInventoryType.Cash] = (byte)pQuery["cash_slots"]; mItems = new PlayerItems((int)pQuery["mesos"], slots, query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_skill WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { mSkills = new PlayerSkills(query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_quest WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { mQuests = new PlayerQuests(query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_teleport WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { mTeleports = new PlayerTeleports(query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_card WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { mCards = new PlayerCards(query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_macro WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { mMacros = new PlayerMacros(query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_keymap WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { query.NextRow(); mKeymap = new PlayerKeymap(query); } using (DatabaseQuery query = Database.Query("SELECT * FROM player_buddy WHERE player_identifier=@player_identifier", new MySqlParameter("@player_identifier", mIdentifier))) { mBuddies = new PlayerBuddies((byte)pQuery["buddy_slots"], query); } }