Branan Purvine-Riley
13 years ago
27 changed files with 1310 additions and 1336 deletions
@ -0,0 +1,154 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 _pfGameScoreMsg_h_ |
||||
#define _pfGameScoreMsg_h_ |
||||
|
||||
#include "HeadSpin.h" |
||||
#include "pfGameScoreMgr/pfGameScoreMgr.h" |
||||
#include "pnMessage/plMessage.h" |
||||
#include "pnNetBase/pnNetBase.h" |
||||
#include <vector> |
||||
|
||||
class pfGameScore; |
||||
|
||||
class pfGameScoreMsg : public plMessage |
||||
{ |
||||
ENetError fResult; |
||||
|
||||
public: |
||||
pfGameScoreMsg() { } |
||||
pfGameScoreMsg(ENetError result) |
||||
: fResult(result) |
||||
{ } |
||||
|
||||
CLASSNAME_REGISTER(pfGameScoreMsg); |
||||
GETINTERFACE_ANY(pfGameScoreMsg, plMessage); |
||||
|
||||
ENetError GetResult() const { return fResult; } |
||||
|
||||
virtual void Read(hsStream*, hsResMgr*) { FATAL("wtf are you doing???"); } |
||||
virtual void Write(hsStream*, hsResMgr*) { FATAL("wtf are you doing???"); } |
||||
}; |
||||
|
||||
class pfGameScoreListMsg : public pfGameScoreMsg |
||||
{ |
||||
std::vector<pfGameScore*> fScores; |
||||
uint32_t fOwnerId; |
||||
plString fName; |
||||
|
||||
public: |
||||
pfGameScoreListMsg() { } |
||||
pfGameScoreListMsg(ENetError result, std::vector<pfGameScore*> vec, uint32_t ownerId, plString name) |
||||
: fScores(vec), pfGameScoreMsg(result), fOwnerId(ownerId), fName(name) |
||||
{ } |
||||
|
||||
~pfGameScoreListMsg() |
||||
{ |
||||
for (std::vector<pfGameScore*>::iterator it = fScores.begin(); it != fScores.end(); ++it) |
||||
(*it)->UnRef(); |
||||
} |
||||
|
||||
CLASSNAME_REGISTER(pfGameScoreListMsg); |
||||
GETINTERFACE_ANY(pfGameScoreListMsg, pfGameScoreMsg); |
||||
|
||||
plString GetName() const { return fName; } |
||||
uint32_t GetOwnerID() const { return fOwnerId; } |
||||
size_t GetNumScores() const { return fScores.size(); } |
||||
pfGameScore* GetScore(size_t idx) const { return fScores.at(idx); } |
||||
}; |
||||
|
||||
class pfGameScoreTransferMsg : public pfGameScoreMsg |
||||
{ |
||||
pfGameScore* fSource; |
||||
pfGameScore* fDestination; |
||||
|
||||
public: |
||||
pfGameScoreTransferMsg() { } |
||||
pfGameScoreTransferMsg(ENetError result, pfGameScore* to, pfGameScore* from, int32_t points) |
||||
: fSource(from), fDestination(to), pfGameScoreMsg(result) |
||||
{ |
||||
if (result == kNetSuccess) |
||||
{ |
||||
from->fValue -= points; |
||||
to->fValue += points; |
||||
} |
||||
} |
||||
|
||||
~pfGameScoreTransferMsg() |
||||
{ |
||||
fSource->UnRef(); |
||||
fDestination->UnRef(); |
||||
} |
||||
|
||||
CLASSNAME_REGISTER(pfGameScoreTransferMsg); |
||||
GETINTERFACE_ANY(pfGameScoreTransferMsg, pfGameScoreMsg); |
||||
|
||||
pfGameScore* GetDestination() const { return fDestination; } |
||||
pfGameScore* GetSource() const { return fSource; } |
||||
}; |
||||
|
||||
class pfGameScoreUpdateMsg : public pfGameScoreMsg |
||||
{ |
||||
pfGameScore* fScore; |
||||
|
||||
public: |
||||
pfGameScoreUpdateMsg() { } |
||||
pfGameScoreUpdateMsg(ENetError result, pfGameScore* s, int32_t points) |
||||
: fScore(s), pfGameScoreMsg(result) |
||||
{ |
||||
if (result == kNetSuccess) |
||||
s->fValue = points; |
||||
} |
||||
|
||||
~pfGameScoreUpdateMsg() |
||||
{ |
||||
fScore->UnRef(); |
||||
} |
||||
|
||||
CLASSNAME_REGISTER(pfGameScoreUpdateMsg); |
||||
GETINTERFACE_ANY(pfGameScoreUpdateMsg, pfGameScoreMsg); |
||||
|
||||
pfGameScore* GetScore() const { return fScore; } |
||||
}; |
||||
|
||||
#endif // _pfGameScoreMsg_h_
|
@ -0,0 +1,118 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 "pyGameScoreMsg.h" |
||||
#include "pyGameScore.h" |
||||
|
||||
PyObject* pyGameScoreMsg::CreateFinal(pfGameScoreMsg* msg) |
||||
{ |
||||
if (pfGameScoreListMsg* l = pfGameScoreListMsg::ConvertNoRef(msg)) |
||||
return pyGameScoreListMsg::New(l); |
||||
if (pfGameScoreTransferMsg* t = pfGameScoreTransferMsg::ConvertNoRef(msg)) |
||||
return pyGameScoreTransferMsg::New(t); |
||||
if (pfGameScoreUpdateMsg* u = pfGameScoreUpdateMsg::ConvertNoRef(msg)) |
||||
return pyGameScoreUpdateMsg::New(u); |
||||
return nil; |
||||
} |
||||
|
||||
plString pyGameScoreMsg::GetError() const |
||||
{ |
||||
if (fMsg) |
||||
return _TEMP_CONVERT_FROM_WCHAR_T(NetErrorToString(fMsg->GetResult())); |
||||
return _TEMP_CONVERT_FROM_LITERAL("pfGameScoreMsg is NULL"); |
||||
} |
||||
|
||||
bool pyGameScoreMsg::IsValid() const |
||||
{ |
||||
if (fMsg) |
||||
return IS_NET_SUCCESS(fMsg->GetResult()); |
||||
return false; |
||||
} |
||||
|
||||
plString pyGameScoreListMsg::GetName() const |
||||
{ |
||||
if (pfGameScoreListMsg* pList = pfGameScoreListMsg::ConvertNoRef(fMsg)) |
||||
return pList->GetName(); |
||||
return plString::Null; |
||||
} |
||||
|
||||
uint32_t pyGameScoreListMsg::GetOwnerID() const |
||||
{ |
||||
if (pfGameScoreListMsg* pList = pfGameScoreListMsg::ConvertNoRef(fMsg)) |
||||
return pList->GetOwnerID(); |
||||
return 0; |
||||
} |
||||
|
||||
size_t pyGameScoreListMsg::GetNumScores() const |
||||
{ |
||||
if (pfGameScoreListMsg* pList = pfGameScoreListMsg::ConvertNoRef(fMsg)) |
||||
return pList->GetNumScores(); |
||||
return 0; |
||||
} |
||||
|
||||
PyObject* pyGameScoreListMsg::GetScore(size_t idx) const |
||||
{ |
||||
if (pfGameScoreListMsg* pList = pfGameScoreListMsg::ConvertNoRef(fMsg)) |
||||
return pyGameScore::New(pList->GetScore(idx)); |
||||
return nil; |
||||
} |
||||
|
||||
PyObject* pyGameScoreTransferMsg::GetDestinationScore() const |
||||
{ |
||||
if (pfGameScoreTransferMsg* pTrans = pfGameScoreTransferMsg::ConvertNoRef(fMsg)) |
||||
return pyGameScore::New(pTrans->GetDestination()); |
||||
return nil; |
||||
} |
||||
|
||||
PyObject* pyGameScoreTransferMsg::GetSourceScore() const |
||||
{ |
||||
if (pfGameScoreTransferMsg* pTrans = pfGameScoreTransferMsg::ConvertNoRef(fMsg)) |
||||
return pyGameScore::New(pTrans->GetSource()); |
||||
return nil; |
||||
} |
||||
|
||||
PyObject* pyGameScoreUpdateMsg::GetScore() const |
||||
{ |
||||
if (pfGameScoreUpdateMsg* pUp = pfGameScoreUpdateMsg::ConvertNoRef(fMsg)) |
||||
return pyGameScore::New(pUp->GetScore()); |
||||
return nil; |
||||
} |
@ -0,0 +1,149 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 _pyGameScoreMsg_h_ |
||||
#define _pyGameScoreMsg_h_ |
||||
|
||||
#include "pyGlueHelpers.h" |
||||
#include "pfMessage/pfGameScoreMsg.h" |
||||
|
||||
class pyGameScoreMsg |
||||
{ |
||||
protected: |
||||
pfGameScoreMsg* fMsg; |
||||
|
||||
pyGameScoreMsg() |
||||
: fMsg(nil) |
||||
{ } |
||||
|
||||
pyGameScoreMsg(pfGameScoreMsg* msg) |
||||
: fMsg(msg) |
||||
{ |
||||
hsRefCnt_SafeRef(msg); |
||||
} |
||||
|
||||
public: |
||||
virtual ~pyGameScoreMsg() |
||||
{ |
||||
hsRefCnt_SafeUnRef(fMsg); |
||||
} |
||||
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_EXPOSE_TYPE; // so we can subclass
|
||||
PYTHON_CLASS_NEW_FRIEND(ptGameScoreMsg); |
||||
static PyObject* CreateFinal(pfGameScoreMsg* msg); // returns the proper descendant. Note there is no New
|
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameScoreMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameScoreMsg); // converts a PyObject to a pyGameScoreMsg (throws error if not correct type)
|
||||
|
||||
plString GetError() const; |
||||
bool IsValid() const; |
||||
|
||||
static void AddPlasmaClasses(PyObject* m); |
||||
}; |
||||
|
||||
class pyGameScoreListMsg : public pyGameScoreMsg |
||||
{ |
||||
pyGameScoreListMsg() |
||||
: pyGameScoreMsg() |
||||
{ } |
||||
|
||||
pyGameScoreListMsg(pfGameScoreListMsg* msg) |
||||
: pyGameScoreMsg(msg) |
||||
{ } |
||||
|
||||
public: |
||||
PYTHON_CLASS_NEW_FRIEND(ptGameScoreListMsg); |
||||
static PyObject* New(pfGameScoreListMsg* msg); |
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameScoreListMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameScoreListMsg); // converts a PyObject to a pyGameScoreListMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m); |
||||
|
||||
plString GetName() const; |
||||
uint32_t GetOwnerID() const; |
||||
size_t GetNumScores() const; |
||||
PyObject* GetScore(size_t idx) const; |
||||
}; |
||||
|
||||
class pyGameScoreTransferMsg : public pyGameScoreMsg |
||||
{ |
||||
pyGameScoreTransferMsg() |
||||
: pyGameScoreMsg() |
||||
{ } |
||||
|
||||
pyGameScoreTransferMsg(pfGameScoreTransferMsg* msg) |
||||
: pyGameScoreMsg(msg) |
||||
{ } |
||||
|
||||
public: |
||||
PYTHON_CLASS_NEW_FRIEND(ptGameScoreTransferMsg); |
||||
static PyObject* New(pfGameScoreTransferMsg* msg); |
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameScoreTransferMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameScoreTransferMsg); // converts a PyObject to a pyGameScoreTransferMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m); |
||||
|
||||
PyObject* GetDestinationScore() const; |
||||
PyObject* GetSourceScore() const; |
||||
}; |
||||
|
||||
class pyGameScoreUpdateMsg : public pyGameScoreMsg |
||||
{ |
||||
pyGameScoreUpdateMsg() |
||||
: pyGameScoreMsg() |
||||
{ } |
||||
|
||||
pyGameScoreUpdateMsg(pfGameScoreUpdateMsg* msg) |
||||
: pyGameScoreMsg(msg) |
||||
{ } |
||||
|
||||
public: |
||||
PYTHON_CLASS_NEW_FRIEND(ptGameScoreUpdateMsg); |
||||
static PyObject* New(pfGameScoreUpdateMsg* msg); |
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameScoreUpdateMsg object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameScoreUpdateMsg); // converts a PyObject to a pyGameScoreUpdateMsg (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject* m); |
||||
|
||||
PyObject* GetScore() const; |
||||
}; |
||||
|
||||
#endif // _pyGameScoreMsg_h_
|
@ -0,0 +1,251 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 "pyGameScoreMsg.h" |
||||
|
||||
// Maybe we need a better exception? Seems to be the best built in one though
|
||||
#define PFGS_PYERR PyExc_RuntimeError |
||||
|
||||
// =================================================================
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameScoreMsg, pyGameScoreMsg); |
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameScoreMsg, pyGameScoreMsg); |
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameScoreMsg); |
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameScoreMsg); |
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameScoreMsg) |
||||
// We have no methods, but our helpers want a table...
|
||||
// Eh. Not the end of the world.
|
||||
PYTHON_END_METHODS_TABLE; |
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE(ptGameScoreMsg, "Game Score operation callback message"); |
||||
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameScoreMsg, pyGameScoreMsg); |
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameScoreMsg, pyGameScoreMsg) |
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameScoreMsg, pyGameScoreMsg) |
||||
|
||||
// Module and method definitions
|
||||
void pyGameScoreMsg::AddPlasmaClasses(PyObject* m) |
||||
{ |
||||
PYTHON_CLASS_IMPORT_START(m); |
||||
PYTHON_CLASS_IMPORT(m, ptGameScoreMsg); |
||||
PYTHON_CLASS_IMPORT_END(m); |
||||
} |
||||
|
||||
// =================================================================
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameScoreListMsg, pyGameScoreListMsg); |
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameScoreListMsg, pyGameScoreListMsg); |
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameScoreListMsg); |
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameScoreListMsg); |
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameScoreListMsg, getName) |
||||
{ |
||||
return PyUnicode_FromStringEx(self->fThis->GetName()); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameScoreListMsg, getOwnerID) |
||||
{ |
||||
return PyInt_FromLong(self->fThis->GetOwnerID()); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameScoreListMsg, getScores) |
||||
{ |
||||
if (self->fThis->IsValid()) |
||||
{ |
||||
size_t count = self->fThis->GetNumScores(); |
||||
PyObject* tup = PyTuple_New(count); |
||||
for (size_t i = 0; i < count; ++i) |
||||
PyTuple_SetItem(tup, i, self->fThis->GetScore(i)); |
||||
return tup; |
||||
} |
||||
|
||||
PyErr_SetString(PFGS_PYERR, self->fThis->GetError().c_str()); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameScoreListMsg) |
||||
PYTHON_METHOD_NOARGS(ptGameScoreListMsg, getName, "Returns the template score name"), |
||||
PYTHON_METHOD_NOARGS(ptGameScoreListMsg, getOwnerID, "Returns the template score ownerID"), |
||||
PYTHON_METHOD_NOARGS(ptGameScoreListMsg, getScores, "Returns a list of scores found by the server"), |
||||
PYTHON_END_METHODS_TABLE; |
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameScoreListMsg, pyGameScoreMsg, "Game Score message for scores found on the server"); |
||||
|
||||
// PyObject interop
|
||||
PyObject* pyGameScoreListMsg::New(pfGameScoreListMsg* msg) |
||||
{ |
||||
ptGameScoreListMsg* newObj = (ptGameScoreListMsg*)ptGameScoreListMsg_type.tp_new(&ptGameScoreListMsg_type, NULL, NULL); |
||||
hsRefCnt_SafeUnRef(newObj->fThis->fMsg); |
||||
newObj->fThis->fMsg = msg; |
||||
hsRefCnt_SafeRef(newObj->fThis->fMsg); |
||||
return (PyObject*)newObj; |
||||
} |
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameScoreListMsg, pyGameScoreListMsg) |
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameScoreListMsg, pyGameScoreListMsg) |
||||
|
||||
// Module and method definitions
|
||||
void pyGameScoreListMsg::AddPlasmaClasses(PyObject* m) |
||||
{ |
||||
PYTHON_CLASS_IMPORT_START(m); |
||||
PYTHON_CLASS_IMPORT(m, ptGameScoreListMsg); |
||||
PYTHON_CLASS_IMPORT_END(m); |
||||
} |
||||
|
||||
// =================================================================
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameScoreTransferMsg, pyGameScoreTransferMsg); |
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameScoreTransferMsg, pyGameScoreTransferMsg); |
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameScoreTransferMsg); |
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameScoreTransferMsg); |
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameScoreTransferMsg, getDestination) |
||||
{ |
||||
if (self->fThis->IsValid()) |
||||
{ |
||||
return self->fThis->GetDestinationScore(); |
||||
} |
||||
|
||||
PyErr_SetString(PFGS_PYERR, self->fThis->GetError().c_str()); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameScoreTransferMsg, getSource) |
||||
{ |
||||
if (self->fThis->IsValid()) |
||||
{ |
||||
return self->fThis->GetSourceScore(); |
||||
} |
||||
|
||||
PyErr_SetString(PFGS_PYERR, self->fThis->GetError().c_str()); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameScoreTransferMsg) |
||||
PYTHON_METHOD_NOARGS(ptGameScoreTransferMsg, getDestination, "Returns the score points were transferred to"), |
||||
PYTHON_METHOD_NOARGS(ptGameScoreTransferMsg, getSource, "Returns the score points were transferred from"), |
||||
PYTHON_END_METHODS_TABLE; |
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameScoreTransferMsg, pyGameScoreMsg, "Game Score message indicating a score point transfer"); |
||||
|
||||
// PyObject interop
|
||||
PyObject* pyGameScoreTransferMsg::New(pfGameScoreTransferMsg* msg) |
||||
{ |
||||
ptGameScoreTransferMsg* newObj = (ptGameScoreTransferMsg*)ptGameScoreTransferMsg_type.tp_new(&ptGameScoreTransferMsg_type, NULL, NULL); |
||||
hsRefCnt_SafeUnRef(newObj->fThis->fMsg); |
||||
newObj->fThis->fMsg = msg; |
||||
hsRefCnt_SafeRef(newObj->fThis->fMsg); |
||||
return (PyObject*)newObj; |
||||
} |
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameScoreTransferMsg, pyGameScoreTransferMsg) |
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameScoreTransferMsg, pyGameScoreTransferMsg) |
||||
|
||||
// Module and method definitions
|
||||
void pyGameScoreTransferMsg::AddPlasmaClasses(PyObject* m) |
||||
{ |
||||
PYTHON_CLASS_IMPORT_START(m); |
||||
PYTHON_CLASS_IMPORT(m, ptGameScoreTransferMsg); |
||||
PYTHON_CLASS_IMPORT_END(m); |
||||
} |
||||
|
||||
// =================================================================
|
||||
|
||||
PYTHON_CLASS_DEFINITION(ptGameScoreUpdateMsg, pyGameScoreUpdateMsg); |
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptGameScoreUpdateMsg, pyGameScoreUpdateMsg); |
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameScoreUpdateMsg); |
||||
|
||||
PYTHON_NO_INIT_DEFINITION(ptGameScoreUpdateMsg); |
||||
|
||||
PYTHON_METHOD_DEFINITION_NOARGS(ptGameScoreUpdateMsg, getScore) |
||||
{ |
||||
if (self->fThis->IsValid()) |
||||
{ |
||||
return self->fThis->GetScore(); |
||||
} |
||||
|
||||
PyErr_SetString(PFGS_PYERR, self->fThis->GetError().c_str()); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
|
||||
PYTHON_START_METHODS_TABLE(ptGameScoreUpdateMsg) |
||||
PYTHON_METHOD_NOARGS(ptGameScoreUpdateMsg, getScore, "Returns the updated game score"), |
||||
PYTHON_END_METHODS_TABLE; |
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE_WBASE(ptGameScoreUpdateMsg, pyGameScoreMsg, "Game Score message for a score update operation"); |
||||
|
||||
// PyObject interop
|
||||
PyObject* pyGameScoreUpdateMsg::New(pfGameScoreUpdateMsg* msg) |
||||
{ |
||||
ptGameScoreUpdateMsg* newObj = (ptGameScoreUpdateMsg*)ptGameScoreUpdateMsg_type.tp_new(&ptGameScoreUpdateMsg_type, NULL, NULL); |
||||
hsRefCnt_SafeUnRef(newObj->fThis->fMsg); |
||||
newObj->fThis->fMsg = msg; |
||||
hsRefCnt_SafeRef(newObj->fThis->fMsg); |
||||
return (PyObject*)newObj; |
||||
} |
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptGameScoreUpdateMsg, pyGameScoreUpdateMsg) |
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameScoreUpdateMsg, pyGameScoreUpdateMsg) |
||||
|
||||
// Module and method definitions
|
||||
void pyGameScoreUpdateMsg::AddPlasmaClasses(PyObject* m) |
||||
{ |
||||
PYTHON_CLASS_IMPORT_START(m); |
||||
PYTHON_CLASS_IMPORT(m, ptGameScoreUpdateMsg); |
||||
PYTHON_CLASS_IMPORT_END(m); |
||||
} |
||||
|
||||
// =================================================================
|
||||
|
||||
#undef PFGS_PYERR |
@ -1,354 +0,0 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 "pyScoreMgr.h" |
||||
|
||||
#include "pfGameScoreMgr/pfGameScoreMgr.h" |
||||
#include "plVault/plVault.h" |
||||
#include "plNetCommon/plNetCommon.h" |
||||
#include "pyGameScore.h" |
||||
|
||||
pyScoreMgr::pyScoreMgr() |
||||
{ |
||||
} |
||||
|
||||
pyScoreMgr::~pyScoreMgr() |
||||
{ |
||||
} |
||||
|
||||
bool pyScoreMgr::DeleteScore(unsigned scoreId) |
||||
{ |
||||
return IS_NET_SUCCESS(pfGameScoreMgr::GetInstance()->DeleteScore(scoreId)); |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::CreateGlobalScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
) { |
||||
pfGameScore * score = NEWZERO(pfGameScore); |
||||
score->IncRef(); |
||||
|
||||
pfGameScoreMgr::GetInstance()->CreateScore(0, gameName, gameType, value, *score); |
||||
|
||||
if (score) |
||||
{ |
||||
if (score->scoreId > 0) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(score); |
||||
score->DecRef(); |
||||
|
||||
return pyScore; |
||||
} |
||||
|
||||
score->DecRef(); |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::GetGlobalScores(const char* gameName) |
||||
{ |
||||
pfGameScore** scoreList = nil; |
||||
int scoreListCount = 0; |
||||
ENetError result = pfGameScoreMgr::GetInstance()->GetScoresIncRef(0, gameName, scoreList, scoreListCount); |
||||
|
||||
if (IS_NET_SUCCESS(result) && scoreListCount > 0) |
||||
{ |
||||
PyObject* pyScoreList = PyList_New(scoreListCount); |
||||
for (int i = 0; i < scoreListCount; ++i) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(scoreList[i]); |
||||
PyList_SetItem(pyScoreList, i, pyScore); |
||||
scoreList[i]->DecRef(); |
||||
} |
||||
|
||||
delete [] scoreList; |
||||
|
||||
return pyScoreList; |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::CreatePlayerScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
) { |
||||
pfGameScore * score = nil; |
||||
|
||||
if (RelVaultNode * rvn = VaultGetPlayerInfoNodeIncRef()) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
score = NEWZERO(pfGameScore); |
||||
score->IncRef(); |
||||
pfGameScoreMgr::GetInstance()->CreateScore(ownerId, gameName, gameType, value, *score); |
||||
} |
||||
|
||||
if (score) |
||||
{ |
||||
if (score->scoreId > 0) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(score); |
||||
score->DecRef(); |
||||
|
||||
return pyScore; |
||||
} |
||||
|
||||
score->DecRef(); |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::GetPlayerScores(const char* gameName) |
||||
{ |
||||
if (RelVaultNode * rvn = VaultGetPlayerInfoNodeIncRef()) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
pfGameScore** scoreList = nil; |
||||
int scoreListCount = 0; |
||||
ENetError result = pfGameScoreMgr::GetInstance()->GetScoresIncRef(ownerId, gameName, scoreList, scoreListCount); |
||||
|
||||
if (IS_NET_SUCCESS(result) && scoreListCount > 0) |
||||
{ |
||||
PyObject* pyScoreList = PyList_New(scoreListCount); |
||||
for (int i = 0; i < scoreListCount; ++i) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(scoreList[i]); |
||||
PyList_SetItem(pyScoreList, i, pyScore); |
||||
scoreList[i]->DecRef(); |
||||
} |
||||
|
||||
delete [] scoreList; |
||||
|
||||
return pyScoreList; |
||||
} |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::CreateNeighborhoodScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
) { |
||||
pfGameScore * score = nil; |
||||
|
||||
plAgeInfoStruct info; |
||||
info.SetAgeFilename(kNeighborhoodAgeFilename); |
||||
|
||||
if (RelVaultNode * rvn = VaultGetOwnedAgeInfoIncRef(&info)) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
score = NEWZERO(pfGameScore); |
||||
score->IncRef(); |
||||
pfGameScoreMgr::GetInstance()->CreateScore(ownerId, gameName, gameType, value, *score); |
||||
} |
||||
|
||||
if (score) |
||||
{ |
||||
if (score->scoreId > 0) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(score); |
||||
score->DecRef(); |
||||
|
||||
return pyScore; |
||||
} |
||||
|
||||
score->DecRef(); |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::GetNeighborhoodScores(const char* gameName) |
||||
{ |
||||
plAgeInfoStruct info; |
||||
info.SetAgeFilename(kNeighborhoodAgeFilename); |
||||
|
||||
if (RelVaultNode * rvn = VaultGetOwnedAgeInfoIncRef(&info)) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
pfGameScore** scoreList = nil; |
||||
int scoreListCount = 0; |
||||
ENetError result = pfGameScoreMgr::GetInstance()->GetScoresIncRef(ownerId, gameName, scoreList, scoreListCount); |
||||
|
||||
if (IS_NET_SUCCESS(result) && scoreListCount > 0) |
||||
{ |
||||
PyObject* pyScoreList = PyList_New(scoreListCount); |
||||
for (int i = 0; i < scoreListCount; ++i) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(scoreList[i]); |
||||
PyList_SetItem(pyScoreList, i, pyScore); |
||||
scoreList[i]->DecRef(); |
||||
} |
||||
|
||||
delete [] scoreList; |
||||
|
||||
return pyScoreList; |
||||
} |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::CreateCurrentAgeScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
) { |
||||
pfGameScore * score = nil; |
||||
|
||||
if (RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef()) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
score = NEWZERO(pfGameScore); |
||||
score->IncRef(); |
||||
pfGameScoreMgr::GetInstance()->CreateScore(ownerId, gameName, gameType, value, *score); |
||||
} |
||||
|
||||
if (score) |
||||
{ |
||||
if (score->scoreId > 0) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(score); |
||||
score->DecRef(); |
||||
|
||||
return pyScore; |
||||
} |
||||
|
||||
score->DecRef(); |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject* pyScoreMgr::GetCurrentAgeScores(const char* gameName) |
||||
{ |
||||
if (RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef()) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
pfGameScore** scoreList = nil; |
||||
int scoreListCount = 0; |
||||
ENetError result = pfGameScoreMgr::GetInstance()->GetScoresIncRef(ownerId, gameName, scoreList, scoreListCount); |
||||
|
||||
if (IS_NET_SUCCESS(result) && scoreListCount > 0) |
||||
{ |
||||
PyObject* pyScoreList = PyList_New(scoreListCount); |
||||
for (int i = 0; i < scoreListCount; ++i) |
||||
{ |
||||
PyObject* pyScore = pyGameScore::New(scoreList[i]); |
||||
PyList_SetItem(pyScoreList, i, pyScore); |
||||
scoreList[i]->DecRef(); |
||||
} |
||||
|
||||
delete [] scoreList; |
||||
|
||||
return pyScoreList; |
||||
} |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
||||
|
||||
PyObject * pyScoreMgr::GetRankList( |
||||
unsigned scoreGroup, |
||||
unsigned parentFolderId, |
||||
const char * gameName, |
||||
unsigned timePeriod, |
||||
unsigned numResults, |
||||
unsigned pageNumber, |
||||
bool sortDesc |
||||
) { |
||||
if (RelVaultNode * rvn = VaultGetPlayerInfoNodeIncRef()) { |
||||
unsigned ownerId = rvn->nodeId; |
||||
rvn->DecRef(); |
||||
|
||||
NetGameRank** rankList = nil; |
||||
int rankListCount = 0; |
||||
ENetError result = pfGameScoreMgr::GetInstance()->GetRankList( |
||||
ownerId, |
||||
scoreGroup, |
||||
parentFolderId, |
||||
gameName, |
||||
timePeriod, |
||||
numResults, |
||||
pageNumber, |
||||
sortDesc, |
||||
rankList, |
||||
rankListCount |
||||
); |
||||
|
||||
if (IS_NET_SUCCESS(result) && rankListCount > 0) |
||||
{ |
||||
PyObject* pyRankList = PyList_New(rankListCount); |
||||
for (int i = 0; i < rankListCount; ++i) |
||||
{ |
||||
char tempStr[kMaxPlayerNameLength]; |
||||
StrToAnsi(tempStr, rankList[i]->name, arrsize(tempStr)); |
||||
|
||||
PyObject* pyRank = PyTuple_New(3); |
||||
PyTuple_SetItem(pyRank, 0, PyInt_FromLong(rankList[i]->rank)); |
||||
PyTuple_SetItem(pyRank, 1, PyString_FromString(tempStr)); |
||||
PyTuple_SetItem(pyRank, 2, PyInt_FromLong(rankList[i]->score)); |
||||
|
||||
PyList_SetItem(pyRankList, i, pyRank); |
||||
|
||||
delete rankList[i]; |
||||
} |
||||
|
||||
delete [] rankList; |
||||
|
||||
return pyRankList; |
||||
} |
||||
} |
||||
|
||||
PYTHON_RETURN_NONE; |
||||
} |
@ -1,115 +0,0 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 pyScoreMgr_h |
||||
#define pyScoreMgr_h |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAME: pyScoreMgr
|
||||
//
|
||||
// PURPOSE: a wrapper class to provide an interface to the scoring system
|
||||
//
|
||||
#include <Python.h> |
||||
|
||||
#include "HeadSpin.h" |
||||
#include "hsStlUtils.h" |
||||
|
||||
#include "pyGlueHelpers.h" |
||||
|
||||
|
||||
class pyScoreMgr |
||||
{ |
||||
public: |
||||
pyScoreMgr(); |
||||
~pyScoreMgr(); |
||||
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_FRIEND(ptScoreMgr); |
||||
PYTHON_CLASS_NEW_DEFINITION; |
||||
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyScoreMgr object
|
||||
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyScoreMgr); // converts a PyObject to a pyScoreMgr (throws error if not correct type)
|
||||
|
||||
static void AddPlasmaClasses(PyObject *m); |
||||
static void AddPlasmaConstantsClasses(PyObject *m); |
||||
|
||||
bool DeleteScore(unsigned scoreId); |
||||
|
||||
PyObject* CreateGlobalScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
); |
||||
PyObject* GetGlobalScores(const char* gameName); |
||||
|
||||
PyObject* CreatePlayerScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
); |
||||
PyObject* GetPlayerScores(const char* gameName); |
||||
|
||||
PyObject* CreateNeighborhoodScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
); |
||||
PyObject* GetNeighborhoodScores(const char* gameName); |
||||
|
||||
PyObject* CreateCurrentAgeScore( |
||||
const char * gameName, |
||||
unsigned gameType, |
||||
int value |
||||
); |
||||
PyObject* GetCurrentAgeScores(const char* gameName); |
||||
|
||||
PyObject * GetRankList( |
||||
unsigned scoreGroup, |
||||
unsigned parentFolderId, |
||||
const char * gameName, |
||||
unsigned timePeriod, |
||||
unsigned numResults, |
||||
unsigned pageNumber, |
||||
bool sortDesc |
||||
); |
||||
}; |
||||
|
||||
#endif |
@ -1,235 +0,0 @@
|
||||
/*==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/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7 |
||||
|
||||
If you modify this Program, or any covered work, by linking or |
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK, |
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent |
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK |
||||
(or a modified version of those libraries), |
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA, |
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG |
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the |
||||
licensors of this Program grant you additional |
||||
permission to convey the resulting work. Corresponding Source for a |
||||
non-source form of such a combination shall include the source code for |
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered |
||||
work. |
||||
|
||||
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 "pyScoreMgr.h" |
||||
|
||||
#include "pyEnum.h" |
||||
#include "pfGameScoreMgr/pfGameScoreMgr.h" |
||||
|
||||
// glue functions
|
||||
PYTHON_CLASS_DEFINITION(ptScoreMgr, pyScoreMgr); |
||||
|
||||
PYTHON_DEFAULT_NEW_DEFINITION(ptScoreMgr, pyScoreMgr) |
||||
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptScoreMgr) |
||||
|
||||
PYTHON_INIT_DEFINITION(ptScoreMgr, args, keywords) |
||||
{ |
||||
PYTHON_RETURN_INIT_OK; |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, deleteScore, args) |
||||
{ |
||||
int scoreId; |
||||
if (!PyArg_ParseTuple(args, "i", &scoreId)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "deleteScore expects an int"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
PYTHON_RETURN_BOOL(self->fThis->DeleteScore(scoreId)); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, createGlobalScore, args) |
||||
{ |
||||
char* gameName; |
||||
int gameType; |
||||
int value; |
||||
if (!PyArg_ParseTuple(args, "sii", &gameName, &gameType, &value)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "createGlobalScore expects a string, an int, and an int"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->CreateGlobalScore(gameName, gameType, value); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, getGlobalScores, args) |
||||
{ |
||||
char* gameName; |
||||
if (!PyArg_ParseTuple(args, "s", &gameName)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "getGlobalScores expects a string"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->GetGlobalScores(gameName); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, createPlayerScore, args) |
||||
{ |
||||
char* gameName; |
||||
int gameType; |
||||
int value; |
||||
if (!PyArg_ParseTuple(args, "sii", &gameName, &gameType, &value)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "createPlayerScore expects a string, an int, and an int"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->CreatePlayerScore(gameName, gameType, value); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, getPlayerScores, args) |
||||
{ |
||||
char* gameName; |
||||
if (!PyArg_ParseTuple(args, "s", &gameName)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "getPlayerScores expects a string"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->GetPlayerScores(gameName); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, createNeighborhoodScore, args) |
||||
{ |
||||
char* gameName; |
||||
int gameType; |
||||
int value; |
||||
if (!PyArg_ParseTuple(args, "sii", &gameName, &gameType, &value)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "createNeighborhoodScore expects a string, an int, and an int"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->CreateNeighborhoodScore(gameName, gameType, value); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, getNeighborhoodScores, args) |
||||
{ |
||||
char* gameName; |
||||
if (!PyArg_ParseTuple(args, "s", &gameName)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "getNeighborhoodScores expects a string"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->GetNeighborhoodScores(gameName); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, createCurrentAgeScore, args) |
||||
{ |
||||
char* gameName; |
||||
int gameType; |
||||
int value; |
||||
if (!PyArg_ParseTuple(args, "sii", &gameName, &gameType, &value)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "createCurrentAgeScore expects a string, an int, and an int"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->CreateCurrentAgeScore(gameName, gameType, value); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, getCurrentAgeScores, args) |
||||
{ |
||||
char* gameName; |
||||
if (!PyArg_ParseTuple(args, "s", &gameName)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "getCurrentAgeScores expects a string"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
return self->fThis->GetCurrentAgeScores(gameName); |
||||
} |
||||
|
||||
PYTHON_METHOD_DEFINITION(ptScoreMgr, getRankList, args) |
||||
{ |
||||
int scoreGroup; |
||||
int parentFolderId; |
||||
char* gameName; |
||||
int timePeriod; |
||||
int numResults; |
||||
int pageNumber; |
||||
int sortDesc; |
||||
if (!PyArg_ParseTuple(args, "iisiiii", &scoreGroup, &parentFolderId, &gameName, &timePeriod, &numResults, &pageNumber, &sortDesc)) |
||||
{ |
||||
PyErr_SetString(PyExc_TypeError, "getRankList expects two ints, a string, and four more ints"); |
||||
PYTHON_RETURN_ERROR; |
||||
} |
||||
|
||||
return self->fThis->GetRankList(scoreGroup, parentFolderId, gameName, timePeriod, numResults, pageNumber, sortDesc != 0); |
||||
} |
||||
|
||||
PYTHON_START_METHODS_TABLE(ptScoreMgr) |
||||
PYTHON_METHOD(ptScoreMgr, deleteScore, "Params: scoreId\nDeletes the specified score"), |
||||
PYTHON_METHOD(ptScoreMgr, createGlobalScore, "Params: gameName, gameType, value\nCreates a score and returns it"), |
||||
PYTHON_METHOD(ptScoreMgr, getGlobalScores, "Params: gameName\nReturns a list of scores associated with the specified game."), |
||||
PYTHON_METHOD(ptScoreMgr, createPlayerScore, "Params: gameName, gameType, value\nCreates a score and returns it"), |
||||
PYTHON_METHOD(ptScoreMgr, getPlayerScores, "Params: gameName\nReturns a list of scores associated with the specified game."), |
||||
PYTHON_METHOD(ptScoreMgr, createNeighborhoodScore, "Params: gameName, gameType, value\nCreates a score and returns it"), |
||||
PYTHON_METHOD(ptScoreMgr, getNeighborhoodScores, "Params: gameName\nReturns a list of scores associated with the specified game."), |
||||
PYTHON_METHOD(ptScoreMgr, createCurrentAgeScore, "Params: gameName, gameType, value\nCreates a score and returns it"), |
||||
PYTHON_METHOD(ptScoreMgr, getCurrentAgeScores, "Params: gameName\nReturns a list of scores associated with the specified game."), |
||||
PYTHON_METHOD(ptScoreMgr, getRankList, "Params: ownerInfoId, scoreGroup, parentFolderId, gameName, timePeriod, numResults, pageNumber, sortDesc\nReturns a list of scores and rank"), |
||||
PYTHON_END_METHODS_TABLE; |
||||
|
||||
// Type structure definition
|
||||
PLASMA_DEFAULT_TYPE(ptScoreMgr, "Game score manager"); |
||||
|
||||
// required functions for PyObject interoperability
|
||||
PYTHON_CLASS_NEW_IMPL(ptScoreMgr, pyScoreMgr) |
||||
|
||||
PYTHON_CLASS_CHECK_IMPL(ptScoreMgr, pyScoreMgr) |
||||
PYTHON_CLASS_CONVERT_FROM_IMPL(ptScoreMgr, pyScoreMgr) |
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AddPlasmaClasses - the python module definitions
|
||||
//
|
||||
void pyScoreMgr::AddPlasmaClasses(PyObject *m) |
||||
{ |
||||
PYTHON_CLASS_IMPORT_START(m); |
||||
PYTHON_CLASS_IMPORT(m, ptScoreMgr); |
||||
PYTHON_CLASS_IMPORT_END(m); |
||||
} |
||||
|
||||
void pyScoreMgr::AddPlasmaConstantsClasses(PyObject *m) |
||||
{ |
||||
PYTHON_ENUM_START(PtGameScoreTypes); |
||||
PYTHON_ENUM_ELEMENT(PtGameScoreTypes, kFixed, kScoreTypeFixed); |
||||
PYTHON_ENUM_ELEMENT(PtGameScoreTypes, kAccumulative, kScoreTypeAccumulative); |
||||
PYTHON_ENUM_ELEMENT(PtGameScoreTypes, kAccumAllowNegative, kScoreTypeAccumAllowNegative); |
||||
PYTHON_ENUM_END(m, PtGameScoreTypes); |
||||
|
||||
PYTHON_ENUM_START(PtScoreRankGroups); |
||||
PYTHON_ENUM_ELEMENT(PtScoreRankGroups, kIndividual, kScoreRankGroupIndividual); |
||||
PYTHON_ENUM_ELEMENT(PtScoreRankGroups, kNeighborhood, kScoreRankGroupNeighborhood); |
||||
PYTHON_ENUM_END(m, PtScoreRankGroups); |
||||
|
||||
PYTHON_ENUM_START(PtScoreTimePeriods); |
||||
PYTHON_ENUM_ELEMENT(PtScoreTimePeriods, kOverall, kScoreTimePeriodOverall); |
||||
PYTHON_ENUM_ELEMENT(PtScoreTimePeriods, kYear, kScoreTimePeriodYear); |
||||
PYTHON_ENUM_ELEMENT(PtScoreTimePeriods, kMonth, kScoreTimePeriodMonth); |
||||
PYTHON_ENUM_ELEMENT(PtScoreTimePeriods, kDay, kScoreTimePeriodDay); |
||||
PYTHON_ENUM_END(m, PtScoreTimePeriods); |
||||
} |
Loading…
Reference in new issue