Browse Source

Const strings for Python function names.

Darryl Pogue 14 years ago
parent
commit
d0d12d24c6
  1. 4
      Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp
  2. 4
      Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h
  3. 284
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  4. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h
  5. 6
      Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp

4
Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp

@ -1919,7 +1919,7 @@ void PythonInterface::WriteToStdErr(const char* text)
// //
// PURPOSE : Find module. If it doesn't exist then don't create, return nil. // PURPOSE : Find module. If it doesn't exist then don't create, return nil.
// //
PyObject* PythonInterface::FindModule(char* module) PyObject* PythonInterface::FindModule(const char* module)
{ {
PyObject *m; PyObject *m;
// first we must get rid of any old modules of the same name, we'll replace it // first we must get rid of any old modules of the same name, we'll replace it
@ -1960,7 +1960,7 @@ hsBool PythonInterface::IsModuleNameUnique(char* module)
// //
// PURPOSE : create a new module with built-ins // PURPOSE : create a new module with built-ins
// //
PyObject* PythonInterface::CreateModule(char* module) PyObject* PythonInterface::CreateModule(const char* module)
{ {
PyObject *m, *d; PyObject *m, *d;
// first we must get rid of any old modules of the same name, we'll replace it // first we must get rid of any old modules of the same name, we'll replace it

4
Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.h

@ -123,10 +123,10 @@ public:
static void WriteToStdErr(const char* text); static void WriteToStdErr(const char* text);
// Find module. If it doesn't exist then don't create, return nil. // Find module. If it doesn't exist then don't create, return nil.
static PyObject* FindModule(char* module); static PyObject* FindModule(const char* module);
// create a new module with built-ins // create a new module with built-ins
static PyObject* CreateModule(char* module); static PyObject* CreateModule(const char* module);
// checks to see if a specific function is defined in this module // checks to see if a specific function is defined in this module
// get an item (probably a function) from the Plasma module // get an item (probably a function) from the Plasma module

284
Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp

@ -133,47 +133,47 @@ plProfile_CreateTimer("Update", "Python", PythonUpdate);
// //
// fFunctionNames - the actual names of the functions for On[event] types // fFunctionNames - the actual names of the functions for On[event] types
// //
char* plPythonFileMod::fFunctionNames[] = const char* plPythonFileMod::fFunctionNames[] =
{ {
{ "OnFirstUpdate" }, // kfunc_FirstUpdate "OnFirstUpdate", // kfunc_FirstUpdate
{ "OnUpdate" }, // kfunc_Update "OnUpdate", // kfunc_Update
{ "OnNotify" }, // kfunc_Notify "OnNotify", // kfunc_Notify
{ "OnTimer" }, // kfunc_AtTimer "OnTimer", // kfunc_AtTimer
{ "OnControlKeyEvent" }, // kfunc_OnKeyEvent "OnControlKeyEvent", // kfunc_OnKeyEvent
{ "Load" }, // kfunc_Load "Load", // kfunc_Load
{ "Save" }, // kfunc_Save "Save", // kfunc_Save
{ "OnGUINotify" }, // kfunc_GUINotify "OnGUINotify", // kfunc_GUINotify
{ "OnPageLoad" }, // kfunc_PageLoad "OnPageLoad", // kfunc_PageLoad
{ "OnClothingUpdate" }, // kfunc_ClothingUpdate "OnClothingUpdate", // kfunc_ClothingUpdate
{ "OnKIMsg" }, // kfunc_KIMsg, "OnKIMsg", // kfunc_KIMsg,
{ "OnMemberUpdate" }, // kfunc_MemberUpdate, "OnMemberUpdate", // kfunc_MemberUpdate,
{ "OnRemoteAvatarInfo" }, // kfunc_RemoteAvatarInfo, "OnRemoteAvatarInfo", // kfunc_RemoteAvatarInfo,
{ "OnRTChat" }, // kfunc_RTChat, "OnRTChat", // kfunc_RTChat,
{ "OnVaultEvent" }, // kfunc_VaultEvent, "OnVaultEvent", // kfunc_VaultEvent,
{ "AvatarPage" }, // kfunc_AvatarPage, "AvatarPage", // kfunc_AvatarPage,
{ "OnSDLNotify" }, // kfunc_SDLNotify "OnSDLNotify", // kfunc_SDLNotify
{ "OnOwnershipChanged" }, // kfunc_OwnershipNotify "OnOwnershipChanged", // kfunc_OwnershipNotify
{ "OnAgeVaultEvent" }, // kfunc_AgeVaultEvent "OnAgeVaultEvent", // kfunc_AgeVaultEvent
{ "OnInit" }, // kfunc_Init, "OnInit", // kfunc_Init,
{ "OnCCRMsg" }, // kfunc_OnCCRMsg, "OnCCRMsg", // kfunc_OnCCRMsg,
{ "OnServerInitComplete" }, // kfunc_OnServerInitComplete "OnServerInitComplete", // kfunc_OnServerInitComplete
{ "OnVaultNotify" }, // kfunc_OnVaultNotify "OnVaultNotify", // kfunc_OnVaultNotify
{ "OnDefaultKeyCaught" }, // kfunc_OnDefaultKeyCaught "OnDefaultKeyCaught", // kfunc_OnDefaultKeyCaught
{ "OnMarkerMsg" }, // kfunc_OnMarkerMsg, "OnMarkerMsg", // kfunc_OnMarkerMsg,
{ "OnBackdoorMsg" }, // kfunc_OnBackdoorMsg, "OnBackdoorMsg", // kfunc_OnBackdoorMsg,
{ "OnBehaviorNotify" }, // kfunc_OnBehaviorNotify, "OnBehaviorNotify", // kfunc_OnBehaviorNotify,
{ "OnLOSNotify" }, // kfunc_OnLOSNotify, "OnLOSNotify", // kfunc_OnLOSNotify,
{ "BeginAgeUnLoad" }, // kfunc_OnBeginAgeLoad, "BeginAgeUnLoad", // kfunc_OnBeginAgeLoad,
{ "OnMovieEvent" }, // kfunc_OnMovieEvent, "OnMovieEvent", // kfunc_OnMovieEvent,
{ "OnScreenCaptureDone" }, // kfunc_OnScreenCaptureDone, "OnScreenCaptureDone", // kfunc_OnScreenCaptureDone,
{ "OnClimbingBlockerEvent"},// kFunc_OnClimbingBlockerEvent, "OnClimbingBlockerEvent",// kFunc_OnClimbingBlockerEvent,
{ "OnAvatarSpawn"}, // kFunc_OnAvatarSpawn "OnAvatarSpawn", // kFunc_OnAvatarSpawn
{ "OnAccountUpdate"}, // kFunc_OnAccountUpdate "OnAccountUpdate", // kFunc_OnAccountUpdate
{ "gotPublicAgeList"}, // kfunc_gotPublicAgeList "gotPublicAgeList", // kfunc_gotPublicAgeList
{ "OnGameMgrMsg" }, // kfunc_OnGameMgrMsg "OnGameMgrMsg", // kfunc_OnGameMgrMsg
{ "OnGameCliMsg" }, // kfunc_OnGameCliMsg "OnGameCliMsg", // kfunc_OnGameCliMsg
{ "OnAIMsg" }, // kfunc_OnAIMsg "OnAIMsg", // kfunc_OnAIMsg
{ nil } nil
}; };
//// Callback From the Vault Events ////////////////////////////////////////////// //// Callback From the Vault Events //////////////////////////////////////////////
@ -199,8 +199,9 @@ public:
PyTuple_SetItem(ptuple, 0, pyVaultNodeRef::New(parentNode, childNode)); PyTuple_SetItem(ptuple, 0, pyVaultNodeRef::New(parentNode, childNode));
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFileMod->fPyFunctionInstances[fFunctionIdx], PyObject* retVal = PyObject_CallMethod(
fPyFileMod->fFunctionNames[fFunctionIdx], fPyFileMod->fPyFunctionInstances[fFunctionIdx],
(char*)fPyFileMod->fFunctionNames[fFunctionIdx],
"lO",pyVault::kVaultNodeRefAdded,ptuple); "lO",pyVault::kVaultNodeRefAdded,ptuple);
if ( retVal == nil ) if ( retVal == nil )
{ {
@ -228,8 +229,9 @@ public:
PyTuple_SetItem(ptuple, 0, pyVaultNodeRef::New(parentNode, childNode)); PyTuple_SetItem(ptuple, 0, pyVaultNodeRef::New(parentNode, childNode));
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFileMod->fPyFunctionInstances[fFunctionIdx], PyObject* retVal = PyObject_CallMethod(
fPyFileMod->fFunctionNames[fFunctionIdx], fPyFileMod->fPyFunctionInstances[fFunctionIdx],
(char*)fPyFileMod->fFunctionNames[fFunctionIdx],
"lO",pyVault::kVaultRemovingNodeRef,ptuple); "lO",pyVault::kVaultRemovingNodeRef,ptuple);
if ( retVal == nil ) if ( retVal == nil )
{ {
@ -257,8 +259,9 @@ public:
PyTuple_SetItem(ptuple, 0, pyVaultNode::New(changedNode)); PyTuple_SetItem(ptuple, 0, pyVaultNode::New(changedNode));
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFileMod->fPyFunctionInstances[fFunctionIdx], PyObject* retVal = PyObject_CallMethod(
fPyFileMod->fFunctionNames[fFunctionIdx], fPyFileMod->fPyFunctionInstances[fFunctionIdx],
(char*)fPyFileMod->fFunctionNames[fFunctionIdx],
"lO",pyVault::kVaultNodeSaved,ptuple); "lO",pyVault::kVaultNodeSaved,ptuple);
if ( retVal == nil ) if ( retVal == nil )
{ {
@ -686,7 +689,7 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
} }
// - find functions in class they've defined. // - find functions in class they've defined.
PythonInterface::CheckInstanceForFunctions(fInstance,fFunctionNames,fPyFunctionInstances); PythonInterface::CheckInstanceForFunctions(fInstance,(char**)fFunctionNames,fPyFunctionInstances);
// clear any errors created by checking for methods in a class // clear any errors created by checking for methods in a class
PyErr_Clear(); // clear the error PyErr_Clear(); // clear the error
// register for messages that they have functions defined for // register for messages that they have functions defined for
@ -818,7 +821,9 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
{ {
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
// call it // call it
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_Init],fFunctionNames[kfunc_Init],nil); PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_Init],
(char*)fFunctionNames[kfunc_Init], nil);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -906,8 +911,9 @@ void plPythonFileMod::HandleDiscardedKey( plKeyEventMsg *msg )
plProfile_BeginTiming( PythonUpdate ); plProfile_BeginTiming( PythonUpdate );
PyObject* retVal = PyObject_CallMethod( fPyFunctionInstances[ kfunc_OnDefaultKeyCaught ], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[ kfunc_OnDefaultKeyCaught ], fPyFunctionInstances[ kfunc_OnDefaultKeyCaught ],
(char*)fFunctionNames[ kfunc_OnDefaultKeyCaught ],
"ciiiii", "ciiiii",
keyChar, keyChar,
(int)msg->GetKeyDown(), (int)msg->GetKeyDown(),
@ -1135,7 +1141,9 @@ hsBool plPythonFileMod::IEval(double secs, hsScalar del, UInt32 dirty)
{ {
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
// call it // call it
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_FirstUpdate],fFunctionNames[kfunc_FirstUpdate],nil); PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_FirstUpdate],
(char*)fFunctionNames[kfunc_FirstUpdate], nil);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1157,7 +1165,10 @@ hsBool plPythonFileMod::IEval(double secs, hsScalar del, UInt32 dirty)
{ {
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
// call it // call it
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_Update],fFunctionNames[kfunc_Update],"df",secs,del); PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_Update],
(char*)fFunctionNames[kfunc_Update],
"df", secs, del);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1507,8 +1518,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_Notify],fFunctionNames[kfunc_Notify], PyObject* retVal = PyObject_CallMethod(
"flO",pNtfyMsg->fState,id,levents); fPyFunctionInstances[kfunc_Notify],
(char*)fFunctionNames[kfunc_Notify],
"flO", pNtfyMsg->fState, id, levents);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1537,8 +1550,11 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{ {
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnKeyEvent],fFunctionNames[kfunc_OnKeyEvent], PyObject* retVal = PyObject_CallMethod(
"ll",pEMsg->GetControlCode(),pEMsg->ControlActivated()); fPyFunctionInstances[kfunc_OnKeyEvent],
(char*)fFunctionNames[kfunc_OnKeyEvent],
"ll", pEMsg->GetControlCode(),
pEMsg->ControlActivated());
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1568,8 +1584,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
// yes... // yes...
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_AtTimer],fFunctionNames[kfunc_AtTimer], PyObject* retVal = PyObject_CallMethod(
"l",pTimerMsg->fID); fPyFunctionInstances[kfunc_AtTimer],
(char*)fFunctionNames[kfunc_AtTimer],
"l", pTimerMsg->fID);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1702,8 +1720,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
// call their OnGUINotify method // call their OnGUINotify method
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_GUINotify],fFunctionNames[kfunc_GUINotify], PyObject* retVal = PyObject_CallMethod(
"lOl",id,pyControl,pGUIMsg->GetEvent() ); fPyFunctionInstances[kfunc_GUINotify],
(char*)fFunctionNames[kfunc_GUINotify],
"lOl", id, pyControl, pGUIMsg->GetEvent());
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1737,8 +1757,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
roomname = (char*)pRLNMsg->GetRoom()->GetName(); roomname = (char*)pRLNMsg->GetRoom()->GetName();
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_PageLoad],fFunctionNames[kfunc_PageLoad], PyObject* retVal = PyObject_CallMethod(
"ls",pRLNMsg->GetWhatHappen(),roomname); fPyFunctionInstances[kfunc_PageLoad],
(char*)fFunctionNames[kfunc_PageLoad],
"ls", pRLNMsg->GetWhatHappen(), roomname);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1768,7 +1790,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
// yes... // yes...
// call it // call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_ClothingUpdate],fFunctionNames[kfunc_ClothingUpdate],nil); PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_ClothingUpdate],
(char*)fFunctionNames[kfunc_ClothingUpdate], nil);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1862,8 +1886,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
} }
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_KIMsg],fFunctionNames[kfunc_KIMsg], PyObject* retVal = PyObject_CallMethod(
"lO",pkimsg->GetCommand(),value); fPyFunctionInstances[kfunc_KIMsg],
(char*)fFunctionNames[kfunc_KIMsg],
"lO", pkimsg->GetCommand(), value);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1892,7 +1918,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{ {
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_MemberUpdate],fFunctionNames[kfunc_MemberUpdate],nil); PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_MemberUpdate],
(char*)fFunctionNames[kfunc_MemberUpdate], nil);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1943,8 +1971,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
} }
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_RemoteAvatarInfo],fFunctionNames[kfunc_RemoteAvatarInfo], PyObject* retVal = PyObject_CallMethod(
"O",player); fPyFunctionInstances[kfunc_RemoteAvatarInfo],
(char*)fFunctionNames[kfunc_RemoteAvatarInfo],
"O", player);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -1976,8 +2006,11 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
if ( textmessage == nil) if ( textmessage == nil)
textmessage = ""; textmessage = "";
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnCCRMsg],fFunctionNames[kfunc_OnCCRMsg], PyObject* retVal = PyObject_CallMethod(
"lsl",ccrmsg->GetType(),textmessage,ccrmsg->GetCCRPlayerID()); fPyFunctionInstances[kfunc_OnCCRMsg],
(char*)fFunctionNames[kfunc_OnCCRMsg],
"lsl", ccrmsg->GetType(), textmessage,
ccrmsg->GetCCRPlayerID());
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2035,8 +2068,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
} }
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnVaultNotify],fFunctionNames[kfunc_OnVaultNotify], PyObject* retVal = PyObject_CallMethod(
"lO",vaultNotifyMsg->GetType(),ptuple); fPyFunctionInstances[kfunc_OnVaultNotify],
(char*)fFunctionNames[kfunc_OnVaultNotify],
"lO", vaultNotifyMsg->GetType(), ptuple);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2089,8 +2124,11 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
} }
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_RTChat],fFunctionNames[kfunc_RTChat], PyObject* retVal = PyObject_CallMethod(
"Osl",player,pkimsg->GetString().c_str(),pkimsg->GetFlags()); fPyFunctionInstances[kfunc_RTChat],
(char*)fFunctionNames[kfunc_RTChat],
"Osl", player, pkimsg->GetString().c_str(),
pkimsg->GetFlags());
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2122,8 +2160,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
plSynchEnabler ps(true); // enable dirty state tracking during shutdown plSynchEnabler ps(true); // enable dirty state tracking during shutdown
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_AvatarPage],fFunctionNames[kfunc_AvatarPage], PyObject* retVal = PyObject_CallMethod(
"Oli",pSobj,!ppMsg->fUnload,ppMsg->fLastOut); fPyFunctionInstances[kfunc_AvatarPage],
(char*)fFunctionNames[kfunc_AvatarPage],
"Oli", pSobj, !ppMsg->fUnload, ppMsg->fLastOut);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2155,8 +2195,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
plSynchEnabler ps(true); // enable dirty state tracking during shutdown plSynchEnabler ps(true); // enable dirty state tracking during shutdown
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnBeginAgeLoad],fFunctionNames[kfunc_OnBeginAgeLoad], PyObject* retVal = PyObject_CallMethod(
"O",pSobj); fPyFunctionInstances[kfunc_OnBeginAgeLoad],
(char*)fFunctionNames[kfunc_OnBeginAgeLoad],
"O", pSobj);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2188,7 +2230,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
} }
if (fPyFunctionInstances[kfunc_OnServerInitComplete]) if (fPyFunctionInstances[kfunc_OnServerInitComplete])
{ {
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnServerInitComplete],fFunctionNames[kfunc_OnServerInitComplete],nil); PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnServerInitComplete],
(char*)fFunctionNames[kfunc_OnServerInitComplete],
nil);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2219,8 +2264,11 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
tag = ""; tag = "";
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_SDLNotify],fFunctionNames[kfunc_SDLNotify], PyObject* retVal = PyObject_CallMethod(
"ssls",sn->fVar->GetName(),sn->fSDLName.c_str(),sn->fPlayerID,tag); fPyFunctionInstances[kfunc_SDLNotify],
(char*)fFunctionNames[kfunc_SDLNotify],
"ssls", sn->fVar->GetName(), sn->fSDLName.c_str(),
sn->fPlayerID, tag);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2247,7 +2295,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{ {
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OwnershipNotify],fFunctionNames[kfunc_OwnershipNotify], PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OwnershipNotify],
(char*)fFunctionNames[kfunc_OwnershipNotify],
nil); nil);
if ( retVal == nil ) if ( retVal == nil )
{ {
@ -2286,7 +2336,9 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
break; break;
} }
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnMarkerMsg], fFunctionNames[kfunc_OnMarkerMsg], PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnMarkerMsg],
(char*)fFunctionNames[kfunc_OnMarkerMsg],
"lO", (UInt32)markermsg->fType, ptuple); "lO", (UInt32)markermsg->fType, ptuple);
if (retVal == nil) if (retVal == nil)
{ {
@ -2317,9 +2369,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{ {
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnBackdoorMsg], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnBackdoorMsg], fPyFunctionInstances[kfunc_OnBackdoorMsg],
"ss",dt->GetTarget(),dt->GetString()); (char*)fFunctionNames[kfunc_OnBackdoorMsg],
"ss", dt->GetTarget(), dt->GetString());
if ( retVal == nil ) if ( retVal == nil )
{ {
// if there was an error make sure that the stderr gets flushed so it can be seen // if there was an error make sure that the stderr gets flushed so it can be seen
@ -2360,9 +2413,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
hitpoint = Py_None; hitpoint = Py_None;
} }
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnLOSNotify], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnLOSNotify], fPyFunctionInstances[kfunc_OnLOSNotify],
"llOOf",pLOSMsg->fRequestID,pLOSMsg->fNoHit, (char*)fFunctionNames[kfunc_OnLOSNotify],
"llOOf", pLOSMsg->fRequestID, pLOSMsg->fNoHit,
scobj, hitpoint, pLOSMsg->fDistance); scobj, hitpoint, pLOSMsg->fDistance);
if ( retVal == nil ) if ( retVal == nil )
{ {
@ -2407,9 +2461,11 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
Py_INCREF(Py_None); Py_INCREF(Py_None);
pSobj = Py_None; pSobj = Py_None;
} }
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnBehaviorNotify], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnBehaviorNotify], fPyFunctionInstances[kfunc_OnBehaviorNotify],
"lOl",behNotifymsg->fType,pSobj,behNotifymsg->state); (char*)fFunctionNames[kfunc_OnBehaviorNotify],
"lOl", behNotifymsg->fType, pSobj,
behNotifymsg->state);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2438,9 +2494,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
{ {
// yes... then call it // yes... then call it
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnMovieEvent], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnMovieEvent], fPyFunctionInstances[kfunc_OnMovieEvent],
"si",moviemsg->fMovieName,(UInt32)moviemsg->fReason); (char*)fFunctionNames[kfunc_OnMovieEvent],
"si", moviemsg->fMovieName, (UInt32)moviemsg->fReason);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2480,9 +2537,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
Py_INCREF(Py_None); Py_INCREF(Py_None);
pSobj = Py_None; pSobj = Py_None;
} }
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnScreenCaptureDone], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnScreenCaptureDone], fPyFunctionInstances[kfunc_OnScreenCaptureDone],
"O",pSobj); (char*)fFunctionNames[kfunc_OnScreenCaptureDone],
"O", pSobj);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2510,9 +2568,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
PyObject* pSobj = pySceneObject::New(pEvent->GetSender(), fSelfKey); PyObject* pSobj = pySceneObject::New(pEvent->GetSender(), fSelfKey);
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnClimbBlockerEvent], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnClimbBlockerEvent], fPyFunctionInstances[kfunc_OnClimbBlockerEvent],
"O",pSobj); (char*)fFunctionNames[kfunc_OnClimbBlockerEvent],
"O", pSobj);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2532,9 +2591,10 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
plAvatarSpawnNotifyMsg* pSpawn = plAvatarSpawnNotifyMsg::ConvertNoRef(msg); plAvatarSpawnNotifyMsg* pSpawn = plAvatarSpawnNotifyMsg::ConvertNoRef(msg);
if (pSpawn) if (pSpawn)
{ {
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnAvatarSpawn], PyObject* retVal = PyObject_CallMethod(
fFunctionNames[kfunc_OnAvatarSpawn], fPyFunctionInstances[kfunc_OnAvatarSpawn],
"l",1); (char*)fFunctionNames[kfunc_OnAvatarSpawn],
"l", 1);
if ( retVal == nil ) if ( retVal == nil )
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
@ -2555,8 +2615,12 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
if (pUpdateMsg) if (pUpdateMsg)
{ {
plProfile_BeginTiming(PythonUpdate); plProfile_BeginTiming(PythonUpdate);
PyObject* retVal = PyObject_CallMethod(fPyFunctionInstances[kfunc_OnAccountUpdate], fFunctionNames[kfunc_OnAccountUpdate], PyObject* retVal = PyObject_CallMethod(
"iii", (int)pUpdateMsg->GetUpdateType(), (int)pUpdateMsg->GetResult(), (int)pUpdateMsg->GetPlayerInt() fPyFunctionInstances[kfunc_OnAccountUpdate],
(char*)fFunctionNames[kfunc_OnAccountUpdate],
"iii", (int)pUpdateMsg->GetUpdateType(),
(int)pUpdateMsg->GetResult(),
(int)pUpdateMsg->GetPlayerInt()
); );
if ( retVal == nil ) if ( retVal == nil )
{ {
@ -2598,7 +2662,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_gotPublicAgeList], fPyFunctionInstances[kfunc_gotPublicAgeList],
fFunctionNames[kfunc_gotPublicAgeList], (char*)fFunctionNames[kfunc_gotPublicAgeList],
"O", "O",
pyEL pyEL
); );
@ -2629,7 +2693,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
PyObject* pythonMsg = pyGameMgrMsg::New(gameMgrMsg); PyObject* pythonMsg = pyGameMgrMsg::New(gameMgrMsg);
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnGameMgrMsg], fPyFunctionInstances[kfunc_OnGameMgrMsg],
fFunctionNames[kfunc_OnGameMgrMsg], (char*)fFunctionNames[kfunc_OnGameMgrMsg],
"O", "O",
pythonMsg pythonMsg
); );
@ -2661,7 +2725,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
PyObject* pythonMsg = pyGameCliMsg::New(gameMgrMsg); PyObject* pythonMsg = pyGameCliMsg::New(gameMgrMsg);
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnGameCliMsg], fPyFunctionInstances[kfunc_OnGameCliMsg],
fFunctionNames[kfunc_OnGameCliMsg], (char*)fFunctionNames[kfunc_OnGameCliMsg],
"O", "O",
pythonMsg pythonMsg
); );
@ -2732,7 +2796,7 @@ hsBool plPythonFileMod::MsgReceive(plMessage* msg)
// call the function with the above arguments // call the function with the above arguments
PyObject* retVal = PyObject_CallMethod( PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnAIMsg], fPyFunctionInstances[kfunc_OnAIMsg],
fFunctionNames[kfunc_OnAIMsg], (char*)fFunctionNames[kfunc_OnAIMsg],
"OisO", "OisO",
brainObj, msgType, aiMsg->BrainUserString().c_str(), args brainObj, msgType, aiMsg->BrainUserString().c_str(), args
); );

2
Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.h

@ -191,7 +191,7 @@ public:
// array of matching Python instance where the functions are, if defined // array of matching Python instance where the functions are, if defined
PyObject* fPyFunctionInstances[kfunc_lastone]; PyObject* fPyFunctionInstances[kfunc_lastone];
// array of the names of the standard functions that can be called // array of the names of the standard functions that can be called
static char* fFunctionNames[]; static const char* fFunctionNames[];
// The konstant hard-coded name to be used for all global pythonFileMods // The konstant hard-coded name to be used for all global pythonFileMods
static char kGlobalNameKonstant[]; static char kGlobalNameKonstant[];

6
Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp

@ -273,8 +273,10 @@ void plPythonSDLModifier::ISetCurrentStateFrom(const plStateDataRecord* srcState
// Notify the Python code that we updated the SDL record // Notify the Python code that we updated the SDL record
if (fOwner->fPyFunctionInstances[plPythonFileMod::kfunc_Load] != nil) if (fOwner->fPyFunctionInstances[plPythonFileMod::kfunc_Load] != nil)
{ {
PyObject* retVal = PyObject_CallMethod(fOwner->fPyFunctionInstances[plPythonFileMod::kfunc_Load], PyObject* retVal = PyObject_CallMethod(
fOwner->fFunctionNames[plPythonFileMod::kfunc_Load], nil); fOwner->fPyFunctionInstances[plPythonFileMod::kfunc_Load],
(char*)fOwner->fFunctionNames[plPythonFileMod::kfunc_Load],
nil);
if (retVal == nil) if (retVal == nil)
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE

Loading…
Cancel
Save