public static void GameServerLogin(Connection pConn, byte[] data) { if (data.Length <= 5) { Output.WriteLine("RecvPacketHandlers::GameServerLogin Wrong packet size"); pConn.Close(); } int uid = data[Program.receivePrefixLength]; int pid = data[Program.receivePrefixLength + 4]; byte[] guid = new byte[16]; Array.Copy(data, Program.receivePrefixLength + 4 + 4, guid, 0, 16); Output.WriteLine("RecvPacketHandlers::GameServerLogin Recv UID: " + uid.ToString() + " PID: " + pid.ToString() + " GUID: " + GameServer.ByteArrayToHex(guid)); UsersLobby.LobbyUser uLob = null; UsersLobby.Remove(uid, out uLob); if (uLob != null) { //its ok to process check if (uid == uLob.UserID && pid == uLob.PlayerID && GameServer.ByteArrayCompare(guid, uLob.GUID)) { pConn.client.UserID = uid; pConn.client.PlayerID = pid; //client succesfull authenticated Database.Player player = Database.DB_Acces.GetPlayer(pid, pConn); if (player == null) { Output.WriteLine("RecvPacketHandlers::GameServerLogin Not existing player PID: " + pid.ToString()); pConn.Close(); return; } /* * if (!InGameUsers.Add(uid, pid, pConn)) * { * InGameUsers.GameUser gUser = null; * InGameUsers.Remove(uid, out gUser); * if (gUser != null) * { * gUser.UserConnection.Send(new SendPacketHandlers.LoginError(SendPacketHandlers.LOGIN_ERROR.CURRENTLY_LOGGED)); * gUser.UserConnection.Close(); * } * if (!InGameUsers.Add(uid, pid, pConn)) * { * //shouldn't happen * pConn.Close(); * return; * } * } */ //send info to te Login server about succesfull user login if (LoginServerInterface.LoginServerConnection != null) { LoginServerInterface.LoginServerConnection.SendSync(new Packet.LoginServerSend.UserInGame(pConn.client.UserID)); } pConn.client.SetPlayer(player); pConn.client.recvKeyCOD = uLob.StartKey; pConn.client.sendKeyCOD = uLob.StartKey; pConn.client.DecodeType = Client.DECODE_TYPE.COD; pConn.client.EncodeType = Client.ENCODE_TYPE.COD; Output.WriteLine("RecvPacketHandlers::GameServerLogin User succesfully authenticated"); pConn.SendAsync(new Packet.SendPacketHandlers.PlayerData()); pConn.SendAsync(new Packet.SendPacketHandlers.PlayerSkills()); pConn.SendAsync(new Packet.SendPacketHandlers.Inventory()); //pConn.Send(new Packet.SendPacketHandlers.PlayerSpawn(pConn)); //pConn.client.AddPlayer(player); if (!GameServer.world.AddPlayer(player)) { Output.WriteLine("RecvPacketHandlers::GameServerLogin User failed add to map"); return; } /* * List<Database.Player> pList = GameServer.world.PlayersInSightRange(player.PosX, player.PosY, World.DEBUG_SIGHT_RANGE); * List<Database.Mob> mList = GameServer.world.MobsInSightRange(player.PosX, player.PosY, World.DEBUG_SIGHT_RANGE); * foreach(Database.Player p in pList) * { * if (p.PlayerPID != pConn.client.PlayerID) * { * pConn.client.GetPlayer().AddPlayer(p.PlayerPID); * pConn.Send(new Packet.SendPacketHandlers.PlayerSpawn(p.Con));//send p in this point - data about other players to this player * } * } * foreach (Database.Mob m in mList) * { * pConn.client.GetPlayer().AddMob(m.InternalID); * pConn.Send(new Packet.SendPacketHandlers.MobSpawn(m));//send m in this point - data about other mobs to this player * } */ } else { Output.WriteLine("RecvPacketHandlers::GameServerLogin Client not authenticated by Login server &0x001"); Output.WriteLine("RecvPacketHandlers::GameServerLogin Client UID: " + uid.ToString() + " PID: " + pid.ToString() + " GUID: " + GameServer.ByteArrayToHex(guid)); Output.WriteLine("RecvPacketHandlers::GameServerLogin From S UID: " + uLob.UserID.ToString() + " PID: " + uLob.PlayerID.ToString() + " GUID: " + GameServer.ByteArrayToHex(uLob.GUID)); pConn.Close(); } } else { Output.WriteLine("RecvPacketHandlers::GameServerLogin Client not authenticated by Login server &0x002"); pConn.Close(); } }