private void Connection_PacketRecieved(FrostbiteConnection sender, bool isHandled, Packet packetBeforeDispatch) { if (packetBeforeDispatch.OriginatedFromServer == false) { Packet request = sender.GetRequestPacket(packetBeforeDispatch); if (request != null && String.Compare(request.Words[0], "version", StringComparison.OrdinalIgnoreCase) == 0) { if (Game == null) { if (String.Compare(packetBeforeDispatch.Words[1], "BFBC2", StringComparison.OrdinalIgnoreCase) == 0) { Game = new BFBC2Client(sender); _connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "MOH", StringComparison.OrdinalIgnoreCase) == 0) { Game = new MoHClient(sender); _connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "BF3", StringComparison.OrdinalIgnoreCase) == 0) { Game = new BF3Client(sender); _connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "BF4", StringComparison.OrdinalIgnoreCase) == 0) { Game = new BF4Client(sender); _connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "MOHW", StringComparison.OrdinalIgnoreCase) == 0) { Game = new MOHWClient(sender); _connection = null; } if (Game != null) { VersionNumber = packetBeforeDispatch.Words[2]; Game.ServerInfo += new FrostbiteClient.ServerInfoHandler(OnServerInfo); Game.SendServerinfoPacket(); //sender.SendQueued(new Packet(false, false, sender.AcquireSequenceNumber, "serverInfo")); } } else if (Game.Connection != null) { BeginLoginSequence(); } sender.PacketReceived -= new FrostbiteConnection.PacketDispatchHandler(Connection_PacketRecieved); } } }
private void Connection_PacketRecieved(FrostbiteConnection sender, bool isHandled, Packet packetBeforeDispatch) { if (packetBeforeDispatch.OriginatedFromServer == false) { Packet request = sender.GetRequestPacket(packetBeforeDispatch); /* if (request != null && String.Compare(request.Words[0], "serverInfo", true) == 0) { this.CurrentServerInfo = new CServerInfo( new List<string>() { "ServerName", "PlayerCount", "MaxPlayerCount", "GameMode", "Map", "CurrentRound", "TotalRounds", "TeamScores", "ConnectionState", "Ranked", "PunkBuster", "Passworded", "ServerUptime", "RoundTime", "GameMod", // Note: if another variable is affixed to both games this method "Mappack", // will need to be split into MoHClient and BFBC2Client. "ExternalGameIpandPort", "PunkBusterVersion", "JoinQueueEnabled", "ServerRegion" }, packetBeforeDispatch.Words.GetRange(1, packetBeforeDispatch.Words.Count - 1) ); } */ if (request != null && String.Compare(request.Words[0], "version", true) == 0) { if (this.Game == null) { if (String.Compare(packetBeforeDispatch.Words[1], "BFBC2", true) == 0) { this.Game = new BFBC2Client((FrostbiteConnection)sender); this.m_connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "MOH", true) == 0) { this.Game = new MoHClient((FrostbiteConnection)sender); this.m_connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "BF3", true) == 0) { this.Game = new BF3Client((FrostbiteConnection)sender); this.m_connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "MOHW", true) == 0) { this.Game = new MOHWClient((FrostbiteConnection)sender); this.m_connection = null; } if (this.Game != null) { this.VersionNumber = packetBeforeDispatch.Words[2]; this.Game.ServerInfo += new FrostbiteClient.ServerInfoHandler(this.OnServerInfo); this.Game.SendServerinfoPacket(); //sender.SendQueued(new Packet(false, false, sender.AcquireSequenceNumber, "serverInfo")); } } else if (this.Game.Connection != null) { this.BeginLoginSequence(); } sender.PacketReceived -= new FrostbiteConnection.PacketDispatchHandler(Connection_PacketRecieved); } } }
private void Connection_PacketRecieved(FrostbiteConnection sender, bool isHandled, Packet packetBeforeDispatch) { if (packetBeforeDispatch.OriginatedFromServer == false) { Packet request = sender.GetRequestPacket(packetBeforeDispatch); if (request != null && String.Compare(request.Words[0], "serverInfo", true) == 0) { this.CurrentServerInfo = new CServerInfo( new List<string>() { "ServerName", "PlayerCount", "MaxPlayerCount", "GameMode", "Map", "CurrentRound", "TotalRounds", "TeamScores", "ConnectionState", "Ranked", "PunkBuster", "Passworded", "ServerUptime", "RoundTime", "GameMod", // Note: if another variable is affixed to both games this method "Mappack", // will need to be split into MoHClient and BFBC2Client. "ExternalGameIpandPort", "PunkBusterVersion", "JoinQueueEnabled", "ServerRegion" }, packetBeforeDispatch.Words.GetRange(1, packetBeforeDispatch.Words.Count - 1) ); } else if (request != null && String.Compare(request.Words[0], "version", true) == 0) { if (packetBeforeDispatch.Words.Count >= 1 && String.Compare(packetBeforeDispatch.Words[0], "LogInRequired", true) == 0) { // 0.6.0.0 -> 0.5.4.9 connections. A login would have been required in previous // version for a "version" packet to be sent. this.Game = new BFBC2Client((FrostbiteConnection)sender); this.m_connection = null; if (this.Game != null) { this.InitialSetup(); if (this.GameTypeDiscovered != null) { FrostbiteConnection.RaiseEvent(this.GameTypeDiscovered.GetInvocationList(), this); } } } else if (packetBeforeDispatch.Words.Count >= 3) { if (this.Game == null) { if (String.Compare(packetBeforeDispatch.Words[1], "BFBC2", true) == 0) { this.Game = new BFBC2Client((FrostbiteConnection)sender); this.m_connection = null; } else if (String.Compare(packetBeforeDispatch.Words[1], "MOH", true) == 0) { this.Game = new MoHClient((FrostbiteConnection)sender); this.m_connection = null; } if (this.Game != null) { this.VersionNumber = packetBeforeDispatch.Words[2]; this.InitialSetup(); if (this.GameTypeDiscovered != null) { FrostbiteConnection.RaiseEvent(this.GameTypeDiscovered.GetInvocationList(), this); } } } else if (this.Game.Connection != null) { this.BeginLoginSequence(); } } sender.PacketReceived -= new FrostbiteConnection.PacketDispatchHandler(Connection_PacketRecieved); } } }