diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp index 1acee2d16fa..789e5d1f7ab 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp @@ -54,7 +54,15 @@ CommandList *TheCommandList = NULL; */ GameMessage::GameMessage( GameMessage::Type type ) { - m_playerIndex = ThePlayerList->getLocalPlayer()->getPlayerIndex(); + // Handle early initialization when ThePlayerList might not be initialized yet + if (ThePlayerList && ThePlayerList->getLocalPlayer()) + { + m_playerIndex = ThePlayerList->getLocalPlayer()->getPlayerIndex(); + } + else + { + m_playerIndex = 0; // Default to player 0 during initialization + } m_type = type; m_argList = NULL; m_argTail = NULL; diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index e6c2c70749e..0c89e419c87 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -366,7 +366,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, case WM_QUERYENDSESSION: { - TheMessageStream->appendMessage(GameMessage::MSG_META_DEMO_INSTANT_QUIT); + if (TheMessageStream) + { + TheMessageStream->appendMessage(GameMessage::MSG_META_DEMO_INSTANT_QUIT); + } return 0; //don't allow Windows to shutdown while game is running. } @@ -378,7 +381,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, //This method didn't work in cinematics because we don't process messages. //But it's the cleanest way to exit that's similar to using menus. - TheMessageStream->appendMessage(GameMessage::MSG_META_DEMO_INSTANT_QUIT); + if (TheMessageStream) + { + TheMessageStream->appendMessage(GameMessage::MSG_META_DEMO_INSTANT_QUIT); + } //This method used to disable quitting. We just put up the options screen instead. //TheMessageStream->appendMessage(GameMessage::MSG_META_OPTIONS);