Browse Source

Fix pfPython

Adam Johnson 10 years ago
parent
commit
eb68452554
  1. 12
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp
  2. 6
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  3. 32
      Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp
  4. 15
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp
  5. 10
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h
  6. 2
      Sources/Plasma/FeatureLib/pfPython/pyDniInfoSourceGlue.cpp
  7. 34
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  8. 51
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.cpp
  9. 18
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNode.h
  10. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultAgeInfoNodeGlue.cpp
  11. 51
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.cpp
  12. 11
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.h
  13. 8
      Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp
  14. 47
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.cpp
  15. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.h
  16. 3
      Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNodeGlue.cpp
  17. 33
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.cpp
  18. 5
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNode.h
  19. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultImageNodeGlue.cpp
  20. 14
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.cpp
  21. 10
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNode.h
  22. 2
      Sources/Plasma/FeatureLib/pfPython/pyVaultMarkerGameNodeGlue.cpp
  23. 33
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.cpp
  24. 1
      Sources/Plasma/FeatureLib/pfPython/pyVaultNode.h
  25. 56
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.cpp
  26. 13
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNode.h
  27. 4
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerInfoNodeGlue.cpp
  28. 28
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp
  29. 6
      Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.h
  30. 9
      Sources/Plasma/FeatureLib/pfPython/pyVaultSDLNode.cpp
  31. 86
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp
  32. 9
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.h
  33. 6
      Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNodeGlue.cpp

12
Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp

@ -1665,15 +1665,12 @@ bool cyAvatar::LoadClothingFromFile(plFileName filename)
void cyAvatar::ChangeAvatar(const char* genderName) void cyAvatar::ChangeAvatar(const char* genderName)
{ {
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
plClothingMgr::ChangeAvatar((char*)genderName); plClothingMgr::ChangeAvatar(genderName);
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, genderName, arrsize(wStr));
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode(); hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (rvnPlr) { if (rvnPlr) {
VaultPlayerNode plr(rvnPlr); VaultPlayerNode plr(rvnPlr);
plr.SetAvatarShapeName(wStr); plr.SetAvatarShapeName(genderName);
} }
#endif #endif
} }
@ -1687,13 +1684,10 @@ void cyAvatar::ChangeAvatar(const char* genderName)
// //
void cyAvatar::ChangePlayerName(const char* playerName) void cyAvatar::ChangePlayerName(const char* playerName)
{ {
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, playerName, arrsize(wStr));
hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode(); hsRef<RelVaultNode> rvnPlr = VaultGetPlayerNode();
if (rvnPlr) { if (rvnPlr) {
VaultPlayerNode plr(rvnPlr); VaultPlayerNode plr(rvnPlr);
plr.SetPlayerName(wStr); plr.SetPlayerName(playerName);
} }
} }

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

@ -2469,11 +2469,9 @@ int cyMisc::GetKILevel()
{ {
int result = pfKIMsg::kNanoKI; int result = pfKIMsg::kNanoKI;
wchar_t wStr[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(pfKIMsg::kChronicleKILevel)) {
StrToUnicode(wStr, pfKIMsg::kChronicleKILevel, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wStr)) {
VaultChronicleNode chron(rvn); VaultChronicleNode chron(rvn);
result = wcstol(chron.GetEntryValue(), nil, 0); result = chron.GetEntryValue().ToInt();
} }
return result; return result;

32
Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp

@ -203,10 +203,7 @@ void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32
pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject );
cb->VaultOperationStarted( cbContext ); cb->VaultOperationStarted( cbContext );
wchar_t wStr[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultAgeAddDeviceAndWait(deviceName))
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultAgeAddDeviceAndWait(wStr))
cb->SetNode(rvn); cb->SetNode(rvn);
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here. cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here.
@ -215,27 +212,18 @@ void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, uint32
// Remove a device. // Remove a device.
void pyAgeVault::RemoveDevice( const char * deviceName ) void pyAgeVault::RemoveDevice( const char * deviceName )
{ {
wchar_t wStr[MAX_PATH]; VaultAgeRemoveDevice(deviceName);
StrToUnicode(wStr, deviceName, arrsize(wStr));
VaultAgeRemoveDevice(wStr);
} }
// True if device exists in age. // True if device exists in age.
bool pyAgeVault::HasDevice( const char * deviceName ) bool pyAgeVault::HasDevice( const char * deviceName )
{ {
wchar_t wStr[MAX_PATH]; return VaultAgeHasDevice(deviceName);
StrToUnicode(wStr, deviceName, arrsize(wStr));
return VaultAgeHasDevice(wStr);
} }
PyObject * pyAgeVault::GetDevice( const char * deviceName ) PyObject * pyAgeVault::GetDevice( const char * deviceName )
{ {
wchar_t wStr[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultAgeGetDevice(deviceName))
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultAgeGetDevice(wStr))
return pyVaultTextNoteNode::New(rvn); return pyVaultTextNoteNode::New(rvn);
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
@ -247,12 +235,7 @@ void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName
pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject );
cb->VaultOperationStarted( cbContext ); cb->VaultOperationStarted( cbContext );
wchar_t wDev[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(deviceName, inboxName))
StrToUnicode(wDev, deviceName, arrsize(wDev));
wchar_t wInb[MAX_PATH];
StrToUnicode(wInb, inboxName, arrsize(wInb));
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(wDev, wInb))
cb->SetNode(rvn); cb->SetNode(rvn);
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here. cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.
@ -260,10 +243,7 @@ void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName
PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName ) PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName )
{ {
wchar_t wStr[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultAgeGetDeviceInbox(deviceName))
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultAgeGetDeviceInbox(wStr))
return pyVaultTextNoteNode::New(rvn); return pyVaultTextNoteNode::New(rvn);
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;

15
Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.cpp

@ -50,14 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plVault/plVault.h" #include "plVault/plVault.h"
#include "pyDniCoordinates.h" #include "pyDniCoordinates.h"
pyDniInfoSource::pyDniInfoSource()
: fAgeName(nil)
{}
pyDniInfoSource::~pyDniInfoSource() {
free(fAgeName);
}
PyObject* pyDniInfoSource::GetAgeCoords( void ) PyObject* pyDniInfoSource::GetAgeCoords( void )
{ {
#if 0 // this may get retooled for another purpose someday... #if 0 // this may get retooled for another purpose someday...
@ -85,17 +77,14 @@ uint32_t pyDniInfoSource::GetAgeTime( void ) const
return result; return result;
} }
const char * pyDniInfoSource::GetAgeName( void ) const plString pyDniInfoSource::GetAgeName() const
{ {
hsRef<RelVaultNode> node = VaultGetAgeInfoNode(); hsRef<RelVaultNode> node = VaultGetAgeInfoNode();
if (!node) if (!node)
return ""; return "";
VaultAgeInfoNode ageInfo(node); VaultAgeInfoNode ageInfo(node);
return ageInfo.GetAgeFilename();
fAgeName = StrDupToAnsi(ageInfo.GetAgeInstanceName());
return fAgeName;
} }
plUUID pyDniInfoSource::GetAgeGuid( void ) const plUUID pyDniInfoSource::GetAgeGuid( void ) const

10
Sources/Plasma/FeatureLib/pfPython/pyDniInfoSource.h

@ -46,18 +46,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
class pyDniCoordinates; class pyDniCoordinates;
class plString;
class plUUID; class plUUID;
class pyDniInfoSource class pyDniInfoSource
{ {
private:
mutable char * fAgeName;
protected: protected:
pyDniInfoSource(); pyDniInfoSource() { }
public: public:
~pyDniInfoSource(); ~pyDniInfoSource() { }
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptDniInfoSource); PYTHON_CLASS_NEW_FRIEND(ptDniInfoSource);
@ -72,7 +70,7 @@ public:
// current time in current age (tbd) // current time in current age (tbd)
uint32_t GetAgeTime( void ) const; uint32_t GetAgeTime( void ) const;
// name of current age // name of current age
const char * GetAgeName( void ) const; plString GetAgeName() const;
// unique identifier for this age instance // unique identifier for this age instance
plUUID GetAgeGuid(void) const; plUUID GetAgeGuid(void) const;
}; };

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

@ -69,7 +69,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeTime)
PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeName) PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeName)
{ {
return PyString_FromString(self->fThis->GetAgeName()); return PyString_FromPlString(self->fThis->GetAgeName());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeGuid) PYTHON_METHOD_DEFINITION_NOARGS(ptDniInfoSource, getAgeGuid)

34
Sources/Plasma/FeatureLib/pfPython/pyVault.cpp

@ -328,10 +328,7 @@ PyObject* pyVault::GetVisitAgeLink( const pyAgeInfoStruct & info)
// Chronicle // Chronicle
PyObject* pyVault::FindChronicleEntry( const char * entryName ) PyObject* pyVault::FindChronicleEntry( const char * entryName )
{ {
wchar_t wEntryName[kMaxVaultNodeStringLength]; if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(entryName))
StrToUnicode(wEntryName, entryName, arrsize(wEntryName));
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wEntryName))
return pyVaultChronicleNode::New(rvn); return pyVaultChronicleNode::New(rvn);
// just return a None object // just return a None object
@ -340,16 +337,10 @@ PyObject* pyVault::FindChronicleEntry( const char * entryName )
void pyVault::AddChronicleEntry( const char * name, uint32_t type, const char * value ) void pyVault::AddChronicleEntry( const char * name, uint32_t type, const char * value )
{ {
wchar_t * wEntryName = StrDupToUnicode(name);
wchar_t * wEntryValue = StrDupToUnicode(value);
// FIXME: We should ideally not block, but for now, the Python assumes that when // FIXME: We should ideally not block, but for now, the Python assumes that when
// we return, the chronicle exists and can be found with findChronicleEntry. // we return, the chronicle exists and can be found with findChronicleEntry.
// Maybe we should insert a dummy into the tree? (currently hard) // Maybe we should insert a dummy into the tree? (currently hard)
VaultAddChronicleEntryAndWait(wEntryName, type, wEntryValue); VaultAddChronicleEntryAndWait(name, type, value);
free(wEntryName);
free(wEntryValue);
} }
@ -358,11 +349,8 @@ void pyVault::SendToDevice( pyVaultNode& node, const char * deviceName )
if (!node.GetNode()) if (!node.GetNode())
return; return;
wchar_t wDevName[256];
StrToUnicode(wDevName, deviceName, arrsize(wDevName));
// Note: This actually blocks (~Hoikas) // Note: This actually blocks (~Hoikas)
VaultPublishNode(node.GetNode()->GetNodeId(), wDevName); VaultPublishNode(node.GetNode()->GetNodeId(), deviceName);
} }
@ -412,16 +400,12 @@ PyObject* pyVault::GetPsnlAgeSDL() const
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) { if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode); VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH]; ageInfo.SetAgeFilename(kPersonalAgeFilename);
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->Clear();
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_SDL); templateNode->SetNodeType(plVault::kNodeType_SDL);
if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) { if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) {
@ -451,16 +435,12 @@ void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec )
if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) { if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) {
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_AgeInfo); templateNode->SetNodeType(plVault::kNodeType_AgeInfo);
VaultAgeInfoNode ageInfo(templateNode); VaultAgeInfoNode ageInfo(templateNode);
wchar_t str[MAX_PATH]; ageInfo.SetAgeFilename(kPersonalAgeFilename);
StrToUnicode(str, kPersonalAgeFilename, arrsize(str));
ageInfo.SetAgeFilename(str);
if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) {
templateNode->Clear();
templateNode->ClearFieldFlags();
templateNode->SetNodeType(plVault::kNodeType_SDL); templateNode->SetNodeType(plVault::kNodeType_SDL);
if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) { if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) {

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

@ -177,48 +177,42 @@ PyObject * pyVaultAgeInfoNode::GetParentAgeLink () const
} }
const char * pyVaultAgeInfoNode::GetAgeFilename() const plString pyVaultAgeInfoNode::GetAgeFilename() const
{ {
if (fNode) { if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode); VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeFilename(), arrsize(str)); return access.GetAgeFilename();
fAgeFilename = str;
} }
return fAgeFilename.c_str(); return "";
} }
void pyVaultAgeInfoNode::SetAgeFilename( const char * v ) void pyVaultAgeInfoNode::SetAgeFilename(const plString& v)
{ {
} }
const char * pyVaultAgeInfoNode::GetAgeInstanceName() const plString pyVaultAgeInfoNode::GetAgeInstanceName() const
{ {
if (fNode) { if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode); VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeInstanceName(), arrsize(str)); return access.GetAgeInstanceName();
fAgeInstName = str;
} }
return fAgeInstName.c_str(); return "";
} }
void pyVaultAgeInfoNode::SetAgeInstanceName( const char * v ) void pyVaultAgeInfoNode::SetAgeInstanceName(const plString& v)
{ {
} }
const char * pyVaultAgeInfoNode::GetAgeUserDefinedName() const plString pyVaultAgeInfoNode::GetAgeUserDefinedName() const
{ {
if (fNode) { if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode); VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeUserDefinedName(), arrsize(str)); return access.GetAgeUserDefinedName();
fAgeUserName = str;
} }
return fAgeUserName.c_str(); return "";
} }
void pyVaultAgeInfoNode::SetAgeUserDefinedName( const char * v ) void pyVaultAgeInfoNode::SetAgeUserDefinedName(const plString& v)
{ {
} }
@ -236,19 +230,16 @@ void pyVaultAgeInfoNode::SetAgeInstanceGuid( const char * sguid )
{ {
} }
const char * pyVaultAgeInfoNode::GetAgeDescription() const plString pyVaultAgeInfoNode::GetAgeDescription() const
{ {
if (fNode) { if (fNode) {
char str[MAX_PATH];
memset(str, 0, sizeof(str));
VaultAgeInfoNode access(fNode); VaultAgeInfoNode access(fNode);
StrToAnsi(str, access.GetAgeDescription(), arrsize(str)); return access.GetAgeDescription();
fAgeDescription = str;
} }
return fAgeDescription.c_str(); return "";
} }
void pyVaultAgeInfoNode::SetAgeDescription( const char * v ) void pyVaultAgeInfoNode::SetAgeDescription(const plString& v)
{ {
} }
@ -303,18 +294,16 @@ bool pyVaultAgeInfoNode::IsPublic() const
return false; return false;
} }
const char * pyVaultAgeInfoNode::GetDisplayName() const plString pyVaultAgeInfoNode::GetDisplayName() const
{ {
if (fNode) { if (fNode) {
char str[MAX_PATH];
VaultAgeInfoNode access(fNode); VaultAgeInfoNode access(fNode);
if (access.GetAgeSequenceNumber() > 0) if (access.GetAgeSequenceNumber() > 0)
StrPrintf(str, arrsize(str), "%S(%d) %S", access.GetAgeUserDefinedName(), access.GetAgeSequenceNumber(), access.GetAgeInstanceName()); return plFormat("{}({}) {}", access.GetAgeUserDefinedName(), access.GetAgeSequenceNumber(), access.GetAgeInstanceName());
else else
StrPrintf(str, arrsize(str), "%S %S", access.GetAgeUserDefinedName(), access.GetAgeInstanceName()); return plFormat("{} {}", access.GetAgeUserDefinedName(), access.GetAgeInstanceName());
fAgeDispName = str;
} }
return fAgeDispName.c_str(); return "";
} }
PyObject * pyVaultAgeInfoNode::AsAgeInfoStruct() const PyObject * pyVaultAgeInfoNode::AsAgeInfoStruct() const

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

@ -96,20 +96,20 @@ public:
PyObject * GetParentAgeLink () const; // returns pyVaultAgeLinkNode, or None if not a child age. PyObject * GetParentAgeLink () const; // returns pyVaultAgeLinkNode, or None if not a child age.
const char * GetAgeFilename() const; plString GetAgeFilename() const;
void SetAgeFilename( const char * v ); void SetAgeFilename(const plString& v);
const char * GetAgeInstanceName() const; plString GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v ); void SetAgeInstanceName(const plString& v);
const char * GetAgeUserDefinedName() const; plString GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v ); void SetAgeUserDefinedName(const plString& v);
plUUID GetAgeInstanceGuid() const; plUUID GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid ); void SetAgeInstanceGuid( const char * guid );
const char * GetAgeDescription() const; plString GetAgeDescription() const;
void SetAgeDescription( const char * v ); void SetAgeDescription(const plString& v);
int32_t GetSequenceNumber() const; int32_t GetSequenceNumber() const;
void SetSequenceNumber( int32_t v ); void SetSequenceNumber( int32_t v );
@ -124,7 +124,7 @@ public:
bool IsPublic() const; bool IsPublic() const;
const char * GetDisplayName() const; plString GetDisplayName() const;
PyObject * AsAgeInfoStruct() const; // returns pyAgeInfoStruct PyObject * AsAgeInfoStruct() const; // returns pyAgeInfoStruct
}; };

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

@ -97,7 +97,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getParentAgeLink)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeFilename) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeFilename)
{ {
return PyString_FromString(self->fThis->GetAgeFilename()); return PyString_FromPlString(self->fThis->GetAgeFilename());
} }
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeFilename, args) PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeFilename, args)
@ -114,7 +114,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeFilename, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeInstanceName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeInstanceName)
{ {
return PyString_FromString(self->fThis->GetAgeInstanceName()); return PyString_FromPlString(self->fThis->GetAgeInstanceName());
} }
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceName, args) PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceName, args)
@ -131,7 +131,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeUserDefinedName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeUserDefinedName)
{ {
return PyString_FromString(self->fThis->GetAgeUserDefinedName()); return PyString_FromPlString(self->fThis->GetAgeUserDefinedName());
} }
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeUserDefinedName, args) PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeUserDefinedName, args)
@ -165,7 +165,7 @@ PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeInstanceGuid, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeDescription) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getAgeDescription)
{ {
return PyString_FromString(self->fThis->GetAgeDescription()); return PyString_FromPlString(self->fThis->GetAgeDescription());
} }
PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeDescription, args) PYTHON_METHOD_DEFINITION(ptVaultAgeInfoNode, setAgeDescription, args)
@ -243,7 +243,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, isPublic)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getDisplayName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, getDisplayName)
{ {
return PyString_FromString(self->fThis->GetDisplayName()); return PyString_FromPlString(self->fThis->GetDisplayName());
} }
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, asAgeInfoStruct) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultAgeInfoNode, asAgeInfoStruct)

51
Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.cpp

@ -56,25 +56,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// should only be created from C++ side // should only be created from C++ side
pyVaultChronicleNode::pyVaultChronicleNode(RelVaultNode* nfsNode) pyVaultChronicleNode::pyVaultChronicleNode(RelVaultNode* nfsNode)
: pyVaultNode(nfsNode) : pyVaultNode(nfsNode)
, ansiName(nil)
, ansiValue(nil)
{ {
} }
//create from the Python side //create from the Python side
pyVaultChronicleNode::pyVaultChronicleNode(int n) pyVaultChronicleNode::pyVaultChronicleNode(int n)
: pyVaultNode(new RelVaultNode) : pyVaultNode(new RelVaultNode)
, ansiName(nil)
, ansiValue(nil)
{ {
fNode->SetNodeType(plVault::kNodeType_Chronicle); fNode->SetNodeType(plVault::kNodeType_Chronicle);
} }
pyVaultChronicleNode::~pyVaultChronicleNode () {
free(ansiName);
free(ansiValue);
}
//================================================================== //==================================================================
// class RelVaultNode : public plVaultNode // class RelVaultNode : public plVaultNode
@ -84,50 +75,34 @@ void pyVaultChronicleNode::Chronicle_SetName( const char * text )
if (!fNode) if (!fNode)
return; return;
wchar_t * wStr = StrDupToUnicode(text);
VaultChronicleNode chron(fNode); VaultChronicleNode chron(fNode);
chron.SetEntryName(wStr); chron.SetEntryName(text);
free(wStr);
} }
const char * pyVaultChronicleNode::Chronicle_GetName( void ) plString pyVaultChronicleNode::Chronicle_GetName() const
{ {
if (!fNode) if (fNode) {
return "";
free(ansiName);
VaultChronicleNode chron(fNode); VaultChronicleNode chron(fNode);
ansiName = StrDupToAnsi(chron.GetEntryName()); return chron.GetEntryName();
}
return ansiName; return "";
} }
void pyVaultChronicleNode::Chronicle_SetValue( const char * text ) void pyVaultChronicleNode::Chronicle_SetValue( const char * text )
{ {
if (!fNode) if (fNode) {
return;
wchar_t * wStr = StrDupToUnicode(text);
VaultChronicleNode chron(fNode); VaultChronicleNode chron(fNode);
chron.SetEntryValue(wStr); chron.SetEntryValue(text);
free(wStr); }
} }
const char * pyVaultChronicleNode::Chronicle_GetValue( void ) plString pyVaultChronicleNode::Chronicle_GetValue() const
{ {
if (!fNode) if (fNode) {
return "";
free(ansiValue);
ansiValue = nil;
VaultChronicleNode chron(fNode); VaultChronicleNode chron(fNode);
return chron.GetEntryValue();
if (!chron.GetEntryValue()) }
return ""; return "";
ansiValue = StrDupToAnsi(chron.GetEntryValue());
return ansiValue;
} }
void pyVaultChronicleNode::Chronicle_SetType( uint32_t type ) void pyVaultChronicleNode::Chronicle_SetType( uint32_t type )

11
Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNode.h

@ -52,14 +52,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pyVaultNode.h" #include "pyVaultNode.h"
class plString;
struct RelVaultNode; struct RelVaultNode;
class pyVaultChronicleNode : public pyVaultNode class pyVaultChronicleNode : public pyVaultNode
{ {
char * ansiName;
char * ansiValue;
protected: protected:
// should only be created from C++ side // should only be created from C++ side
pyVaultChronicleNode(RelVaultNode* nfsNode); pyVaultChronicleNode(RelVaultNode* nfsNode);
@ -68,7 +65,7 @@ protected:
pyVaultChronicleNode(int n=0); pyVaultChronicleNode(int n=0);
public: public:
~pyVaultChronicleNode (); ~pyVaultChronicleNode() { }
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVaultChronicleNode); PYTHON_CLASS_NEW_FRIEND(ptVaultChronicleNode);
@ -83,9 +80,9 @@ public:
// class RelVaultNode : public plVaultNode // class RelVaultNode : public plVaultNode
// //
void Chronicle_SetName( const char * text ); void Chronicle_SetName( const char * text );
const char * Chronicle_GetName( void ); plString Chronicle_GetName() const;
void Chronicle_SetValue( const char * text ); void Chronicle_SetValue( const char * text );
const char * Chronicle_GetValue( void ); plString Chronicle_GetValue() const;
void Chronicle_SetType( uint32_t type ); void Chronicle_SetType( uint32_t type );
uint32_t Chronicle_GetType( void ); uint32_t Chronicle_GetType( void );
}; };

8
Sources/Plasma/FeatureLib/pfPython/pyVaultChronicleNodeGlue.cpp

@ -78,7 +78,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, chronicleGetName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, chronicleGetName)
{ {
return PyString_FromString(self->fThis->Chronicle_GetName()); return PyString_FromPlString(self->fThis->Chronicle_GetName());
} }
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetValue, args) PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetValue, args)
@ -95,7 +95,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetValue, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, chronicleGetValue) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, chronicleGetValue)
{ {
return PyString_FromString(self->fThis->Chronicle_GetValue()); return PyString_FromPlString(self->fThis->Chronicle_GetValue());
} }
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetType, args) PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, chronicleSetType, args)
@ -129,7 +129,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, getName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, getName)
{ {
return PyString_FromString(self->fThis->Chronicle_GetName()); return PyString_FromPlString(self->fThis->Chronicle_GetName());
} }
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setValue, args) PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setValue, args)
@ -146,7 +146,7 @@ PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setValue, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, getValue) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultChronicleNode, getValue)
{ {
return PyString_FromString(self->fThis->Chronicle_GetValue()); return PyString_FromPlString(self->fThis->Chronicle_GetValue());
} }
PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setEntryType, args) PYTHON_METHOD_DEFINITION(ptVaultChronicleNode, setEntryType, args)

47
Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.cpp

@ -87,50 +87,27 @@ int pyVaultFolderNode::Folder_GetType( void )
return folder.GetFolderType(); return folder.GetFolderType();
} }
void pyVaultFolderNode::Folder_SetName( std::string name ) void pyVaultFolderNode::Folder_SetName(const char* name)
{ {
if (!fNode) if (fNode) {
return;
wchar_t* wName = hsStringToWString(name.c_str());
VaultFolderNode folder(fNode); VaultFolderNode folder(fNode);
folder.SetFolderName(wName); folder.SetFolderName(name);
delete [] wName; }
} }
void pyVaultFolderNode::Folder_SetNameW( std::wstring name ) void pyVaultFolderNode::Folder_SetNameW(const wchar_t* name)
{ {
if (!fNode) if (fNode) {
return;
VaultFolderNode folder(fNode); VaultFolderNode folder(fNode);
folder.SetFolderName(name.c_str()); folder.SetFolderName(plString::FromWchar(name));
}
} }
std::string pyVaultFolderNode::Folder_GetName( void ) plString pyVaultFolderNode::Folder_GetName() const
{ {
if (!fNode) if (fNode) {
return "";
VaultFolderNode folder(fNode); VaultFolderNode folder(fNode);
if (!folder.GetFolderName())
return "";
std::string retVal;
char* sName = hsWStringToString(folder.GetFolderName());
retVal = sName;
delete [] sName;
return retVal;
}
std::wstring pyVaultFolderNode::Folder_GetNameW( void )
{
if (!fNode)
return L"";
VaultFolderNode folder(fNode);
if (!folder.GetFolderName())
return L"";
return folder.GetFolderName(); return folder.GetFolderName();
}
return "";
} }

10
Sources/Plasma/FeatureLib/pfPython/pyVaultFolderNode.h

@ -50,12 +50,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <string>
#include "pyVaultNode.h" #include "pyVaultNode.h"
class plString;
struct RelVaultNode; struct RelVaultNode;
class pyVaultFolderNode : public pyVaultNode class pyVaultFolderNode : public pyVaultNode
{ {
protected: protected:
@ -80,10 +79,9 @@ public:
virtual void Folder_SetType( int type ); virtual void Folder_SetType( int type );
virtual int Folder_GetType( void ); virtual int Folder_GetType( void );
void Folder_SetName( std::string name ); void Folder_SetName(const char* name);
void Folder_SetNameW( std::wstring name ); void Folder_SetNameW(const wchar_t* name);
std::string Folder_GetName( void ); plString Folder_GetName() const;
std::wstring Folder_GetNameW( void );

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

@ -164,8 +164,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultFolderNode, getFolderName)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultFolderNode, getFolderNameW) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultFolderNode, getFolderNameW)
{ {
std::wstring name = self->fThis->Folder_GetNameW(); return PyUnicode_FromStringEx(self->fThis->Folder_GetName());
return PyUnicode_FromWideChar(name.c_str(), name.length());
} }
PYTHON_START_METHODS_TABLE(ptVaultFolderNode) PYTHON_START_METHODS_TABLE(ptVaultFolderNode)

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

@ -117,11 +117,8 @@ void pyVaultImageNode::Image_SetTitle( const char * text )
if (!fNode) if (!fNode)
return; return;
wchar_t * wStr = hsStringToWString(text);
VaultImageNode image(fNode); VaultImageNode image(fNode);
image.SetImageTitle(wStr); image.SetImageTitle(text);
delete [] wStr;
} }
void pyVaultImageNode::Image_SetTitleW( const wchar_t* text ) void pyVaultImageNode::Image_SetTitleW( const wchar_t* text )
@ -130,34 +127,16 @@ void pyVaultImageNode::Image_SetTitleW( const wchar_t* text )
return; return;
VaultImageNode image(fNode); VaultImageNode image(fNode);
image.SetImageTitle(text); image.SetImageTitle(plString::FromWchar(text));
} }
std::string pyVaultImageNode::Image_GetTitle( void ) plString pyVaultImageNode::Image_GetTitle() const
{ {
if (!fNode) if (fNode) {
return "";
VaultImageNode image(fNode); VaultImageNode image(fNode);
return image.GetImageTitle();
std::string retVal = "";
if (image.GetImageTitle())
{
char* temp = hsWStringToString(image.GetImageTitle());
retVal = temp;
delete [] temp;
} }
return "";
return retVal;
}
std::wstring pyVaultImageNode::Image_GetTitleW( void )
{
if (!fNode)
return L"";
VaultImageNode image(fNode);
return image.GetImageTitle() ? image.GetImageTitle() : L"";
} }
PyObject* pyVaultImageNode::Image_GetImage( void ) PyObject* pyVaultImageNode::Image_GetImage( void )

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

@ -51,12 +51,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pnKeyedObject/plKey.h" #include "pnKeyedObject/plKey.h"
#include <string>
#include "pyVaultNode.h" #include "pyVaultNode.h"
struct RelVaultNode; struct RelVaultNode;
class plMipmap; class plMipmap;
class plString;
class pyVaultImageNode : public pyVaultNode class pyVaultImageNode : public pyVaultNode
{ {
@ -88,8 +88,7 @@ public:
// //
void Image_SetTitle( const char * text ); void Image_SetTitle( const char * text );
void Image_SetTitleW( const wchar_t * text ); void Image_SetTitleW( const wchar_t * text );
std::string Image_GetTitle( void ); plString Image_GetTitle() const;
std::wstring Image_GetTitleW( void );
PyObject* Image_GetImage( void ); // returns pyImage PyObject* Image_GetImage( void ); // returns pyImage
void Image_SetImage(pyImage& image); void Image_SetImage(pyImage& image);

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

@ -154,8 +154,8 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultImageNode, getTitle)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultImageNode, getTitleW) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultImageNode, getTitleW)
{ {
std::wstring retVal = self->fThis->Image_GetTitleW(); plStringBuffer<wchar_t> retVal = self->fThis->Image_GetTitle().ToWchar();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length()); return PyUnicode_FromWideChar(retVal.GetData(), retVal.GetSize());
} }
PYTHON_METHOD_DEFINITION(ptVaultImageNode, setImage, args) PYTHON_METHOD_DEFINITION(ptVaultImageNode, setImage, args)

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

@ -68,24 +68,20 @@ pyVaultMarkerGameNode::pyVaultMarkerGameNode(int n)
// class RelVaultNode : public plVaultNode // class RelVaultNode : public plVaultNode
// //
const char * pyVaultMarkerGameNode::GetGameName () const plString pyVaultMarkerGameNode::GetGameName () const
{ {
fGameName[0] = 0;
if (fNode) { if (fNode) {
VaultMarkerGameNode access(fNode); VaultMarkerGameNode access(fNode);
StrToAnsi(fGameName, access.GetGameName(), arrsize(fGameName)); return access.GetGameName();
} }
return fGameName; return "";
} }
void pyVaultMarkerGameNode::SetGameName (const char v[]) void pyVaultMarkerGameNode::SetGameName (const plString& name)
{ {
if (fNode) { if (fNode) {
VaultMarkerGameNode access(fNode); VaultMarkerGameNode access(fNode);
wchar_t unicode[kMaxVaultNodeStringLength]; access.SetGameName(name);
StrToUnicode(unicode, v, arrsize(unicode));
access.SetGameName(unicode);
} }
} }

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

@ -53,16 +53,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "pyVaultNode.h" #include "pyVaultNode.h"
#include "pnNetBase/pnNetBase.h" class plString;
struct RelVaultNode; struct RelVaultNode;
class plUUID; class plUUID;
class pyVaultMarkerGameNode : public pyVaultNode class pyVaultMarkerGameNode : public pyVaultNode
{ {
private:
mutable char fGameName[kMaxVaultNodeStringLength];
protected: protected:
// should only be created from C++ side // should only be created from C++ side
pyVaultMarkerGameNode(RelVaultNode* vaultNode); pyVaultMarkerGameNode(RelVaultNode* vaultNode);
@ -83,8 +79,8 @@ public:
//================================================================== //==================================================================
// class RelVaultNode : public plVaultNode // class RelVaultNode : public plVaultNode
// //
const char * GetGameName () const; plString GetGameName () const;
void SetGameName (const char v[]); void SetGameName (const plString& name);
plUUID GetGameGuid() const; plUUID GetGameGuid() const;
void SetGameGuid (const char v[]); void SetGameGuid (const char v[]);

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

@ -67,7 +67,7 @@ PYTHON_INIT_DEFINITION(ptVaultMarkerGameNode, args, keywords)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultMarkerGameNode, getGameName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultMarkerGameNode, getGameName)
{ {
return PyString_FromString(self->fThis->GetGameName()); return PyString_FromPlString(self->fThis->GetGameName());
} }
PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameName, args) PYTHON_METHOD_DEFINITION(ptVaultMarkerGameNode, setGameName, args)

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

@ -164,23 +164,17 @@ hsRef<RelVaultNode> pyVaultNode::pyVaultNodeOperationCallback::GetNode() const {
return fNode; return fNode;
} }
// only for python glue, do NOT call
pyVaultNode::pyVaultNode() pyVaultNode::pyVaultNode()
: fCreateAgeName(nil)
{ {
} }
// 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)
, fCreateAgeName(nil)
{ {
} }
pyVaultNode::~pyVaultNode() pyVaultNode::~pyVaultNode() {}
{
free(fCreateAgeName);
}
hsRef<RelVaultNode> pyVaultNode::GetNode() const hsRef<RelVaultNode> pyVaultNode::GetNode() const
@ -291,22 +285,11 @@ uint32_t pyVaultNode::GetCreateAgeTime( void )
return GetCreateTime(); return GetCreateTime();
} }
const char * pyVaultNode::GetCreateAgeName( void ) const char * pyVaultNode::GetCreateAgeName()
{ {
if (!fNode) if (fNode)
return fNode->GetCreateAgeName().c_str();
return ""; return "";
if (fCreateAgeName)
return fCreateAgeName;
if (fNode) {
if (fNode->GetCreateAgeName())
fCreateAgeName = StrDupToAnsi(fNode->GetCreateAgeName());
else
fCreateAgeName = StrDup("");
}
return fCreateAgeName;
} }
plUUID pyVaultNode::GetCreateAgeGuid(void) const plUUID pyVaultNode::GetCreateAgeGuid(void) const
@ -359,13 +342,7 @@ void pyVaultNode::SetCreatorNodeID( uint32_t v )
void pyVaultNode::SetCreateAgeName( const char * v ) void pyVaultNode::SetCreateAgeName( const char * v )
{ {
free(fCreateAgeName); fNode->SetCreateAgeName(v);
fCreateAgeName = nil;
ASSERT(fNode);
wchar_t str[MAX_PATH];
StrToUnicode(str, v, arrsize(str));
fNode->SetCreateAgeName(str);
} }
void pyVaultNode::SetCreateAgeGuid( const char * v ) void pyVaultNode::SetCreateAgeGuid( const char * v )

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

@ -99,7 +99,6 @@ public:
}; };
hsRef<RelVaultNode> fNode; hsRef<RelVaultNode> fNode;
mutable char * fCreateAgeName;
protected: protected:
// only for python glue, do NOT call // only for python glue, do NOT call

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

@ -57,24 +57,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// should only be created from C++ side // should only be created from C++ side
pyVaultPlayerInfoNode::pyVaultPlayerInfoNode(RelVaultNode* nfsNode) pyVaultPlayerInfoNode::pyVaultPlayerInfoNode(RelVaultNode* nfsNode)
: pyVaultNode(nfsNode) : pyVaultNode(nfsNode)
, ansiPlayerName(nil)
, ansiAgeInstName(nil)
{ {
} }
//create from the Python side //create from the Python side
pyVaultPlayerInfoNode::pyVaultPlayerInfoNode() pyVaultPlayerInfoNode::pyVaultPlayerInfoNode()
: pyVaultNode(new RelVaultNode) : pyVaultNode(new RelVaultNode)
, ansiPlayerName(nil)
, ansiAgeInstName(nil)
{ {
fNode->SetNodeType(plVault::kNodeType_PlayerInfo); fNode->SetNodeType(plVault::kNodeType_PlayerInfo);
} }
pyVaultPlayerInfoNode::~pyVaultPlayerInfoNode () {
free(ansiPlayerName);
free(ansiAgeInstName);
}
//================================================================== //==================================================================
// class RelVaultNode : public plVaultNode // class RelVaultNode : public plVaultNode
@ -97,55 +89,39 @@ uint32_t pyVaultPlayerInfoNode::Player_GetPlayerID( void )
return playerInfo.GetPlayerId(); return playerInfo.GetPlayerId();
} }
void pyVaultPlayerInfoNode::Player_SetPlayerName( const char * name ) void pyVaultPlayerInfoNode::Player_SetPlayerName(const plString& name)
{ {
if (!fNode) if (fNode) {
return;
wchar_t * wStr = StrDupToUnicode(name);
VaultPlayerInfoNode playerInfo(fNode); VaultPlayerInfoNode playerInfo(fNode);
playerInfo.SetPlayerName(wStr); playerInfo.SetPlayerName(name);
free(wStr); }
} }
const char * pyVaultPlayerInfoNode::Player_GetPlayerName( void ) plString pyVaultPlayerInfoNode::Player_GetPlayerName() const
{ {
if (!fNode) if (fNode) {
return "";
VaultPlayerInfoNode playerInfo(fNode); VaultPlayerInfoNode playerInfo(fNode);
if (!playerInfo.GetPlayerName()) return playerInfo.GetPlayerName();
}
return ""; return "";
free(ansiPlayerName);
ansiPlayerName = StrDupToAnsi(playerInfo.GetPlayerName());
return ansiPlayerName;
} }
// age the player is currently in, if any. // age the player is currently in, if any.
void pyVaultPlayerInfoNode::Player_SetAgeInstanceName( const char * agename ) void pyVaultPlayerInfoNode::Player_SetAgeInstanceName(const plString& name)
{ {
if (!fNode) if (fNode) {
return;
wchar_t * wStr = StrDupToUnicode(agename);
VaultPlayerInfoNode playerInfo(fNode); VaultPlayerInfoNode playerInfo(fNode);
playerInfo.SetAgeInstName(wStr); playerInfo.SetAgeInstName(name);
free(wStr); }
} }
const char * pyVaultPlayerInfoNode::Player_GetAgeInstanceName( void ) plString pyVaultPlayerInfoNode::Player_GetAgeInstanceName() const
{ {
if (!fNode) if (fNode) {
return "";
VaultPlayerInfoNode playerInfo(fNode); VaultPlayerInfoNode playerInfo(fNode);
if (!playerInfo.GetAgeInstName()) return playerInfo.GetAgeInstName();
}
return ""; return "";
free(ansiAgeInstName);
ansiAgeInstName = StrDupToAnsi(playerInfo.GetAgeInstName());
return ansiAgeInstName;
} }
void pyVaultPlayerInfoNode::Player_SetAgeGuid( const char * guidtext) void pyVaultPlayerInfoNode::Player_SetAgeGuid( const char * guidtext)

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

@ -55,9 +55,6 @@ class plUUID;
class pyVaultPlayerInfoNode : public pyVaultNode class pyVaultPlayerInfoNode : public pyVaultNode
{ {
mutable char * ansiPlayerName;
mutable char * ansiAgeInstName;
protected: protected:
// should only be created from C++ side // should only be created from C++ side
pyVaultPlayerInfoNode(RelVaultNode * node); pyVaultPlayerInfoNode(RelVaultNode * node);
@ -66,7 +63,7 @@ protected:
pyVaultPlayerInfoNode(); pyVaultPlayerInfoNode();
public: public:
~pyVaultPlayerInfoNode (); ~pyVaultPlayerInfoNode() { }
// required functions for PyObject interoperability // required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVaultPlayerInfoNode); PYTHON_CLASS_NEW_FRIEND(ptVaultPlayerInfoNode);
@ -82,12 +79,12 @@ public:
// //
void Player_SetPlayerID( uint32_t plyrid ); void Player_SetPlayerID( uint32_t plyrid );
uint32_t Player_GetPlayerID( void ); uint32_t Player_GetPlayerID( void );
void Player_SetPlayerName( const char * name ); void Player_SetPlayerName(const plString& name);
const char * Player_GetPlayerName( void ); plString Player_GetPlayerName() const;
// age the player is currently in, if any. // age the player is currently in, if any.
void Player_SetAgeInstanceName( const char * agename ); void Player_SetAgeInstanceName(const plString& name);
const char * Player_GetAgeInstanceName( void ); plString Player_GetAgeInstanceName() const;
void Player_SetAgeGuid( const char * guidtext); void Player_SetAgeGuid( const char * guidtext);
plUUID Player_GetAgeGuid(void) const; plUUID Player_GetAgeGuid(void) const;
// online status // online status

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

@ -89,7 +89,7 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetName)
{ {
return PyString_FromString(self->fThis->Player_GetPlayerName()); return PyString_FromPlString(self->fThis->Player_GetPlayerName());
} }
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeInstanceName, args) PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeInstanceName, args)
@ -106,7 +106,7 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeInstanceName, args)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetAgeInstanceName) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultPlayerInfoNode, playerGetAgeInstanceName)
{ {
return PyString_FromString(self->fThis->Player_GetAgeInstanceName()); return PyString_FromPlString(self->fThis->Player_GetAgeInstanceName());
} }
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeGuid, args) PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoNode, playerSetAgeGuid, args)

28
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp

@ -231,9 +231,7 @@ void pyVaultPlayerNode::RemoveVisitAgeLink(const char *guidstr)
PyObject *pyVaultPlayerNode::FindChronicleEntry(const char *entryName) PyObject *pyVaultPlayerNode::FindChronicleEntry(const char *entryName)
{ {
wchar_t wStr[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(entryName))
StrToUnicode(wStr, entryName, arrsize(wStr));
if (hsRef<RelVaultNode> rvn = VaultFindChronicleEntry(wStr))
return pyVaultChronicleNode::New(rvn); return pyVaultChronicleNode::New(rvn);
PYTHON_RETURN_NONE; PYTHON_RETURN_NONE;
@ -244,15 +242,13 @@ void pyVaultPlayerNode::SetPlayerName(const char *value)
hsAssert(false, "python may not change a player's name this way"); hsAssert(false, "python may not change a player's name this way");
} }
std::string pyVaultPlayerNode::GetPlayerName() plString pyVaultPlayerNode::GetPlayerName() const
{ {
if (!fNode) if (fNode) {
return "";
VaultPlayerNode player(fNode); VaultPlayerNode player(fNode);
char ansiStr[MAX_PATH]; return player.GetPlayerName();
StrToAnsi(ansiStr, player.GetPlayerName(), arrsize(ansiStr)); }
return ansiStr; return "";
} }
void pyVaultPlayerNode::SetAvatarShapeName(const char *value) void pyVaultPlayerNode::SetAvatarShapeName(const char *value)
@ -260,15 +256,13 @@ void pyVaultPlayerNode::SetAvatarShapeName(const char *value)
hsAssert(false, "python may not change a player's avatar this way"); hsAssert(false, "python may not change a player's avatar this way");
} }
std::string pyVaultPlayerNode::GetAvatarShapeName() plString pyVaultPlayerNode::GetAvatarShapeName() const
{ {
if (!fNode) if (fNode) {
return "";
VaultPlayerNode player(fNode); VaultPlayerNode player(fNode);
char ansiStr[MAX_PATH]; return player.GetAvatarShapeName();
StrToAnsi(ansiStr, player.GetAvatarShapeName(), arrsize(ansiStr)); }
return ansiStr; return "";
} }
void pyVaultPlayerNode::SetDisabled(bool value) void pyVaultPlayerNode::SetDisabled(bool value)

6
Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.h

@ -49,10 +49,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include "HeadSpin.h" #include "HeadSpin.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <string>
#include "pyVaultNode.h" #include "pyVaultNode.h"
class pyAgeInfoStruct; class pyAgeInfoStruct;
class plString;
struct RelVaultNode; struct RelVaultNode;
class pyVaultPlayerNode : public pyVaultNode class pyVaultPlayerNode : public pyVaultNode
@ -101,10 +101,10 @@ public:
PyObject *FindChronicleEntry(const char *entryName); // returns pyVaultChronicleNode PyObject *FindChronicleEntry(const char *entryName); // returns pyVaultChronicleNode
void SetPlayerName(const char *value); void SetPlayerName(const char *value);
std::string GetPlayerName(); plString GetPlayerName() const;
void SetAvatarShapeName(const char *value); void SetAvatarShapeName(const char *value);
std::string GetAvatarShapeName(); plString GetAvatarShapeName() const;
void SetDisabled(bool value); void SetDisabled(bool value);
bool IsDisabled(); bool IsDisabled();

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

@ -105,13 +105,10 @@ PyObject * pyVaultSDLNode::GetStateDataRecord() const
void pyVaultSDLNode::InitStateDataRecord( const char* agename, int flags) void pyVaultSDLNode::InitStateDataRecord( const char* agename, int flags)
{ {
if (!fNode) if (fNode) {
return;
wchar_t wStr[MAX_PATH];
StrToUnicode(wStr, agename, arrsize(wStr));
VaultSDLNode sdl(fNode); VaultSDLNode sdl(fNode);
sdl.InitStateDataRecord(wStr, flags); sdl.InitStateDataRecord(agename, flags);
}
} }
void pyVaultSDLNode::SetStateDataRecord( const pySDLStateDataRecord & rec, int writeOptions/*=0 */) void pyVaultSDLNode::SetStateDataRecord( const pySDLStateDataRecord & rec, int writeOptions/*=0 */)

86
Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp

@ -75,14 +75,10 @@ pyVaultTextNoteNode::pyVaultTextNoteNode()
// //
void pyVaultTextNoteNode::Note_SetTitle( const char * text ) void pyVaultTextNoteNode::Note_SetTitle( const char * text )
{ {
if (!fNode) if (fNode) {
return;
wchar_t wStr[MAX_PATH] = L"";
if (text)
StrToUnicode(wStr, text, arrsize(wStr));
VaultTextNoteNode textNote(fNode); VaultTextNoteNode textNote(fNode);
textNote.SetNoteTitle(wStr); textNote.SetNoteTitle(text);
}
} }
void pyVaultTextNoteNode::Note_SetTitleW( const wchar_t * text ) void pyVaultTextNoteNode::Note_SetTitleW( const wchar_t * text )
@ -91,48 +87,24 @@ void pyVaultTextNoteNode::Note_SetTitleW( const wchar_t * text )
return; return;
VaultTextNoteNode textNote(fNode); VaultTextNoteNode textNote(fNode);
textNote.SetNoteTitle(text); textNote.SetNoteTitle(plString::FromWchar(text));
} }
std::string pyVaultTextNoteNode::Note_GetTitle( void ) plString pyVaultTextNoteNode::Note_GetTitle() const
{ {
if (!fNode) if (fNode) {
return ""; VaultTextNoteNode note(fNode);
return note.GetNoteTitle();
char * aStr = nil;
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteTitle()) {
std::string result;
aStr = StrDupToAnsi(textNote.GetNoteTitle());
result = aStr;
free(aStr);
return result;
} }
return ""; return "";
} }
std::wstring pyVaultTextNoteNode::Note_GetTitleW( void ) void pyVaultTextNoteNode::Note_SetText(const char * text)
{ {
if (!fNode) if (fNode) {
return L"";
VaultTextNoteNode textNote(fNode); VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteTitle()) textNote.SetNoteText(text);
return textNote.GetNoteTitle(); }
return L"";
}
void pyVaultTextNoteNode::Note_SetText( const char * text )
{
if (!fNode)
return;
wchar_t * wStr = nil;
if (text)
wStr = StrDupToUnicode(text);
VaultTextNoteNode textNote(fNode);
textNote.SetNoteText(wStr);
free(wStr);
} }
void pyVaultTextNoteNode::Note_SetTextW( const wchar_t * text ) void pyVaultTextNoteNode::Note_SetTextW( const wchar_t * text )
@ -141,37 +113,18 @@ void pyVaultTextNoteNode::Note_SetTextW( const wchar_t * text )
return; return;
VaultTextNoteNode textNote(fNode); VaultTextNoteNode textNote(fNode);
textNote.SetNoteText(text); textNote.SetNoteText(plString::FromWchar(text));
} }
std::string pyVaultTextNoteNode::Note_GetText( void ) plString pyVaultTextNoteNode::Note_GetText() const
{ {
if (!fNode) if (fNode) {
return ""; VaultTextNoteNode note(fNode);
return note.GetNoteText();
char * aStr = nil;
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteText()) {
std::string result;
aStr = StrDupToAnsi(textNote.GetNoteText());
result = aStr;
free(aStr);
return result;
} }
return ""; return "";
} }
std::wstring pyVaultTextNoteNode::Note_GetTextW( void )
{
if (!fNode)
return L"";
VaultTextNoteNode textNote(fNode);
if (textNote.GetNoteText())
return textNote.GetNoteText();
return L"";
}
void pyVaultTextNoteNode::Note_SetType( int32_t type ) void pyVaultTextNoteNode::Note_SetType( int32_t type )
{ {
if (!fNode) if (!fNode)
@ -225,10 +178,7 @@ void pyVaultTextNoteNode::SetDeviceInbox( const char * devName, PyObject * cbObj
pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject );
cb->VaultOperationStarted( cbContext ); cb->VaultOperationStarted( cbContext );
wchar_t wDev[MAX_PATH]; if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(devName, DEFAULT_DEVICE_INBOX))
StrToUnicode(wDev, devName, arrsize(wDev));
if (hsRef<RelVaultNode> rvn = VaultAgeSetDeviceInboxAndWait(wDev, DEFAULT_DEVICE_INBOX))
cb->SetNode(rvn); cb->SetNode(rvn);
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here. cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.

9
Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.h

@ -50,13 +50,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include <string>
#include "pyVaultNode.h" #include "pyVaultNode.h"
class plString;
struct RelVaultNode; struct RelVaultNode;
class pyVaultAgeLinkNode; class pyVaultAgeLinkNode;
class pyVaultTextNoteNode : public pyVaultNode class pyVaultTextNoteNode : public pyVaultNode
{ {
protected: protected:
@ -82,12 +81,10 @@ public:
// //
void Note_SetTitle( const char * text ); void Note_SetTitle( const char * text );
void Note_SetTitleW( const wchar_t * text ); void Note_SetTitleW( const wchar_t * text );
std::string Note_GetTitle( void ); plString Note_GetTitle() const;
std::wstring Note_GetTitleW( void );
void Note_SetText( const char * text ); void Note_SetText( const char * text );
void Note_SetTextW( const wchar_t * text ); void Note_SetTextW( const wchar_t * text );
std::string Note_GetText( void ); plString Note_GetText() const;
std::wstring Note_GetTextW( void );
void Note_SetType( int32_t type ); void Note_SetType( int32_t type );
int32_t Note_GetType( void ); int32_t Note_GetType( void );

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

@ -173,8 +173,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTitle)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTitleW) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTitleW)
{ {
std::wstring retVal = self->fThis->Note_GetTitleW(); return PyUnicode_FromStringEx(self->fThis->Note_GetTitle());
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
} }
PYTHON_METHOD_DEFINITION(ptVaultTextNoteNode, setText, args) PYTHON_METHOD_DEFINITION(ptVaultTextNoteNode, setText, args)
@ -225,8 +224,7 @@ PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getText)
PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTextW) PYTHON_METHOD_DEFINITION_NOARGS(ptVaultTextNoteNode, getTextW)
{ {
std::wstring retVal = self->fThis->Note_GetTextW(); return PyUnicode_FromStringEx(self->fThis->Note_GetText());
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
} }
PYTHON_METHOD_DEFINITION(ptVaultTextNoteNode, setType, args) PYTHON_METHOD_DEFINITION(ptVaultTextNoteNode, setType, args)

Loading…
Cancel
Save