mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Clean up for Python interface stuff.
This commit is contained in:
@ -398,4 +398,4 @@ void pyMarkerGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsMarkerGame);
|
||||
PYTHON_GLOBAL_METHOD_WKEY(methods, PtCreateMarkerGame);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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))
|
||||
|
||||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user