diff --git a/Source/automap.cpp b/Source/automap.cpp index dcccb3c51..433151f0f 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -479,9 +479,9 @@ void DrawAutomapText(const Surface &out) Point linePosition { 8, 8 }; if (gbIsMultiplayer) { - if (string_view("0.0.0.0") != szPlayerName) { + if (GameName != "0.0.0.0") { std::string description = std::string(_("Game: ")); - description.append(szPlayerName); + description.append(GameName); DrawString(out, description, linePosition); linePosition.y += 15; } @@ -489,7 +489,7 @@ void DrawAutomapText(const Surface &out) std::string description; if (!PublicGame) { description = std::string(_("Password: ")); - description.append(szPlayerDescript); + description.append(GamePassword); } else { description = std::string(_("Public Game")); } diff --git a/Source/multi.cpp b/Source/multi.cpp index 8887ab998..6f49c066b 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -34,7 +34,6 @@ namespace devilution { bool gbSomebodyWonGameKludge; TBuffer sgHiPriBuf; -char szPlayerDescript[128]; uint16_t sgwPackPlrOffsetTbl[MAX_PLRS]; bool sgbPlayerTurnBitTbl[MAX_PLRS]; bool sgbPlayerLeftGameTbl[MAX_PLRS]; @@ -54,7 +53,8 @@ uint32_t sgdwGameLoops; */ bool gbIsMultiplayer; bool sgbTimeout; -char szPlayerName[128]; +std::string GameName; +std::string GamePassword; bool PublicGame; uint8_t gbDeltaSender; bool sgbNetInited; @@ -764,10 +764,6 @@ bool NetInit(bool bSinglePlayer) for (int i = 0; i < NUMLEVELS; i++) { glSeedTbl[i] = AdvanceRndSeed(); } - if (!SNetGetGameInfo(GAMEINFO_NAME, szPlayerName, 128)) - nthread_terminate_game("SNetGetGameInfo1"); - if (!SNetGetGameInfo(GAMEINFO_PASSWORD, szPlayerDescript, 128)) - nthread_terminate_game("SNetGetGameInfo2"); PublicGame = DvlNet_IsPublicGame(); Player &myPlayer = *MyPlayer; diff --git a/Source/multi.h b/Source/multi.h index a4858db0e..ff5eb55ec 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -41,14 +41,14 @@ struct GameInfo { }; extern bool gbSomebodyWonGameKludge; -extern char szPlayerDescript[128]; extern uint16_t sgwPackPlrOffsetTbl[MAX_PLRS]; extern uint8_t gbActivePlayers; extern bool gbGameDestroyed; extern GameData sgGameInitInfo; extern bool gbSelectProvider; extern DVL_API_FOR_TEST bool gbIsMultiplayer; -extern char szPlayerName[128]; +extern std::string GameName; +extern std::string GamePassword; extern bool PublicGame; extern uint8_t gbDeltaSender; extern uint32_t player_state[MAX_PLRS]; diff --git a/Source/storm/storm_net.cpp b/Source/storm/storm_net.cpp index 274801293..5095ea804 100644 --- a/Source/storm/storm_net.cpp +++ b/Source/storm/storm_net.cpp @@ -18,8 +18,6 @@ namespace devilution { namespace { std::unique_ptr dvlnet_inst; -char gpszGameName[128] = {}; -char gpszGamePassword[128] = {}; bool GameIsPublic = {}; thread_local uint32_t dwLastError = 0; @@ -121,23 +119,6 @@ bool SNetDropPlayer(int playerid, uint32_t flags) return dvlnet_inst->SNetDropPlayer(playerid, flags); } -bool SNetGetGameInfo(game_info type, void *dst, unsigned int length) -{ -#ifndef NONET - std::lock_guard lg(storm_net_mutex); -#endif - switch (type) { - case GAMEINFO_NAME: - CopyUtf8((char *)dst, gpszGameName, length); - break; - case GAMEINFO_PASSWORD: - CopyUtf8((char *)dst, gpszGamePassword, length); - break; - } - - return true; -} - bool SNetLeaveGame(int type) { #ifndef NONET @@ -181,7 +162,7 @@ bool SNetCreateGame(const char *pszGameName, const char *pszGamePassword, char * pszGameName = defaultName.c_str(); } - CopyUtf8(gpszGameName, pszGameName, sizeof(gpszGameName)); + GameName = pszGameName; if (pszGamePassword != nullptr) DvlNet_SetPassword(pszGamePassword); else @@ -196,7 +177,7 @@ bool SNetJoinGame(char *pszGameName, char *pszGamePassword, int *playerID) std::lock_guard lg(storm_net_mutex); #endif if (pszGameName != nullptr) - CopyUtf8(gpszGameName, pszGameName, sizeof(gpszGameName)); + GameName = pszGameName; if (pszGamePassword != nullptr) DvlNet_SetPassword(pszGamePassword); else @@ -253,14 +234,14 @@ std::vector DvlNet_GetGamelist() void DvlNet_SetPassword(std::string pw) { GameIsPublic = false; - CopyUtf8(gpszGamePassword, pw, sizeof(gpszGamePassword)); + GamePassword = pw; dvlnet_inst->setup_password(std::move(pw)); } void DvlNet_ClearPassword() { GameIsPublic = true; - gpszGamePassword[0] = '\0'; + GamePassword.clear(); dvlnet_inst->clear_password(); } diff --git a/Source/storm/storm_net.hpp b/Source/storm/storm_net.hpp index 1aa0b13d2..b7d2fbe18 100644 --- a/Source/storm/storm_net.hpp +++ b/Source/storm/storm_net.hpp @@ -9,11 +9,6 @@ namespace devilution { -enum game_info : uint8_t { - GAMEINFO_NAME, - GAMEINFO_PASSWORD, -}; - enum conn_type : uint8_t { SELCONN_ZT, SELCONN_TCP, @@ -68,19 +63,6 @@ bool SNetDestroy(); */ bool SNetDropPlayer(int playerid, uint32_t flags); -/* SNetGetGameInfo @ 107 - * - * Retrieves specific game information from Storm, such as name, password, - * stats, mode, game template, and players. - * - * type: The type of data to retrieve. See GAMEINFO_ flags. - * dst: The destination buffer for the data. - * length: The maximum size of the destination buffer. - * - * Returns true if the function was called successfully and false otherwise. - */ -bool SNetGetGameInfo(game_info type, void *dst, unsigned int length); - /* SNetGetTurnsInTransit @ 115 * * Retrieves the number of turns (buffers) that have been queued