mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Initial Commit of CyanWorlds.com Engine Open Source Client/Plugin
This commit is contained in:
@ -0,0 +1,69 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyBlueSpiralGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base BlueSpiral game client class
|
||||
//
|
||||
|
||||
pyBlueSpiralGame::pyBlueSpiralGame(): pyGameCli() {}
|
||||
|
||||
pyBlueSpiralGame::pyBlueSpiralGame(pfGameCli* client): pyGameCli(client)
|
||||
{
|
||||
if (client && (client->GetGameTypeId() != kGameTypeId_BlueSpiral))
|
||||
gameClient = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyBlueSpiralGame::IsBlueSpiralGame(std::wstring guid)
|
||||
{
|
||||
Uuid gameUuid(guid.c_str());
|
||||
return gameUuid == kGameTypeId_BlueSpiral;
|
||||
}
|
||||
|
||||
void pyBlueSpiralGame::JoinCommonBlueSpiralGame(pyKey& callbackKey, unsigned gameID)
|
||||
{
|
||||
BlueSpiral_CreateParam init;
|
||||
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_BlueSpiral, gameID, sizeof(init), &init);
|
||||
}
|
||||
|
||||
void pyBlueSpiralGame::StartGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmBlueSpiral* blueSpiral = pfGmBlueSpiral::ConvertNoRef(gameClient);
|
||||
blueSpiral->StartGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyBlueSpiralGame::HitCloth(int clothNum)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmBlueSpiral* blueSpiral = pfGmBlueSpiral::ConvertNoRef(gameClient);
|
||||
blueSpiral->HitCloth(clothNum);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyBlueSpiralGame_h
|
||||
#define pyBlueSpiralGame_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyBlueSpiralGame
|
||||
//
|
||||
// PURPOSE: Class wrapper for the BlueSpiral game client
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCli.h"
|
||||
#include "../../pyKey.h"
|
||||
|
||||
class pyBlueSpiralGame : public pyGameCli
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralGame();
|
||||
pyBlueSpiralGame(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGame);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGame object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGame); // converts a PyObject to a pyBlueSpiralGame (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
|
||||
static bool IsBlueSpiralGame(std::wstring guid);
|
||||
static void JoinCommonBlueSpiralGame(pyKey& callbackKey, unsigned gameID);
|
||||
|
||||
void StartGame();
|
||||
void HitCloth(int clothNum);
|
||||
};
|
||||
|
||||
#endif // pyBlueSpiralGame_h
|
@ -0,0 +1,142 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyBlueSpiralGame.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base BlueSpiral game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralGame, pyBlueSpiralGame);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGame, pyBlueSpiralGame)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGame)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGame)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsBlueSpiralGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a BlueSpiral game")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsBlueSpiralGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
bool retVal = pyBlueSpiralGame::IsBlueSpiralGame(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
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);
|
||||
bool retVal = pyBlueSpiralGame::IsBlueSpiralGame(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsBlueSpiralGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonBlueSpiralGame, args, "Params: callbackKey, gameID\nJoins a common BlueSpiral game with the specified ID. If one doesn't exist, it creates it")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
int gameID = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonBlueSpiralGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonBlueSpiralGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyBlueSpiralGame::JoinCommonBlueSpiralGame(*key, gameID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptBlueSpiralGame, startGame, StartGame)
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptBlueSpiralGame, hitCloth, args)
|
||||
{
|
||||
int clothNum = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &clothNum))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "hitCloth expects one integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->HitCloth(clothNum);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralGame)
|
||||
PYTHON_BASIC_METHOD(ptBlueSpiralGame, startGame, "Starts a new game"),
|
||||
PYTHON_METHOD(ptBlueSpiralGame, hitCloth, "Params: clothNum\nTells the server you hit the specified cloth"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGame, pyGameCli, "Game client for the BlueSpiral game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralGame::New(pfGameCli* client)
|
||||
{
|
||||
ptBlueSpiralGame *newObj = (ptBlueSpiralGame*)ptBlueSpiralGame_type.tp_new(&ptBlueSpiralGame_type, NULL, NULL);
|
||||
if (client && (client->GetGameTypeId() == kGameTypeId_BlueSpiral))
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGame, pyBlueSpiralGame)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGame, pyBlueSpiralGame)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralGame::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGame);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyBlueSpiralGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsBlueSpiralGame);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonBlueSpiralGame);
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyBlueSpiralMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base BlueSpiral msg class
|
||||
//
|
||||
|
||||
pyBlueSpiralMsg::pyBlueSpiralMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyBlueSpiralMsg::pyBlueSpiralMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_BlueSpiral))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyBlueSpiralMsg::GetBlueSpiralMsgType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyBlueSpiralMsg::UpcastToFinalBlueSpiralMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_BlueSpiral_ClothOrder:
|
||||
return pyBlueSpiralClothOrderMsg::New(message);
|
||||
case kSrv2Cli_BlueSpiral_SuccessfulHit:
|
||||
return pyBlueSpiralSuccessfulHitMsg::New(message);
|
||||
case kSrv2Cli_BlueSpiral_GameWon:
|
||||
return pyBlueSpiralGameWonMsg::New(message);
|
||||
case kSrv2Cli_BlueSpiral_GameOver:
|
||||
return pyBlueSpiralGameOverMsg::New(message);
|
||||
case kSrv2Cli_BlueSpiral_GameStarted:
|
||||
return pyBlueSpiralGameStartedMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyBlueSpiralClothOrderMsg::pyBlueSpiralClothOrderMsg(): pyBlueSpiralMsg() {}
|
||||
|
||||
pyBlueSpiralClothOrderMsg::pyBlueSpiralClothOrderMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_ClothOrder))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
std::vector<int> pyBlueSpiralClothOrderMsg::Order()
|
||||
{
|
||||
std::vector<int> retVal;
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_BlueSpiral_ClothOrder* gmMsg = (const Srv2Cli_BlueSpiral_ClothOrder*)message->netMsg;
|
||||
for (int i = 0; i < arrsize(gmMsg->order); ++i)
|
||||
retVal.push_back(gmMsg->order[i]);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyBlueSpiralSuccessfulHitMsg::pyBlueSpiralSuccessfulHitMsg(): pyBlueSpiralMsg() {}
|
||||
|
||||
pyBlueSpiralSuccessfulHitMsg::pyBlueSpiralSuccessfulHitMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_SuccessfulHit))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyBlueSpiralGameWonMsg::pyBlueSpiralGameWonMsg(): pyBlueSpiralMsg() {}
|
||||
|
||||
pyBlueSpiralGameWonMsg::pyBlueSpiralGameWonMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameWon))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyBlueSpiralGameOverMsg::pyBlueSpiralGameOverMsg(): pyBlueSpiralMsg() {}
|
||||
|
||||
pyBlueSpiralGameOverMsg::pyBlueSpiralGameOverMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameOver))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyBlueSpiralGameStartedMsg::pyBlueSpiralGameStartedMsg(): pyBlueSpiralMsg() {}
|
||||
|
||||
pyBlueSpiralGameStartedMsg::pyBlueSpiralGameStartedMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameStarted))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyBlueSpiralGameStartedMsg::StartSpin()
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_BlueSpiral_GameStarted* gmMsg = (const Srv2Cli_BlueSpiral_GameStarted*)message->netMsg;
|
||||
return gmMsg->startSpin;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyBlueSpiralMsg_h
|
||||
#define pyBlueSpiralMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyBlueSpiralMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for BlueSpiral game messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCliMsg.h"
|
||||
|
||||
class pyBlueSpiralMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralMsg();
|
||||
pyBlueSpiralMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralMsg); // converts a PyObject to a pyBlueSpiralMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetBlueSpiralMsgType() const;
|
||||
|
||||
PyObject* UpcastToFinalBlueSpiralMsg() const; // returns this message as the blue spiral message it is
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyBlueSpiralClothOrderMsg : public pyBlueSpiralMsg
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralClothOrderMsg();
|
||||
pyBlueSpiralClothOrderMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralClothOrderMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralClothOrderMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralClothOrderMsg); // converts a PyObject to a pyBlueSpiralClothOrderMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
std::vector<int> Order();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyBlueSpiralSuccessfulHitMsg : public pyBlueSpiralMsg
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralSuccessfulHitMsg();
|
||||
pyBlueSpiralSuccessfulHitMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralSuccessfulHitMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralSuccessfulHitMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralSuccessfulHitMsg); // converts a PyObject to a pyBlueSpiralSuccessfulHitMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyBlueSpiralGameWonMsg : public pyBlueSpiralMsg
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralGameWonMsg();
|
||||
pyBlueSpiralGameWonMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameWonMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameWonMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameWonMsg); // converts a PyObject to a pyBlueSpiralGameWonMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyBlueSpiralGameOverMsg : public pyBlueSpiralMsg
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralGameOverMsg();
|
||||
pyBlueSpiralGameOverMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameOverMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameOverMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameOverMsg); // converts a PyObject to a pyBlueSpiralGameOverMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyBlueSpiralGameStartedMsg : public pyBlueSpiralMsg
|
||||
{
|
||||
protected:
|
||||
pyBlueSpiralGameStartedMsg();
|
||||
pyBlueSpiralGameStartedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameStartedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameStartedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameStartedMsg); // converts a PyObject to a pyBlueSpiralGameStartedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool StartSpin();
|
||||
};
|
||||
|
||||
#endif // pyBlueSpiralMsg_h
|
@ -0,0 +1,281 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyBlueSpiralMsg.h"
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base TTT msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralMsg, getBlueSpiralMsgType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetBlueSpiralMsgType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralMsg, upcastToFinalBlueSpiralMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalBlueSpiralMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralMsg)
|
||||
PYTHON_METHOD_NOARGS(ptBlueSpiralMsg, getBlueSpiralMsgType, "Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptBlueSpiralMsg, upcastToFinalBlueSpiralMsg, "Returns this message as the BlueSpiral message it really is"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralMsg, pyGameCliMsg, "Base class for BlueSpiral game messages");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptBlueSpiralMsg *newObj = (ptBlueSpiralMsg*)ptBlueSpiralMsg_type.tp_new(&ptBlueSpiralMsg_type, NULL, NULL);
|
||||
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_BlueSpiral))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralMsg, pyBlueSpiralMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralMsg, pyBlueSpiralMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyBlueSpiralMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtBlueSpiralMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralClothOrder, kSrv2Cli_BlueSpiral_ClothOrder);
|
||||
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralSuccessfulHit, kSrv2Cli_BlueSpiral_SuccessfulHit);
|
||||
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameWon, kSrv2Cli_BlueSpiral_GameWon);
|
||||
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameOver, kSrv2Cli_BlueSpiral_GameOver);
|
||||
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameStarted, kSrv2Cli_BlueSpiral_GameStarted);
|
||||
PYTHON_ENUM_END(m, PtBlueSpiralMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralClothOrderMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralClothOrderMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralClothOrderMsg, order)
|
||||
{
|
||||
std::vector<int> order = self->fThis->Order();
|
||||
PyObject* retVal = PyList_New(order.size());
|
||||
for (unsigned i = 0; i < order.size(); ++i)
|
||||
PyList_SetItem(retVal, i, PyInt_FromLong(order[i]));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralClothOrderMsg)
|
||||
PYTHON_METHOD_NOARGS(ptBlueSpiralClothOrderMsg, order, "Returns a list of numbers indicating the correct order to hit the clothes in"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralClothOrderMsg, pyBlueSpiralMsg, "BlueSpiral message received when the game is started and the cloth order is set");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralClothOrderMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptBlueSpiralClothOrderMsg *newObj = (ptBlueSpiralClothOrderMsg*)ptBlueSpiralClothOrderMsg_type.tp_new(&ptBlueSpiralClothOrderMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_ClothOrder))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralClothOrderMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralClothOrderMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralSuccessfulHitMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralSuccessfulHitMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralSuccessfulHitMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralMsg, "BlueSpiral message received when a cloth is hit in the correct order");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralSuccessfulHitMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptBlueSpiralSuccessfulHitMsg *newObj = (ptBlueSpiralSuccessfulHitMsg*)ptBlueSpiralSuccessfulHitMsg_type.tp_new(&ptBlueSpiralSuccessfulHitMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_SuccessfulHit))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralSuccessfulHitMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralSuccessfulHitMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameWonMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameWonMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameWonMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameWonMsg, pyBlueSpiralMsg, "BlueSpiral message received when the last cloth is successfully hit");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralGameWonMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptBlueSpiralGameWonMsg *newObj = (ptBlueSpiralGameWonMsg*)ptBlueSpiralGameWonMsg_type.tp_new(&ptBlueSpiralGameWonMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameWon))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralGameWonMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameWonMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameOverMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameOverMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameOverMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameOverMsg, pyBlueSpiralMsg, "BlueSpiral message received when the timer runs out, someone hits the wrong cloth, or the game is restarted (before a game start msg in that last case)");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralGameOverMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptBlueSpiralGameOverMsg *newObj = (ptBlueSpiralGameOverMsg*)ptBlueSpiralGameOverMsg_type.tp_new(&ptBlueSpiralGameOverMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameOver))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralGameOverMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameOverMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameStartedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameStartedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralGameStartedMsg, startSpin)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->StartSpin());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameStartedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptBlueSpiralGameStartedMsg, startSpin, "Returns true if you are supposed to start spinning the door thingy"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameStartedMsg, pyBlueSpiralMsg, "BlueSpiral message received when someone starts the game (or when you join a game that is running)");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyBlueSpiralGameStartedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptBlueSpiralGameStartedMsg *newObj = (ptBlueSpiralGameStartedMsg*)ptBlueSpiralGameStartedMsg_type.tp_new(&ptBlueSpiralGameStartedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameStarted))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyBlueSpiralGameStartedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameStartedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyClimbingWallGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base climbing wall game client class
|
||||
//
|
||||
|
||||
pyClimbingWallGame::pyClimbingWallGame(): pyGameCli() {}
|
||||
|
||||
pyClimbingWallGame::pyClimbingWallGame(pfGameCli* client): pyGameCli(client)
|
||||
{
|
||||
if (client && (client->GetGameTypeId() != kGameTypeId_ClimbingWall))
|
||||
gameClient = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyClimbingWallGame::IsClimbingWallGame(std::wstring guid)
|
||||
{
|
||||
Uuid gameUuid(guid.c_str());
|
||||
return gameUuid == kGameTypeId_ClimbingWall;
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::JoinCommonClimbingWallGame(pyKey& callbackKey, unsigned gameID)
|
||||
{
|
||||
ClimbingWall_CreateParam init;
|
||||
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_ClimbingWall, gameID, sizeof(init), &init);
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::ChangeNumBlockers(int amountToAdjust)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->ChangeNumBlockers(amountToAdjust);
|
||||
}
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::Ready(unsigned readyType, unsigned teamNumber)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->Ready(readyType, teamNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::ChangeBlocker(unsigned teamNumber, unsigned blockerNumber, bool added)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->ChangeBlocker(teamNumber, blockerNumber, added);
|
||||
}
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::Reset()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::PlayerEntered(unsigned teamNumber)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->PlayerEntered(teamNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::FinishedGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->FinishedGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::Panic()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
|
||||
climbingWall->Panic();
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyClimbingWallGame_h
|
||||
#define pyClimbingWallGame_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyClimbingWallGame
|
||||
//
|
||||
// PURPOSE: Class wrapper for the climbing wall game client
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCli.h"
|
||||
#include "../../pyKey.h"
|
||||
|
||||
class pyClimbingWallGame : public pyGameCli
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallGame();
|
||||
pyClimbingWallGame(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallGame);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallGame object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallGame); // converts a PyObject to a pyClimbingWallGame (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
static bool IsClimbingWallGame(std::wstring guid);
|
||||
static void JoinCommonClimbingWallGame(pyKey& callbackKey, unsigned gameID);
|
||||
|
||||
void ChangeNumBlockers(int amountToAdjust);
|
||||
void Ready(unsigned readyType, unsigned teamNumber);
|
||||
void ChangeBlocker(unsigned teamNumber, unsigned blockerNumber, bool added);
|
||||
void Reset();
|
||||
void PlayerEntered(unsigned teamNumber);
|
||||
void FinishedGame();
|
||||
void Panic();
|
||||
};
|
||||
|
||||
#endif // pyClimbingWallGame_h
|
@ -0,0 +1,196 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyClimbingWallGame.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base climbing wall game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallGame, pyClimbingWallGame);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallGame, pyClimbingWallGame)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallGame)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallGame)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsClimbingWallGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a ClimbingWall game")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsClimbingWallGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
bool retVal = pyClimbingWallGame::IsClimbingWallGame(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
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);
|
||||
bool retVal = pyClimbingWallGame::IsClimbingWallGame(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsClimbingWallGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonClimbingWallGame, args, "Params: callbackKey, gameID\nJoins a common ClimbingWall game with the specified ID. If one doesn't exist, it creates it")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
int gameID = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oii", &callbackObj, &gameID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonClimbingWallGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonClimbingWallGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyClimbingWallGame::JoinCommonClimbingWallGame(*key, gameID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, changeNumBlockers, args)
|
||||
{
|
||||
int amountToAdjust;
|
||||
if (!PyArg_ParseTuple(args, "i", &amountToAdjust))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeNumBlockers expects an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->ChangeNumBlockers(amountToAdjust);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, ready, args)
|
||||
{
|
||||
int readyType, teamNumber;
|
||||
if (!PyArg_ParseTuple(args, "ii", &readyType, &teamNumber))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "ready expects two integers");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->Ready((unsigned)readyType, (unsigned)teamNumber);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, changeBlocker, args)
|
||||
{
|
||||
int teamNumber, blockerNumber;
|
||||
char added;
|
||||
if (!PyArg_ParseTuple(args, "iib", &teamNumber, &blockerNumber, &added))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeBlocker expects two integers and a boolean");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->ChangeBlocker(teamNumber, blockerNumber, added != 0);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, reset, Reset)
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, playerEntered, args)
|
||||
{
|
||||
int teamNumber;
|
||||
if (!PyArg_ParseTuple(args, "i", &teamNumber))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "playerEntered expects an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->PlayerEntered(teamNumber);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, finishedGame, FinishedGame)
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, panic, Panic)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallGame)
|
||||
PYTHON_METHOD(ptClimbingWallGame, changeNumBlockers, "Params: amountToAdjust\nAdjusts the number of blockers we are playing with"),
|
||||
PYTHON_METHOD(ptClimbingWallGame, ready, "Params: readyType, teamNumber\nMarks the specified team as ready for the specified type (See PtClimbingWallReadyTypes)"),
|
||||
PYTHON_METHOD(ptClimbingWallGame, changeBlocker, "Params: teamNumber, blockerNumber, added\nChanges the specified marker's state for the specified team"),
|
||||
PYTHON_BASIC_METHOD(ptClimbingWallGame, reset, "Attempts to reset the game's control panel"),
|
||||
PYTHON_METHOD(ptClimbingWallGame, playerEntered, "Params: teamNumber\nTells the server that you are trying to play the game for the specified team"),
|
||||
PYTHON_BASIC_METHOD(ptClimbingWallGame, finishedGame, "Tells the server you reached the top of the wall"),
|
||||
PYTHON_BASIC_METHOD(ptClimbingWallGame, panic, "Tells the server you are panicking and want your blockers reset"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallGame, pyGameCli, "Game client for the ClimbingWall game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallGame::New(pfGameCli* client)
|
||||
{
|
||||
ptClimbingWallGame *newObj = (ptClimbingWallGame*)ptClimbingWallGame_type.tp_new(&ptClimbingWallGame_type, NULL, NULL);
|
||||
if (client && (client->GetGameTypeId() == kGameTypeId_ClimbingWall))
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallGame, pyClimbingWallGame)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallGame, pyClimbingWallGame)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallGame::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallGame);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsClimbingWallGame);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonClimbingWallGame);
|
||||
}
|
||||
|
||||
void pyClimbingWallGame::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtClimbingWallReadyTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallReadyTypes, kClimbingWallReadyNumBlockers, kClimbingWallReadyNumBlockers);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallReadyTypes, kClimbingWallReadyBlockers, kClimbingWallReadyBlockers);
|
||||
PYTHON_ENUM_END(m, PtClimbingWallReadyTypes);
|
||||
}
|
@ -0,0 +1,308 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyClimbingWallMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base climbing wall msg class
|
||||
//
|
||||
|
||||
pyClimbingWallMsg::pyClimbingWallMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyClimbingWallMsg::pyClimbingWallMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_ClimbingWall))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyClimbingWallMsg::GetClimbingWallMsgType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyClimbingWallMsg::UpcastToFinalClimbingWallMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_ClimbingWall_NumBlockersChanged:
|
||||
return pyClimbingWallNumBlockersChangedMsg::New(message);
|
||||
case kSrv2Cli_ClimbingWall_Ready:
|
||||
return pyClimbingWallReadyMsg::New(message);
|
||||
case kSrv2Cli_ClimbingWall_BlockersChanged:
|
||||
return pyClimbingWallBlockersChangedMsg::New(message);
|
||||
case kSrv2Cli_ClimbingWall_PlayerEntered:
|
||||
return pyClimbingWallPlayerEnteredMsg::New(message);
|
||||
case kSrv2Cli_ClimbingWall_SuitMachineLocked:
|
||||
return pyClimbingWallSuitMachineLockedMsg::New(message);
|
||||
case kSrv2Cli_ClimbingWall_GameOver:
|
||||
return pyClimbingWallGameOverMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyClimbingWallNumBlockersChangedMsg::pyClimbingWallNumBlockersChangedMsg(): pyClimbingWallMsg() {}
|
||||
|
||||
pyClimbingWallNumBlockersChangedMsg::pyClimbingWallNumBlockersChangedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_NumBlockersChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyClimbingWallNumBlockersChangedMsg::NewBlockerCount() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_NumBlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_NumBlockersChanged*)message->netMsg;
|
||||
return gmMsg->newBlockerCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pyClimbingWallNumBlockersChangedMsg::LocalOnly() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
|
||||
return gmMsg->localOnly;
|
||||
}
|
||||
return true; // safe-guard so we don't screw up other's state if the python does something stupid
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyClimbingWallReadyMsg::pyClimbingWallReadyMsg(): pyClimbingWallMsg() {}
|
||||
|
||||
pyClimbingWallReadyMsg::pyClimbingWallReadyMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_Ready))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyClimbingWallReadyMsg::ReadyType() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
|
||||
return gmMsg->readyType;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pyClimbingWallReadyMsg::Team1Ready() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
|
||||
return gmMsg->team1Ready;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pyClimbingWallReadyMsg::Team2Ready() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
|
||||
return gmMsg->team2Ready;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pyClimbingWallReadyMsg::LocalOnly() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
|
||||
return gmMsg->localOnly;
|
||||
}
|
||||
return true; // safe-guard so we don't screw up other's state if the python does something stupid
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyClimbingWallBlockersChangedMsg::pyClimbingWallBlockersChangedMsg(): pyClimbingWallMsg() {}
|
||||
|
||||
pyClimbingWallBlockersChangedMsg::pyClimbingWallBlockersChangedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_BlockersChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyClimbingWallBlockersChangedMsg::TeamNumber() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
|
||||
return gmMsg->teamNumber;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<int> pyClimbingWallBlockersChangedMsg::BlockersSet() const
|
||||
{
|
||||
std::vector<int> retVal;
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
|
||||
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
|
||||
{
|
||||
if (gmMsg->blockersSet[i] != kClimbingWallNoBlocker)
|
||||
retVal.push_back(gmMsg->blockersSet[i]);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool pyClimbingWallBlockersChangedMsg::LocalOnly() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
|
||||
return gmMsg->localOnly;
|
||||
}
|
||||
return true; // safe-guard so we don't screw up other's state if the python does something stupid
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyClimbingWallPlayerEnteredMsg::pyClimbingWallPlayerEnteredMsg(): pyClimbingWallMsg() {}
|
||||
|
||||
pyClimbingWallPlayerEnteredMsg::pyClimbingWallPlayerEnteredMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_PlayerEntered))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyClimbingWallSuitMachineLockedMsg::pyClimbingWallSuitMachineLockedMsg(): pyClimbingWallMsg() {}
|
||||
|
||||
pyClimbingWallSuitMachineLockedMsg::pyClimbingWallSuitMachineLockedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_SuitMachineLocked))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyClimbingWallSuitMachineLockedMsg::Team1MachineLocked() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
|
||||
return gmMsg->team1MachineLocked;
|
||||
}
|
||||
return true; // err on the side of caution
|
||||
}
|
||||
|
||||
bool pyClimbingWallSuitMachineLockedMsg::Team2MachineLocked() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
|
||||
return gmMsg->team2MachineLocked;
|
||||
}
|
||||
return true; // err on the side of caution
|
||||
}
|
||||
|
||||
bool pyClimbingWallSuitMachineLockedMsg::LocalOnly() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
|
||||
return gmMsg->localOnly;
|
||||
}
|
||||
return true; // safe-guard so we don't screw up other's state if the python does something stupid
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyClimbingWallGameOverMsg::pyClimbingWallGameOverMsg(): pyClimbingWallMsg() {}
|
||||
|
||||
pyClimbingWallGameOverMsg::pyClimbingWallGameOverMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_GameOver))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyClimbingWallGameOverMsg::TeamWon() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
|
||||
return gmMsg->teamWon;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<int> pyClimbingWallGameOverMsg::Team1Blockers() const
|
||||
{
|
||||
std::vector<int> retVal;
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
|
||||
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
|
||||
{
|
||||
if (gmMsg->team1Blockers[i] != kClimbingWallNoBlocker)
|
||||
retVal.push_back(gmMsg->team1Blockers[i]);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::vector<int> pyClimbingWallGameOverMsg::Team2Blockers() const
|
||||
{
|
||||
std::vector<int> retVal;
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
|
||||
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
|
||||
{
|
||||
if (gmMsg->team2Blockers[i] != kClimbingWallNoBlocker)
|
||||
retVal.push_back(gmMsg->team2Blockers[i]);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool pyClimbingWallGameOverMsg::LocalOnly() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
|
||||
return gmMsg->localOnly;
|
||||
}
|
||||
return true; // safe-guard so we don't screw up other's state if the python does something stupid
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyClimbingWallMsg_h
|
||||
#define pyClimbingWallMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyClimbingWallMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for ClimbingWall game messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCliMsg.h"
|
||||
|
||||
class pyClimbingWallMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallMsg();
|
||||
pyClimbingWallMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallMsg); // converts a PyObject to a pyClimbingWallMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetClimbingWallMsgType() const;
|
||||
|
||||
PyObject* UpcastToFinalClimbingWallMsg() const; // returns the climbing wall message that this really is
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyClimbingWallNumBlockersChangedMsg : public pyClimbingWallMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallNumBlockersChangedMsg();
|
||||
pyClimbingWallNumBlockersChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallNumBlockersChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallNumBlockersChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallNumBlockersChangedMsg); // converts a PyObject to a pyClimbingWallNumBlockersChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int NewBlockerCount() const;
|
||||
bool LocalOnly() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyClimbingWallReadyMsg : public pyClimbingWallMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallReadyMsg();
|
||||
pyClimbingWallReadyMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallReadyMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallReadyMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallReadyMsg); // converts a PyObject to a pyClimbingWallReadyMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int ReadyType() const;
|
||||
bool Team1Ready() const;
|
||||
bool Team2Ready() const;
|
||||
bool LocalOnly() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyClimbingWallBlockersChangedMsg : public pyClimbingWallMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallBlockersChangedMsg();
|
||||
pyClimbingWallBlockersChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallBlockersChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallBlockersChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallBlockersChangedMsg); // converts a PyObject to a pyClimbingWallBlockersChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int TeamNumber() const;
|
||||
std::vector<int> BlockersSet() const;
|
||||
bool LocalOnly() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyClimbingWallPlayerEnteredMsg : public pyClimbingWallMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallPlayerEnteredMsg();
|
||||
pyClimbingWallPlayerEnteredMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallPlayerEnteredMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallPlayerEnteredMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallPlayerEnteredMsg); // converts a PyObject to a pyClimbingWallPlayerEnteredMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyClimbingWallSuitMachineLockedMsg : public pyClimbingWallMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallSuitMachineLockedMsg();
|
||||
pyClimbingWallSuitMachineLockedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallSuitMachineLockedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallSuitMachineLockedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallSuitMachineLockedMsg); // converts a PyObject to a pyClimbingWallSuitMachineLockedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool Team1MachineLocked() const;
|
||||
bool Team2MachineLocked() const;
|
||||
bool LocalOnly() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyClimbingWallGameOverMsg : public pyClimbingWallMsg
|
||||
{
|
||||
protected:
|
||||
pyClimbingWallGameOverMsg();
|
||||
pyClimbingWallGameOverMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallGameOverMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallGameOverMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallGameOverMsg); // converts a PyObject to a pyClimbingWallGameOverMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int TeamWon() const;
|
||||
std::vector<int> Team1Blockers() const;
|
||||
std::vector<int> Team2Blockers() const;
|
||||
bool LocalOnly() const;
|
||||
};
|
||||
|
||||
#endif // pyClimbingWallMsg_h
|
@ -0,0 +1,413 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyClimbingWallMsg.h"
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base climbing wall msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallMsg, getClimbingWallMsgType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetClimbingWallMsgType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallMsg, upcastToFinalClimbingWallMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalClimbingWallMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallMsg)
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallMsg, getClimbingWallMsgType, "Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallMsg, upcastToFinalClimbingWallMsg, "Returns this message as the ClimbingWall msg it is"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallMsg, pyGameCliMsg, "Base class for ClimbingWall game messages");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallMsg *newObj = (ptClimbingWallMsg*)ptClimbingWallMsg_type.tp_new(&ptClimbingWallMsg_type, NULL, NULL);
|
||||
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_ClimbingWall))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallMsg, pyClimbingWallMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallMsg, pyClimbingWallMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyClimbingWallMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtClimbingWallMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallNumBlockersChanged, kSrv2Cli_ClimbingWall_NumBlockersChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallReadyMsg, kSrv2Cli_ClimbingWall_Ready);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallBlockersChanged, kSrv2Cli_ClimbingWall_BlockersChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallPlayerEntered, kSrv2Cli_ClimbingWall_PlayerEntered);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallSuitMachineLocked, kSrv2Cli_ClimbingWall_SuitMachineLocked);
|
||||
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallGameOver, kSrv2Cli_ClimbingWall_GameOver);
|
||||
PYTHON_ENUM_END(m, PtClimbingWallMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallNumBlockersChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallNumBlockersChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallNumBlockersChangedMsg, newBlockerCount)
|
||||
{
|
||||
return PyInt_FromLong((long)self->fThis->NewBlockerCount());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallNumBlockersChangedMsg, localOnly)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallNumBlockersChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallNumBlockersChangedMsg, newBlockerCount, "Returns the number of blockers this game is current running with"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallNumBlockersChangedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallMsg, "ClimbingWall message received when the number of blockers is changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallNumBlockersChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallNumBlockersChangedMsg *newObj = (ptClimbingWallNumBlockersChangedMsg*)ptClimbingWallNumBlockersChangedMsg_type.tp_new(&ptClimbingWallNumBlockersChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_NumBlockersChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallNumBlockersChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallNumBlockersChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallReadyMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallReadyMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, readyType)
|
||||
{
|
||||
return PyInt_FromLong((long)self->fThis->ReadyType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, team1Ready)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->Team1Ready());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, team2Ready)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->Team2Ready());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, localOnly)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallReadyMsg)
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, readyType, "The type of ready message this represents (see PtClimbingWallReadyTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, team1Ready, "Whether team 1 is ready or not"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, team2Ready, "Whether team 2 is ready or not"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallReadyMsg, pyClimbingWallMsg, "ClimbingWall message received when the ready state of the teams is changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallReadyMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallReadyMsg *newObj = (ptClimbingWallReadyMsg*)ptClimbingWallReadyMsg_type.tp_new(&ptClimbingWallReadyMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_Ready))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallReadyMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallReadyMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallBlockersChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallBlockersChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, teamNumber)
|
||||
{
|
||||
return PyInt_FromLong((long)self->fThis->TeamNumber());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, blockersSet)
|
||||
{
|
||||
std::vector<int> blockers = self->fThis->BlockersSet();
|
||||
PyObject* retVal = PyList_New(blockers.size());
|
||||
for (unsigned i = 0; i < blockers.size(); ++i)
|
||||
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, localOnly)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallBlockersChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, teamNumber, "The team that this message is for"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, blockersSet, "Returns an array of blocker indicies denoting which blockers are set"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallBlockersChangedMsg, pyClimbingWallMsg, "ClimbingWall message received when the blocker state changes");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallBlockersChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallBlockersChangedMsg *newObj = (ptClimbingWallBlockersChangedMsg*)ptClimbingWallBlockersChangedMsg_type.tp_new(&ptClimbingWallBlockersChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_BlockersChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallBlockersChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallBlockersChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallPlayerEnteredMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallPlayerEnteredMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallPlayerEnteredMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallPlayerEnteredMsg, pyClimbingWallMsg, "ClimbingWall message received when you successfully enter the suit machine");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallPlayerEnteredMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallPlayerEnteredMsg *newObj = (ptClimbingWallPlayerEnteredMsg*)ptClimbingWallPlayerEnteredMsg_type.tp_new(&ptClimbingWallPlayerEnteredMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_PlayerEntered))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallPlayerEnteredMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallPlayerEnteredMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallSuitMachineLockedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallSuitMachineLockedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, team1MachineLocked)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->Team1MachineLocked());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, team2MachineLocked)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->Team2MachineLocked());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, localOnly)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallSuitMachineLockedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, team1MachineLocked, "Whether team 1's suit machine is locked or not"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, team2MachineLocked, "Whether team 2's suit machine is locked or not"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallMsg, "ClimbingWall message received when the locked state of the suit machines is changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallSuitMachineLockedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallSuitMachineLockedMsg *newObj = (ptClimbingWallSuitMachineLockedMsg*)ptClimbingWallSuitMachineLockedMsg_type.tp_new(&ptClimbingWallSuitMachineLockedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_SuitMachineLocked))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallSuitMachineLockedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallSuitMachineLockedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallGameOverMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptClimbingWallGameOverMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, teamWon)
|
||||
{
|
||||
return PyInt_FromLong((long)self->fThis->TeamWon());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, team1Blockers)
|
||||
{
|
||||
std::vector<int> blockers = self->fThis->Team1Blockers();
|
||||
PyObject* retVal = PyList_New(blockers.size());
|
||||
for (unsigned i = 0; i < blockers.size(); ++i)
|
||||
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, team2Blockers)
|
||||
{
|
||||
std::vector<int> blockers = self->fThis->Team2Blockers();
|
||||
PyObject* retVal = PyList_New(blockers.size());
|
||||
for (unsigned i = 0; i < blockers.size(); ++i)
|
||||
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, localOnly)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptClimbingWallGameOverMsg)
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, teamWon, "The team that won the game"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, team1Blockers, "Returns an array of blocker indicies denoting which blockers team 1 set"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, team2Blockers, "Returns an array of blocker indicies denoting which blockers team 2 set"),
|
||||
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallGameOverMsg, pyClimbingWallMsg, "ClimbingWall message received when the game is over");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyClimbingWallGameOverMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptClimbingWallGameOverMsg *newObj = (ptClimbingWallGameOverMsg*)ptClimbingWallGameOverMsg_type.tp_new(&ptClimbingWallGameOverMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_GameOver))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyClimbingWallGameOverMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptClimbingWallGameOverMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyHeekGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Heek game client class
|
||||
//
|
||||
|
||||
pyHeekGame::pyHeekGame(): pyGameCli() {}
|
||||
|
||||
pyHeekGame::pyHeekGame(pfGameCli* client): pyGameCli(client)
|
||||
{
|
||||
if (client && (client->GetGameTypeId() != kGameTypeId_Heek))
|
||||
gameClient = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyHeekGame::IsHeekGame(std::wstring guid)
|
||||
{
|
||||
Uuid gameUuid(guid.c_str());
|
||||
return gameUuid == kGameTypeId_Heek;
|
||||
}
|
||||
|
||||
void pyHeekGame::JoinCommonHeekGame(pyKey& callbackKey, unsigned gameID)
|
||||
{
|
||||
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_Heek, gameID, 0, NULL);
|
||||
}
|
||||
|
||||
void pyHeekGame::PlayGame(int position, UInt32 points, std::wstring name)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
|
||||
heek->PlayGame((unsigned)position, (dword)points, name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void pyHeekGame::LeaveGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
|
||||
heek->LeaveGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyHeekGame::Choose(int choice)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
|
||||
heek->Choose((EHeekChoice)choice);
|
||||
}
|
||||
}
|
||||
|
||||
void pyHeekGame::SequenceFinished(int seq)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
|
||||
heek->SequenceFinished((EHeekSeqFinished)seq);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyHeekGame_h
|
||||
#define pyHeekGame_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyHeekGame
|
||||
//
|
||||
// PURPOSE: Class wrapper for the Heek game client
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCli.h"
|
||||
#include "../../pyKey.h"
|
||||
|
||||
class pyHeekGame : public pyGameCli
|
||||
{
|
||||
protected:
|
||||
pyHeekGame();
|
||||
pyHeekGame(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekGame);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGame object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGame); // converts a PyObject to a pyHeekGame (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
|
||||
static bool IsHeekGame(std::wstring guid);
|
||||
static void JoinCommonHeekGame(pyKey& callbackKey, unsigned gameID);
|
||||
|
||||
void PlayGame(int position, UInt32 points, std::wstring name);
|
||||
void LeaveGame();
|
||||
void Choose(int choice);
|
||||
void SequenceFinished(int seq);
|
||||
};
|
||||
|
||||
#endif // pyHeekGame_h
|
@ -0,0 +1,207 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyHeekGame.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Heek game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptHeekGame, pyHeekGame);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekGame, pyHeekGame)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekGame)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekGame)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsHeekGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a Heek game")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsHeekGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
bool retVal = pyHeekGame::IsHeekGame(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
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);
|
||||
bool retVal = pyHeekGame::IsHeekGame(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsHeekGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonHeekGame, args, "Params: callbackKey, gameID\nJoins a common Heek game with the specified ID. If one doesn't exist, it creates it")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
int gameID = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonHeekGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonHeekGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyHeekGame::JoinCommonHeekGame(*key, gameID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptHeekGame, playGame, args)
|
||||
{
|
||||
int position = 0;
|
||||
long points = 0;
|
||||
PyObject* textObj = NULL;
|
||||
if (!PyArg_ParseTuple(args,"ilO", &position, &points, &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "playGame expects an int, a long, and a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* temp = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, temp, strLen);
|
||||
temp[strLen] = L'\0';
|
||||
self->fThis->PlayGame(position, points, temp);
|
||||
delete [] temp;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else if (PyString_Check(textObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* temp = PyString_AsString(textObj);
|
||||
wchar_t* wTemp = hsStringToWString(temp);
|
||||
self->fThis->PlayGame(position, points, wTemp);
|
||||
delete [] wTemp;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "playGame expects an int, a long, and a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptHeekGame, leaveGame, LeaveGame)
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptHeekGame, choose, args)
|
||||
{
|
||||
int choice = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &choice))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "choose expects an int");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->Choose(choice);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptHeekGame, sequenceFinished, args)
|
||||
{
|
||||
int seq = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &seq))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "sequenceFinished expects an int");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->SequenceFinished(seq);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekGame)
|
||||
PYTHON_METHOD(ptHeekGame, playGame, "Params: position, points, name\nRequests to start playing the game in the specified position"),
|
||||
PYTHON_BASIC_METHOD(ptHeekGame, leaveGame, "Leaves this game (puts us into \"observer\" mode"),
|
||||
PYTHON_METHOD(ptHeekGame, choose, "Params: choice\nMakes the specified move (see PtHeekGameChoice)"),
|
||||
PYTHON_METHOD(ptHeekGame, sequenceFinished, "Params: sequence\nTells the server that the specified animation finished (see PtHeekGameSeq)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekGame, pyGameCli, "Game client for the Heek game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekGame::New(pfGameCli* client)
|
||||
{
|
||||
ptHeekGame *newObj = (ptHeekGame*)ptHeekGame_type.tp_new(&ptHeekGame_type, NULL, NULL);
|
||||
if (client && (client->GetGameTypeId() == kGameTypeId_Heek))
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekGame, pyHeekGame)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekGame, pyHeekGame)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekGame::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekGame);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyHeekGame::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtHeekGameChoice);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoiceRock, kHeekRock);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoicePaper, kHeekPaper);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoiceScissors, kHeekScissors);
|
||||
PYTHON_ENUM_END(m, PtHeekGameChoice);
|
||||
|
||||
PYTHON_ENUM_START(PtHeekGameSeq);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqCountdown, kHeekCountdownSeq);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqChoiceAnim, kHeekChoiceAnimSeq);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqGameWinAnim, kHeekGameWinAnimSeq);
|
||||
PYTHON_ENUM_END(m, PtHeekGameSeq);
|
||||
}
|
||||
|
||||
void pyHeekGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsHeekGame);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonHeekGame);
|
||||
}
|
@ -0,0 +1,386 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyHeekMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Heek msg class
|
||||
//
|
||||
|
||||
pyHeekMsg::pyHeekMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyHeekMsg::pyHeekMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_Heek))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyHeekMsg::GetHeekMsgType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyHeekMsg::UpcastToFinalHeekMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_Heek_PlayGame:
|
||||
return pyHeekPlayGameMsg::New(message);
|
||||
case kSrv2Cli_Heek_Goodbye:
|
||||
return pyHeekGoodbyeMsg::New(message);
|
||||
case kSrv2Cli_Heek_Welcome:
|
||||
return pyHeekWelcomeMsg::New(message);
|
||||
case kSrv2Cli_Heek_Drop:
|
||||
return pyHeekDropMsg::New(message);
|
||||
case kSrv2Cli_Heek_Setup:
|
||||
return pyHeekSetupMsg::New(message);
|
||||
case kSrv2Cli_Heek_LightState:
|
||||
return pyHeekLightStateMsg::New(message);
|
||||
case kSrv2Cli_Heek_InterfaceState:
|
||||
return pyHeekInterfaceStateMsg::New(message);
|
||||
case kSrv2Cli_Heek_CountdownState:
|
||||
return pyHeekCountdownStateMsg::New(message);
|
||||
case kSrv2Cli_Heek_WinLose:
|
||||
return pyHeekWinLoseMsg::New(message);
|
||||
case kSrv2Cli_Heek_GameWin:
|
||||
return pyHeekGameWinMsg::New(message);
|
||||
case kSrv2Cli_Heek_PointUpdate:
|
||||
return pyHeekPointUpdateMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyHeekPlayGameMsg::pyHeekPlayGameMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekPlayGameMsg::pyHeekPlayGameMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_PlayGame))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyHeekPlayGameMsg::IsPlaying() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
|
||||
return gmMsg->isPlaying;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pyHeekPlayGameMsg::IsSinglePlayer() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
|
||||
return gmMsg->isSinglePlayer;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pyHeekPlayGameMsg::EnableButtons() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
|
||||
return gmMsg->enableButtons;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekGoodbyeMsg::pyHeekGoodbyeMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekGoodbyeMsg::pyHeekGoodbyeMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Goodbye))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekWelcomeMsg::pyHeekWelcomeMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekWelcomeMsg::pyHeekWelcomeMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Welcome))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyHeekWelcomeMsg::Points() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
|
||||
return gmMsg->points;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long pyHeekWelcomeMsg::Rank() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
|
||||
return gmMsg->rank;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyHeekWelcomeMsg::Name() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
|
||||
return gmMsg->name;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekDropMsg::pyHeekDropMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekDropMsg::pyHeekDropMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Drop))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyHeekDropMsg::Position() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Drop* gmMsg = (const Srv2Cli_Heek_Drop*)message->netMsg;
|
||||
return gmMsg->position;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekSetupMsg::pyHeekSetupMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekSetupMsg::pyHeekSetupMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Welcome))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyHeekSetupMsg::Position() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
|
||||
return gmMsg->position;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool pyHeekSetupMsg::ButtonState() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
|
||||
return gmMsg->buttonState;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<bool> pyHeekSetupMsg::LightOn() const
|
||||
{
|
||||
std::vector<bool> retVal;
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
|
||||
int numLights = arrsize(gmMsg->lightOn);
|
||||
for (int i = 0; i < numLights; ++i)
|
||||
retVal.push_back(gmMsg->lightOn[i]);
|
||||
return retVal;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekLightStateMsg::pyHeekLightStateMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekLightStateMsg::pyHeekLightStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_LightState))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyHeekLightStateMsg::LightNum() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_LightState* gmMsg = (const Srv2Cli_Heek_LightState*)message->netMsg;
|
||||
return gmMsg->lightNum;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pyHeekLightStateMsg::State() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_LightState* gmMsg = (const Srv2Cli_Heek_LightState*)message->netMsg;
|
||||
return gmMsg->state;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekInterfaceStateMsg::pyHeekInterfaceStateMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekInterfaceStateMsg::pyHeekInterfaceStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_InterfaceState))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyHeekInterfaceStateMsg::ButtonsEnabled() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_InterfaceState* gmMsg = (const Srv2Cli_Heek_InterfaceState*)message->netMsg;
|
||||
return gmMsg->buttonsEnabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekCountdownStateMsg::pyHeekCountdownStateMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekCountdownStateMsg::pyHeekCountdownStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_CountdownState))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyHeekCountdownStateMsg::State() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_CountdownState* gmMsg = (const Srv2Cli_Heek_CountdownState*)message->netMsg;
|
||||
return gmMsg->state;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekWinLoseMsg::pyHeekWinLoseMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekWinLoseMsg::pyHeekWinLoseMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_WinLose))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyHeekWinLoseMsg::Win() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_WinLose* gmMsg = (const Srv2Cli_Heek_WinLose*)message->netMsg;
|
||||
return gmMsg->win;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int pyHeekWinLoseMsg::Choice() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_WinLose* gmMsg = (const Srv2Cli_Heek_WinLose*)message->netMsg;
|
||||
return gmMsg->choice;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekGameWinMsg::pyHeekGameWinMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekGameWinMsg::pyHeekGameWinMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_GameWin))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyHeekGameWinMsg::Choice() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_GameWin* gmMsg = (const Srv2Cli_Heek_GameWin*)message->netMsg;
|
||||
return gmMsg->choice;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyHeekPointUpdateMsg::pyHeekPointUpdateMsg(): pyHeekMsg() {}
|
||||
|
||||
pyHeekPointUpdateMsg::pyHeekPointUpdateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_PointUpdate))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyHeekPointUpdateMsg::DisplayUpdate() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
|
||||
return gmMsg->displayUpdate;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long pyHeekPointUpdateMsg::Points() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
|
||||
return gmMsg->points;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long pyHeekPointUpdateMsg::Rank() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
|
||||
return gmMsg->rank;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,283 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyHeekMsg_h
|
||||
#define pyHeekMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyHeekMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for Heek game messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCliMsg.h"
|
||||
|
||||
class pyHeekMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekMsg();
|
||||
pyHeekMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekMsg); // converts a PyObject to a pyHeekMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetHeekMsgType() const;
|
||||
|
||||
PyObject* UpcastToFinalHeekMsg() const; // returns the heek message this really is
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekPlayGameMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekPlayGameMsg();
|
||||
pyHeekPlayGameMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekPlayGameMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekPlayGameMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekPlayGameMsg); // converts a PyObject to a pyHeekPlayGameMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool IsPlaying() const;
|
||||
bool IsSinglePlayer() const;
|
||||
bool EnableButtons() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekGoodbyeMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekGoodbyeMsg();
|
||||
pyHeekGoodbyeMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekGoodbyeMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGoodbyeMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGoodbyeMsg); // converts a PyObject to a pyHeekGoodbyeMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekWelcomeMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekWelcomeMsg();
|
||||
pyHeekWelcomeMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekWelcomeMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekWelcomeMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekWelcomeMsg); // converts a PyObject to a pyHeekWelcomeMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long Points() const;
|
||||
unsigned long Rank() const;
|
||||
std::wstring Name() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekDropMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekDropMsg();
|
||||
pyHeekDropMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekDropMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekDropMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekDropMsg); // converts a PyObject to a pyHeekDropMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int Position() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekSetupMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekSetupMsg();
|
||||
pyHeekSetupMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekSetupMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekSetupMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekSetupMsg); // converts a PyObject to a pyHeekSetupMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int Position() const;
|
||||
bool ButtonState() const;
|
||||
std::vector<bool> LightOn() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekLightStateMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekLightStateMsg();
|
||||
pyHeekLightStateMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekLightStateMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekLightStateMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekLightStateMsg); // converts a PyObject to a pyHeekLightStateMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int LightNum() const;
|
||||
int State() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekInterfaceStateMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekInterfaceStateMsg();
|
||||
pyHeekInterfaceStateMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekInterfaceStateMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekInterfaceStateMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekInterfaceStateMsg); // converts a PyObject to a pyHeekInterfaceStateMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool ButtonsEnabled() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekCountdownStateMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekCountdownStateMsg();
|
||||
pyHeekCountdownStateMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekCountdownStateMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekCountdownStateMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekCountdownStateMsg); // converts a PyObject to a pyHeekCountdownStateMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int State() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekWinLoseMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekWinLoseMsg();
|
||||
pyHeekWinLoseMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekWinLoseMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekWinLoseMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekWinLoseMsg); // converts a PyObject to a pyHeekWinLoseMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool Win() const;
|
||||
int Choice() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekGameWinMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekGameWinMsg();
|
||||
pyHeekGameWinMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekGameWinMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGameWinMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGameWinMsg); // converts a PyObject to a pyHeekGameWinMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int Choice() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyHeekPointUpdateMsg : public pyHeekMsg
|
||||
{
|
||||
protected:
|
||||
pyHeekPointUpdateMsg();
|
||||
pyHeekPointUpdateMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptHeekPointUpdateMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekPointUpdateMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekPointUpdateMsg); // converts a PyObject to a pyHeekPointUpdateMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool DisplayUpdate() const;
|
||||
unsigned long Points() const;
|
||||
unsigned long Rank() const;
|
||||
};
|
||||
|
||||
#endif // pyHeekMsg_h
|
@ -0,0 +1,618 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyHeekMsg.h"
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Heek msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptHeekMsg, pyHeekMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekMsg, pyHeekMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekMsg, getHeekMsgType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetHeekMsgType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekMsg, upcastToFinalHeekMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalHeekMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekMsg, getHeekMsgType, "Returns the type of the Heek message (see PtHeekMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekMsg, upcastToFinalHeekMsg, "Returns this message as the Heek message it is"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekMsg, pyGameCliMsg, "Base class for Heek game messages");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptHeekMsg, pyHeekMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekMsg *newObj = (ptHeekMsg*)ptHeekMsg_type.tp_new(&ptHeekMsg_type, NULL, NULL);
|
||||
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_Heek))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekMsg, pyHeekMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekMsg, pyHeekMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyHeekMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtHeekMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekPlayGame, kSrv2Cli_Heek_PlayGame);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekGoodbye, kSrv2Cli_Heek_Goodbye);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekWelcome, kSrv2Cli_Heek_Welcome);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekDrop, kSrv2Cli_Heek_Drop);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekSetup, kSrv2Cli_Heek_Setup);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekLightState, kSrv2Cli_Heek_LightState);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekInterfaceState, kSrv2Cli_Heek_InterfaceState);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekCountdownState, kSrv2Cli_Heek_CountdownState);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekWinLose, kSrv2Cli_Heek_WinLose);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekGameWin, kSrv2Cli_Heek_GameWin);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekMsgTypes, kHeekPointUpdate, kSrv2Cli_Heek_PointUpdate);
|
||||
PYTHON_ENUM_END(m, PtHeekMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptHeekPlayGameMsg, pyHeekPlayGameMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekPlayGameMsg, pyHeekPlayGameMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekPlayGameMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekPlayGameMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekPlayGameMsg, isPlaying)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->IsPlaying());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekPlayGameMsg, isSinglePlayer)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->IsSinglePlayer());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekPlayGameMsg, enableButtons)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->EnableButtons())
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekPlayGameMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekPlayGameMsg, isPlaying, "Returns true if the server accepted the play game request"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekPlayGameMsg, isSinglePlayer, "Returns true if you are the only player at the table"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekPlayGameMsg, enableButtons, "Returns true if we should enable the buttons at the place we sat down"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekPlayGameMsg, pyHeekMsg, "Heek message received when the server processes your play game request");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekPlayGameMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekPlayGameMsg *newObj = (ptHeekPlayGameMsg*)ptHeekPlayGameMsg_type.tp_new(&ptHeekPlayGameMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_PlayGame))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekPlayGameMsg, pyHeekPlayGameMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekPlayGameMsg, pyHeekPlayGameMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekPlayGameMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekPlayGameMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekGoodbyeMsg, pyHeekGoodbyeMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekGoodbyeMsg, pyHeekGoodbyeMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekGoodbyeMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekGoodbyeMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekGoodbyeMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekGoodbyeMsg, pyHeekMsg, "Heek message received when the server processes leave request");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekGoodbyeMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekGoodbyeMsg *newObj = (ptHeekGoodbyeMsg*)ptHeekGoodbyeMsg_type.tp_new(&ptHeekGoodbyeMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_Goodbye))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekGoodbyeMsg, pyHeekGoodbyeMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekGoodbyeMsg, pyHeekGoodbyeMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekGoodbyeMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekGoodbyeMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekWelcomeMsg, pyHeekWelcomeMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekWelcomeMsg, pyHeekWelcomeMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekWelcomeMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekWelcomeMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekWelcomeMsg, points)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->Points());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekWelcomeMsg, rank)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->Rank());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekWelcomeMsg, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekWelcomeMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekWelcomeMsg, points, "Returns the new player's points"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekWelcomeMsg, rank, "Returns the new player's rank"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekWelcomeMsg, name, "Returns the new player's name"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekWelcomeMsg, pyHeekMsg, "Heek message received when a new player sits down");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekWelcomeMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekWelcomeMsg *newObj = (ptHeekWelcomeMsg*)ptHeekWelcomeMsg_type.tp_new(&ptHeekWelcomeMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_Welcome))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekWelcomeMsg, pyHeekWelcomeMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekWelcomeMsg, pyHeekWelcomeMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekWelcomeMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekWelcomeMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekDropMsg, pyHeekDropMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekDropMsg, pyHeekDropMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekDropMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekDropMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekDropMsg, position)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->Position());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekDropMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekDropMsg, position, "Returns player position to cleanup and dump"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekDropMsg, pyHeekMsg, "Heek message received when another player's position needs to be reset/modified");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekDropMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekDropMsg *newObj = (ptHeekDropMsg*)ptHeekDropMsg_type.tp_new(&ptHeekDropMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_Drop))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekDropMsg, pyHeekDropMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekDropMsg, pyHeekDropMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekDropMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekDropMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekSetupMsg, pyHeekSetupMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekSetupMsg, pyHeekSetupMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekSetupMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekSetupMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekSetupMsg, position)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->Position());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekSetupMsg, buttonState)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->ButtonState());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekSetupMsg, lightOn)
|
||||
{
|
||||
std::vector<bool> lights = self->fThis->LightOn();
|
||||
PyObject* retVal = PyList_New(lights.size());
|
||||
for (unsigned i = 0; i < lights.size(); ++i)
|
||||
PyList_SetItem(retVal, i, PyInt_FromLong(lights[i] ? 1 : 0));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekSetupMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekSetupMsg, position, "Returns the position this message is for"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekSetupMsg, buttonState, "Returns whether the buttons are enabled or not"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekSetupMsg, lightOn, "Returns a list of bools representing lights on or off"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekSetupMsg, pyHeekMsg, "Heek message for setting up each position's state");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekSetupMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekSetupMsg *newObj = (ptHeekSetupMsg*)ptHeekSetupMsg_type.tp_new(&ptHeekSetupMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_Setup))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekSetupMsg, pyHeekSetupMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekSetupMsg, pyHeekSetupMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekSetupMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekSetupMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekLightStateMsg, pyHeekLightStateMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekLightStateMsg, pyHeekLightStateMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekLightStateMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekLightStateMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekLightStateMsg, lightNum)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->LightNum());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekLightStateMsg, state)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->State());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekLightStateMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekLightStateMsg, lightNum, "Returns the index of the light this refers to"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekLightStateMsg, state, "Returns state the light should be switched to (see PtHeekLightStates)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekLightStateMsg, pyHeekMsg, "Heek message received when one of your local lights needs to change state");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekLightStateMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekLightStateMsg *newObj = (ptHeekLightStateMsg*)ptHeekLightStateMsg_type.tp_new(&ptHeekLightStateMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_LightState))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekLightStateMsg, pyHeekLightStateMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekLightStateMsg, pyHeekLightStateMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekLightStateMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekLightStateMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyHeekLightStateMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtHeekLightStates);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekLightStates, kHeekLightOn, kHeekLightOn);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekLightStates, kHeekLightOff, kHeekLightOff);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekLightStates, kHeekLightFlash, kHeekLightFlash);
|
||||
PYTHON_ENUM_END(m, PtHeekLightStates);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekInterfaceStateMsg, pyHeekInterfaceStateMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekInterfaceStateMsg, pyHeekInterfaceStateMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekInterfaceStateMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekInterfaceStateMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekInterfaceStateMsg, buttonsEnabled)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->ButtonsEnabled());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekInterfaceStateMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekInterfaceStateMsg, buttonsEnabled, "Returns whether your buttons should be enabled"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekInterfaceStateMsg, pyHeekMsg, "Heek message received when your interface buttons need to enable or disable");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekInterfaceStateMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekInterfaceStateMsg *newObj = (ptHeekInterfaceStateMsg*)ptHeekInterfaceStateMsg_type.tp_new(&ptHeekInterfaceStateMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_InterfaceState))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekInterfaceStateMsg, pyHeekInterfaceStateMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekInterfaceStateMsg, pyHeekInterfaceStateMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekInterfaceStateMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekInterfaceStateMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekCountdownStateMsg, pyHeekCountdownStateMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekCountdownStateMsg, pyHeekCountdownStateMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekCountdownStateMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekCountdownStateMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekCountdownStateMsg, state)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->State());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekCountdownStateMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekCountdownStateMsg, state, "Returns state the countdown should be switched to (see PtHeekCountdownStates)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekCountdownStateMsg, pyHeekMsg, "Heek message received by game admin when the countdown state needs to change");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekCountdownStateMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekCountdownStateMsg *newObj = (ptHeekCountdownStateMsg*)ptHeekCountdownStateMsg_type.tp_new(&ptHeekCountdownStateMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_CountdownState))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekCountdownStateMsg, pyHeekCountdownStateMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekCountdownStateMsg, pyHeekCountdownStateMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekCountdownStateMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekCountdownStateMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyHeekCountdownStateMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtHeekCountdownStates);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekCountdownStates, kHeekCountdownStart, kHeekCountdownStart);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekCountdownStates, kHeekCountdownStop, kHeekCountdownStop);
|
||||
PYTHON_ENUM_ELEMENT(PtHeekCountdownStates, kHeekCountdownIdle, kHeekCountdownIdle);
|
||||
PYTHON_ENUM_END(m, PtHeekCountdownStates);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekWinLoseMsg, pyHeekWinLoseMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekWinLoseMsg, pyHeekWinLoseMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekWinLoseMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekWinLoseMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekWinLoseMsg, win)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->Win());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekWinLoseMsg, choice)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->Choice());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekWinLoseMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekWinLoseMsg, win, "Returns true if you won"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekWinLoseMsg, choice, "Returns the choice that won or lost (see PtHeekGameChoice)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekWinLoseMsg, pyHeekMsg, "Heek message received when the round is over and you won or lost");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekWinLoseMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekWinLoseMsg *newObj = (ptHeekWinLoseMsg*)ptHeekWinLoseMsg_type.tp_new(&ptHeekWinLoseMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_WinLose))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekWinLoseMsg, pyHeekWinLoseMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekWinLoseMsg, pyHeekWinLoseMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekWinLoseMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekWinLoseMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekGameWinMsg, pyHeekGameWinMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekGameWinMsg, pyHeekGameWinMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekGameWinMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekGameWinMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekGameWinMsg, choice)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->Choice());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekGameWinMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekGameWinMsg, choice, "Returns the choice that won (see PtHeekGameChoice)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekGameWinMsg, pyHeekMsg, "Heek message received by game admin when a game is won");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekGameWinMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekGameWinMsg *newObj = (ptHeekGameWinMsg*)ptHeekGameWinMsg_type.tp_new(&ptHeekGameWinMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_GameWin))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekGameWinMsg, pyHeekGameWinMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekGameWinMsg, pyHeekGameWinMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekGameWinMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekGameWinMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptHeekPointUpdateMsg, pyHeekPointUpdateMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekPointUpdateMsg, pyHeekPointUpdateMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekPointUpdateMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptHeekPointUpdateMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekPointUpdateMsg, displayUpdate)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->DisplayUpdate());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekPointUpdateMsg, points)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->Points());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptHeekPointUpdateMsg, rank)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->Rank());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptHeekPointUpdateMsg)
|
||||
PYTHON_METHOD_NOARGS(ptHeekPointUpdateMsg, displayUpdate, "Returns whether you should display a message to the user"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekPointUpdateMsg, points, "Returns your new amount of points"),
|
||||
PYTHON_METHOD_NOARGS(ptHeekPointUpdateMsg, rank, "Returns your new rank"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptHeekPointUpdateMsg, pyHeekMsg, "Heek message received when the number of points you have needs to be changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyHeekPointUpdateMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptHeekPointUpdateMsg *newObj = (ptHeekPointUpdateMsg*)ptHeekPointUpdateMsg_type.tp_new(&ptHeekPointUpdateMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Heek_PointUpdate))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptHeekPointUpdateMsg, pyHeekPointUpdateMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekPointUpdateMsg, pyHeekPointUpdateMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyHeekPointUpdateMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptHeekPointUpdateMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyMarkerGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Marker game client class
|
||||
//
|
||||
|
||||
pyMarkerGame::pyMarkerGame(): pyGameCli() {}
|
||||
|
||||
pyMarkerGame::pyMarkerGame(pfGameCli* client): pyGameCli(client)
|
||||
{
|
||||
if (client && (client->GetGameTypeId() != kGameTypeId_Marker))
|
||||
gameClient = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyMarkerGame::IsMarkerGame(std::wstring guid)
|
||||
{
|
||||
Uuid gameUuid(guid.c_str());
|
||||
return gameUuid == kGameTypeId_Marker;
|
||||
}
|
||||
|
||||
void pyMarkerGame::CreateMarkerGame(pyKey& callbackKey, unsigned gameType, std::wstring gameName, unsigned long timeLimit, std::wstring templateId)
|
||||
{
|
||||
Marker_CreateParam init;
|
||||
init.gameType = gameType;
|
||||
StrCopy(init.gameName, gameName.c_str(), arrsize(init.gameName));
|
||||
init.timeLimit = timeLimit;
|
||||
StrCopy(init.templateID, templateId.c_str(), arrsize(init.templateID));
|
||||
pfGameMgr::GetInstance()->CreateGame(callbackKey.getKey(), kGameTypeId_Marker, 0, sizeof(init), &init);
|
||||
}
|
||||
|
||||
void pyMarkerGame::StartGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->StartGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::PauseGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->PauseGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::ResetGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->ResetGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::ChangeGameName(std::wstring newName)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->ChangeGameName(newName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::ChangeTimeLimit(unsigned long timeLimit)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->ChangeTimeLimit(timeLimit);
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::DeleteGame()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->DeleteGame();
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::AddMarker(double x, double y, double z, std::wstring name, std::wstring age)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->AddMarker(x, y, z, name.c_str(), age.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::DeleteMarker(unsigned long markerId)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->DeleteMarker(markerId);
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::ChangeMarkerName(unsigned long markerId, std::wstring newName)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->ChangeMarkerName(markerId, newName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void pyMarkerGame::CaptureMarker(unsigned long markerId)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
|
||||
marker->CaptureMarker(markerId);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyMarkerGame_h
|
||||
#define pyMarkerGame_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyMarkerGame
|
||||
//
|
||||
// PURPOSE: Class wrapper for the Marker game client
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCli.h"
|
||||
#include "../../pyKey.h"
|
||||
|
||||
class pyMarkerGame : public pyGameCli
|
||||
{
|
||||
protected:
|
||||
pyMarkerGame();
|
||||
pyMarkerGame(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGame);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a ptMarkerGame object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGame); // converts a PyObject to a pyMarkerGame (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
|
||||
static bool IsMarkerGame(std::wstring guid);
|
||||
static void CreateMarkerGame(pyKey& callbackKey, unsigned gameType, std::wstring gameName, unsigned long timeLimit, std::wstring templateId);
|
||||
|
||||
void StartGame();
|
||||
void PauseGame();
|
||||
void ResetGame();
|
||||
void ChangeGameName(std::wstring newName);
|
||||
void ChangeTimeLimit(unsigned long timeLimit);
|
||||
void DeleteGame();
|
||||
void AddMarker(double x, double y, double z, std::wstring name, std::wstring age);
|
||||
void DeleteMarker(unsigned long markerId);
|
||||
void ChangeMarkerName(unsigned long markerId, std::wstring newName);
|
||||
void CaptureMarker(unsigned long markerId);
|
||||
};
|
||||
|
||||
#endif // pyMarkerGame_h
|
@ -0,0 +1,381 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyMarkerGame.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base TTT game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGame, pyMarkerGame);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGame, pyMarkerGame)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGame)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGame)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsMarkerGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a Marker game")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsMarkerGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
bool retVal = pyMarkerGame::IsMarkerGame(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
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);
|
||||
bool retVal = pyMarkerGame::IsMarkerGame(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsMarkerGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION_WKEY(PtCreateMarkerGame, args, keywords, "Params: callbackKey, gameType, gameName = \"\", timeLimit = 0, templateId = \"\"\n"
|
||||
"Creates a new Marker game with the specified callback key, game type (from PtMarkerGameTypes), time limit (in ms), and template id (guid string)")
|
||||
{
|
||||
char *kwlist[] = {"callbackKey", "gameType", "gameName", "timeLimit", "templateId", NULL};
|
||||
PyObject* callbackObj = NULL;
|
||||
unsigned int gameType = 0;
|
||||
PyObject* gameNameObj = NULL;
|
||||
unsigned long timeLimit = 0;
|
||||
PyObject* templateIdObj = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywords, "OI|OkO", kwlist, &callbackObj, &gameType, &gameNameObj, &timeLimit, &templateIdObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
std::wstring name = L"";
|
||||
std::wstring templateId = L"";
|
||||
if (gameNameObj != NULL)
|
||||
{
|
||||
if (PyUnicode_Check(gameNameObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(gameNameObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)gameNameObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
name = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(gameNameObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(gameNameObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
name = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
if (templateIdObj != NULL)
|
||||
{
|
||||
if (PyUnicode_Check(templateIdObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(templateIdObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)templateIdObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
templateId = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(templateIdObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(templateIdObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
templateId = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
pyMarkerGame::CreateMarkerGame(*key, gameType, name, timeLimit, templateId);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, startGame, StartGame)
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, pauseGame, PauseGame)
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, resetGame, ResetGame)
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeGameName, args)
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeGameName expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
self->fThis->ChangeGameName(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
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);
|
||||
self->fThis->ChangeGameName(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeGameName expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeTimeLimit, args)
|
||||
{
|
||||
unsigned long timeLimit;
|
||||
if (!PyArg_ParseTuple(args, "k", &timeLimit))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeTimeLimit expects an unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->ChangeTimeLimit(timeLimit);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, deleteGame, DeleteGame)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_WKEY(ptMarkerGame, addMarker, args, keywords)
|
||||
{
|
||||
char *kwlist[] = {"x", "y", "z", "name", "age", NULL};
|
||||
double x, y, z;
|
||||
PyObject* nameObj = NULL;
|
||||
PyObject* ageObj = NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywords, "ddd|OO", kwlist, &x, &y, &z, &nameObj, &ageObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
std::wstring name = L"";
|
||||
std::wstring age = L"";
|
||||
if (nameObj != NULL)
|
||||
{
|
||||
if (PyUnicode_Check(nameObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(nameObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
name = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(nameObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(nameObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
name = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
if (ageObj != NULL)
|
||||
{
|
||||
if (PyUnicode_Check(ageObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(ageObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)ageObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
age = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(ageObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(ageObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
age = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
self->fThis->AddMarker(x, y, z, name, age);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptMarkerGame, deleteMarker, args)
|
||||
{
|
||||
unsigned long markerId;
|
||||
if (!PyArg_ParseTuple(args, "k", &markerId))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "deleteMarker expects an unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->DeleteMarker(markerId);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeMarkerName, args)
|
||||
{
|
||||
unsigned long markerId;
|
||||
PyObject* nameObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "kO", &markerId, &nameObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeMarkerName expects an unsigned long and a string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(nameObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(nameObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
self->fThis->ChangeMarkerName(markerId, text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else if (PyString_Check(nameObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(nameObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
self->fThis->ChangeMarkerName(markerId, wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "changeMarkerName expects an unsigned long and a string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptMarkerGame, captureMarker, args)
|
||||
{
|
||||
unsigned long markerId;
|
||||
if (!PyArg_ParseTuple(args, "k", &markerId))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "captureMarker expects an unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->CaptureMarker(markerId);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGame)
|
||||
PYTHON_BASIC_METHOD(ptMarkerGame, startGame, "Starts the game. Won't work on MP games if you're not the owner/creator"),
|
||||
PYTHON_BASIC_METHOD(ptMarkerGame, pauseGame, "Pauses the game. Won't work on MP games if you're not the owner/creator"),
|
||||
PYTHON_BASIC_METHOD(ptMarkerGame, resetGame, "Resets the game. Won't work on MP games if you're not the owner/creator"),
|
||||
PYTHON_METHOD(ptMarkerGame, changeGameName, "Params: newName\nChanges the name of the game. Won't work if you're not the game owner/creator"),
|
||||
PYTHON_METHOD(ptMarkerGame, changeTimeLimit, "Params: newTimeLimit\nChanges the time limit on the game (in ms). Won't work if you're not the game owner/creator, or if it's a quest game"),
|
||||
PYTHON_BASIC_METHOD(ptMarkerGame, deleteGame, "Tells the server to delete the game. Won't work if you're not the game owner/creator"),
|
||||
PYTHON_METHOD_WKEY(ptMarkerGame, addMarker, "Params: x, y, z, name = \"\", age = \"\"\nAdds a marker to the game. Age is ignored in a non-quest game. Won't work if you're not the owner/creator"),
|
||||
PYTHON_METHOD(ptMarkerGame, deleteMarker, "Params: markerId\nDeletes the specified marker from the game. Won't work if you're not the game owner/creator"),
|
||||
PYTHON_METHOD(ptMarkerGame, changeMarkerName, "Params: markerId, newName\nChanges the name of the specified marker. Won't work if you're not the game owner/creator"),
|
||||
PYTHON_METHOD(ptMarkerGame, captureMarker, "Params: markerId\nCaptures the specified marker"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGame, pyGameCli, "Game client for the Marker game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGame::New(pfGameCli* client)
|
||||
{
|
||||
ptMarkerGame *newObj = (ptMarkerGame*)ptMarkerGame_type.tp_new(&ptMarkerGame_type, NULL, NULL);
|
||||
if (client && (client->GetGameTypeId() == kGameTypeId_Marker))
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGame, pyMarkerGame)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGame, pyMarkerGame)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGame::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGame);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyMarkerGame::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtMarkerGameTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameQuest, kMarkerGameQuest);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCGZ, kMarkerGameCGZ);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCapture, kMarkerGameCapture);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCaptureAndHold, kMarkerGameCaptureAndHold);
|
||||
PYTHON_ENUM_END(m, PtMarkerGameTypes);
|
||||
}
|
||||
|
||||
void pyMarkerGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsMarkerGame);
|
||||
PYTHON_GLOBAL_METHOD_WKEY(methods, PtCreateMarkerGame);
|
||||
}
|
@ -0,0 +1,408 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyMarkerMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Marker msg class
|
||||
//
|
||||
|
||||
pyMarkerMsg::pyMarkerMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyMarkerMsg::pyMarkerMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_Marker))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyMarkerMsg::GetMarkerMsgType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyMarkerMsg::UpcastToFinalMarkerMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_Marker_TemplateCreated:
|
||||
return pyMarkerTemplateCreatedMsg::New(message);
|
||||
case kSrv2Cli_Marker_TeamAssigned:
|
||||
return pyMarkerTeamAssignedMsg::New(message);
|
||||
case kSrv2Cli_Marker_GameType:
|
||||
return pyMarkerGameTypeMsg::New(message);
|
||||
case kSrv2Cli_Marker_GameStarted:
|
||||
return pyMarkerGameStartedMsg::New(message);
|
||||
case kSrv2Cli_Marker_GamePaused:
|
||||
return pyMarkerGamePausedMsg::New(message);
|
||||
case kSrv2Cli_Marker_GameReset:
|
||||
return pyMarkerGameResetMsg::New(message);
|
||||
case kSrv2Cli_Marker_GameOver:
|
||||
return pyMarkerGameOverMsg::New(message);
|
||||
case kSrv2Cli_Marker_GameNameChanged:
|
||||
return pyMarkerGameNameChangedMsg::New(message);
|
||||
case kSrv2Cli_Marker_TimeLimitChanged:
|
||||
return pyMarkerTimeLimitChangedMsg::New(message);
|
||||
case kSrv2Cli_Marker_GameDeleted:
|
||||
return pyMarkerGameDeletedMsg::New(message);
|
||||
case kSrv2Cli_Marker_MarkerAdded:
|
||||
return pyMarkerMarkerAddedMsg::New(message);
|
||||
case kSrv2Cli_Marker_MarkerDeleted:
|
||||
return pyMarkerMarkerDeletedMsg::New(message);
|
||||
case kSrv2Cli_Marker_MarkerNameChanged:
|
||||
return pyMarkerMarkerNameChangedMsg::New(message);
|
||||
case kSrv2Cli_Marker_MarkerCaptured:
|
||||
return pyMarkerMarkerCapturedMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyMarkerTemplateCreatedMsg::pyMarkerTemplateCreatedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerTemplateCreatedMsg::pyMarkerTemplateCreatedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TemplateCreated))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
std::wstring pyMarkerTemplateCreatedMsg::TemplateID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_TemplateCreated* gmMsg = (const Srv2Cli_Marker_TemplateCreated*)message->netMsg;
|
||||
return gmMsg->templateID;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerTeamAssignedMsg::pyMarkerTeamAssignedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerTeamAssignedMsg::pyMarkerTeamAssignedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TeamAssigned))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyMarkerTeamAssignedMsg::TeamNumber() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_TeamAssigned* gmMsg = (const Srv2Cli_Marker_TeamAssigned*)message->netMsg;
|
||||
return gmMsg->teamNumber;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGameTypeMsg::pyMarkerGameTypeMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGameTypeMsg::pyMarkerGameTypeMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameType))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyMarkerGameTypeMsg::GameType() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_GameType* gmMsg = (const Srv2Cli_Marker_GameType*)message->netMsg;
|
||||
return gmMsg->gameType;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGameStartedMsg::pyMarkerGameStartedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGameStartedMsg::pyMarkerGameStartedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameStarted))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGamePausedMsg::pyMarkerGamePausedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGamePausedMsg::pyMarkerGamePausedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GamePaused))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyMarkerGamePausedMsg::TimeLeft() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_GamePaused* gmMsg = (const Srv2Cli_Marker_GamePaused*)message->netMsg;
|
||||
return gmMsg->timeLeft;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGameResetMsg::pyMarkerGameResetMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGameResetMsg::pyMarkerGameResetMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameReset))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGameOverMsg::pyMarkerGameOverMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGameOverMsg::pyMarkerGameOverMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameOver))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGameNameChangedMsg::pyMarkerGameNameChangedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGameNameChangedMsg::pyMarkerGameNameChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameNameChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
std::wstring pyMarkerGameNameChangedMsg::Name() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_GameNameChanged* gmMsg = (const Srv2Cli_Marker_GameNameChanged*)message->netMsg;
|
||||
return gmMsg->newName;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerTimeLimitChangedMsg::pyMarkerTimeLimitChangedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerTimeLimitChangedMsg::pyMarkerTimeLimitChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TimeLimitChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyMarkerTimeLimitChangedMsg::TimeLimit() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_TimeLimitChanged* gmMsg = (const Srv2Cli_Marker_TimeLimitChanged*)message->netMsg;
|
||||
return gmMsg->newTimeLimit;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerGameDeletedMsg::pyMarkerGameDeletedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerGameDeletedMsg::pyMarkerGameDeletedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameDeleted))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyMarkerGameDeletedMsg::Failed() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_GameDeleted* gmMsg = (const Srv2Cli_Marker_GameDeleted*)message->netMsg;
|
||||
return gmMsg->failed;
|
||||
}
|
||||
return true; // assume it failed if we have a problem
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerMarkerAddedMsg::pyMarkerMarkerAddedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerMarkerAddedMsg::pyMarkerMarkerAddedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerAdded))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
double pyMarkerMarkerAddedMsg::X() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
|
||||
return gmMsg->x;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double pyMarkerMarkerAddedMsg::Y() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
|
||||
return gmMsg->y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double pyMarkerMarkerAddedMsg::Z() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
|
||||
return gmMsg->z;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long pyMarkerMarkerAddedMsg::MarkerId() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
|
||||
return gmMsg->markerID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyMarkerMarkerAddedMsg::Name() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
|
||||
return gmMsg->name;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring pyMarkerMarkerAddedMsg::Age() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
|
||||
return gmMsg->age;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerMarkerDeletedMsg::pyMarkerMarkerDeletedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerMarkerDeletedMsg::pyMarkerMarkerDeletedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerDeleted))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyMarkerMarkerDeletedMsg::MarkerId() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerDeleted* gmMsg = (const Srv2Cli_Marker_MarkerDeleted*)message->netMsg;
|
||||
return gmMsg->markerID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerMarkerNameChangedMsg::pyMarkerMarkerNameChangedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerMarkerNameChangedMsg::pyMarkerMarkerNameChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerNameChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyMarkerMarkerNameChangedMsg::MarkerId() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerNameChanged* gmMsg = (const Srv2Cli_Marker_MarkerNameChanged*)message->netMsg;
|
||||
return gmMsg->markerID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyMarkerMarkerNameChangedMsg::Name() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerNameChanged* gmMsg = (const Srv2Cli_Marker_MarkerNameChanged*)message->netMsg;
|
||||
return gmMsg->newName;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pyMarkerMarkerCapturedMsg::pyMarkerMarkerCapturedMsg(): pyMarkerMsg() {}
|
||||
|
||||
pyMarkerMarkerCapturedMsg::pyMarkerMarkerCapturedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerCaptured))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyMarkerMarkerCapturedMsg::MarkerId() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerCaptured* gmMsg = (const Srv2Cli_Marker_MarkerCaptured*)message->netMsg;
|
||||
return gmMsg->markerID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int pyMarkerMarkerCapturedMsg::Team() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Marker_MarkerCaptured* gmMsg = (const Srv2Cli_Marker_MarkerCaptured*)message->netMsg;
|
||||
return gmMsg->team;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,331 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyMarkerMsg_h
|
||||
#define pyMarkerMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyMarkerMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for Marker game messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCliMsg.h"
|
||||
|
||||
class pyMarkerMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerMsg();
|
||||
pyMarkerMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMsg); // converts a PyObject to a pyMarkerMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetMarkerMsgType() const;
|
||||
|
||||
PyObject* UpcastToFinalMarkerMsg() const; // returns this message as the marker message it really is
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerTemplateCreatedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerTemplateCreatedMsg();
|
||||
pyMarkerTemplateCreatedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerTemplateCreatedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTemplateCreatedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTemplateCreatedMsg); // converts a PyObject to a pyMarkerTemplateCreatedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
std::wstring TemplateID() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerTeamAssignedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerTeamAssignedMsg();
|
||||
pyMarkerTeamAssignedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerTeamAssignedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTeamAssignedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTeamAssignedMsg); // converts a PyObject to a pyMarkerTeamAssignedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int TeamNumber() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGameTypeMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGameTypeMsg();
|
||||
pyMarkerGameTypeMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameTypeMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameTypeMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameTypeMsg); // converts a PyObject to a pyMarkerGameTypeMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int GameType() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGameStartedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGameStartedMsg();
|
||||
pyMarkerGameStartedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameStartedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameStartedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameStartedMsg); // converts a PyObject to a pyMarkerGameStartedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGamePausedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGamePausedMsg();
|
||||
pyMarkerGamePausedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGamePausedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGamePausedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGamePausedMsg); // converts a PyObject to a pyMarkerGamePausedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long TimeLeft() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGameResetMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGameResetMsg();
|
||||
pyMarkerGameResetMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameResetMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameResetMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameResetMsg); // converts a PyObject to a pyMarkerGameResetMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGameOverMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGameOverMsg();
|
||||
pyMarkerGameOverMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameOverMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameOverMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameOverMsg); // converts a PyObject to a pyMarkerGameOverMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGameNameChangedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGameNameChangedMsg();
|
||||
pyMarkerGameNameChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameNameChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameNameChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameNameChangedMsg); // converts a PyObject to a pyMarkerGameNameChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
std::wstring Name() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerTimeLimitChangedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerTimeLimitChangedMsg();
|
||||
pyMarkerTimeLimitChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerTimeLimitChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTimeLimitChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTimeLimitChangedMsg); // converts a PyObject to a pyMarkerTimeLimitChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long TimeLimit() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerGameDeletedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerGameDeletedMsg();
|
||||
pyMarkerGameDeletedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameDeletedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameDeletedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameDeletedMsg); // converts a PyObject to a pyMarkerGameDeletedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool Failed() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerMarkerAddedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerMarkerAddedMsg();
|
||||
pyMarkerMarkerAddedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerAddedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerAddedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerAddedMsg); // converts a PyObject to a pyMarkerMarkerAddedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
double X() const;
|
||||
double Y() const;
|
||||
double Z() const;
|
||||
unsigned long MarkerId() const;
|
||||
std::wstring Name() const;
|
||||
std::wstring Age() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerMarkerDeletedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerMarkerDeletedMsg();
|
||||
pyMarkerMarkerDeletedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerDeletedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerDeletedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerDeletedMsg); // converts a PyObject to a pyMarkerMarkerDeletedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long MarkerId() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerMarkerNameChangedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerMarkerNameChangedMsg();
|
||||
pyMarkerMarkerNameChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerNameChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerNameChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerNameChangedMsg); // converts a PyObject to a pyMarkerMarkerNameChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long MarkerId() const;
|
||||
std::wstring Name() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyMarkerMarkerCapturedMsg : public pyMarkerMsg
|
||||
{
|
||||
protected:
|
||||
pyMarkerMarkerCapturedMsg();
|
||||
pyMarkerMarkerCapturedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerCapturedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerCapturedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerCapturedMsg); // converts a PyObject to a pyMarkerMarkerCapturedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long MarkerId() const;
|
||||
unsigned int Team() const;
|
||||
};
|
||||
|
||||
#endif // pyMarkerMsg_h
|
@ -0,0 +1,706 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyMarkerMsg.h"
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base Marker msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerMsg, pyMarkerMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerMsg, pyMarkerMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMsg, getMarkerMsgType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetMarkerMsgType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMsg, upcastToFinalMarkerMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalMarkerMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMsg, getMarkerMsgType, "Returns the type of the Marker message (see PtMarkerMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMsg, upcastToFinalMarkerMsg, "Returns this message as the Marker message it is"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerMsg, pyGameCliMsg, "Base class for Marker game messages");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptMarkerMsg, pyMarkerMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerMsg *newObj = (ptMarkerMsg*)ptMarkerMsg_type.tp_new(&ptMarkerMsg_type, NULL, NULL);
|
||||
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_Marker))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerMsg, pyMarkerMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerMsg, pyMarkerMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyMarkerMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtMarkerMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerTemplateCreated, kSrv2Cli_Marker_TemplateCreated);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerTeamAssigned, kSrv2Cli_Marker_TeamAssigned);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGameType, kSrv2Cli_Marker_GameType);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGameStarted, kSrv2Cli_Marker_GameStarted);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGamePaused, kSrv2Cli_Marker_GamePaused);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGameReset, kSrv2Cli_Marker_GameReset);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGameOver, kSrv2Cli_Marker_GameOver);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGameNameChanged, kSrv2Cli_Marker_GameNameChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerTimeLimitChanged, kSrv2Cli_Marker_TimeLimitChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerGameDeleted, kSrv2Cli_Marker_GameDeleted);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerMarkerAdded, kSrv2Cli_Marker_MarkerAdded);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerMarkerDeleted, kSrv2Cli_Marker_MarkerDeleted);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerMarkerNameChanged, kSrv2Cli_Marker_MarkerNameChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtMarkerMsgTypes, kMarkerMarkerCaptured, kSrv2Cli_Marker_MarkerCaptured);
|
||||
PYTHON_ENUM_END(m, PtMarkerMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerTemplateCreatedMsg, pyMarkerTemplateCreatedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerTemplateCreatedMsg, pyMarkerTemplateCreatedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerTemplateCreatedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerTemplateCreatedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerTemplateCreatedMsg, templateID)
|
||||
{
|
||||
std::wstring retVal = self->fThis->TemplateID();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerTemplateCreatedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerTemplateCreatedMsg, templateID, "Returns the ID number of the template that was created"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerTemplateCreatedMsg, pyMarkerMsg, "Marker message received when a quest game template is created");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerTemplateCreatedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerTemplateCreatedMsg *newObj = (ptMarkerTemplateCreatedMsg*)ptMarkerTemplateCreatedMsg_type.tp_new(&ptMarkerTemplateCreatedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_TemplateCreated))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerTemplateCreatedMsg, pyMarkerTemplateCreatedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerTemplateCreatedMsg, pyMarkerTemplateCreatedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerTemplateCreatedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerTemplateCreatedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerTeamAssignedMsg, pyMarkerTeamAssignedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerTeamAssignedMsg, pyMarkerTeamAssignedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerTeamAssignedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerTeamAssignedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerTeamAssignedMsg, teamNumber)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->TeamNumber());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerTeamAssignedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerTeamAssignedMsg, teamNumber, "Returns the number of the team you were assigned to"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerTeamAssignedMsg, pyMarkerMsg, "Marker message received when you are assigned a team number");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerTeamAssignedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerTeamAssignedMsg *newObj = (ptMarkerTeamAssignedMsg*)ptMarkerTeamAssignedMsg_type.tp_new(&ptMarkerTeamAssignedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_TeamAssigned))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerTeamAssignedMsg, pyMarkerTeamAssignedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerTeamAssignedMsg, pyMarkerTeamAssignedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerTeamAssignedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerTeamAssignedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGameTypeMsg, pyMarkerGameTypeMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGameTypeMsg, pyMarkerGameTypeMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGameTypeMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGameTypeMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerGameTypeMsg, gameType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GameType());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGameTypeMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerGameTypeMsg, gameType, "Returns the type of the game you just joined"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGameTypeMsg, pyMarkerMsg, "Marker message received when you are assigned a team number");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGameTypeMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGameTypeMsg *newObj = (ptMarkerGameTypeMsg*)ptMarkerGameTypeMsg_type.tp_new(&ptMarkerGameTypeMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GameType))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGameTypeMsg, pyMarkerGameTypeMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGameTypeMsg, pyMarkerGameTypeMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGameTypeMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGameTypeMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGameStartedMsg, pyMarkerGameStartedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGameStartedMsg, pyMarkerGameStartedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGameStartedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGameStartedMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGameStartedMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGameStartedMsg, pyMarkerMsg, "Marker message received when the game is started by the owner");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGameStartedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGameStartedMsg *newObj = (ptMarkerGameStartedMsg*)ptMarkerGameStartedMsg_type.tp_new(&ptMarkerGameStartedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GameStarted))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGameStartedMsg, pyMarkerGameStartedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGameStartedMsg, pyMarkerGameStartedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGameStartedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGameStartedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGamePausedMsg, pyMarkerGamePausedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGamePausedMsg, pyMarkerGamePausedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGamePausedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGamePausedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerGamePausedMsg, timeLeft)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->TimeLeft());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGamePausedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerGamePausedMsg, timeLeft, "Returns the amount of time left on the server clock"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGamePausedMsg, pyMarkerMsg, "Marker message received when the game is paused by the owner");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGamePausedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGamePausedMsg *newObj = (ptMarkerGamePausedMsg*)ptMarkerGamePausedMsg_type.tp_new(&ptMarkerGamePausedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GamePaused))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGamePausedMsg, pyMarkerGamePausedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGamePausedMsg, pyMarkerGamePausedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGamePausedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGamePausedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGameResetMsg, pyMarkerGameResetMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGameResetMsg, pyMarkerGameResetMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGameResetMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGameResetMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGameResetMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGameResetMsg, pyMarkerMsg, "Marker message received when the game is reset by the owner");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGameResetMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGameResetMsg *newObj = (ptMarkerGameResetMsg*)ptMarkerGameResetMsg_type.tp_new(&ptMarkerGameResetMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GameReset))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGameResetMsg, pyMarkerGameResetMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGameResetMsg, pyMarkerGameResetMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGameResetMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGameResetMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGameOverMsg, pyMarkerGameOverMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGameOverMsg, pyMarkerGameOverMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGameOverMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGameOverMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGameOverMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGameOverMsg, pyMarkerMsg, "Marker message received when the server determines the game is over (usually via timeout)");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGameOverMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGameOverMsg *newObj = (ptMarkerGameOverMsg*)ptMarkerGameOverMsg_type.tp_new(&ptMarkerGameOverMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GameOver))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGameOverMsg, pyMarkerGameOverMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGameOverMsg, pyMarkerGameOverMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGameOverMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGameOverMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGameNameChangedMsg, pyMarkerGameNameChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGameNameChangedMsg, pyMarkerGameNameChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGameNameChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGameNameChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerGameNameChangedMsg, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGameNameChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerGameNameChangedMsg, name, "Returns the new game name"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGameNameChangedMsg, pyMarkerMsg, "Marker message received when the game name is changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGameNameChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGameNameChangedMsg *newObj = (ptMarkerGameNameChangedMsg*)ptMarkerGameNameChangedMsg_type.tp_new(&ptMarkerGameNameChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GameNameChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGameNameChangedMsg, pyMarkerGameNameChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGameNameChangedMsg, pyMarkerGameNameChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGameNameChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGameNameChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerTimeLimitChangedMsg, pyMarkerTimeLimitChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerTimeLimitChangedMsg, pyMarkerTimeLimitChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerTimeLimitChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerTimeLimitChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerTimeLimitChangedMsg, timeLimit)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->TimeLimit());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerTimeLimitChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerTimeLimitChangedMsg, timeLimit, "Returns the new time limit (in ms)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerTimeLimitChangedMsg, pyMarkerMsg, "Marker message received when the game name is changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerTimeLimitChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerTimeLimitChangedMsg *newObj = (ptMarkerTimeLimitChangedMsg*)ptMarkerTimeLimitChangedMsg_type.tp_new(&ptMarkerTimeLimitChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_TimeLimitChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerTimeLimitChangedMsg, pyMarkerTimeLimitChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerTimeLimitChangedMsg, pyMarkerTimeLimitChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerTimeLimitChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerTimeLimitChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerGameDeletedMsg, pyMarkerGameDeletedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGameDeletedMsg, pyMarkerGameDeletedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGameDeletedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerGameDeletedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerGameDeletedMsg, failed)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->Failed());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerGameDeletedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerGameDeletedMsg, failed, "Returns whether the delete succeeded or not"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGameDeletedMsg, pyMarkerMsg, "Marker message received when the game is deleted");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerGameDeletedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerGameDeletedMsg *newObj = (ptMarkerGameDeletedMsg*)ptMarkerGameDeletedMsg_type.tp_new(&ptMarkerGameDeletedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_GameDeleted))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerGameDeletedMsg, pyMarkerGameDeletedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGameDeletedMsg, pyMarkerGameDeletedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerGameDeletedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerGameDeletedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerMarkerAddedMsg, pyMarkerMarkerAddedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerMarkerAddedMsg, pyMarkerMarkerAddedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerMarkerAddedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerMarkerAddedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerAddedMsg, x)
|
||||
{
|
||||
return PyFloat_FromDouble(self->fThis->X());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerAddedMsg, y)
|
||||
{
|
||||
return PyFloat_FromDouble(self->fThis->Y());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerAddedMsg, z)
|
||||
{
|
||||
return PyFloat_FromDouble(self->fThis->Z());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerAddedMsg, markerId)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->MarkerId());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerAddedMsg, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerAddedMsg, age)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Age();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerMarkerAddedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerAddedMsg, x, "Returns x coord of the marker"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerAddedMsg, y, "Returns y coord of the marker"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerAddedMsg, z, "Returns z coord of the marker"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerAddedMsg, markerId, "Returns the id number of the marker"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerAddedMsg, name, "Returns the name of the marker"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerAddedMsg, age, "Returns the age the marker was created in"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerMarkerAddedMsg, pyMarkerMsg, "Marker message received when a marker is added to the game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerMarkerAddedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerMarkerAddedMsg *newObj = (ptMarkerMarkerAddedMsg*)ptMarkerMarkerAddedMsg_type.tp_new(&ptMarkerMarkerAddedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_MarkerAdded))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerMarkerAddedMsg, pyMarkerMarkerAddedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerMarkerAddedMsg, pyMarkerMarkerAddedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerMarkerAddedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerMarkerAddedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerMarkerDeletedMsg, pyMarkerMarkerDeletedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerMarkerDeletedMsg, pyMarkerMarkerDeletedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerMarkerDeletedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerMarkerDeletedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerDeletedMsg, markerId)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->MarkerId());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerMarkerDeletedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerDeletedMsg, markerId, "Returns id of the marker that was deleted"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerMarkerDeletedMsg, pyMarkerMsg, "Marker message received when a marker is deleted");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerMarkerDeletedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerMarkerDeletedMsg *newObj = (ptMarkerMarkerDeletedMsg*)ptMarkerMarkerDeletedMsg_type.tp_new(&ptMarkerMarkerDeletedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_MarkerDeleted))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerMarkerDeletedMsg, pyMarkerMarkerDeletedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerMarkerDeletedMsg, pyMarkerMarkerDeletedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerMarkerDeletedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerMarkerDeletedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerMarkerNameChangedMsg, pyMarkerMarkerNameChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerMarkerNameChangedMsg, pyMarkerMarkerNameChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerMarkerNameChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerMarkerNameChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerNameChangedMsg, markerId)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->MarkerId());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerNameChangedMsg, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerMarkerNameChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerNameChangedMsg, markerId, "Returns id of the marker who's name was changed"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerNameChangedMsg, name, "Returns the new name"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerMarkerNameChangedMsg, pyMarkerMsg, "Marker message received when the name of a marker is changed");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerMarkerNameChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerMarkerNameChangedMsg *newObj = (ptMarkerMarkerNameChangedMsg*)ptMarkerMarkerNameChangedMsg_type.tp_new(&ptMarkerMarkerNameChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_MarkerNameChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerMarkerNameChangedMsg, pyMarkerMarkerNameChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerMarkerNameChangedMsg, pyMarkerMarkerNameChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerMarkerNameChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerMarkerNameChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptMarkerMarkerCapturedMsg, pyMarkerMarkerCapturedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerMarkerCapturedMsg, pyMarkerMarkerCapturedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerMarkerCapturedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptMarkerMarkerCapturedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerCapturedMsg, markerId)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->MarkerId());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptMarkerMarkerCapturedMsg, team)
|
||||
{
|
||||
return PyInt_FromLong((long)self->fThis->Team());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptMarkerMarkerCapturedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerCapturedMsg, markerId, "Returns id of the marker which was captured"),
|
||||
PYTHON_METHOD_NOARGS(ptMarkerMarkerCapturedMsg, team, "Returns the team number of the team that captured it (0 for no team, or a quest game)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerMarkerCapturedMsg, pyMarkerMsg, "Marker message received when a marker is captured");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyMarkerMarkerCapturedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptMarkerMarkerCapturedMsg *newObj = (ptMarkerMarkerCapturedMsg*)ptMarkerMarkerCapturedMsg_type.tp_new(&ptMarkerMarkerNameChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Marker_MarkerCaptured))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptMarkerMarkerCapturedMsg, pyMarkerMarkerCapturedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerMarkerCapturedMsg, pyMarkerMarkerCapturedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyMarkerMarkerCapturedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptMarkerMarkerCapturedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyTTTGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base TTT game client class
|
||||
//
|
||||
|
||||
pyTTTGame::pyTTTGame(): pyGameCli() {}
|
||||
|
||||
pyTTTGame::pyTTTGame(pfGameCli* client): pyGameCli(client)
|
||||
{
|
||||
if (client && (client->GetGameTypeId() != kGameTypeId_TicTacToe))
|
||||
gameClient = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyTTTGame::IsTTTGame(std::wstring guid)
|
||||
{
|
||||
Uuid gameUuid(guid.c_str());
|
||||
return gameUuid == kGameTypeId_TicTacToe;
|
||||
}
|
||||
|
||||
void pyTTTGame::CreateTTTGame(pyKey& callbackKey, unsigned numPlayers)
|
||||
{
|
||||
TTT_CreateParam init;
|
||||
init.playerCount = numPlayers;
|
||||
pfGameMgr::GetInstance()->CreateGame(callbackKey.getKey(), kGameTypeId_TicTacToe, 0, sizeof(init), &init);
|
||||
}
|
||||
|
||||
void pyTTTGame::JoinCommonTTTGame(pyKey& callbackKey, unsigned gameID, unsigned numPlayers)
|
||||
{
|
||||
TTT_CreateParam init;
|
||||
init.playerCount = numPlayers;
|
||||
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_TicTacToe, gameID, sizeof(init), &init);
|
||||
}
|
||||
|
||||
void pyTTTGame::MakeMove(unsigned row, unsigned col)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmTicTacToe* ttt = pfGmTicTacToe::ConvertNoRef(gameClient);
|
||||
ttt->MakeMove(row, col);
|
||||
}
|
||||
}
|
||||
|
||||
void pyTTTGame::ShowBoard()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmTicTacToe* ttt = pfGmTicTacToe::ConvertNoRef(gameClient);
|
||||
ttt->ShowBoard();
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyTTTGame_h
|
||||
#define pyTTTGame_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyTTTGame
|
||||
//
|
||||
// PURPOSE: Class wrapper for the TTT game client
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCli.h"
|
||||
#include "../../pyKey.h"
|
||||
|
||||
class pyTTTGame : public pyGameCli
|
||||
{
|
||||
protected:
|
||||
pyTTTGame();
|
||||
pyTTTGame(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptTTTGame);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGame object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGame); // converts a PyObject to a pyTTTGame (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
|
||||
static bool IsTTTGame(std::wstring guid);
|
||||
static void CreateTTTGame(pyKey& callbackKey, unsigned numPlayers);
|
||||
static void JoinCommonTTTGame(pyKey& callbackKey, unsigned gameID, unsigned numPlayers);
|
||||
|
||||
void MakeMove(unsigned row, unsigned col);
|
||||
void ShowBoard();
|
||||
};
|
||||
|
||||
#endif // pyTTTGame_h
|
@ -0,0 +1,172 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyTTTGame.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base TTT game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptTTTGame, pyTTTGame);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGame, pyTTTGame)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGame)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptTTTGame)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsTTTGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a TicTacToe game")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsTTTGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
bool retVal = pyTTTGame::IsTTTGame(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
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);
|
||||
bool retVal = pyTTTGame::IsTTTGame(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsTTTGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreateTTTGame, args, "Params: callbackKey, numPlayers\nCreates a new TicTacToe game with the specified callback key and number of players (1 or 2)")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
int numPlayers = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &numPlayers))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtCreateTTTGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtCreateTTTGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyTTTGame::CreateTTTGame(*key, numPlayers);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonTTTGame, args, "Params: callbackKey, gameID, numPlayers\nJoins a common TicTacToe game with the specified ID. If one doesn't exist, it creates it with the specified number of players")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
int gameID = 0, numPlayers = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oii", &callbackObj, &gameID, &numPlayers))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonTTTGame expects a ptKey and two integers");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonTTTGame expects a ptKey and two integers");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyTTTGame::JoinCommonTTTGame(*key, gameID, numPlayers);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptTTTGame, makeMove, args)
|
||||
{
|
||||
int row = 0, col = 0;
|
||||
if (!PyArg_ParseTuple(args, "ii", &row, &col))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "makeMove expects two integers");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->MakeMove(row, col);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptTTTGame, showBoard, ShowBoard)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptTTTGame)
|
||||
PYTHON_METHOD(ptTTTGame, makeMove, "Params: row, col\nMakes a move in the specified spot"),
|
||||
PYTHON_BASIC_METHOD(ptTTTGame, showBoard, "Prints the current board layout to the console"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGame, pyGameCli, "Game client for the TicTacToe game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyTTTGame::New(pfGameCli* client)
|
||||
{
|
||||
ptTTTGame *newObj = (ptTTTGame*)ptTTTGame_type.tp_new(&ptTTTGame_type, NULL, NULL);
|
||||
if (client && (client->GetGameTypeId() == kGameTypeId_TicTacToe))
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptTTTGame, pyTTTGame)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGame, pyTTTGame)
|
||||
|
||||
// Module and method definitions
|
||||
void pyTTTGame::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptTTTGame);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyTTTGame::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtTTTGameResult);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultWinner, kTTTGameResultWinner);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultTied, kTTTGameResultTied);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultGave, kTTTGameResultGave);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultError, kTTTGameResultError);
|
||||
PYTHON_ENUM_END(m, PtTTTGameResult);
|
||||
}
|
||||
|
||||
void pyTTTGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsTTTGame);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtCreateTTTGame);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonTTTGame);
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyTTTMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base TTT msg class
|
||||
//
|
||||
|
||||
pyTTTMsg::pyTTTMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyTTTMsg::pyTTTMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_TicTacToe))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyTTTMsg::GetTTTMsgType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyTTTMsg::UpcastToFinalTTTMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_TTT_GameStarted:
|
||||
return pyTTTGameStartedMsg::New(message);
|
||||
case kSrv2Cli_TTT_GameOver:
|
||||
return pyTTTGameOverMsg::New(message);
|
||||
case kSrv2Cli_TTT_MoveMade:
|
||||
return pyTTTMoveMadeMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyTTTGameStartedMsg::pyTTTGameStartedMsg(): pyTTTMsg() {}
|
||||
|
||||
pyTTTGameStartedMsg::pyTTTGameStartedMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_GameStarted))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyTTTGameStartedMsg::YourTurn() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_TTT_GameStarted* gmMsg = (const Srv2Cli_TTT_GameStarted*)message->netMsg;
|
||||
return gmMsg->yourTurn;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyTTTGameOverMsg::pyTTTGameOverMsg(): pyTTTMsg() {}
|
||||
|
||||
pyTTTGameOverMsg::pyTTTGameOverMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_GameOver))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyTTTGameOverMsg::Result() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_TTT_GameOver* gmMsg = (const Srv2Cli_TTT_GameOver*)message->netMsg;
|
||||
return gmMsg->result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long pyTTTGameOverMsg::WinnerID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_TTT_GameOver* gmMsg = (const Srv2Cli_TTT_GameOver*)message->netMsg;
|
||||
return gmMsg->winnerId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyTTTMoveMadeMsg::pyTTTMoveMadeMsg(): pyTTTMsg() {}
|
||||
|
||||
pyTTTMoveMadeMsg::pyTTTMoveMadeMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_MoveMade))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyTTTMoveMadeMsg::PlayerID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
|
||||
return gmMsg->playerId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int pyTTTMoveMadeMsg::Row() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
|
||||
return gmMsg->row;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int pyTTTMoveMadeMsg::Col() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
|
||||
return gmMsg->col;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyTTTMsg_h
|
||||
#define pyTTTMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyTTTMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for TTT game messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCliMsg.h"
|
||||
|
||||
class pyTTTMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyTTTMsg();
|
||||
pyTTTMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptTTTMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTMsg); // converts a PyObject to a pyTTTMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetTTTMsgType() const;
|
||||
|
||||
PyObject* UpcastToFinalTTTMsg() const; // returns the ttt message that this really is
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyTTTGameStartedMsg : public pyTTTMsg
|
||||
{
|
||||
protected:
|
||||
pyTTTGameStartedMsg();
|
||||
pyTTTGameStartedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptTTTGameStartedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGameStartedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGameStartedMsg); // converts a PyObject to a pyTTTGameStartedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
bool YourTurn() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyTTTGameOverMsg : public pyTTTMsg
|
||||
{
|
||||
protected:
|
||||
pyTTTGameOverMsg();
|
||||
pyTTTGameOverMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptTTTGameOverMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGameOverMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGameOverMsg); // converts a PyObject to a pyTTTGameOverMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
int Result() const;
|
||||
unsigned long WinnerID() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyTTTMoveMadeMsg : public pyTTTMsg
|
||||
{
|
||||
protected:
|
||||
pyTTTMoveMadeMsg();
|
||||
pyTTTMoveMadeMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptTTTMoveMadeMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTMoveMadeMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTMoveMadeMsg); // converts a PyObject to a pyTTTMoveMadeMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long PlayerID() const;
|
||||
int Row() const;
|
||||
int Col() const;
|
||||
};
|
||||
|
||||
#endif // pyTTTMsg_h
|
@ -0,0 +1,231 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyTTTMsg.h"
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base TTT msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptTTTMsg, pyTTTMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTMsg, pyTTTMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptTTTMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMsg, getTTTMsgType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetTTTMsgType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMsg, upcastToFinalTTTMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalTTTMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptTTTMsg)
|
||||
PYTHON_METHOD_NOARGS(ptTTTMsg, getTTTMsgType, "Returns the type of the TTT message (see PtTTTMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptTTTMsg, upcastToFinalTTTMsg, "Returns this message as the TTT msg it is"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptTTTMsg, pyGameCliMsg, "Base class for TicTacToe game messages");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptTTTMsg, pyTTTMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyTTTMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptTTTMsg *newObj = (ptTTTMsg*)ptTTTMsg_type.tp_new(&ptTTTMsg_type, NULL, NULL);
|
||||
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_TicTacToe))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptTTTMsg, pyTTTMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTMsg, pyTTTMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyTTTMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptTTTMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyTTTMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtTTTMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTGameStarted, kSrv2Cli_TTT_GameStarted);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTGameOver, kSrv2Cli_TTT_GameOver);
|
||||
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTMoveMade, kSrv2Cli_TTT_MoveMade);
|
||||
PYTHON_ENUM_END(m, PtTTTMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptTTTGameStartedMsg, pyTTTGameStartedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGameStartedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptTTTGameStartedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameStartedMsg, yourTurn)
|
||||
{
|
||||
PYTHON_RETURN_BOOL(self->fThis->YourTurn());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptTTTGameStartedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptTTTGameStartedMsg, yourTurn, "Returns true if you are the first player (and therefore it's your turn)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGameStartedMsg, pyTTTMsg, "TicTacToe message received when the game is started");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyTTTGameStartedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptTTTGameStartedMsg *newObj = (ptTTTGameStartedMsg*)ptTTTGameStartedMsg_type.tp_new(&ptTTTGameStartedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_GameStarted))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyTTTGameStartedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptTTTGameStartedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptTTTGameOverMsg, pyTTTGameOverMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGameOverMsg, pyTTTGameOverMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGameOverMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptTTTGameOverMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameOverMsg, result)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->Result());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameOverMsg, winnerID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->WinnerID());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptTTTGameOverMsg)
|
||||
PYTHON_METHOD_NOARGS(ptTTTGameOverMsg, result, "Returns the result of the game (see PtTTTGameResult)"),
|
||||
PYTHON_METHOD_NOARGS(ptTTTGameOverMsg, winnerID, "Returns the winner's ID"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGameOverMsg, pyTTTMsg, "TicTacToe message received when the game is over");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyTTTGameOverMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptTTTGameOverMsg *newObj = (ptTTTGameOverMsg*)ptTTTGameOverMsg_type.tp_new(&ptTTTGameOverMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_GameOver))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptTTTGameOverMsg, pyTTTGameOverMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGameOverMsg, pyTTTGameOverMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyTTTGameOverMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptTTTGameOverMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTMoveMadeMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptTTTMoveMadeMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, playerID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, row)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->Row());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, col)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->Col());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptTTTMoveMadeMsg)
|
||||
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, playerID, "Returns the the ID of the player that just moved"),
|
||||
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, row, "Returns the row index of the move (1..3)"),
|
||||
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, col, "Returns the col index of the move (1..3)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptTTTMoveMadeMsg, pyTTTMsg, "TicTacToe message received when someone makes a move");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyTTTMoveMadeMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptTTTMoveMadeMsg *newObj = (ptTTTMoveMadeMsg*)ptTTTMoveMadeMsg_type.tp_new(&ptTTTMoveMadeMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_MoveMade))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyTTTMoveMadeMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptTTTMoveMadeMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyVarSyncGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base VarSync game client class
|
||||
//
|
||||
|
||||
const unsigned kGameId = 255; // random number that should be high enough to avoid collisions with other global games
|
||||
|
||||
pyVarSyncGame::pyVarSyncGame(): pyGameCli() {}
|
||||
|
||||
pyVarSyncGame::pyVarSyncGame(pfGameCli* client): pyGameCli(client)
|
||||
{
|
||||
if (client && (client->GetGameTypeId() != kGameTypeId_VarSync))
|
||||
gameClient = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
bool pyVarSyncGame::IsVarSyncGame(std::wstring guid)
|
||||
{
|
||||
Uuid gameUuid(guid.c_str());
|
||||
return gameUuid == kGameTypeId_VarSync;
|
||||
}
|
||||
|
||||
void pyVarSyncGame::JoinCommonVarSyncGame(pyKey& callbackKey)
|
||||
{
|
||||
// NOTE: We don't let the player specify the game ID, because there should only be one of these in an age, ever
|
||||
VarSync_CreateParam init;
|
||||
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_VarSync, kGameId, sizeof(init), &init);
|
||||
}
|
||||
|
||||
void pyVarSyncGame::SetStringVar(unsigned long id, std::wstring val)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
|
||||
vsync->SetStringVar(id, val.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void pyVarSyncGame::SetNumericVar(unsigned long id, double val)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
|
||||
vsync->SetNumericVar(id, val);
|
||||
}
|
||||
}
|
||||
|
||||
void pyVarSyncGame::RequestAllVars()
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
|
||||
vsync->RequestAllVars();
|
||||
}
|
||||
}
|
||||
|
||||
void pyVarSyncGame::CreateStringVar(std::wstring name, std::wstring val)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
|
||||
vsync->CreateStringVar(name.c_str(), val.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void pyVarSyncGame::CreateNumericVar(std::wstring name, double val)
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
|
||||
vsync->CreateNumericVar(name.c_str(), val);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyVarSyncGame_h
|
||||
#define pyVarSyncGame_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyVarSyncGame
|
||||
//
|
||||
// PURPOSE: Class wrapper for the VarSync game client
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCli.h"
|
||||
#include "../../pyKey.h"
|
||||
|
||||
class pyVarSyncGame : public pyGameCli
|
||||
{
|
||||
protected:
|
||||
pyVarSyncGame();
|
||||
pyVarSyncGame(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncGame);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncGame object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncGame); // converts a PyObject to a pyVarSyncGame (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
|
||||
static bool IsVarSyncGame(std::wstring guid);
|
||||
static void JoinCommonVarSyncGame(pyKey& callbackKey);
|
||||
|
||||
void SetStringVar(unsigned long id, std::wstring val);
|
||||
void SetNumericVar(unsigned long id, double val);
|
||||
void RequestAllVars();
|
||||
void CreateStringVar(std::wstring name, std::wstring val);
|
||||
void CreateNumericVar(std::wstring name, double val);
|
||||
};
|
||||
|
||||
#endif // pyVarSyncGame_h
|
@ -0,0 +1,308 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyVarSyncGame.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base VarSync game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncGame, pyVarSyncGame);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncGame, pyVarSyncGame)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncGame)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncGame)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsVarSyncGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a VarSync game")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsVarSyncGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
bool retVal = pyVarSyncGame::IsVarSyncGame(text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
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);
|
||||
bool retVal = pyVarSyncGame::IsVarSyncGame(wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_BOOL(retVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtIsVarSyncGame expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonVarSyncGame, args, "Params: callbackKey\nJoins the common VarSync game. If one doesn't exist, it creates it")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "O", &callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonVarSyncGame expects a ptKey");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinCommonVarSyncGame expects a ptKey");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyVarSyncGame::JoinCommonVarSyncGame(*key);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVarSyncGame, setStringVar, args)
|
||||
{
|
||||
unsigned long id;
|
||||
PyObject* valueObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "kO", &id, &valueObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setStringVar expects an unsigned long and a string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (PyUnicode_Check(valueObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(valueObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)valueObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
self->fThis->SetStringVar(id, text);
|
||||
delete [] text;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else if (PyString_Check(valueObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(valueObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
self->fThis->SetStringVar(id, wText);
|
||||
delete [] wText;
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setStringVar expects an unsigned long and a string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVarSyncGame, setNumericVar, args)
|
||||
{
|
||||
unsigned long id;
|
||||
PyObject* valueObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "kO", &id, &valueObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setNumericVar expects an unsigned long and a number");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
double val = 0;
|
||||
if (PyFloat_Check(valueObj))
|
||||
val = PyFloat_AsDouble(valueObj);
|
||||
else if (PyInt_Check(valueObj))
|
||||
val = (double)PyInt_AsLong(valueObj);
|
||||
else if (PyLong_Check(valueObj))
|
||||
val = PyLong_AsDouble(valueObj);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setNumericVar expects an unsigned long and a number");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
self->fThis->SetNumericVar(id, val);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptVarSyncGame, requestAllVars, RequestAllVars)
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVarSyncGame, createStringVar, args)
|
||||
{
|
||||
PyObject* varNameObj = NULL;
|
||||
PyObject* valueObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "OO", &varNameObj, &valueObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
std::wstring varName = L"";
|
||||
if (PyUnicode_Check(varNameObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(varNameObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)varNameObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
varName = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(varNameObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(varNameObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
varName = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
std::wstring val = L"";
|
||||
if (PyUnicode_Check(valueObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(valueObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)valueObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
val = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(valueObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(valueObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
val = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
self->fThis->CreateStringVar(varName, val);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVarSyncGame, createNumericVar, args)
|
||||
{
|
||||
PyObject* varNameObj = NULL;
|
||||
PyObject* valueObj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "OO", &varNameObj, &valueObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
std::wstring varName = L"";
|
||||
if (PyUnicode_Check(varNameObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(varNameObj);
|
||||
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
|
||||
PyUnicode_AsWideChar((PyUnicodeObject*)varNameObj, text, strLen);
|
||||
text[strLen] = L'\0';
|
||||
varName = text;
|
||||
delete [] text;
|
||||
}
|
||||
else if (PyString_Check(varNameObj))
|
||||
{
|
||||
// we'll allow this, just in case something goes weird
|
||||
char* text = PyString_AsString(varNameObj);
|
||||
wchar_t* wText = hsStringToWString(text);
|
||||
varName = wText;
|
||||
delete [] wText;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
double val = 0;
|
||||
if (PyFloat_Check(valueObj))
|
||||
val = PyFloat_AsDouble(valueObj);
|
||||
else if (PyInt_Check(valueObj))
|
||||
val = (double)PyInt_AsLong(valueObj);
|
||||
else if (PyLong_Check(valueObj))
|
||||
val = PyLong_AsDouble(valueObj);
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
self->fThis->CreateNumericVar(varName, val);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncGame)
|
||||
PYTHON_METHOD(ptVarSyncGame, setStringVar, "Params: varID, value\nAttempts to set a string variable to the specified string (clipped to 255 chars)"),
|
||||
PYTHON_METHOD(ptVarSyncGame, setNumericVar, "Params: varID, value\nAttempts to set a numeric variable to the specified number (clipped to double)"),
|
||||
PYTHON_BASIC_METHOD(ptVarSyncGame, requestAllVars, "Requests all the vars the server knows about"),
|
||||
PYTHON_METHOD(ptVarSyncGame, createStringVar, "Params: varName, value\nAttempts to create a new string variable and set it to the specified string (clipped to 255 chars)"),
|
||||
PYTHON_METHOD(ptVarSyncGame, createNumericVar, "Params: varName, value\nAttempts to create a new numeric variable and set it to the specified number (clipped to double)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncGame, pyGameCli, "Game client for the VarSync game");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncGame::New(pfGameCli* client)
|
||||
{
|
||||
ptVarSyncGame *newObj = (ptVarSyncGame*)ptVarSyncGame_type.tp_new(&ptVarSyncGame_type, NULL, NULL);
|
||||
if (client && (client->GetGameTypeId() == kGameTypeId_VarSync))
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncGame, pyVarSyncGame)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncGame, pyVarSyncGame)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncGame::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncGame);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyVarSyncGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD(methods, PtIsVarSyncGame);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonVarSyncGame);
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyVarSyncMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base VarSync msg class
|
||||
//
|
||||
|
||||
pyVarSyncMsg::pyVarSyncMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyVarSyncMsg::pyVarSyncMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_VarSync))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
int pyVarSyncMsg::GetVarSyncMsgType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyVarSyncMsg::UpcastToFinalVarSyncMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_VarSync_StringVarChanged:
|
||||
return pyVarSyncStringVarChangedMsg::New(message);
|
||||
case kSrv2Cli_VarSync_NumericVarChanged:
|
||||
return pyVarSyncNumericVarChangedMsg::New(message);
|
||||
case kSrv2Cli_VarSync_AllVarsSent:
|
||||
return pyVarSyncAllVarsSentMsg::New(message);
|
||||
case kSrv2Cli_VarSync_StringVarCreated:
|
||||
return pyVarSyncStringVarCreatedMsg::New(message);
|
||||
case kSrv2Cli_VarSync_NumericVarCreated:
|
||||
return pyVarSyncNumericVarCreatedMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyVarSyncStringVarChangedMsg::pyVarSyncStringVarChangedMsg(): pyVarSyncMsg() {}
|
||||
|
||||
pyVarSyncStringVarChangedMsg::pyVarSyncStringVarChangedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_StringVarChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyVarSyncStringVarChangedMsg::ID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_StringVarChanged* gmMsg = (const Srv2Cli_VarSync_StringVarChanged*)message->netMsg;
|
||||
return gmMsg->varID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyVarSyncStringVarChangedMsg::Value() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_StringVarChanged* gmMsg = (const Srv2Cli_VarSync_StringVarChanged*)message->netMsg;
|
||||
return gmMsg->varValue;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyVarSyncNumericVarChangedMsg::pyVarSyncNumericVarChangedMsg(): pyVarSyncMsg() {}
|
||||
|
||||
pyVarSyncNumericVarChangedMsg::pyVarSyncNumericVarChangedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_NumericVarChanged))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyVarSyncNumericVarChangedMsg::ID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_NumericVarChanged* gmMsg = (const Srv2Cli_VarSync_NumericVarChanged*)message->netMsg;
|
||||
return gmMsg->varID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double pyVarSyncNumericVarChangedMsg::Value() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_NumericVarChanged* gmMsg = (const Srv2Cli_VarSync_NumericVarChanged*)message->netMsg;
|
||||
return gmMsg->varValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyVarSyncAllVarsSentMsg::pyVarSyncAllVarsSentMsg(): pyVarSyncMsg() {}
|
||||
|
||||
pyVarSyncAllVarsSentMsg::pyVarSyncAllVarsSentMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_AllVarsSent))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyVarSyncStringVarCreatedMsg::pyVarSyncStringVarCreatedMsg(): pyVarSyncMsg() {}
|
||||
|
||||
pyVarSyncStringVarCreatedMsg::pyVarSyncStringVarCreatedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_StringVarCreated))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
std::wstring pyVarSyncStringVarCreatedMsg::Name() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
|
||||
return gmMsg->varName;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
unsigned long pyVarSyncStringVarCreatedMsg::ID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
|
||||
return gmMsg->varID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyVarSyncStringVarCreatedMsg::Value() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
|
||||
return gmMsg->varValue;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyVarSyncNumericVarCreatedMsg::pyVarSyncNumericVarCreatedMsg(): pyVarSyncMsg() {}
|
||||
|
||||
pyVarSyncNumericVarCreatedMsg::pyVarSyncNumericVarCreatedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_NumericVarCreated))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
std::wstring pyVarSyncNumericVarCreatedMsg::Name() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
|
||||
return gmMsg->varName;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
unsigned long pyVarSyncNumericVarCreatedMsg::ID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
|
||||
return gmMsg->varID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double pyVarSyncNumericVarCreatedMsg::Value() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
|
||||
return gmMsg->varValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyVarSyncMsg_h
|
||||
#define pyVarSyncMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyVarSyncMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for VarSync game messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../../pyGlueHelpers.h"
|
||||
#include "../pyGameCliMsg.h"
|
||||
|
||||
class pyVarSyncMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyVarSyncMsg();
|
||||
pyVarSyncMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncMsg); // converts a PyObject to a pyVarSyncMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetVarSyncMsgType() const;
|
||||
|
||||
PyObject* UpcastToFinalVarSyncMsg() const; // returns the VarSync message that this really is
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyVarSyncStringVarChangedMsg : public pyVarSyncMsg
|
||||
{
|
||||
protected:
|
||||
pyVarSyncStringVarChangedMsg();
|
||||
pyVarSyncStringVarChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncStringVarChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncStringVarChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncStringVarChangedMsg); // converts a PyObject to a pyVarSyncStringVarChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long ID() const;
|
||||
std::wstring Value() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyVarSyncNumericVarChangedMsg : public pyVarSyncMsg
|
||||
{
|
||||
protected:
|
||||
pyVarSyncNumericVarChangedMsg();
|
||||
pyVarSyncNumericVarChangedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncNumericVarChangedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncNumericVarChangedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncNumericVarChangedMsg); // converts a PyObject to a pyVarSyncNumericVarChangedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long ID() const;
|
||||
double Value() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyVarSyncAllVarsSentMsg : public pyVarSyncMsg
|
||||
{
|
||||
protected:
|
||||
pyVarSyncAllVarsSentMsg();
|
||||
pyVarSyncAllVarsSentMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncAllVarsSentMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncAllVarsSentMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncAllVarsSentMsg); // converts a PyObject to a pyVarSyncAllVarsSentMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyVarSyncStringVarCreatedMsg : public pyVarSyncMsg
|
||||
{
|
||||
protected:
|
||||
pyVarSyncStringVarCreatedMsg();
|
||||
pyVarSyncStringVarCreatedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncStringVarCreatedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncStringVarCreatedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncStringVarCreatedMsg); // converts a PyObject to a pyVarSyncStringVarCreatedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
std::wstring Name() const;
|
||||
unsigned long ID() const;
|
||||
std::wstring Value() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyVarSyncNumericVarCreatedMsg : public pyVarSyncMsg
|
||||
{
|
||||
protected:
|
||||
pyVarSyncNumericVarCreatedMsg();
|
||||
pyVarSyncNumericVarCreatedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptVarSyncNumericVarCreatedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncNumericVarCreatedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncNumericVarCreatedMsg); // converts a PyObject to a pyVarSyncNumericVarCreatedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
std::wstring Name() const;
|
||||
unsigned long ID() const;
|
||||
double Value() const;
|
||||
};
|
||||
|
||||
#endif // pyVarSyncMsg_h
|
@ -0,0 +1,329 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyVarSyncMsg.h"
|
||||
#include "../../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base VarSync msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncMsg, pyVarSyncMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncMsg, pyVarSyncMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncMsg, getVarSyncMsgType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetVarSyncMsgType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncMsg, upcastToFinalVarSyncMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalVarSyncMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncMsg)
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncMsg, getVarSyncMsgType, "Returns the type of the VarSync message (see PtVarSyncMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncMsg, upcastToFinalVarSyncMsg, "Returns this message as the VarSync msg it is"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncMsg, pyGameCliMsg, "Base class for VarSync game messages");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptVarSyncMsg, pyVarSyncMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptVarSyncMsg *newObj = (ptVarSyncMsg*)ptVarSyncMsg_type.tp_new(&ptVarSyncMsg_type, NULL, NULL);
|
||||
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_VarSync))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncMsg, pyVarSyncMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncMsg, pyVarSyncMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyVarSyncMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtVarSyncMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncStringVarChanged, kSrv2Cli_VarSync_StringVarChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncNumericVarChanged, kSrv2Cli_VarSync_NumericVarChanged);
|
||||
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncAllVarsSent, kSrv2Cli_VarSync_AllVarsSent);
|
||||
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncStringVarCreated, kSrv2Cli_VarSync_StringVarCreated);
|
||||
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncNumericVarCreated, kSrv2Cli_VarSync_NumericVarCreated);
|
||||
PYTHON_ENUM_END(m, PtVarSyncMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncStringVarChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncStringVarChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarChangedMsg, id)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->ID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarChangedMsg, value)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Value();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncStringVarChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncStringVarChangedMsg, id, "Returns the id of the var that changed"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncStringVarChangedMsg, value, "Returns the variable's new value"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncStringVarChangedMsg, pyVarSyncMsg, "VarSync message received when a string variable's value changes");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncStringVarChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptVarSyncStringVarChangedMsg *newObj = (ptVarSyncStringVarChangedMsg*)ptVarSyncStringVarChangedMsg_type.tp_new(&ptVarSyncStringVarChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_StringVarChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncStringVarChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncStringVarChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncNumericVarChangedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncNumericVarChangedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarChangedMsg, id)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->ID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarChangedMsg, value)
|
||||
{
|
||||
return PyLong_FromDouble(self->fThis->Value());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncNumericVarChangedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarChangedMsg, id, "Returns the id of the var that changed"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarChangedMsg, value, "Returns the variable's new value"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncNumericVarChangedMsg, pyVarSyncMsg, "VarSync message received when a numeric variable's value changes");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncNumericVarChangedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptVarSyncNumericVarChangedMsg *newObj = (ptVarSyncNumericVarChangedMsg*)ptVarSyncNumericVarChangedMsg_type.tp_new(&ptVarSyncNumericVarChangedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_NumericVarChanged))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncNumericVarChangedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncNumericVarChangedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncAllVarsSentMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncAllVarsSentMsg)
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncAllVarsSentMsg)
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncAllVarsSentMsg, pyVarSyncMsg, "VarSync message received after the last var is sent to you when you join the game, or request a list of vars");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncAllVarsSentMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptVarSyncAllVarsSentMsg *newObj = (ptVarSyncAllVarsSentMsg*)ptVarSyncAllVarsSentMsg_type.tp_new(&ptVarSyncAllVarsSentMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_AllVarsSent))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncAllVarsSentMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncAllVarsSentMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncStringVarCreatedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncStringVarCreatedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, id)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->ID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, value)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Value();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncStringVarCreatedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, name, "Returns the name of the var that was created"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, id, "Returns the id that was assigned to this variable"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, value, "Returns the variable's new value"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncStringVarCreatedMsg, pyVarSyncMsg, "VarSync message received when a string variable is created and assigned an id");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncStringVarCreatedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptVarSyncStringVarCreatedMsg *newObj = (ptVarSyncStringVarCreatedMsg*)ptVarSyncStringVarCreatedMsg_type.tp_new(&ptVarSyncStringVarCreatedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_StringVarCreated))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncStringVarCreatedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncStringVarCreatedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncNumericVarCreatedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptVarSyncNumericVarCreatedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, id)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->ID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, value)
|
||||
{
|
||||
return PyLong_FromDouble(self->fThis->Value());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptVarSyncNumericVarCreatedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, name, "Returns the name of the var that was created"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, id, "Returns the id assigned to this variable"),
|
||||
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, value, "Returns the variable's new value"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncNumericVarCreatedMsg, pyVarSyncMsg, "VarSync message received when a numeric variable is created and assigned an id");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyVarSyncNumericVarCreatedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptVarSyncNumericVarCreatedMsg *newObj = (ptVarSyncNumericVarCreatedMsg*)ptVarSyncNumericVarCreatedMsg_type.tp_new(&ptVarSyncNumericVarCreatedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_NumericVarCreated))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyVarSyncNumericVarCreatedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptVarSyncNumericVarCreatedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyGameCli.h"
|
||||
|
||||
#include "TicTacToe/pyTTTGame.h"
|
||||
#include "Heek/pyHeekGame.h"
|
||||
#include "Marker/pyMarkerGame.h"
|
||||
#include "BlueSpiral/pyBlueSpiralGame.h"
|
||||
#include "ClimbingWall/pyClimbingWallGame.h"
|
||||
#include "VarSync/pyVarSyncGame.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base game client class
|
||||
//
|
||||
|
||||
pyGameCli::pyGameCli(): gameClient(nil) {}
|
||||
|
||||
pyGameCli::pyGameCli(pfGameCli* client): gameClient(client) {}
|
||||
|
||||
std::vector<unsigned> pyGameCli::GetGameIDs()
|
||||
{
|
||||
ARRAY(unsigned) gameIDs;
|
||||
std::vector<unsigned> retVal;
|
||||
pfGameMgr::GetInstance()->GetGameIds(&gameIDs);
|
||||
for (unsigned i = 0; i < gameIDs.Count(); ++i)
|
||||
retVal.push_back(gameIDs[i]);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::GetGameCli(unsigned gameID)
|
||||
{
|
||||
pfGameCli* client = pfGameMgr::GetInstance()->GetGameCli(gameID);
|
||||
if (client)
|
||||
return pyGameCli::New(client);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
std::wstring pyGameCli::GetGameNameByTypeID(std::wstring typeID)
|
||||
{
|
||||
Uuid gameUuid(typeID.c_str());
|
||||
return pfGameMgr::GetInstance()->GetGameNameByTypeId(gameUuid);
|
||||
}
|
||||
|
||||
void pyGameCli::JoinGame(pyKey& callbackKey, unsigned gameID)
|
||||
{
|
||||
pfGameMgr::GetInstance()->JoinGame(callbackKey.getKey(), gameID);
|
||||
}
|
||||
|
||||
unsigned pyGameCli::GameID() const
|
||||
{
|
||||
if (gameClient)
|
||||
return gameClient->GetGameId();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyGameCli::GameTypeID() const
|
||||
{
|
||||
if (gameClient)
|
||||
{
|
||||
wchar_t guidStr[256];
|
||||
GuidToString(gameClient->GetGameTypeId(), guidStr, arrsize(guidStr));
|
||||
return guidStr;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring pyGameCli::Name() const
|
||||
{
|
||||
if (gameClient)
|
||||
return gameClient->GetName();
|
||||
return L"";
|
||||
}
|
||||
|
||||
unsigned pyGameCli::PlayerCount() const
|
||||
{
|
||||
if (gameClient)
|
||||
return gameClient->GetPlayerCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pyGameCli::InvitePlayer(unsigned playerID)
|
||||
{
|
||||
if (gameClient)
|
||||
gameClient->InvitePlayer(playerID);
|
||||
}
|
||||
|
||||
void pyGameCli::UninvitePlayer(unsigned playerID)
|
||||
{
|
||||
if (gameClient)
|
||||
gameClient->UninvitePlayer(playerID);
|
||||
}
|
||||
|
||||
void pyGameCli::LeaveGame()
|
||||
{
|
||||
if (gameClient)
|
||||
gameClient->LeaveGame();
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::UpcastToTTTGame()
|
||||
{
|
||||
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_TicTacToe))
|
||||
return pyTTTGame::New(gameClient);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::UpcastToHeekGame()
|
||||
{
|
||||
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_Heek))
|
||||
return pyHeekGame::New(gameClient);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::UpcastToMarkerGame()
|
||||
{
|
||||
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_Marker))
|
||||
return pyMarkerGame::New(gameClient);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::UpcastToBlueSpiralGame()
|
||||
{
|
||||
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_BlueSpiral))
|
||||
return pyBlueSpiralGame::New(gameClient);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::UpcastToClimbingWallGame()
|
||||
{
|
||||
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_ClimbingWall))
|
||||
return pyClimbingWallGame::New(gameClient);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* pyGameCli::UpcastToVarSyncGame()
|
||||
{
|
||||
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_VarSync))
|
||||
return pyVarSyncGame::New(gameClient);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyGameCli_h
|
||||
#define pyGameCli_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyGameCli
|
||||
//
|
||||
// PURPOSE: Class wrapper for the game client base class
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../pyGlueHelpers.h"
|
||||
#include "../pyKey.h"
|
||||
|
||||
class pyGameCli
|
||||
{
|
||||
protected:
|
||||
pfGameCli* gameClient;
|
||||
|
||||
pyGameCli();
|
||||
pyGameCli(pfGameCli* client);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameCli);
|
||||
static PyObject* New(pfGameCli* client);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCli object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCli); // converts a PyObject to a pyGameCli (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
|
||||
|
||||
static std::vector<unsigned> GetGameIDs();
|
||||
static PyObject* GetGameCli(unsigned gameID); // returns a ptGameCli
|
||||
static std::wstring GetGameNameByTypeID(std::wstring typeID);
|
||||
static void JoinGame(pyKey& callbackKey, unsigned gameID);
|
||||
|
||||
unsigned GameID() const;
|
||||
std::wstring GameTypeID() const;
|
||||
std::wstring Name() const;
|
||||
unsigned PlayerCount() const;
|
||||
|
||||
void InvitePlayer(unsigned playerID);
|
||||
void UninvitePlayer(unsigned playerID);
|
||||
|
||||
void LeaveGame();
|
||||
|
||||
PyObject* UpcastToTTTGame(); // returns ptTTTGame
|
||||
PyObject* UpcastToHeekGame(); // returns ptHeekGame
|
||||
PyObject* UpcastToMarkerGame(); // returns ptMarkerGame
|
||||
PyObject* UpcastToBlueSpiralGame(); // returns ptBlueSpiralGame
|
||||
PyObject* UpcastToClimbingWallGame(); // returns ptClimbingWallGame
|
||||
PyObject* UpcastToVarSyncGame(); // returns ptVarSyncGame
|
||||
};
|
||||
|
||||
#endif // pyGameCli_h
|
@ -0,0 +1,239 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyGameCli.h"
|
||||
#include "../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base game client class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameCli, pyGameCli);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCli, pyGameCli)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCli)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameCli)
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetGameIDs, "Returns a list of game IDs that the player is currently joined to")
|
||||
{
|
||||
std::vector<unsigned> ids = pyGameCli::GetGameIDs();
|
||||
PyObject* retVal = PyList_New(ids.size());
|
||||
for (unsigned i = 0; i < ids.size(); ++i)
|
||||
PyList_SetItem(retVal, i, PyInt_FromLong(ids[i]));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameCli, args, "Params: gameID\nReturns a ptGameCli associated with the specified id")
|
||||
{
|
||||
int gameID = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &gameID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtGetGameCli expects an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
return pyGameCli::GetGameCli(gameID);
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameNameByTypeID, args, "Params: guid\nReturns the name of the game represented by guid passed in as a string")
|
||||
{
|
||||
PyObject* textObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &textObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (PyUnicode_Check(textObj))
|
||||
{
|
||||
int strLen = PyUnicode_GetSize(textObj);
|
||||
wchar_t* text = TRACKED_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;
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinGame, args, "Params: callbackKey, gameID\nSends a join request to the specified game. Messages are sent to the callback key")
|
||||
{
|
||||
PyObject* callbackObj = NULL;
|
||||
int gameID = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
if (!pyKey::Check(callbackObj))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtJoinGame expects a ptKey and an integer");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
pyKey* key = pyKey::ConvertFrom(callbackObj);
|
||||
pyGameCli::JoinGame(*key, gameID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameID)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GameID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameTypeID)
|
||||
{
|
||||
std::wstring retVal = self->fThis->GameTypeID();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, name)
|
||||
{
|
||||
std::wstring retVal = self->fThis->Name();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, playerCount)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->PlayerCount());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptGameCli, invitePlayer, args)
|
||||
{
|
||||
int playerID = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &playerID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "invitePlayer expects an unsigned int");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->InvitePlayer(playerID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptGameCli, uninvitePlayer, args)
|
||||
{
|
||||
int playerID = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &playerID))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "uninvitePlayer expects an unsigned int");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
self->fThis->UninvitePlayer(playerID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_BASIC_METHOD_DEFINITION(ptGameCli, leaveGame, LeaveGame)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToTTTGame)
|
||||
{
|
||||
return self->fThis->UpcastToTTTGame();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToHeekGame)
|
||||
{
|
||||
return self->fThis->UpcastToHeekGame();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToMarkerGame)
|
||||
{
|
||||
return self->fThis->UpcastToMarkerGame();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToBlueSpiralGame)
|
||||
{
|
||||
return self->fThis->UpcastToBlueSpiralGame();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToClimbingWallGame)
|
||||
{
|
||||
return self->fThis->UpcastToClimbingWallGame();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToVarSyncGame)
|
||||
{
|
||||
return self->fThis->UpcastToVarSyncGame();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameCli)
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, gameID, "Returns the ID number for this game"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, gameTypeID, "Returns the game type ID for this game (as a guid string)"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, name, "Returns the name of the game"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, playerCount, "Returns the current number of players"),
|
||||
PYTHON_METHOD(ptGameCli, invitePlayer, "Params: playerID\nInvites the specified player to join the game"),
|
||||
PYTHON_METHOD(ptGameCli, uninvitePlayer, "Params: playerID\nRevokes the invitation for the specified player"),
|
||||
PYTHON_BASIC_METHOD(ptGameCli, leaveGame, "Leaves this game"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, upcastToTTTGame, "Returns this game client as a ptTTTGame"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, upcastToHeekGame, "Returns this game client as a ptHeekGame"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, upcastToMarkerGame, "Returns this game client as a ptMarkerGame"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, upcastToBlueSpiralGame, "Returns this game client as a ptBlueSpiralGame"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, upcastToClimbingWallGame, "Returns this game client as a ptClimbingWallGame"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCli, upcastToVarSyncGame, "Returns this game client as a ptVarSyncGame"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE(ptGameCli, "Base class for all game client interfaces");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameCli, pyGameCli);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameCli::New(pfGameCli* client)
|
||||
{
|
||||
ptGameCli *newObj = (ptGameCli*)ptGameCli_type.tp_new(&ptGameCli_type, NULL, NULL);
|
||||
newObj->fThis->gameClient = client;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameCli, pyGameCli)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCli, pyGameCli)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameCli::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameCli);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyGameCli::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
|
||||
{
|
||||
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetGameIDs);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtGetGameCli);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtGetGameNameByTypeID);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtJoinGame);
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyGameCliMsg.h"
|
||||
#include "pyGameCli.h"
|
||||
|
||||
#include "TicTacToe\pyTTTMsg.h"
|
||||
#include "Heek\pyHeekMsg.h"
|
||||
#include "Marker\pyMarkerMsg.h"
|
||||
#include "BlueSpiral\pyBlueSpiralMsg.h"
|
||||
#include "ClimbingWall\pyClimbingWallMsg.h"
|
||||
#include "VarSync/pyVarSyncMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base game cli msg class
|
||||
//
|
||||
|
||||
pyGameCliMsg::pyGameCliMsg(): message(nil) {}
|
||||
|
||||
pyGameCliMsg::pyGameCliMsg(pfGameCliMsg* msg): message(msg) {}
|
||||
|
||||
int pyGameCliMsg::GetType() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_Game_PlayerJoined:
|
||||
case kSrv2Cli_Game_PlayerLeft:
|
||||
case kSrv2Cli_Game_InviteFailed:
|
||||
case kSrv2Cli_Game_OwnerChange:
|
||||
return message->netMsg->messageId; // just return the type straight up
|
||||
}
|
||||
|
||||
// if we get here, it's probably a game message, check the game guid
|
||||
if (message->gameCli->GetGameTypeId() == kGameTypeId_TicTacToe)
|
||||
return kPyGameCliTTTMsg;
|
||||
|
||||
if (message->gameCli->GetGameTypeId() == kGameTypeId_Heek)
|
||||
return kPyGameCliHeekMsg;
|
||||
|
||||
if (message->gameCli->GetGameTypeId() == kGameTypeId_Marker)
|
||||
return kPyGameCliMarkerMsg;
|
||||
|
||||
if (message->gameCli->GetGameTypeId() == kGameTypeId_BlueSpiral)
|
||||
return kPyGameCliBlueSpiralMsg;
|
||||
|
||||
if (message->gameCli->GetGameTypeId() == kGameTypeId_ClimbingWall)
|
||||
return kPyGameCliClimbingWallMsg;
|
||||
|
||||
if (message->gameCli->GetGameTypeId() == kGameTypeId_VarSync)
|
||||
return kPyGameCliVarSyncMsg;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyGameCliMsg::GetGameCli() const
|
||||
{
|
||||
if (message && (message->gameCli))
|
||||
return pyGameCli::New(message->gameCli);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* pyGameCliMsg::UpcastToFinalGameCliMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
switch (message->netMsg->messageId)
|
||||
{
|
||||
case kSrv2Cli_Game_PlayerJoined:
|
||||
return pyGameCliPlayerJoinedMsg::New(message);
|
||||
case kSrv2Cli_Game_PlayerLeft:
|
||||
return pyGameCliPlayerLeftMsg::New(message);
|
||||
case kSrv2Cli_Game_InviteFailed:
|
||||
return pyGameCliInviteFailedMsg::New(message);
|
||||
case kSrv2Cli_Game_OwnerChange:
|
||||
return pyGameCliOwnerChangeMsg::New(message);
|
||||
default:
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* pyGameCliMsg::UpcastToGameMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
|
||||
const Uuid& gameTypeId = message->gameCli->GetGameTypeId();
|
||||
if (gameTypeId == kGameTypeId_TicTacToe)
|
||||
return pyTTTMsg::New(message);
|
||||
else if (gameTypeId == kGameTypeId_Heek)
|
||||
return pyHeekMsg::New(message);
|
||||
else if (gameTypeId == kGameTypeId_Marker)
|
||||
return pyMarkerMsg::New(message);
|
||||
else if (gameTypeId == kGameTypeId_BlueSpiral)
|
||||
return pyBlueSpiralMsg::New(message);
|
||||
else if (gameTypeId == kGameTypeId_ClimbingWall)
|
||||
return pyClimbingWallMsg::New(message);
|
||||
else if (gameTypeId == kGameTypeId_VarSync)
|
||||
return pyVarSyncMsg::New(message);
|
||||
else
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyGameCliPlayerJoinedMsg::pyGameCliPlayerJoinedMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyGameCliPlayerJoinedMsg::pyGameCliPlayerJoinedMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Game_PlayerJoined))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyGameCliPlayerJoinedMsg::PlayerID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Game_PlayerJoined* gmMsg = (const Srv2Cli_Game_PlayerJoined*)message->netMsg;
|
||||
return gmMsg->playerId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyGameCliPlayerLeftMsg::pyGameCliPlayerLeftMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyGameCliPlayerLeftMsg::pyGameCliPlayerLeftMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Game_PlayerLeft))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyGameCliPlayerLeftMsg::PlayerID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Game_PlayerLeft* gmMsg = (const Srv2Cli_Game_PlayerLeft*)message->netMsg;
|
||||
return gmMsg->playerId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyGameCliInviteFailedMsg::pyGameCliInviteFailedMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyGameCliInviteFailedMsg::pyGameCliInviteFailedMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Game_InviteFailed))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyGameCliInviteFailedMsg::InviteeID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
|
||||
return gmMsg->inviteeId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long pyGameCliInviteFailedMsg::OperationID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
|
||||
return gmMsg->operationId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pyGameCliInviteFailedMsg::Error() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
|
||||
return gmMsg->error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyGameCliOwnerChangeMsg::pyGameCliOwnerChangeMsg(): pyGameCliMsg() {}
|
||||
|
||||
pyGameCliOwnerChangeMsg::pyGameCliOwnerChangeMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_Game_OwnerChange))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyGameCliOwnerChangeMsg::OwnerID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_Game_OwnerChange* gmMsg = (const Srv2Cli_Game_OwnerChange*)message->netMsg;
|
||||
return gmMsg->ownerId;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyGameCliMsg_h
|
||||
#define pyGameCliMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyGameCliMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for game client messages
|
||||
//
|
||||
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../pyGlueHelpers.h"
|
||||
|
||||
class pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pfGameCliMsg* message;
|
||||
|
||||
pyGameCliMsg();
|
||||
pyGameCliMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameCliMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliMsg); // converts a PyObject to a pyGameCliMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetType() const;
|
||||
PyObject* GetGameCli() const; // returns ptGameCli
|
||||
|
||||
PyObject* UpcastToFinalGameCliMsg() const; // returns it upcasted to player joined/left/invite/owner change message
|
||||
PyObject* UpcastToGameMsg() const; // returns it upcasted to a game's message base class
|
||||
|
||||
// for convenience, we define our own message types, one message type for each game, so that we can have
|
||||
// a "base class" for each game's messages. Anything under kCli2Srv_NumGameMsgIds keeps their normal type
|
||||
// (and is exposed to python here), but anything above it has the message code look at the game type and
|
||||
// return the "message type" indicating what game the message is from
|
||||
enum pyGameCliMsgType
|
||||
{
|
||||
kPyGameCliMsgTypeStart = kCli2Srv_NumGameMsgIds,
|
||||
kPyGameCliTTTMsg, // Tick Tack Toe game messages
|
||||
kPyGameCliHeekMsg, // Heek game messages
|
||||
kPyGameCliMarkerMsg, // Marker game messages
|
||||
kPyGameCliBlueSpiralMsg, // Blue Spiral game messages
|
||||
kPyGameCliClimbingWallMsg, // Climbing Wall game messages
|
||||
kPyGameCliVarSyncMsg, // Var Sync game messages
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyGameCliPlayerJoinedMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyGameCliPlayerJoinedMsg();
|
||||
pyGameCliPlayerJoinedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameCliPlayerJoinedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliPlayerJoinedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliPlayerJoinedMsg); // converts a PyObject to a pyGameCliPlayerJoinedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long PlayerID() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyGameCliPlayerLeftMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyGameCliPlayerLeftMsg();
|
||||
pyGameCliPlayerLeftMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameCliPlayerLeftMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliPlayerLeftMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliPlayerLeftMsg); // converts a PyObject to a pyGameCliPlayerLeftMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long PlayerID() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyGameCliInviteFailedMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyGameCliInviteFailedMsg();
|
||||
pyGameCliInviteFailedMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameCliInviteFailedMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliInviteFailedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliInviteFailedMsg); // converts a PyObject to a pyGameCliInviteFailedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
unsigned long InviteeID() const;
|
||||
unsigned long OperationID() const;
|
||||
int Error() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyGameCliOwnerChangeMsg : public pyGameCliMsg
|
||||
{
|
||||
protected:
|
||||
pyGameCliOwnerChangeMsg();
|
||||
pyGameCliOwnerChangeMsg(pfGameCliMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameCliOwnerChangeMsg);
|
||||
static PyObject* New(pfGameCliMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliOwnerChangeMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliOwnerChangeMsg); // converts a PyObject to a pyGameCliOwnerChangeMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long OwnerID() const;
|
||||
};
|
||||
|
||||
#endif // pyGameCliMsg_h
|
@ -0,0 +1,297 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyGameCliMsg.h"
|
||||
#include "../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base game client msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameCliMsg, pyGameCliMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliMsg, pyGameCliMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameCliMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, getType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, getGameCli)
|
||||
{
|
||||
return self->fThis->GetGameCli();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, upcastToFinalGameCliMsg)
|
||||
{
|
||||
return self->fThis->UpcastToFinalGameCliMsg();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, upcastToGameMsg)
|
||||
{
|
||||
return self->fThis->UpcastToGameMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameCliMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameCliMsg, getType, "Returns the type of the message (see PtGameCliMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCliMsg, getGameCli, "Returns the game client associated with this message"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCliMsg, upcastToFinalGameCliMsg, "Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCliMsg, upcastToGameMsg, "Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE(ptGameCliMsg, "Message from the game server from a game");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameCliMsg, pyGameCliMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameCliMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptGameCliMsg *newObj = (ptGameCliMsg*)ptGameCliMsg_type.tp_new(&ptGameCliMsg_type, NULL, NULL);
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameCliMsg, pyGameCliMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliMsg, pyGameCliMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameCliMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameCliMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyGameCliMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtGameCliMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliPlayerJoinedMsg, kSrv2Cli_Game_PlayerJoined);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliPlayerLeftMsg, kSrv2Cli_Game_PlayerLeft);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliInviteFailedMsg, kSrv2Cli_Game_InviteFailed);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliOwnerChangeMsg, kSrv2Cli_Game_OwnerChange);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliTTTMsg, kPyGameCliTTTMsg);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliHeekMsg, kPyGameCliHeekMsg);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliMarkerMsg, kPyGameCliMarkerMsg);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliBlueSpiralMsg, kPyGameCliBlueSpiralMsg);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliClimbingWallMsg, kPyGameCliClimbingWallMsg);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliVarSyncMsg, kPyGameCliVarSyncMsg);
|
||||
PYTHON_ENUM_END(m, PtGameCliMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game client message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliPlayerJoinedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameCliPlayerJoinedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliPlayerJoinedMsg, playerID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameCliPlayerJoinedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameCliPlayerJoinedMsg, playerID, "Returns the player's ID number"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliPlayerJoinedMsg, pyGameCliMsg, "Game client message when a player joined message is received");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameCliPlayerJoinedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptGameCliPlayerJoinedMsg *newObj = (ptGameCliPlayerJoinedMsg*)ptGameCliPlayerJoinedMsg_type.tp_new(&ptGameCliPlayerJoinedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_PlayerJoined))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameCliPlayerJoinedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameCliPlayerJoinedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliPlayerLeftMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameCliPlayerLeftMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliPlayerLeftMsg, playerID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameCliPlayerLeftMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameCliPlayerLeftMsg, playerID, "Returns the player's ID number"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliPlayerLeftMsg, pyGameCliMsg, "Game client message when a player left message is received");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameCliPlayerLeftMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptGameCliPlayerLeftMsg *newObj = (ptGameCliPlayerLeftMsg*)ptGameCliPlayerLeftMsg_type.tp_new(&ptGameCliPlayerLeftMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_PlayerLeft))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameCliPlayerLeftMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameCliPlayerLeftMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliInviteFailedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameCliInviteFailedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, inviteeID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->InviteeID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, operationID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->OperationID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, error)
|
||||
{
|
||||
return PyLong_FromLong(self->fThis->Error());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameCliInviteFailedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, inviteeID, "Returns the invitee's ID number"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, operationID, "Returns the operation's ID number"),
|
||||
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, error, "Returns the error value (See PtGameCliInviteErrors)"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliInviteFailedMsg, pyGameCliMsg, "Game client message when an invite failed message is received");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameCliInviteFailedMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptGameCliInviteFailedMsg *newObj = (ptGameCliInviteFailedMsg*)ptGameCliInviteFailedMsg_type.tp_new(&ptGameCliInviteFailedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_InviteFailed))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameCliInviteFailedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameCliInviteFailedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyGameCliInviteFailedMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtGameCliInviteErrors);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteSuccess, kGameInviteSuccess);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrNotOwner, kGameInviteErrNotOwner);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrAlreadyInvited, kGameInviteErrAlreadyInvited);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrAlreadyJoined, kGameInviteErrAlreadyJoined);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameStarted, kGameInviteErrGameStarted);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameOver, kGameInviteErrGameOver);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameFull, kGameInviteErrGameFull);
|
||||
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrNoJoin, kGameInviteErrNoJoin);
|
||||
PYTHON_ENUM_END(m, PtGameCliInviteErrors);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliOwnerChangeMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameCliOwnerChangeMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliOwnerChangeMsg, ownerID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->OwnerID());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameCliOwnerChangeMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameCliOwnerChangeMsg, ownerID, "Returns the owner's ID number"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliOwnerChangeMsg, pyGameCliMsg, "Game client message when a owner change message is received");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameCliOwnerChangeMsg::New(pfGameCliMsg* msg)
|
||||
{
|
||||
ptGameCliOwnerChangeMsg *newObj = (ptGameCliOwnerChangeMsg*)ptGameCliOwnerChangeMsg_type.tp_new(&ptGameCliOwnerChangeMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_OwnerChange))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameCliOwnerChangeMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameCliOwnerChangeMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyGameMgrMsg.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base game mgr msg class
|
||||
//
|
||||
|
||||
pyGameMgrMsg::pyGameMgrMsg(): message(nil) {}
|
||||
|
||||
pyGameMgrMsg::pyGameMgrMsg(pfGameMgrMsg* msg): message(msg) {}
|
||||
|
||||
int pyGameMgrMsg::GetType() const
|
||||
{
|
||||
if (message)
|
||||
return message->netMsg->messageId;
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* pyGameMgrMsg::UpcastToInviteReceivedMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
if (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteReceived)
|
||||
PYTHON_RETURN_NONE;
|
||||
return pyGameMgrInviteReceivedMsg::New(message);
|
||||
}
|
||||
|
||||
PyObject* pyGameMgrMsg::UpcastToInviteRevokedMsg() const
|
||||
{
|
||||
if (!message)
|
||||
PYTHON_RETURN_NONE;
|
||||
if (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteRevoked)
|
||||
PYTHON_RETURN_NONE;
|
||||
return pyGameMgrInviteRevokedMsg::New(message);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The different messages we can receive
|
||||
//
|
||||
|
||||
pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(): pyGameMgrMsg() {}
|
||||
|
||||
pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg): pyGameMgrMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteReceived))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyGameMgrInviteReceivedMsg::InviterID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
|
||||
return gmMsg->inviterId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyGameMgrInviteReceivedMsg::GameTypeID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
|
||||
wchar_t buffer[256];
|
||||
GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer));
|
||||
return buffer;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
unsigned long pyGameMgrInviteReceivedMsg::NewGameID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
|
||||
return gmMsg->newGameId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(): pyGameMgrMsg() {}
|
||||
|
||||
pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg): pyGameMgrMsg(msg)
|
||||
{
|
||||
if (message && (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteRevoked))
|
||||
message = nil; // wrong type, just clear it out
|
||||
}
|
||||
|
||||
unsigned long pyGameMgrInviteRevokedMsg::InviterID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
|
||||
return gmMsg->inviterId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring pyGameMgrInviteRevokedMsg::GameTypeID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
|
||||
wchar_t buffer[256];
|
||||
GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer));
|
||||
return buffer;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
unsigned long pyGameMgrInviteRevokedMsg::NewGameID() const
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
|
||||
return gmMsg->newGameId;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef pyGameMgrMsg_h
|
||||
#define pyGameMgrMsg_h
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyGameMgrMsg
|
||||
//
|
||||
// PURPOSE: Class wrapper for game manager messages
|
||||
//
|
||||
|
||||
#include "hsStlUtils.h"
|
||||
#include "../pfGameMgr/pfGameMgr.h"
|
||||
|
||||
#include <python.h>
|
||||
#include "../pyGlueHelpers.h"
|
||||
|
||||
class pyGameMgrMsg
|
||||
{
|
||||
protected:
|
||||
pfGameMgrMsg* message;
|
||||
|
||||
pyGameMgrMsg();
|
||||
pyGameMgrMsg(pfGameMgrMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameMgrMsg);
|
||||
static PyObject* New(pfGameMgrMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrMsg); // converts a PyObject to a pyGameMgrMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
static void AddPlasmaConstantsClasses(PyObject* m);
|
||||
|
||||
int GetType() const;
|
||||
|
||||
PyObject* UpcastToInviteReceivedMsg() const; // returns ptGameMgrInviteReceivedMsg
|
||||
PyObject* UpcastToInviteRevokedMsg() const; // returns ptGameMgrInviteRevokedMsg
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyGameMgrInviteReceivedMsg : public pyGameMgrMsg
|
||||
{
|
||||
protected:
|
||||
pyGameMgrInviteReceivedMsg();
|
||||
pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameMgrInviteReceivedMsg);
|
||||
static PyObject* New(pfGameMgrMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrInviteReceivedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrInviteReceivedMsg); // converts a PyObject to a pyGameMgrInviteReceivedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long InviterID() const;
|
||||
std::wstring GameTypeID() const;
|
||||
unsigned long NewGameID() const;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class pyGameMgrInviteRevokedMsg : public pyGameMgrMsg
|
||||
{
|
||||
protected:
|
||||
pyGameMgrInviteRevokedMsg();
|
||||
pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg);
|
||||
|
||||
public:
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameMgrInviteRevokedMsg);
|
||||
static PyObject* New(pfGameMgrMsg* msg);
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrInviteRevokedMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrInviteRevokedMsg); // converts a PyObject to a pyGameMgrInviteRevokedMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m);
|
||||
|
||||
unsigned long InviterID() const;
|
||||
std::wstring GameTypeID() const;
|
||||
unsigned long NewGameID() const;
|
||||
};
|
||||
|
||||
#endif // pyGameMgrMsg_h
|
@ -0,0 +1,203 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pyGameMgrMsg.h"
|
||||
#include "../pyEnum.h"
|
||||
|
||||
#include <python.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Base game manager msg class
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameMgrMsg, pyGameMgrMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrMsg, pyGameMgrMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameMgrMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, getType)
|
||||
{
|
||||
return PyInt_FromLong(self->fThis->GetType());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, upcastToInviteReceivedMsg)
|
||||
{
|
||||
return self->fThis->UpcastToInviteReceivedMsg();
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, upcastToInviteRevokedMsg)
|
||||
{
|
||||
return self->fThis->UpcastToInviteRevokedMsg();
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameMgrMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrMsg, getType, "Returns the type of the message (see PtGameMgrMsgTypes)"),
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrMsg, upcastToInviteReceivedMsg, "Returns this message as a ptGameMgrInviteReceivedMsg"),
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrMsg, upcastToInviteRevokedMsg, "Returns this message as a ptGameMgrInviteRevokedMsg"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE(ptGameMgrMsg, "Message from the game manager");
|
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameMgrMsg, pyGameMgrMsg);
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameMgrMsg::New(pfGameMgrMsg* msg)
|
||||
{
|
||||
ptGameMgrMsg *newObj = (ptGameMgrMsg*)ptGameMgrMsg_type.tp_new(&ptGameMgrMsg_type, NULL, NULL);
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameMgrMsg, pyGameMgrMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrMsg, pyGameMgrMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameMgrMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameMgrMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
void pyGameMgrMsg::AddPlasmaConstantsClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_ENUM_START(PtGameMgrMsgTypes);
|
||||
PYTHON_ENUM_ELEMENT(PtGameMgrMsgTypes, kGameMgrInviteReceivedMsg, kSrv2Cli_GameMgr_InviteReceived);
|
||||
PYTHON_ENUM_ELEMENT(PtGameMgrMsgTypes, kGameMgrInviteRevokedMsg, kSrv2Cli_GameMgr_InviteRevoked);
|
||||
PYTHON_ENUM_END(m, PtGameMgrMsgTypes);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Game manager message subclasses
|
||||
//
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrInviteReceivedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameMgrInviteReceivedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, inviterID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->InviterID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID)
|
||||
{
|
||||
std::wstring retVal = self->fThis->GameTypeID();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, newGameID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->NewGameID());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameMgrInviteReceivedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, inviterID, "Returns the inviter's ID number"),
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID, "Returns the game type ID (as a guid string)"),
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, newGameID, "Returns the new game's ID number"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameMgrInviteReceivedMsg, pyGameMgrMsg, "Game manager message when an invite is received");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameMgrInviteReceivedMsg::New(pfGameMgrMsg* msg)
|
||||
{
|
||||
ptGameMgrInviteReceivedMsg *newObj = (ptGameMgrInviteReceivedMsg*)ptGameMgrInviteReceivedMsg_type.tp_new(&ptGameMgrInviteReceivedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_GameMgr_InviteReceived))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
void pyGameMgrInviteReceivedMsg::AddPlasmaClasses(PyObject* m)
|
||||
{
|
||||
PYTHON_CLASS_IMPORT_START(m);
|
||||
PYTHON_CLASS_IMPORT(m, ptGameMgrInviteReceivedMsg);
|
||||
PYTHON_CLASS_IMPORT_END(m);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
PYTHON_CLASS_DEFINITION(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg);
|
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
|
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrInviteRevokedMsg)
|
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameMgrInviteRevokedMsg)
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, inviterID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->InviterID());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID)
|
||||
{
|
||||
std::wstring retVal = self->fThis->GameTypeID();
|
||||
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, newGameID)
|
||||
{
|
||||
return PyLong_FromUnsignedLong(self->fThis->NewGameID());
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameMgrInviteRevokedMsg)
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, inviterID, "Returns the inviter's ID number"),
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID, "Returns the game type ID (as a guid string)"),
|
||||
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, newGameID, "Returns the new game's ID number"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameMgrInviteRevokedMsg, pyGameMgrMsg, "Game manager message when an invite is received");
|
||||
|
||||
// required functions for PyObject interoperability
|
||||
PyObject* pyGameMgrInviteRevokedMsg::New(pfGameMgrMsg* msg)
|
||||
{
|
||||
ptGameMgrInviteRevokedMsg *newObj = (ptGameMgrInviteRevokedMsg*)ptGameMgrInviteRevokedMsg_type.tp_new(&ptGameMgrInviteRevokedMsg_type, NULL, NULL);
|
||||
if (msg && (msg->netMsg->messageId == kSrv2Cli_GameMgr_InviteRevoked))
|
||||
newObj->fThis->message = msg;
|
||||
return (PyObject*)newObj;
|
||||
}
|
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
|
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
|
||||
|
||||
// Module and method definitions
|
||||
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