From 98822d400f028768845832e1eacc2ee34832931a Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:15:31 -0800 Subject: [PATCH] fix: ChatServer crash on startup (#1303) --- dChatServer/ChatServer.cpp | 2 ++ dChatServer/PlayerContainer.cpp | 2 +- dChatServer/PlayerContainer.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 5fc861b6..b41ad4ec 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -108,6 +108,8 @@ int main(int argc, char** argv) { Game::randomEngine = std::mt19937(time(0)); + playerContainer.Initialize(); + //Run it until server gets a kill message from Master: auto t = std::chrono::high_resolution_clock::now(); Packet* packet = nullptr; diff --git a/dChatServer/PlayerContainer.cpp b/dChatServer/PlayerContainer.cpp index 8b9eb744..d9b33825 100644 --- a/dChatServer/PlayerContainer.cpp +++ b/dChatServer/PlayerContainer.cpp @@ -13,7 +13,7 @@ #include "ChatPackets.h" #include "dConfig.h" -PlayerContainer::PlayerContainer() { +void PlayerContainer::Initialize() { GeneralUtils::TryParse(Game::config->GetValue("max_number_of_best_friends"), m_MaxNumberOfBestFriends); GeneralUtils::TryParse(Game::config->GetValue("max_number_of_friends"), m_MaxNumberOfFriends); } diff --git a/dChatServer/PlayerContainer.h b/dChatServer/PlayerContainer.h index 000164ac..d055ed95 100644 --- a/dChatServer/PlayerContainer.h +++ b/dChatServer/PlayerContainer.h @@ -29,9 +29,9 @@ struct TeamData { class PlayerContainer { public: - PlayerContainer(); ~PlayerContainer(); + void Initialize(); void InsertPlayer(Packet* packet); void RemovePlayer(Packet* packet); void MuteUpdate(Packet* packet);