public bool HandlePacket(Peer peer, byte[] data) { var version = new SynchVersion(data); //Logging->writeLine("Client version: %s", version->version); var mapId = _game.Config.GameConfig.Map; _logger.LogCoreInfo("Current map: " + mapId); bool versionMatch = true; // Version might be an invalid value, currently it trusts the client if (version.version != Config.VERSION) { versionMatch = false; _logger.LogCoreWarning("Client " + version.version + " does not match Server " + Config.VERSION); } else { _logger.LogCoreInfo("Accepted client version (" + version.version + ")"); } foreach (var player in _playerManager.GetPlayers()) { if (player.Item1 == peer.Address.port) { player.Item2.IsMatchingVersion = versionMatch; break; } } var answer = new SynchVersionAns(_playerManager.GetPlayers(), Config.VERSION, "CLASSIC", mapId); return(_game.PacketHandlerManager.sendPacket(peer, answer, Channel.CHL_S2C)); }
public unsafe bool HandlePacket(ENetPeer *peer, byte[] data, Game game) { var version = new SynchVersion(data); //Logging->writeLine("Client version: %s", version->version); var mapId = Config.gameConfig.map; Logger.LogCoreInfo("Current map: " + mapId); bool versionMatch = true; // Version might be an invalid value, currently it trusts the client if (version.version != Config.version) { versionMatch = false; Logger.LogCoreWarning("Client " + version.version + " does not match Server " + Config.version); } else { Logger.LogCoreInfo("Accepted client version (" + version.version + ")"); } foreach (var player in game.getPlayers()) { if (player.Item1 == peer->address.host) { player.Item2.setVersionMatch(versionMatch); break; } } var answer = new SynchVersionAns(game.getPlayers(), Config.version, "CLASSIC", mapId); return(PacketHandlerManager.getInstace().sendPacket(peer, answer, Channel.CHL_S2C)); }
private void OnQueryStatusAns(byte[] packet, Channel channel) { var status = Serialize <QueryStatusAns>(packet); if (status.Ok == 1) { //Log.Write("Sendiong Version information."); var version = SynchVersion.Create(); Send(Deserialize <SynchVersion>(version)); } }