Browse Source

Clean up for Python interface stuff.

Darryl Pogue 12 years ago
parent
commit
a0641ba66b
  1. 13
      Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.cpp
  2. 6
      Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.h
  3. 29
      Sources/Plasma/FeatureLib/pfPython/Games/pyGameCliGlue.cpp
  4. 25
      Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.cpp
  5. 13
      Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.h
  6. 7
      Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsgGlue.cpp
  7. 2
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  8. 3
      Sources/Plasma/FeatureLib/pfPython/cyPythonInterface.cpp
  9. 2
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  10. 2
      Sources/Plasma/FeatureLib/pfPython/pyEnum.cpp
  11. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlDraggable.cpp
  12. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIControlRadioGroup.cpp
  13. 1
      Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.cpp
  14. 4
      Sources/Plasma/FeatureLib/pfPython/pyNotifyGlue.cpp
  15. 9
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp
  16. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.h
  17. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp
  18. 2
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeLinkNode.h
  19. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp
  20. 9
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp
  21. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.h
  22. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp
  23. 24
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp
  24. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.h
  25. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp
  26. 2
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp
  27. 13
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp
  28. 5
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h
  29. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp

13
Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.cpp

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <Python.h> #include <Python.h>
#include "../pyKey.h" #include "../pyKey.h"
#include "plString.h"
#pragma hdrstop #pragma hdrstop
#include "pyGameCli.h" #include "pyGameCli.h"
@ -81,9 +82,9 @@ PyObject* pyGameCli::GetGameCli(unsigned gameID)
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
} }
std::wstring pyGameCli::GetGameNameByTypeID(std::wstring typeID) std::wstring pyGameCli::GetGameNameByTypeID(plString& typeID)
{ {
Uuid gameUuid(typeID.c_str()); plUUID gameUuid(typeID);
return pfGameMgr::GetInstance()->GetGameNameByTypeId(gameUuid); return pfGameMgr::GetInstance()->GetGameNameByTypeId(gameUuid);
} }
@ -99,15 +100,13 @@ unsigned pyGameCli::GameID() const
return 0; return 0;
} }
std::wstring pyGameCli::GameTypeID() const plUUID pyGameCli::GameTypeID() const
{ {
if (gameClient) if (gameClient)
{ {
wchar_t guidStr[64]; return plUUID(gameClient->GetGameTypeId());
wcsncpy(guidStr, plUUID(gameClient->GetGameTypeId()).AsString().ToWchar(), 64);
return guidStr;
} }
return L""; return plUUID();
} }
std::wstring pyGameCli::Name() const std::wstring pyGameCli::Name() const

6
Sources/Plasma/FeatureLib/pfPython/Games/pyGameCli.h

@ -52,8 +52,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../pyGlueHelpers.h" #include "../pyGlueHelpers.h"
#include <string> #include <string>
#include <vector> #include <vector>
#include "pnUUID/pnUUID.h"
class pfGameCli; class pfGameCli;
class plString;
class pyGameCli class pyGameCli
{ {
@ -76,11 +78,11 @@ public:
static std::vector<unsigned> GetGameIDs(); static std::vector<unsigned> GetGameIDs();
static PyObject* GetGameCli(unsigned gameID); // returns a ptGameCli static PyObject* GetGameCli(unsigned gameID); // returns a ptGameCli
static std::wstring GetGameNameByTypeID(std::wstring typeID); static std::wstring GetGameNameByTypeID(plString& typeID);
static void JoinGame(pyKey& callbackKey, unsigned gameID); static void JoinGame(pyKey& callbackKey, unsigned gameID);
unsigned GameID() const; unsigned GameID() const;
std::wstring GameTypeID() const; plUUID GameTypeID() const;
std::wstring Name() const; std::wstring Name() const;
unsigned PlayerCount() const; unsigned PlayerCount() const;

29
Sources/Plasma/FeatureLib/pfPython/Games/pyGameCliGlue.cpp

@ -84,31 +84,20 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameNameByTypeID, args, "Params: guid\nRetu
PyObject* textObj; PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj)) if (!PyArg_ParseTuple(args, "O", &textObj))
{ {
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string"); PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
if (PyUnicode_Check(textObj))
{ if (PyString_CheckEx(textObj))
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
std::wstring retVal = pyGameCli::GetGameNameByTypeID(text);
delete [] text;
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
else if (PyString_Check(textObj))
{ {
// we'll allow this, just in case something goes weird plString guid = PyString_AsStringEx(textObj);
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text); std::wstring retVal = pyGameCli::GetGameNameByTypeID(guid);
std::wstring retVal = pyGameCli::GetGameNameByTypeID(wText);
delete [] wText;
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length()); return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
} }
else else
{ {
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string"); PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a string");
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
} }
@ -139,8 +128,8 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameID)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameTypeID) PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameTypeID)
{ {
std::wstring retVal = self->fThis->GameTypeID(); plUUID retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length()); return PyString_FromPlString(retVal.AsString());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, name) PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, name)

25
Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGameMgrMsg.h" #include "pyGameMgrMsg.h"
#include "pfGameMgr/pfGameMgr.h" #include "pfGameMgr/pfGameMgr.h"
#include "pnUUID/pnUUID.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
@ -93,7 +94,7 @@ pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg): pyGam
message = nil; // wrong type, just clear it out message = nil; // wrong type, just clear it out
} }
unsigned long pyGameMgrInviteReceivedMsg::InviterID() const uint32_t pyGameMgrInviteReceivedMsg::InviterID() const
{ {
if (message) if (message)
{ {
@ -103,19 +104,17 @@ unsigned long pyGameMgrInviteReceivedMsg::InviterID() const
return 0; return 0;
} }
std::wstring pyGameMgrInviteReceivedMsg::GameTypeID() const plUUID pyGameMgrInviteReceivedMsg::GameTypeID() const
{ {
if (message) if (message)
{ {
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg; const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
wchar_t buffer[64]; return plUUID(gmMsg->gameTypeId);
wcsncpy(buffer, plUUID(gmMsg->gameTypeId).AsString().ToWchar(), 64);
return buffer;
} }
return L""; return plUUID();
} }
unsigned long pyGameMgrInviteReceivedMsg::NewGameID() const uint32_t pyGameMgrInviteReceivedMsg::NewGameID() const
{ {
if (message) if (message)
{ {
@ -134,7 +133,7 @@ pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg): pyGameM
message = nil; // wrong type, just clear it out message = nil; // wrong type, just clear it out
} }
unsigned long pyGameMgrInviteRevokedMsg::InviterID() const uint32_t pyGameMgrInviteRevokedMsg::InviterID() const
{ {
if (message) if (message)
{ {
@ -144,19 +143,17 @@ unsigned long pyGameMgrInviteRevokedMsg::InviterID() const
return 0; return 0;
} }
std::wstring pyGameMgrInviteRevokedMsg::GameTypeID() const plUUID pyGameMgrInviteRevokedMsg::GameTypeID() const
{ {
if (message) if (message)
{ {
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg; const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
wchar_t buffer[64]; return plUUID(gmMsg->gameTypeId);
wcsncpy(buffer, plUUID(gmMsg->gameTypeId).AsString().ToWchar(), 64);
return buffer;
} }
return L""; return plUUID();
} }
unsigned long pyGameMgrInviteRevokedMsg::NewGameID() const uint32_t pyGameMgrInviteRevokedMsg::NewGameID() const
{ {
if (message) if (message)
{ {

13
Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsg.h

@ -53,6 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <string> #include <string>
class pfGameMgrMsg; class pfGameMgrMsg;
class plUUID;
class pyGameMgrMsg class pyGameMgrMsg
{ {
@ -95,9 +96,9 @@ public:
static void AddPlasmaClasses(PyObject* m); static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const; uint32_t InviterID() const;
std::wstring GameTypeID() const; plUUID GameTypeID() const;
unsigned long NewGameID() const; uint32_t NewGameID() const;
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -116,9 +117,9 @@ public:
static void AddPlasmaClasses(PyObject* m); static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const; uint32_t InviterID() const;
std::wstring GameTypeID() const; plUUID GameTypeID() const;
unsigned long NewGameID() const; uint32_t NewGameID() const;
}; };
#endif // pyGameMgrMsg_h #endif // pyGameMgrMsg_h

7
Sources/Plasma/FeatureLib/pfPython/Games/pyGameMgrMsgGlue.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGameMgrMsg.h" #include "pyGameMgrMsg.h"
#include "pfGameMgr/pfGameMgr.h" #include "pfGameMgr/pfGameMgr.h"
#include "pnUUID/pnUUID.h"
#include "../pyEnum.h" #include "../pyEnum.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -130,8 +131,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, inviterID)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID) PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID)
{ {
std::wstring retVal = self->fThis->GameTypeID(); return PyString_FromString(self->fThis->GameTypeID().AsString().c_str());
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, newGameID) PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, newGameID)
@ -183,8 +183,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, inviterID)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID) PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID)
{ {
std::wstring retVal = self->fThis->GameTypeID(); return PyString_FromString(self->fThis->GameTypeID().AsString().c_str());
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, newGameID) PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, newGameID)

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

@ -42,6 +42,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef cyMisc_h #ifndef cyMisc_h
#define cyMisc_h #define cyMisc_h
#include <string>
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// NAME: cyMisc // NAME: cyMisc

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

@ -906,7 +906,8 @@ PyObject *ptImportHook_load_module_detail(ptImportHook *self, char* module_name,
PyObject* modules = PyImport_GetModuleDict(); PyObject* modules = PyImport_GetModuleDict();
hsAssert(PyDict_Check(modules), "sys.modules is not a dict"); hsAssert(PyDict_Check(modules), "sys.modules is not a dict");
if (result = PyDict_GetItemString(modules, module_name)) result = PyDict_GetItemString(modules, module_name);
if (result)
{ {
if (!PyModule_Check(result)) if (!PyModule_Check(result))
{ {

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

@ -47,8 +47,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#include <locale>
#include <Python.h> #include <Python.h>
#include <locale>
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "pyGeometry3.h" #include "pyGeometry3.h"

2
Sources/Plasma/FeatureLib/pfPython/pyEnum.cpp

@ -107,7 +107,7 @@ static int EnumValue_print(PyObject *self, FILE *fp, int flags)
if (text == NULL) if (text == NULL)
return -1; return -1;
fprintf(fp, text); // and print it to the file fprintf(fp, "%s", text); // and print it to the file
return 0; return 0;
} }

1
Sources/Plasma/FeatureLib/pfPython/pyGUIControlDraggable.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include <Python.h>
#include "pyKey.h" #include "pyKey.h"
#pragma hdrstop #pragma hdrstop

1
Sources/Plasma/FeatureLib/pfPython/pyGUIControlRadioGroup.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include <Python.h>
#include "pyKey.h" #include "pyKey.h"
#pragma hdrstop #pragma hdrstop

1
Sources/Plasma/FeatureLib/pfPython/pyGUIPopUpMenu.cpp

@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include <Python.h>
#include "pyKey.h" #include "pyKey.h"
#pragma hdrstop #pragma hdrstop

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

@ -210,14 +210,14 @@ PYTHON_METHOD_DEFINITION(ptNotify, addVarNumber, args)
if (number == NULL || number == Py_None) if (number == NULL || number == Py_None)
self->fThis->AddVarNull(name); self->fThis->AddVarNull(name);
else if (PyInt_Check(number)) else if (PyInt_Check(number))
self->fThis->AddVarNumber(name, PyInt_AsLong(number)); self->fThis->AddVarNumber(name, (int)PyInt_AsLong(number));
else if (PyLong_Check(number)) else if (PyLong_Check(number))
{ {
// try as int first // try as int first
long i = PyLong_AsLong(number); long i = PyLong_AsLong(number);
if (!PyErr_Occurred()) if (!PyErr_Occurred())
{ {
self->fThis->AddVarNumber(name, i); self->fThis->AddVarNumber(name, (int)i);
} }
else else
{ {

9
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp

@ -58,6 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyNetLinkingMgr.h" #include "pyNetLinkingMgr.h"
#include "pyAgeInfoStruct.h" #include "pyAgeInfoStruct.h"
#include "pnUUID/pnUUID.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
// should only be created from C++ side // should only be created from C++ side
@ -228,16 +229,14 @@ void pyVaultAgeInfoNode::SetAgeUserDefinedName( const char * v )
{ {
} }
const char * pyVaultAgeInfoNode::GetAgeInstanceGuid() const plUUID pyVaultAgeInfoNode::GetAgeInstanceGuid() const
{ {
fAgeInstGuid[0] = 0;
if (fNode) { if (fNode) {
VaultAgeInfoNode access(fNode); VaultAgeInfoNode access(fNode);
strncpy(fAgeInstGuid, plUUID(access.ageInstUuid).AsString().c_str(), 64); return plUUID(access.ageInstUuid);
} }
return fAgeInstGuid; return plUUID();
} }
void pyVaultAgeInfoNode::SetAgeInstanceGuid( const char * sguid ) void pyVaultAgeInfoNode::SetAgeInstanceGuid( const char * sguid )

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

@ -56,12 +56,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct RelVaultNode; struct RelVaultNode;
class pyVaultSDLNode; class pyVaultSDLNode;
class pyAgeInfoStruct; class pyAgeInfoStruct;
class plUUID;
class pyVaultAgeInfoNode : public pyVaultNode class pyVaultAgeInfoNode : public pyVaultNode
{ {
private: private:
mutable char fAgeInstGuid[64];
mutable std::string fAgeFilename; mutable std::string fAgeFilename;
mutable std::string fAgeInstName; mutable std::string fAgeInstName;
mutable std::string fAgeUserName; mutable std::string fAgeUserName;
@ -105,7 +105,7 @@ public:
const char * GetAgeUserDefinedName() const; const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v ); void SetAgeUserDefinedName( const char * v );
const char * GetAgeInstanceGuid() const; plUUID GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid ); void SetAgeInstanceGuid( const char * guid );
const char * GetAgeDescription() const; const char * GetAgeDescription() const;

3
Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyVaultAgeInfoNode.h" #include "pyVaultAgeInfoNode.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
// glue functions // glue functions
PYTHON_CLASS_DEFINITION(ptVaultAgeInfoNode, pyVaultAgeInfoNode); PYTHON_CLASS_DEFINITION(ptVaultAgeInfoNode, pyVaultAgeInfoNode);
@ -147,7 +148,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeUserDefinedName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeInstanceGuid) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeInstanceGuid)
{ {
return PyString_FromString(self->fThis->GetAgeInstanceGuid()); return PyString_FromPlString(self->fThis->GetAgeInstanceGuid().AsString());
} }
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceGuid, args) PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceGuid, args)

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

@ -64,8 +64,6 @@ class pySpawnPointInfoRef;
class pyVaultAgeLinkNode : public pyVaultNode class pyVaultAgeLinkNode : public pyVaultNode
{ {
private: private:
mutable std::string fAgeGuidStr; // for getting Age GUID
mutable plAgeLinkStruct fAgeLinkStruct; // for use with AsAgeLinkStruct() mutable plAgeLinkStruct fAgeLinkStruct; // for use with AsAgeLinkStruct()
protected: protected:

3
Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp

@ -192,7 +192,8 @@ void pyVaultImageNode::Image_SetImage(pyImage& image)
fMipmap = nil; fMipmap = nil;
} }
if (fMipmap = image.GetImage()) { fMipmap = image.GetImage();
if (fMipmap) {
VaultImageNode access(fNode); VaultImageNode access(fNode);
access.StuffImage(fMipmap); access.StuffImage(fMipmap);

9
Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyVaultMarkerGameNode.h" #include "pyVaultMarkerGameNode.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
// should only be created from C++ side // should only be created from C++ side
pyVaultMarkerGameNode::pyVaultMarkerGameNode(RelVaultNode* nfsNode) pyVaultMarkerGameNode::pyVaultMarkerGameNode(RelVaultNode* nfsNode)
@ -88,15 +89,13 @@ void pyVaultMarkerGameNode::SetGameName (const char v[])
} }
} }
const char * pyVaultMarkerGameNode::GetGameGuid () const plUUID pyVaultMarkerGameNode::GetGameGuid() const
{ {
fGameGuid[0] = 0;
if (fNode) { if (fNode) {
VaultMarkerGameNode access(fNode); VaultMarkerGameNode access(fNode);
strncpy(fGameGuid, plUUID(access.gameGuid).AsString().c_str(), 64); return plUUID(access.gameGuid);
} }
return fGameGuid; return plUUID();
} }
void pyVaultMarkerGameNode::SetGameGuid (const char v[]) void pyVaultMarkerGameNode::SetGameGuid (const char v[])

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

@ -56,12 +56,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetBase/pnNetBase.h" #include "pnNetBase/pnNetBase.h"
struct RelVaultNode; struct RelVaultNode;
class plUUID;
class pyVaultMarkerGameNode : public pyVaultNode class pyVaultMarkerGameNode : public pyVaultNode
{ {
private: private:
mutable char fGameName[kMaxVaultNodeStringLength]; mutable char fGameName[kMaxVaultNodeStringLength];
mutable char fGameGuid[64];
protected: protected:
// should only be created from C++ side // should only be created from C++ side
@ -86,7 +86,7 @@ public:
const char * GetGameName () const; const char * GetGameName () const;
void SetGameName (const char v[]); void SetGameName (const char v[]);
const char * GetGameGuid () const; plUUID GetGameGuid() const;
void SetGameGuid (const char v[]); void SetGameGuid (const char v[]);
}; };

3
Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp

@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyVaultMarkerGameNode.h" #include "pyVaultMarkerGameNode.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
// glue functions // glue functions
PYTHON_CLASS_DEFINITION(ptVaultMarkerGameNode, pyVaultMarkerGameNode); PYTHON_CLASS_DEFINITION(ptVaultMarkerGameNode, pyVaultMarkerGameNode);
@ -84,7 +85,7 @@ PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultMarkerGameNode, getGameGuid) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultMarkerGameNode, getGameGuid)
{ {
return PyString_FromString(self->fThis->GetGameGuid()); return PyString_FromPlString(self->fThis->GetGameGuid().AsString());
} }
PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameGuid, args) PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameGuid, args)

24
Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp

@ -45,17 +45,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include <exception>
#include <Python.h> #include <Python.h>
#include <exception>
#pragma hdrstop #pragma hdrstop
#include "pyVaultNode.h" #include "pyVaultNode.h"
#ifndef BUILDING_PYPLASMA #ifndef BUILDING_PYPLASMA
# include "pyVault.h" # include "pyVault.h"
# include "pyVaultSystemNode.h" # include "pyVaultSystemNode.h"
# include "pnNetCommon/plNetApp.h" # include "pnNetCommon/plNetApp.h"
# include "plNetClientComm/plNetClientComm.h" # include "plNetClientComm/plNetClientComm.h"
#endif #endif
#include "pyImage.h" #include "pyImage.h"
#include "pyDniCoordinates.h" #include "pyDniCoordinates.h"
#include "pyVaultNodeRef.h" #include "pyVaultNodeRef.h"
@ -72,6 +74,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyVaultPlayerNode.h" #include "pyVaultPlayerNode.h"
#include "pyVaultSDLNode.h" #include "pyVaultSDLNode.h"
#include "pnUUID/pnUUID.h"
#include "plGImage/plMipmap.h" #include "plGImage/plMipmap.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
@ -168,7 +171,6 @@ RelVaultNode * pyVaultNode::pyVaultNodeOperationCallback::GetNode () {
// only for python glue, do NOT call // only for python glue, do NOT call
pyVaultNode::pyVaultNode() pyVaultNode::pyVaultNode()
: fNode(nil) : fNode(nil)
, fCreateAgeGuid(nil)
, fCreateAgeName(nil) , fCreateAgeName(nil)
{ {
} }
@ -176,7 +178,6 @@ pyVaultNode::pyVaultNode()
// should only be created from C++ side // should only be created from C++ side
pyVaultNode::pyVaultNode( RelVaultNode* nfsNode ) pyVaultNode::pyVaultNode( RelVaultNode* nfsNode )
: fNode(nfsNode) : fNode(nfsNode)
, fCreateAgeGuid(nil)
, fCreateAgeName(nil) , fCreateAgeName(nil)
{ {
if (fNode) if (fNode)
@ -187,7 +188,6 @@ pyVaultNode::~pyVaultNode()
{ {
if (fNode) if (fNode)
fNode->DecRef("pyVaultNode"); fNode->DecRef("pyVaultNode");
free(fCreateAgeGuid);
free(fCreateAgeName); free(fCreateAgeName);
} }
@ -322,20 +322,13 @@ const char * pyVaultNode::GetCreateAgeName( void )
return fCreateAgeName; return fCreateAgeName;
} }
const char * pyVaultNode::GetCreateAgeGuid( void ) plUUID pyVaultNode::GetCreateAgeGuid(void) const
{ {
if (!fNode)
return "";
if (fCreateAgeGuid)
return fCreateAgeGuid;
if (fNode) { if (fNode) {
fCreateAgeGuid = (char*)malloc(64); return plUUID(fNode->createAgeUuid);
strncpy(fCreateAgeGuid, plUUID(fNode->createAgeUuid).AsString().c_str(), 64);
} }
return fCreateAgeGuid; return plUUID();
} }
PyObject* pyVaultNode::GetCreateAgeCoords () { PyObject* pyVaultNode::GetCreateAgeCoords () {
@ -390,9 +383,6 @@ void pyVaultNode::SetCreateAgeName( const char * v )
void pyVaultNode::SetCreateAgeGuid( const char * v ) void pyVaultNode::SetCreateAgeGuid( const char * v )
{ {
free(fCreateAgeGuid);
fCreateAgeGuid = nil;
ASSERT(fNode); ASSERT(fNode);
Uuid uuid; Uuid uuid;
GuidFromString(v, &uuid); GuidFromString(v, &uuid);

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

@ -54,6 +54,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct RelVaultNode; struct RelVaultNode;
class plMipmap; class plMipmap;
class pyImage; class pyImage;
class plUUID;
class pyDniCoordinates; class pyDniCoordinates;
@ -97,7 +98,6 @@ public:
}; };
RelVaultNode * fNode; RelVaultNode * fNode;
mutable char * fCreateAgeGuid;
mutable char * fCreateAgeName; mutable char * fCreateAgeName;
protected: protected:
@ -138,7 +138,7 @@ public:
uint32_t GetCreateTime( void ); uint32_t GetCreateTime( void );
uint32_t GetCreateAgeTime( void ); uint32_t GetCreateAgeTime( void );
const char * GetCreateAgeName( void ); const char * GetCreateAgeName( void );
const char * GetCreateAgeGuid( void ); plUUID GetCreateAgeGuid(void) const;
PyObject* GetCreateAgeCoords (); PyObject* GetCreateAgeCoords ();
// public setters // public setters

3
Sources/Plasma/FeatureLib/pfPython/pyVaultNodeGlue.cpp

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop #pragma hdrstop
#include "pyVaultNode.h" #include "pyVaultNode.h"
#include "pnUUID/pnUUID.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
// glue functions // glue functions
@ -153,7 +154,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultNode, getCreateAgeName)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultNode, getCreateAgeGuid) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultNode, getCreateAgeGuid)
{ {
return PyString_FromString(self->fThis->GetCreateAgeGuid()); return PyString_FromPlString(self->fThis->GetCreateAgeGuid().AsString());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultNode, getCreateAgeCoords) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultNode, getCreateAgeCoords)

2
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoListNode.cpp

@ -45,8 +45,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <Python.h> #include <Python.h>
#include <algorithm>
#pragma hdrstop #pragma hdrstop
#include "pyVaultPlayerInfoListNode.h" #include "pyVaultPlayerInfoListNode.h"

13
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyVaultPlayerInfoNode.h" #include "pyVaultPlayerInfoNode.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
#ifndef BUILDING_PYPLASMA #ifndef BUILDING_PYPLASMA
# include "pyVault.h" # include "pyVault.h"
#endif #endif
@ -158,15 +159,13 @@ void pyVaultPlayerInfoNode::Player_SetAgeGuid( const char * guidtext)
playerInfo.SetAgeInstUuid(ageInstId); playerInfo.SetAgeInstUuid(ageInstId);
} }
const char * pyVaultPlayerInfoNode::Player_GetAgeGuid( void ) plUUID pyVaultPlayerInfoNode::Player_GetAgeGuid(void) const
{ {
if (!fNode) if (fNode) {
return "";
VaultPlayerInfoNode playerInfo(fNode); VaultPlayerInfoNode playerInfo(fNode);
return plUUID(playerInfo.ageInstUuid);
strncpy(ansiAgeInstUuid, plUUID(playerInfo.ageInstUuid).AsString().c_str(), 64); }
return ansiAgeInstUuid; return plUUID();
} }
// online status // online status

5
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h

@ -51,11 +51,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyVaultNode.h" #include "pyVaultNode.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
class plUUID;
class pyVaultPlayerInfoNode : public pyVaultNode class pyVaultPlayerInfoNode : public pyVaultNode
{ {
mutable char * ansiPlayerName; mutable char * ansiPlayerName;
mutable char * ansiAgeInstName; mutable char * ansiAgeInstName;
mutable char ansiAgeInstUuid[64];
protected: protected:
// should only be created from C++ side // should only be created from C++ side
@ -88,7 +89,7 @@ public:
void Player_SetAgeInstanceName( const char * agename ); void Player_SetAgeInstanceName( const char * agename );
const char * Player_GetAgeInstanceName( void ); const char * Player_GetAgeInstanceName( void );
void Player_SetAgeGuid( const char * guidtext); void Player_SetAgeGuid( const char * guidtext);
const char * Player_GetAgeGuid( void ); plUUID Player_GetAgeGuid(void) const;
// online status // online status
void Player_SetOnline( bool b ); void Player_SetOnline( bool b );
bool Player_IsOnline( void ); bool Player_IsOnline( void );

3
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop #pragma hdrstop
#include "pyVaultPlayerInfoNode.h" #include "pyVaultPlayerInfoNode.h"
#include "pnUUID/pnUUID.h"
#include "plVault/plVault.h" #include "plVault/plVault.h"
// glue functions // glue functions
@ -122,7 +123,7 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeGuid, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetAgeGuid) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetAgeGuid)
{ {
return PyString_FromString(self->fThis->Player_GetAgeGuid()); return PyString_FromPlString(self->fThis->Player_GetAgeGuid().AsString());
} }
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetOnline, args) PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetOnline, args)

Loading…
Cancel
Save