SuperMarioOdysseyOnline/source/layouts/LayoutPlayerList.cpp

56 lines
1.8 KiB
C++
Raw Normal View History

refac: abstracting game mode - change: general game mode management more abstract and less H&S oriented - change: split 8bit updateType into 4bit game mode and 4bit update type. - change: don't process packets from other game modes (legacy mode for backwards compatibility) - change: cache game mode of other players in puppet, resend GameModeInf on detected game mode change - change: send gamemode NONE when H&S is selected but not active - change: improved distance calculations in squared distance space - change: change from hider to seeker when dead even if there are no other players - fix: add hours to the minutes for the H&S GameModeInf packet - fix: set milliseconds and hours when receiving time from server - fix: keep the new time from the server for longer than a single frame - fix: reset H&S icon after receiving a new state from the server - refac: move code to generate PlayerList into own abstract LayoutPlayerList class. - refac: to_string() method for GameTime to simplify code in the Game Mode Icon class. - refac: rename TagInf packet to GameModeInf packet - refac: remove param from `SocketClient::tryGetPacket()` (unused) - refac: move all H&S specific files into the same directory (out of layouts) - refac: move GameModeTimer.cpp from source/server/hns/ to source/server/gamemode/ - refac: clean up some unused, duplicate or complicated imports - [mod menu] change: use the game mode name in the options & menu title - [mod menu] change: select the next game mode in the game mode select menu - [mod menu] change: possibility to always change the gravity setting in the H&S config menu - [mod menu] add: toggle options to control mario/cappy collision/bounciness (cherry picked from commit a9b2c87aa024cee6ba85ad2856db60de7ec67124) (cherry picked from commit 918f61fbfd619d781d88dc74878d392c48cfa480) (cherry picked from commit 96aff7dd7167d8244acef7884fa3503d4c3f868a) (cherry picked from commit 0fb6413ec91bbf679e9f8cea1aa512159101fa46) (cherry picked from commit ab78a812fd18781655ccf38e803f619ea427d1ac) Co-authored-by: Robin C. Ladiges <rcl.git@blackpinguin.de>
2022-06-22 03:01:18 +00:00
#include "layouts/LayoutPlayerList.h"
#include "server/Client.hpp"
sead::BufferedSafeStringBase<char> LayoutPlayerList::getPlayerList() {
int playerCount = Client::getMaxPlayerCount();
char playerNameBuf[0x100] = {0}; // max of 16 player names if player name size is 0x10
sead::BufferedSafeStringBase<char> playerList = sead::BufferedSafeStringBase<char>(playerNameBuf, 0x200);
if (playerCount <= 0) { return playerList; }
GameMode gmode = getGameMode();
// Add your own name to the list at the top
playerList.appendWithFormat("%s %s\n", getRoleIcon(isMeIt()), Client::instance()->getClientName());
bool hasOtherGameModes = false;
// seekers then hiders
for (int i = 0; i <= 1; i++) {
bool isIt = i == 0;
// Add players to the list that are in the same game mode
for (int j = 0; j < playerCount; j++) {
PuppetInfo* other = Client::getPuppetInfo(j);
if (!other || !other->isConnected) { continue; }
if (other->gameMode != gmode && other->gameMode != GameMode::LEGACY) {
hasOtherGameModes = true;
continue;
}
if (other->isIt != isIt) { continue; }
playerList.appendWithFormat("%s %s\n", getRoleIcon(isIt), other->puppetName);
}
}
// Add players to the list that are in different game modes
if (hasOtherGameModes) {
playerList.appendWithFormat("\n");
for (int j = 0; j < playerCount; j++) {
PuppetInfo* other = Client::getPuppetInfo(j);
if (!other || !other->isConnected) { continue; }
if (other->gameMode == gmode || other->gameMode == GameMode::LEGACY) { continue; }
playerList.appendWithFormat("%s\n", other->puppetName);
}
}
return playerList;
}