/// <summary> /// Parses the player join message and adds the user to the current game /// </summary> /// <param name="msg"></param> /// <param name="currIndex"></param> private void ProcessPlayerJoin(byte[] msg, int currIndex) { currIndex += 2; int gameId = BitConverter.ToInt32(msg, currIndex); currIndex += 4; StringBuilder s = new StringBuilder(); while (msg[currIndex] != 0) { s.Append((char)msg[currIndex++]); } currIndex++; int ping = BitConverter.ToInt32(msg, currIndex); currIndex += 4; int userID = BitConverter.ToInt16(msg, currIndex); currIndex += 2; byte connection = msg[currIndex]; User newPlayer = users.GetUserFromID(userID); //This is bad! if (newPlayer == null) { return; } if (newPlayer.Category.Equals("Buddies")) { KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyJoinedGame, newPlayer); } if (currGame != null) { currGame.users.AddUser(newPlayer); } GUIBundle playerJoinedBundle = new GUIBundle(); playerJoinedBundle.Users = new UserList(currGame.users); playerJoinedBundle.gameNum = currGame.id; WindowMngr.updateWindow(playerJoinedBundle); }
private void ProcessUserLeave(byte[] msg, int currIndex) { currIndex++; while (msg[currIndex++] != 0) { ; } int userID = BitConverter.ToInt16(msg, currIndex); users.RemoveUser(users.GetUserFromID(userID)); GUIBundle bund = new GUIBundle(); bund.Users = users; WindowMngr.updateWindow(bund); }