/// <summary> /// Handles InformationMessageIn packets. Keeps track of total number of players /// in game. /// </summary> /// <param name="packet">The packet.</param> private void OnInformationMessage(GameServerPacket packet) { InformationMessageIn fromServer = new InformationMessageIn(packet); Log(fromServer); switch (fromServer.Event) { case InformationMessageIn.InformationEvents.PlayerTimeout: case InformationMessageIn.InformationEvents.PlayerDropped: case InformationMessageIn.InformationEvents.PlayerQuit: { bool isBot = settings.BotNames.Contains(fromServer.First.ToLower()); PlayerNames.Remove(fromServer.First); Log(String.Format("{0}/{1} players remaining", PlayerNames.Count, MaxPlayers)); FireOnPlayerCountEvent(new PlayerCountArgs(PlayerNames.Count, MaxPlayers, fromServer.First, false, isBot)); break; } case InformationMessageIn.InformationEvents.PlayerJoined: { bool isBot = settings.BotNames.Contains(fromServer.First.ToLower()); PlayerNames.Add(fromServer.First); Log(String.Format("{0}/{1} players total", PlayerNames.Count, MaxPlayers)); FireOnPlayerCountEvent(new PlayerCountArgs(PlayerNames.Count, MaxPlayers, fromServer.First, true, isBot)); } break; case InformationMessageIn.InformationEvents.PlayerRelation: // Accept any party requests if (fromServer.Action == 0x02 && fromServer.EntityType == 0x05) { SendPacket(new PartyRequestOut(PartyRequestOut.RequestType.Accept, fromServer.EntityID)); } break; default: break; } }
/// <summary> /// Handles InformationMessageIn packets. Keeps track of total number of players /// in game. /// </summary> /// <param name="packet">The packet.</param> private void OnInformationMessage(GameServerPacket packet) { InformationMessageIn fromServer = new InformationMessageIn(packet); Log(fromServer); switch (fromServer.Event) { case InformationMessageIn.InformationEvents.PlayerTimeout: case InformationMessageIn.InformationEvents.PlayerDropped: case InformationMessageIn.InformationEvents.PlayerQuit: { bool isBot = settings.BotNames.Contains(fromServer.First.ToLower()); PlayerNames.Remove(fromServer.First); Log(String.Format("{0}/{1} players remaining", PlayerNames.Count, MaxPlayers)); FireOnPlayerCountEvent(new PlayerCountArgs(PlayerNames.Count, MaxPlayers, fromServer.First, false, isBot)); break; } case InformationMessageIn.InformationEvents.PlayerJoined: { bool isBot = settings.BotNames.Contains(fromServer.First.ToLower()); PlayerNames.Add(fromServer.First); Log(String.Format("{0}/{1} players total", PlayerNames.Count, MaxPlayers)); FireOnPlayerCountEvent(new PlayerCountArgs(PlayerNames.Count, MaxPlayers, fromServer.First, true, isBot)); } break; case InformationMessageIn.InformationEvents.PlayerRelation: // Accept any party requests if (fromServer.Action == 0x02 && fromServer.EntityType == 0x05) { SendPacket(new PartyRequestOut(PartyRequestOut.RequestType.Accept, fromServer.EntityID)); } break; default: break; } }