Browse Source

Clean up for Python interface stuff.

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

2
Sources/Plasma/FeatureLib/pfPython/Games/Marker/pyMarkerGameGlue.cpp

@ -398,4 +398,4 @@ void pyMarkerGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsMarkerGame);
PYTHON_GLOBAL_METHOD_WKEY(methods, PtCreateMarkerGame);
}
}

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 "../pyKey.h"
#include "plString.h"
#pragma hdrstop
#include "pyGameCli.h"
@ -81,9 +82,9 @@ PyObject* pyGameCli::GetGameCli(unsigned gameID)
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);
}
@ -99,15 +100,13 @@ unsigned pyGameCli::GameID() const
return 0;
}
std::wstring pyGameCli::GameTypeID() const
plUUID pyGameCli::GameTypeID() const
{
if (gameClient)
{
wchar_t guidStr[64];
wcsncpy(guidStr, plUUID(gameClient->GetGameTypeId()).AsString().ToWchar(), 64);
return guidStr;
return plUUID(gameClient->GetGameTypeId());
}
return L"";
return plUUID();
}
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 <string>
#include <vector>
#include "pnUUID/pnUUID.h"
class pfGameCli;
class plString;
class pyGameCli
{
@ -76,11 +78,11 @@ public:
static std::vector<unsigned> GetGameIDs();
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);
unsigned GameID() const;
std::wstring GameTypeID() const;
plUUID GameTypeID() const;
std::wstring Name() const;
unsigned PlayerCount() const;

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

@ -84,31 +84,20 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameNameByTypeID, args, "Params: guid\nRetu
PyObject* 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;
}
if (PyUnicode_Check(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))
if (PyString_CheckEx(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
std::wstring retVal = pyGameCli::GetGameNameByTypeID(wText);
delete [] wText;
plString guid = PyString_AsStringEx(textObj);
std::wstring retVal = pyGameCli::GetGameNameByTypeID(guid);
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
else
{
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a string");
PYTHON_RETURN_ERROR;
}
}
@ -139,8 +128,8 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameID)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
plUUID retVal = self->fThis->GameTypeID();
return PyString_FromPlString(retVal.AsString());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, name)
@ -255,4 +244,4 @@ void pyGameCli::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
PYTHON_GLOBAL_METHOD(methods, PtGetGameCli);
PYTHON_GLOBAL_METHOD(methods, PtGetGameNameByTypeID);
PYTHON_GLOBAL_METHOD(methods, PtJoinGame);
}
}

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 "pfGameMgr/pfGameMgr.h"
#include "pnUUID/pnUUID.h"
///////////////////////////////////////////////////////////////////////////////
//
@ -93,7 +94,7 @@ pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg): pyGam
message = nil; // wrong type, just clear it out
}
unsigned long pyGameMgrInviteReceivedMsg::InviterID() const
uint32_t pyGameMgrInviteReceivedMsg::InviterID() const
{
if (message)
{
@ -103,19 +104,17 @@ unsigned long pyGameMgrInviteReceivedMsg::InviterID() const
return 0;
}
std::wstring pyGameMgrInviteReceivedMsg::GameTypeID() const
plUUID pyGameMgrInviteReceivedMsg::GameTypeID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
wchar_t buffer[64];
wcsncpy(buffer, plUUID(gmMsg->gameTypeId).AsString().ToWchar(), 64);
return buffer;
return plUUID(gmMsg->gameTypeId);
}
return L"";
return plUUID();
}
unsigned long pyGameMgrInviteReceivedMsg::NewGameID() const
uint32_t pyGameMgrInviteReceivedMsg::NewGameID() const
{
if (message)
{
@ -134,7 +133,7 @@ pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg): pyGameM
message = nil; // wrong type, just clear it out
}
unsigned long pyGameMgrInviteRevokedMsg::InviterID() const
uint32_t pyGameMgrInviteRevokedMsg::InviterID() const
{
if (message)
{
@ -144,19 +143,17 @@ unsigned long pyGameMgrInviteRevokedMsg::InviterID() const
return 0;
}
std::wstring pyGameMgrInviteRevokedMsg::GameTypeID() const
plUUID pyGameMgrInviteRevokedMsg::GameTypeID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
wchar_t buffer[64];
wcsncpy(buffer, plUUID(gmMsg->gameTypeId).AsString().ToWchar(), 64);
return buffer;
return plUUID(gmMsg->gameTypeId);
}
return L"";
return plUUID();
}
unsigned long pyGameMgrInviteRevokedMsg::NewGameID() const
uint32_t pyGameMgrInviteRevokedMsg::NewGameID() const
{
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>
class pfGameMgrMsg;
class plUUID;
class pyGameMgrMsg
{
@ -95,9 +96,9 @@ public:
static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const;
std::wstring GameTypeID() const;
unsigned long NewGameID() const;
uint32_t InviterID() const;
plUUID GameTypeID() const;
uint32_t NewGameID() const;
};
///////////////////////////////////////////////////////////////////////////////
@ -116,9 +117,9 @@ public:
static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const;
std::wstring GameTypeID() const;
unsigned long NewGameID() const;
uint32_t InviterID() const;
plUUID GameTypeID() const;
uint32_t NewGameID() const;
};
#endif // pyGameMgrMsg_h

9
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 "pfGameMgr/pfGameMgr.h"
#include "pnUUID/pnUUID.h"
#include "../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
@ -130,8 +131,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, inviterID)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
return PyString_FromString(self->fThis->GameTypeID().AsString().c_str());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, newGameID)
@ -183,8 +183,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, inviterID)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
return PyString_FromString(self->fThis->GameTypeID().AsString().c_str());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, newGameID)
@ -219,4 +218,4 @@ void pyGameMgrInviteRevokedMsg::AddPlasmaClasses(PyObject* m)
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrInviteRevokedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
}

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
#define cyMisc_h
#include <string>
/////////////////////////////////////////////////////////////////////////////
//
// 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();
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))
{

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 <locale>
#include "HeadSpin.h"
#include "plgDispatch.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)
return -1;
fprintf(fp, text); // and print it to the file
fprintf(fp, "%s", text); // and print it to the file
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==*/
#include <Python.h>
#include "pyKey.h"
#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==*/
#include <Python.h>
#include "pyKey.h"
#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==*/
#include <Python.h>
#include "pyKey.h"
#pragma hdrstop

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

@ -210,14 +210,14 @@ PYTHON_METHOD_DEFINITION(ptNotify, addVarNumber, args)
if (number == NULL || number == Py_None)
self->fThis->AddVarNull(name);
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))
{
// try as int first
long i = PyLong_AsLong(number);
if (!PyErr_Occurred())
{
self->fThis->AddVarNumber(name, i);
self->fThis->AddVarNumber(name, (int)i);
}
else
{
@ -493,4 +493,4 @@ void pyNotify::AddPlasmaConstantsClasses(PyObject *m)
PYTHON_ENUM_ELEMENT(PtMultiStageEventType, kAdvanceNextStage, proEventData::kAdvanceNextStage);
PYTHON_ENUM_ELEMENT(PtMultiStageEventType, kRegressPrevStage, proEventData::kRegressPrevStage);
PYTHON_ENUM_END(m, PtMultiStageEventType);
}
}

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 "pyAgeInfoStruct.h"
#include "pnUUID/pnUUID.h"
#include "plVault/plVault.h"
// 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) {
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 )

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

@ -56,12 +56,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct RelVaultNode;
class pyVaultSDLNode;
class pyAgeInfoStruct;
class plUUID;
class pyVaultAgeInfoNode : public pyVaultNode
{
private:
mutable char fAgeInstGuid[64];
mutable std::string fAgeFilename;
mutable std::string fAgeInstName;
mutable std::string fAgeUserName;
@ -105,7 +105,7 @@ public:
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
const char * GetAgeInstanceGuid() const;
plUUID GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
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 "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
// glue functions
PYTHON_CLASS_DEFINITION(ptVaultAgeInfoNode, pyVaultAgeInfoNode);
@ -147,7 +148,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeUserDefinedName, args)
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)

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

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

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

@ -192,10 +192,11 @@ void pyVaultImageNode::Image_SetImage(pyImage& image)
fMipmap = nil;
}
if (fMipmap = image.GetImage()) {
fMipmap = image.GetImage();
if (fMipmap) {
VaultImageNode access(fNode);
access.StuffImage(fMipmap);
fMipmapKey = image.GetKey();
if (!fMipmapKey)
fMipmapKey = CreateAndRefImageKey(fNode->nodeId, 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 "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
// should only be created from C++ side
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) {
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[])

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"
struct RelVaultNode;
class plUUID;
class pyVaultMarkerGameNode : public pyVaultNode
{
private:
mutable char fGameName[kMaxVaultNodeStringLength];
mutable char fGameGuid[64];
protected:
// should only be created from C++ side
@ -86,7 +86,7 @@ public:
const char * GetGameName () const;
void SetGameName (const char v[]);
const char * GetGameGuid () const;
plUUID GetGameGuid() const;
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 "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
// glue functions
PYTHON_CLASS_DEFINITION(ptVaultMarkerGameNode, pyVaultMarkerGameNode);
@ -84,7 +85,7 @@ PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameName, args)
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)

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

@ -45,33 +45,36 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//
//////////////////////////////////////////////////////////////////////
#include <exception>
#include <Python.h>
#include <exception>
#pragma hdrstop
#include "pyVaultNode.h"
#ifndef BUILDING_PYPLASMA
# include "pyVault.h"
# include "pyVaultSystemNode.h"
# include "pnNetCommon/plNetApp.h"
# include "plNetClientComm/plNetClientComm.h"
#endif
# include "pyImage.h"
# include "pyDniCoordinates.h"
# include "pyVaultNodeRef.h"
# include "pyVaultFolderNode.h"
# include "pyVaultPlayerInfoListNode.h"
# include "pyVaultImageNode.h"
# include "pyVaultTextNoteNode.h"
# include "pyVaultAgeLinkNode.h"
# include "pyVaultChronicleNode.h"
# include "pyVaultPlayerInfoNode.h"
# include "pyVaultMarkerGameNode.h"
# include "pyVaultAgeInfoNode.h"
# include "pyVaultAgeInfoListNode.h"
# include "pyVaultPlayerNode.h"
# include "pyVaultSDLNode.h"
#include "pyImage.h"
#include "pyDniCoordinates.h"
#include "pyVaultNodeRef.h"
#include "pyVaultFolderNode.h"
#include "pyVaultPlayerInfoListNode.h"
#include "pyVaultImageNode.h"
#include "pyVaultTextNoteNode.h"
#include "pyVaultAgeLinkNode.h"
#include "pyVaultChronicleNode.h"
#include "pyVaultPlayerInfoNode.h"
#include "pyVaultMarkerGameNode.h"
#include "pyVaultAgeInfoNode.h"
#include "pyVaultAgeInfoListNode.h"
#include "pyVaultPlayerNode.h"
#include "pyVaultSDLNode.h"
#include "pnUUID/pnUUID.h"
#include "plGImage/plMipmap.h"
#include "plVault/plVault.h"
@ -168,7 +171,6 @@ RelVaultNode * pyVaultNode::pyVaultNodeOperationCallback::GetNode () {
// only for python glue, do NOT call
pyVaultNode::pyVaultNode()
: fNode(nil)
, fCreateAgeGuid(nil)
, fCreateAgeName(nil)
{
}
@ -176,7 +178,6 @@ pyVaultNode::pyVaultNode()
// should only be created from C++ side
pyVaultNode::pyVaultNode( RelVaultNode* nfsNode )
: fNode(nfsNode)
, fCreateAgeGuid(nil)
, fCreateAgeName(nil)
{
if (fNode)
@ -187,7 +188,6 @@ pyVaultNode::~pyVaultNode()
{
if (fNode)
fNode->DecRef("pyVaultNode");
free(fCreateAgeGuid);
free(fCreateAgeName);
}
@ -322,20 +322,13 @@ const char * pyVaultNode::GetCreateAgeName( void )
return fCreateAgeName;
}
const char * pyVaultNode::GetCreateAgeGuid( void )
plUUID pyVaultNode::GetCreateAgeGuid(void) const
{
if (!fNode)
return "";
if (fCreateAgeGuid)
return fCreateAgeGuid;
if (fNode) {
fCreateAgeGuid = (char*)malloc(64);
strncpy(fCreateAgeGuid, plUUID(fNode->createAgeUuid).AsString().c_str(), 64);
return plUUID(fNode->createAgeUuid);
}
return fCreateAgeGuid;
return plUUID();
}
PyObject* pyVaultNode::GetCreateAgeCoords () {
@ -390,9 +383,6 @@ void pyVaultNode::SetCreateAgeName( const char * v )
void pyVaultNode::SetCreateAgeGuid( const char * v )
{
free(fCreateAgeGuid);
fCreateAgeGuid = nil;
ASSERT(fNode);
Uuid 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;
class plMipmap;
class pyImage;
class plUUID;
class pyDniCoordinates;
@ -97,7 +98,6 @@ public:
};
RelVaultNode * fNode;
mutable char * fCreateAgeGuid;
mutable char * fCreateAgeName;
protected:
@ -138,7 +138,7 @@ public:
uint32_t GetCreateTime( void );
uint32_t GetCreateAgeTime( void );
const char * GetCreateAgeName( void );
const char * GetCreateAgeGuid( void );
plUUID GetCreateAgeGuid(void) const;
PyObject* GetCreateAgeCoords ();
// 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
#include "pyVaultNode.h"
#include "pnUUID/pnUUID.h"
#include "plVault/plVault.h"
// glue functions
@ -153,7 +154,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultNode, getCreateAgeName)
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)

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 <algorithm>
#pragma hdrstop
#include "pyVaultPlayerInfoListNode.h"

15
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 "plVault/plVault.h"
#include "pnUUID/pnUUID.h"
#ifndef BUILDING_PYPLASMA
# include "pyVault.h"
#endif
@ -158,15 +159,13 @@ void pyVaultPlayerInfoNode::Player_SetAgeGuid( const char * guidtext)
playerInfo.SetAgeInstUuid(ageInstId);
}
const char * pyVaultPlayerInfoNode::Player_GetAgeGuid( void )
plUUID pyVaultPlayerInfoNode::Player_GetAgeGuid(void) const
{
if (!fNode)
return "";
VaultPlayerInfoNode playerInfo(fNode);
strncpy(ansiAgeInstUuid, plUUID(playerInfo.ageInstUuid).AsString().c_str(), 64);
return ansiAgeInstUuid;
if (fNode) {
VaultPlayerInfoNode playerInfo(fNode);
return plUUID(playerInfo.ageInstUuid);
}
return plUUID();
}
// 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 "pyGlueHelpers.h"
class plUUID;
class pyVaultPlayerInfoNode : public pyVaultNode
{
mutable char * ansiPlayerName;
mutable char * ansiAgeInstName;
mutable char ansiAgeInstUuid[64];
protected:
// should only be created from C++ side
@ -88,7 +89,7 @@ public:
void Player_SetAgeInstanceName( const char * agename );
const char * Player_GetAgeInstanceName( void );
void Player_SetAgeGuid( const char * guidtext);
const char * Player_GetAgeGuid( void );
plUUID Player_GetAgeGuid(void) const;
// online status
void Player_SetOnline( bool b );
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
#include "pyVaultPlayerInfoNode.h"
#include "pnUUID/pnUUID.h"
#include "plVault/plVault.h"
// glue functions
@ -122,7 +123,7 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeGuid, args)
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)

Loading…
Cancel
Save