From c13a12c58ebba73043cc904eff14d229a02dd8a3 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 15 Dec 2012 23:41:12 -0500 Subject: [PATCH] Fix those scary SystemErrors we see in DS As it turns out, my old OnServerInitComplete fix didn't check to see if the script had an OnServerInitComplete method. So, when we called that method-of-doom from C++, we'd see a SystemError. Aside from removing an error message, this probably has no effect. --- .../FeatureLib/pfPython/plPythonFileMod.cpp | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp index 63d97889..871ae0ec 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp @@ -859,28 +859,29 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj) // We should really let the script know about that via OnServerInitComplete anyway because it's // not good to make assumptions about game state in workarounds for that method not being called plNetClientApp* na = plNetClientApp::GetInstance(); - if (!na->GetFlagsBit(plNetClientApp::kLoadingInitialAgeState) && - na->GetFlagsBit(plNetClientApp::kPlayingGame)) + if (!na->GetFlagsBit(plNetClientApp::kLoadingInitialAgeState) && na->GetFlagsBit(plNetClientApp::kPlayingGame)) { plgDispatch::Dispatch()->UnRegisterForExactType(plInitialAgeStateLoadedMsg::Index(), GetKey()); - plProfile_BeginTiming(PythonUpdate); - // call it - PyObject* retVal = PyObject_CallMethod( - fPyFunctionInstances[kfunc_OnServerInitComplete], - (char*)fFunctionNames[kfunc_OnServerInitComplete], nil); - if ( retVal == nil ) + if (fPyFunctionInstances[kfunc_OnServerInitComplete]) { + plProfile_BeginTiming(PythonUpdate); + // call it + PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnServerInitComplete], + (char*)fFunctionNames[kfunc_OnServerInitComplete], nil); + if ( retVal == nil ) + { #ifndef PLASMA_EXTERNAL_RELEASE - // for some reason this function didn't, remember that and not call it again - fPyFunctionInstances[kfunc_OnServerInitComplete] = nil; + // for some reason this function didn't, remember that and not call it again + fPyFunctionInstances[kfunc_OnServerInitComplete] = nil; #endif //PLASMA_EXTERNAL_RELEASE - // if there was an error make sure that the stderr gets flushed so it can be seen - ReportError(); + // if there was an error make sure that the stderr gets flushed so it can be seen + ReportError(); + } + Py_XDECREF(retVal); + plProfile_EndTiming(PythonUpdate); + // display any output (NOTE: this would be disabled in production) + DisplayPythonOutput(); } - Py_XDECREF(retVal); - plProfile_EndTiming(PythonUpdate); - // display any output (NOTE: this would be disabled in production) - DisplayPythonOutput(); } // display python output