Browse Source

Fix crashes related to dispatching messages from netcode

The dispatcher may or may not be ready when these things happen. If it
isn't... KABOOOOOOOOM
Adam Johnson 10 years ago
parent
commit
f075496888
  1. 1
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientCommInterface.cpp
  2. 22
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  3. 1
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h

1
Sources/Plasma/PubUtilLib/plNetClient/plNetClientCommInterface.cpp

@ -65,6 +65,7 @@ int plNetClientCommMsgHandler::HandleMessage( plNetMessage* msg )
int plNetClientMgr::IInitNetClientComm() int plNetClientMgr::IInitNetClientComm()
{ {
NetCommActivatePostInitErrorHandler(); NetCommActivatePostInitErrorHandler();
NetCommActivateMsgDispatchers();
ASSERT(!GetFlagsBit(kNetClientCommInited)); ASSERT(!GetFlagsBit(kNetClientCommInited));
fNetClientComm.SetDefaultHandler(&fNetClientCommMsgHandler); fNetClientComm.SetDefaultHandler(&fNetClientCommMsgHandler);

22
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -741,10 +741,6 @@ void NetCommStartup () {
NetClientInitialize(); NetClientInitialize();
NetClientSetErrorHandler(IPreInitNetErrorCallback); NetClientSetErrorHandler(IPreInitNetErrorCallback);
NetCliGameSetRecvBufferHandler(INetBufferCallback);
// NetCliAuthSetRecvBufferHandler(INetBufferCallback);
NetCliAuthSetNotifyNewBuildHandler(INotifyNewBuildCallback);
NetCliAuthSetConnectCallback(INotifyAuthConnectedCallback);
// Set startup age info // Set startup age info
memset(&s_startupAge, 0, sizeof(s_startupAge)); memset(&s_startupAge, 0, sizeof(s_startupAge));
@ -780,22 +776,26 @@ void NetCommEnableNet (
bool enabled, bool enabled,
bool wait bool wait
) { ) {
if (enabled) { if (enabled)
NetClientInitialize(); NetClientInitialize();
NetClientSetErrorHandler(INetErrorCallback); else
NetCliGameSetRecvBufferHandler(INetBufferCallback);
// NetCliAuthSetRecvBufferHandler(INetBufferCallback);
}
else {
NetClientDestroy(wait); NetClientDestroy(wait);
} }
}
//============================================================================ //============================================================================
void NetCommActivatePostInitErrorHandler () { void NetCommActivatePostInitErrorHandler () {
NetClientSetErrorHandler(INetErrorCallback); NetClientSetErrorHandler(INetErrorCallback);
} }
//============================================================================
void NetCommActivateMsgDispatchers() {
NetClientSetErrorHandler(INetErrorCallback);
NetCliGameSetRecvBufferHandler(INetBufferCallback);
// NetCliAuthSetRecvBufferHandler(INetBufferCallback);
NetCliAuthSetNotifyNewBuildHandler(INotifyNewBuildCallback);
NetCliAuthSetConnectCallback(INotifyAuthConnectedCallback);
}
//============================================================================ //============================================================================
void NetCommUpdate () { void NetCommUpdate () {
// plClient likes to recursively call us on occasion; debounce that crap. // plClient likes to recursively call us on occasion; debounce that crap.

1
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.h

@ -136,6 +136,7 @@ void NetCommEnableNet (
bool wait bool wait
); );
void NetCommActivatePostInitErrorHandler(); void NetCommActivatePostInitErrorHandler();
void NetCommActivateMsgDispatchers();
/***************************************************************************** /*****************************************************************************

Loading…
Cancel
Save