/// <summary> /// Copia a estrutura para a Player e remove da lista de HexID. /// </summary> /// <param name="index"></param> /// <param name="hexIndex"></param> public static void AcceptHexID(NetConnection connection, HexaID hexID) { PlayerData pData = FindByConnection(connection); pData.HexID = hexID.HexID; pData.AccountID = hexID.AccountID; pData.Account = hexID.Account; pData.LanguageID = hexID.LanguageID; pData.AccessLevel = hexID.AccessLevel; pData.CharacterID = hexID.CharacterID; pData.CharSlot = hexID.CharSlot; pData.Service = hexID.Service; HexID.Remove(hexID); }
/// <summary> /// Adiciona os dados recebido do login server. /// </summary> /// <param name="data"></param> public static void AddHexID(NetIncomingMessage data) { HexaID hexID = new HexaID(); hexID.HexID = data.ReadString(); hexID.Account = data.ReadString(); hexID.AccountID = data.ReadInt32(); hexID.LanguageID = data.ReadByte(); hexID.AccessLevel = data.ReadInt16(); hexID.CharacterID = data.ReadInt32(); hexID.CharSlot = data.ReadInt32(); var service = data.ReadInt32(); for (var n = 0; n < service; n++) { hexID.Service.Add(data.ReadString()); } hexID.Time = Environment.TickCount; HexID.Add(hexID); FileLog.WriteLog($"Data From World Server ID: {hexID.AccountID} Account: {hexID.Account} Char ID: {hexID.CharacterID} Slot: {hexID.CharSlot} {hexID.HexID}", System.Drawing.Color.Black); }
/// <summary> /// Percorre todos os jogadores e verifica o estado atual do HexID. /// </summary> public static void VerifyPlayerHexID() { HexaID hexID = null; foreach (PlayerData pData in Player) { if (!string.IsNullOrEmpty(pData.Account)) { continue; } if (string.IsNullOrEmpty(pData.HexID)) { continue; } //Aceita o hexID e permite a conexão do world server for (int i = 0; i < Constant.MAX_SERVER; i++) { if (pData.HexID.CompareTo(Settings.WorldServerID[i]) == 0) { hexID = new HexaID(); hexID.Account = pData.HexID; hexID.HexID = pData.HexID; AcceptHexID(pData.Connection, hexID); } } hexID = FindHexID(pData.HexID); // Se não encontrar o hexid, desconecta o usuário pelo cliente if (hexID == null) { GamePacket.Message(pData.Connection, (int)PacketList.Disconnect); continue; } //aceita a conexão AcceptHexID(pData.Connection, hexID); //pega o nome do personagem. var charname = Character_DB.CharacterName(pData.AccountID, pData.CharSlot); //verifica se há algum personagem conectado. var playerData = FindByCharacterName(charname); //salva o personagem e limpa para uma nova conexão if (playerData != null) { Character_DB.Save(playerData); FileLog.WriteLog($"Player disconnected: {playerData.CharacterName}", System.Drawing.Color.Peru); //remove o jogador do mapa var _mapid = playerData.WorldID; MapManager.FindMapByID(_mapid).RemovePlayer(pData.CharacterID); playerData.Clear(); playerData.Connection.Disconnect(""); } // Carrega dados do personagem Character_DB.Load(pData.HexID, pData.CharSlot); FileLog.WriteLog($"Player Found ID: {pData.CharacterID} Name: {pData.CharacterName}", System.Drawing.Color.Black); //Realiza o calculo dos stats CharacterLogic.UpdateCharacterStats(pData.AccountID); //Aceita a conexão GamePacket.Message(pData.Connection, (int)PacketList.AcceptedConnection); //Envia dados para o jogador pData.SendPlayerBasicData(); pData.SendPlayerElementalStats(); pData.SendPlayerLocation(); pData.SendPlayerMagicStats(); pData.SendPlayerPhysicalStats(); pData.SendPlayerResistStats(); pData.SendPlayerStats(); pData.SendPlayerUniqueStats(); pData.SendPlayerVital(); pData.SendPlayerVitalRegen(); pData.SendPlayerExp(); // adiciona o jogador ao mapa MapManager.FindMapByID(pData.WorldID).CharacterID.Add(pData.CharacterID); FileLog.WriteLog($"{pData.CharacterName} joined map id {pData.WorldID}", System.Drawing.Color.Black); //envia outros jogadores do mapa MapManager.FindMapByID(pData.WorldID).GetPlayerOnMap(pData); //envia jogador para outros jogadores do mapa MapManager.FindMapByID(pData.WorldID).SendPlayerToMap(pData); //######################## //#### GET MAP DATA #### //######################## // Maps.MapPacket.SendNpc(pData.Connection, 0); // Muda de janela GamePacket.GameState(pData.HexID, 6); } }