2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 10:37:41 -04:00

CWE Directory Reorganization

Rearrange directory structure of CWE to be loosely equivalent to
the H'uru Plasma repository.

Part 1: Movement of directories and files.
This commit is contained in:
rarified
2021-05-15 12:49:46 -06:00
parent c3f4a640a3
commit 96903e8dca
4002 changed files with 159 additions and 644 deletions

View File

@ -0,0 +1,332 @@
/*==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 "pyNetClientComm.h"
#include "../pfPython/pyAgeLinkStruct.h"
#include "../pfPython/pyNetServerSessionInfo.h"
#include "../pfPython/pyStatusLog.h"
#include "../plNetCommon/plCreatePlayerFlags.h"
#include "../pnNetCommon/plGenericVar.h"
#include "hsStlUtils.h"
#include "hsTimer.h"
#include <python.h>
////////////////////////////////////////////////////////////////////
class pyNetClientCommCallback : public plNetClientComm::Callback
{
public:
PyObject * fPyObject;
pyNetClientCommCallback( PyObject * pyObject )
: fPyObject( pyObject )
{
Py_XINCREF( fPyObject );
}
~pyNetClientCommCallback()
{
Py_XDECREF( fPyObject );
}
void OperationStarted( UInt32 context )
{
if ( fPyObject )
{
// Call the callback.
PyObject* func = PyObject_GetAttrString( fPyObject, "operationStarted" );
if ( func )
{
if ( PyCallable_Check(func)>0 )
{
PyObject* retVal = PyObject_CallMethod(fPyObject, "operationStarted", "l", context);
Py_XDECREF(retVal);
}
}
}
}
void OperationComplete( UInt32 context, int resultCode )
{
if ( fPyObject )
{
// Pass args.
PyObject* pyArgs = PyObject_GetAttrString( fPyObject, "fCbArgs" );
if ( pyArgs )
{
PyObject* pyDict = PyDict_New();
std::map<UInt16,plCreatable*> args;
fCbArgs.GetItems( args );
for ( std::map<UInt16,plCreatable*>::iterator ii=args.begin(); ii!=args.end(); ++ii )
{
UInt16 key = ii->first;
PyObject* keyObj = PyInt_FromLong(key);
char* strTemp = NULL;
plCreatable* arg = ii->second;
plCreatableGenericValue * genValue = plCreatableGenericValue::ConvertNoRef( arg );
if ( genValue )
{
PyObject* valueObj;
plGenericType & value = genValue->Value();
switch ( value.GetType() )
{
case plGenericType::kInt:
valueObj = PyLong_FromLong((Int32)value);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
break;
case plGenericType::kUInt:
valueObj = PyLong_FromUnsignedLong((UInt32)value);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
break;
case plGenericType::kFloat:
valueObj = PyFloat_FromDouble((float)value);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
break;
case plGenericType::kDouble:
valueObj = PyFloat_FromDouble((double)value);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
break;
case plGenericType::kBool:
if ((bool)value)
valueObj = PyInt_FromLong(1);
else
valueObj = PyInt_FromLong(0);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
break;
case plGenericType::kChar:
strTemp = new char[2];
strTemp[0] = (char)value;
strTemp[1] = 0;
valueObj = PyString_FromString(strTemp);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
delete [] strTemp;
break;
case plGenericType::kString:
valueObj = PyString_FromString((const char*)value);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
break;
case plGenericType::kAny:
break;
case plGenericType::kNone:
break;
}
}
plNetServerSessionInfo * serverInfo = plNetServerSessionInfo::ConvertNoRef( arg );
if ( serverInfo )
{
PyObject* valueObj = pyNetServerSessionInfo::New(*serverInfo);
PyDict_SetItem(pyDict, keyObj, valueObj);
Py_DECREF(valueObj);
}
Py_DECREF(keyObj);
}
PyObject_SetAttrString( fPyObject, "fCbArgs", pyDict );
Py_DECREF(pyDict);
}
// Call the callback.
PyObject* func = PyObject_GetAttrString( fPyObject, "operationComplete" );
if ( func )
{
if ( PyCallable_Check(func)>0 )
{
PyObject* retVal = PyObject_CallMethod(fPyObject, "operationComplete", "li", context, resultCode);
Py_XDECREF(retVal);
}
}
}
delete this;
}
};
////////////////////////////////////////////////////////////////////
// Error handler - throws exception in python script
class pyNetClientCommErrorHandler : public plNetClientComm::ErrorHandler
{
public:
void HandleError( Error err, int result )
{
std::string msg;
xtl::format( msg, "pyNetClientComm: Error: %s", plNetClientComm::ErrorHandler::ErrorStr( err ) );
PyErr_SetString(PyExc_KeyError, msg.c_str());
}
} ThePyNetClientCommErrorHandler;
////////////////////////////////////////////////////////////////////
// pyNetClientComm ----------------------------------------------
pyNetClientComm::pyNetClientComm()
{
fNetClient.SetErrorHandler( &ThePyNetClientCommErrorHandler );
}
// ~pyNetClientComm ----------------------------------------------
pyNetClientComm::~pyNetClientComm()
{
}
// NetAuthenticate ----------------------------------------------
int pyNetClientComm::NetAuthenticate( double maxAuthSecs, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetAuthenticate( maxAuthSecs, new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetLeave ----------------------------------------------
int pyNetClientComm::NetLeave( UInt8 reason, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetLeave( reason, new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetPing ----------------------------------------------
int pyNetClientComm::NetPing( int serverType, int timeoutSecs/*=0*/, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetPing( serverType, timeoutSecs, new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetFindAge ----------------------------------------------
int pyNetClientComm::NetFindAge( const pyAgeLinkStruct* linkInfo, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetFindAge( linkInfo->GetAgeLink(), new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetGetPlayerList ----------------------------------------------
int pyNetClientComm::NetGetPlayerList( PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetGetPlayerList( new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetSetActivePlayer ----------------------------------------------
int pyNetClientComm::NetSetActivePlayer( UInt32 playerID, const char* playerName, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetSetActivePlayer( playerID, playerName, 0 /*ccrLevel*/, new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetCreatePlayer ----------------------------------------------
int pyNetClientComm::NetCreatePlayer( const char* playerName, const char* avatarShape, UInt32 createFlags, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetCreatePlayer( playerName, avatarShape, createFlags, nil, nil, nil, new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetJoinAge ----------------------------------------------
int pyNetClientComm::NetJoinAge( PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetJoinAge( true /*tryP2P*/, true /*allowTimeout*/, new pyNetClientCommCallback( cbClass ), cbContext );
}
// NetSetTimeout ----------------------------------------------
int pyNetClientComm::NetSetTimeout( float timeoutSecs, PyObject* cbClass/*=nil*/, UInt32 cbContext/*=0 */)
{
return fNetClient.NetSetTimeout( timeoutSecs, new pyNetClientCommCallback( cbClass ), cbContext );
}
// SetLogLevel ----------------------------------------------
void pyNetClientComm::SetLogLevel( int logLevel )
{
fNetClient.SetLogLevel( logLevel );
}
// Startup ----------------------------------------------
int pyNetClientComm::Init( bool threaded/*=true */, int logLevel/*=0 */)
{
return fNetClient.Init( threaded, logLevel );
}
// Shutdown ----------------------------------------------
int pyNetClientComm::Fini( float flushMsgsSecs/*=0.f */)
{
return fNetClient.Fini( flushMsgsSecs );
}
// Update ----------------------------------------------
int pyNetClientComm::Update()
{
return fNetClient.Update( hsTimer::GetSeconds() );
}
// SetActiveServer ----------------------------------------------
int pyNetClientComm::SetActiveServer( pyNetServerSessionInfo* nfo )
{
return fNetClient.SetActiveServer( &nfo->ServerInfo() );
}
// SetActiveServer2 ----------------------------------------------
int pyNetClientComm::SetActiveServer2( const char * addr, int port )
{
plNetServerSessionInfo nfo;
nfo.SetServerAddr( addr );
nfo.SetServerPort( port );
return fNetClient.SetActiveServer( &nfo );
}
// SetAuthInfo ----------------------------------------------
int pyNetClientComm::SetAuthInfo( const char* acctName, const char* password )
{
return fNetClient.SetAuthInfo( acctName, password );
}
// SetLogByName ----------------------------------------------
void pyNetClientComm::SetLogByName( const char * name, UInt32 flags )
{
plStatusLog * log = plStatusLogMgr::GetInstance().CreateStatusLog( 80, name,
flags | plStatusLog::kTimestamp | plStatusLog::kDeleteForMe );
fNetClient.SetLog( log );
}
// GetLog ----------------------------------------------
PyObject* pyNetClientComm::GetLog() const
{
return pyStatusLog::New( fNetClient.GetLog() );
}
// SetServerSilenceTime ----------------------------------------------
void pyNetClientComm::SetServerSilenceTime( float secs )
{
fNetClient.SetServerSilenceTime( secs );
}
////////////////////////////////////////////////////////////////////
// End.

View File

@ -0,0 +1,209 @@
/*==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==*/
////////////////////////////////////////////////////////////////////
// pyNetClientComm - python wrapper for plNetClientComm class.
#ifndef pyNetClientComm_h_inc
#define pyNetClientComm_h_inc
#include "../plNetClientComm/plNetClientComm.h"
#include "../plStatusLog/plStatusLog.h"
#include "../FeatureLib/pfPython/pyGlueHelpers.h"
#include <python.h>
////////////////////////////////////////////////////////////////////
class pyAgeLinkStruct;
class pyNetServerSessionInfo;
class pyStatusLog;
class pyNetCore;
////////////////////////////////////////////////////////////////
// plNetClientComm Callback Wrappers
// Message handler for unsolicited msgs or registered
// for specific msg types.
class pyNetClientCommMsgHandler : public plNetClientComm::MsgHandler
{
public:
PyObject* fPyObject;
pyNetClientCommMsgHandler( PyObject* pyObject ): fPyObject( pyObject ) {}
int HandleMessage( plNetMessage* msg );
};
// Receipt handler for changed msg receipts.
class pyNetClientCommRcptHandler : public plNetClientComm::RcptHandler
{
public:
PyObject* fPyObject;
pyNetClientCommRcptHandler( PyObject* pyObject ): fPyObject( pyObject ) {}
void HandleMsgReceipt( plNetCoreMsgReceipt* rcpt );
};
////////////////////////////////////////////////////////////////////
class pyNetClientComm
{
// We contain the plNetClientComm we are wrapping.
plNetClientComm fNetClient;
protected:
////////////////////////////////////////////////////////////////
pyNetClientComm();
public:
~pyNetClientComm();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptNetClientComm);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyNetClientComm object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyNetClientComm); // converts a PyObject to a pyNetClientComm (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
plNetClientComm * GetNetClientComm() { return &fNetClient; }
////////////////////////////////////////////////////////////////
// NETWORK OPERATIONS
// Auth with active server using auth info set earlier.
// Will timeout after maxAuthSecs elapsed.
int NetAuthenticate( double maxAuthSecs, PyObject* cbClass=nil, UInt32 cbContext=0 );
// Leave the active server.
int NetLeave( UInt8 reason, PyObject* cbClass=nil, UInt32 cbContext=0 );
// Ping the specified server.
int NetPing( int serverType, int timeoutSecs=0, PyObject* cbClass=nil, UInt32 cbContext=0 );
// Spawn a game for us.
int NetFindAge( const pyAgeLinkStruct* linkInfo, PyObject* cbClass=nil, UInt32 cbContext=0 );
// Get player list.
int NetGetPlayerList( PyObject* cbClass=nil, UInt32 cbContext=0 );
// Set the active player.
int NetSetActivePlayer( UInt32 playerID, const char* playerName, PyObject* cbClass=nil, UInt32 cbContext=0 );
// Create a player
int NetCreatePlayer( const char* playerName, const char* avatarShape, UInt32 createFlags, PyObject* cbClass=nil, UInt32 cbContext=0 );
// Join age
int NetJoinAge( PyObject* cbClass=nil, UInt32 cbContext=0 );
// Set server-side timeout
int NetSetTimeout( float timeoutSecs, PyObject* cbClass=nil, UInt32 cbContext=0 );
////////////////////////////////////////////////////////////////
// Calls ErrorHandler, if set. Returns value of result
// that was passed in (for use in return/compound statements).
int ReportError( int err, int result );
////////////////////////////////////////////////////////////////
// Get/Set Log object
void SetLog( pyStatusLog* log );
void SetLogByName( const char * name, UInt32 flags=0 );
PyObject* GetLog() const; // return pyStatusLog
// NetCore log level
void SetLogLevel( int logLevel );
// Startup/Shutdown this object
int Init( bool threaded=true, int logLevel=0 );
// flushMsgsSecs: time to spend flushing net msgs queued in net core.
// <0 means no time limit. spin until all msgs are flushed.
int Fini( float flushMsgsSecs=0.f );
// Call this in your update loop.
int Update();
// Access to the NetCore object.
pyNetCore* GetNetCore() const;
// Get/Set Authentication info
int SetAuthInfo( const char* acctName, const char* password );
const char* GetAcctName() const;
const char* GetPassword() const;
// Sets the server we want to communicate with.
int SetActiveServer( pyNetServerSessionInfo* nfo );
int SetActiveServer2( const char * addr, int port );
const pyNetServerSessionInfo* GetActiveServer() const;
// Sets/clears receipt tracking for given message class.
void SetReceiptTrackingForType( UInt16 msgClassIdx, bool on );
// Adds a msg handler for a msg that is convertable to specified type.
void AddMsgHandlerForType( UInt16 msgClassIdx, pyNetClientCommMsgHandler* handler );
// Adds a msg handler for a specific msg type.
void AddMsgHandlerForExactType( UInt16 msgClassIdx, pyNetClientCommMsgHandler* handler );
void RemoveMsgHandler( pyNetClientCommMsgHandler* handler );
// Msgs not part of a task controlled by this
// object, and doesn't have a handler set for its type
// are sent to this handler (if set).
void SetDefaultHandler( pyNetClientCommMsgHandler* msgHandler );
// Changed message rcpts are sent to this handler if set.
void SetMsgReceiptHandler( pyNetClientCommRcptHandler* rcptHandler );
// Send a message to the server.
int SendMsg( plNetMessage* msg, UInt32 sendFlags=0 );
// Send a message to specified peer
int SendMsg( plNetMessage* msg, plNetCore::PeerID peerID, UInt32 sendFlags=0 );
// Set the alive message send frequency. 0 means don't send periodic alive msgs.
void SetAliveFreq( float secs );
float GetAliveFreq() const;
// Set the amount of time before we declare server-silence.
void SetServerSilenceTime( float secs );
float GetServerSilenceTime() const;
// Set the maximum amount of time to spend processing
// incoming msgs per call to Update().
void SetMaxMsgProcessingTime( float secs );
};
////////////////////////////////////////////////////////////////////
#endif // pyNetClientComm_h_inc

View File

@ -0,0 +1,336 @@
/*==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 "pyNetClientComm.h"
#include "../FeatureLib/pfPython/pyEnum.h"
#include "../FeatureLib/pfPython/pyNetServerSessionInfo.h"
#include "../FeatureLib/pfPython/pyAgeLinkStruct.h"
#include "../plNetCommon/plCreatePlayerFlags.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptNetClientComm, pyNetClientComm);
PYTHON_DEFAULT_NEW_DEFINITION(ptNetClientComm, pyNetClientComm)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptNetClientComm)
PYTHON_INIT_DEFINITION(ptNetClientComm, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, initObj, args)
{
char threaded = 1;
int logLevel = 0;
if (!PyArg_ParseTuple(args, "bi", &threaded, &logLevel))
{
PyErr_SetString(PyExc_TypeError, "initObj expects a boolean and an int");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->Init(threaded != 0, logLevel));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, fini, args)
{
float flushMsgsSecs = 0;
if (!PyArg_ParseTuple(args, "f", &flushMsgsSecs))
{
PyErr_SetString(PyExc_TypeError, "fini expects a float");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->Fini(flushMsgsSecs));
}
PYTHON_METHOD_DEFINITION_NOARGS(ptNetClientComm, update)
{
return PyInt_FromLong(self->fThis->Update());
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setActiveServer, args)
{
PyObject* arg1;
int port = 0;
if (!PyArg_ParseTuple(args, "O|i", &arg1, &port))
{
PyErr_SetString(PyExc_TypeError, "setActiveServer expects a string and an int, or a ptNetServerSessionInfo");
PYTHON_RETURN_ERROR;
}
if (pyNetServerSessionInfo::Check(arg1))
{
pyNetServerSessionInfo* info = pyNetServerSessionInfo::ConvertFrom(arg1);
return PyInt_FromLong(self->fThis->SetActiveServer(info));
}
else if (PyString_Check(arg1))
{
char* addr = PyString_AsString(arg1);
return PyInt_FromLong(self->fThis->SetActiveServer2(addr, port));
}
PyErr_SetString(PyExc_TypeError, "setActiveServer expects a string and an int, or a ptNetServerSessionInfo");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setAuthInfo, args)
{
char* account;
char* password;
if (!PyArg_ParseTuple(args, "ss", &account, &password))
{
PyErr_SetString(PyExc_TypeError, "setAuthInfo expects two strings");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->SetAuthInfo(account, password));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, authenticate, args)
{
double maxAuthSecs;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "d|Ol", &maxAuthSecs, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "authenticate expects a double, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetAuthenticate(maxAuthSecs, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, getPlayerList, args)
{
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "|Ol", &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "getPlayerList expects an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetGetPlayerList(cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setActivePlayer, args)
{
unsigned long playerID;
char* playerName;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "ls|Ol", &playerID, &playerName, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "setActivePlayer expects a double, a string, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetSetActivePlayer(playerID, playerName, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, createPlayer, args)
{
char* playerName;
char* avatarShape;
unsigned long createFlags;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "ssl|Ol", &playerName, &avatarShape, &createFlags, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "createPlayer expects two strings, a double, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetCreatePlayer(playerName, avatarShape, createFlags, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, findAge, args)
{
PyObject* linkObj = NULL;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "O|Ol", &linkObj, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "findAge expects a ptAgeLinkStruct, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
if (!pyAgeLinkStruct::Check(linkObj))
{
PyErr_SetString(PyExc_TypeError, "findAge expects a ptAgeLinkStruct, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
pyAgeLinkStruct* link = pyAgeLinkStruct::ConvertFrom(linkObj);
return PyInt_FromLong(self->fThis->NetFindAge(link, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, joinAge, args)
{
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "|Ol", &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "joinAge expects an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetJoinAge(cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, leave, args)
{
unsigned char reason;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "b|Ol", &reason, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "leave expects an unsigned 8-bit int, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetLeave(reason, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, ping, args)
{
int serverType;
int timeoutSecs = 0;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "i|iOl", &serverType, &timeoutSecs, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "ping expects an int, and optional int, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetPing(serverType, timeoutSecs, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setTimeout, args)
{
float timeoutSecs;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "f|Ol", &timeoutSecs, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "setTimeout expects a float, an optional object and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
return PyInt_FromLong(self->fThis->NetSetTimeout(timeoutSecs, cb, context));
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setLog, args)
{
char* name;
unsigned long flags = 0;
if (!PyArg_ParseTuple(args, "s|l", &name, &flags))
{
PyErr_SetString(PyExc_TypeError, "setLog expects a string and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLogByName(name, flags);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptNetClientComm, getLog)
{
return self->fThis->GetLog();
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setLogLevel, args)
{
int level;
if (!PyArg_ParseTuple(args, "i", &level))
{
PyErr_SetString(PyExc_TypeError, "setLogLevel expects an integer");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLogLevel(level);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptNetClientComm, setServerSilenceTime, args)
{
float secs;
if (!PyArg_ParseTuple(args, "f", &secs))
{
PyErr_SetString(PyExc_TypeError, "setServerSilenceTime expects a float");
PYTHON_RETURN_ERROR;
}
self->fThis->SetServerSilenceTime(secs);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptNetClientComm)
PYTHON_METHOD(ptNetClientComm, initObj, "Params: threaded=1,logLevel=0\nInitialize this object"),
PYTHON_METHOD(ptNetClientComm, fini, "Params: flushMsgsSecs=0\nFinalize this object"),
PYTHON_METHOD_NOARGS(ptNetClientComm, update, "Update this object"),
PYTHON_METHOD(ptNetClientComm, setActiveServer, "Params: addr,port\nAlso accepts a ptNetServerSessionInfo instead of address and port"),
PYTHON_METHOD(ptNetClientComm, setAuthInfo, "Params: accountName,password\nSets the authentication info"),
PYTHON_METHOD(ptNetClientComm, authenticate, "Params: maxAuthSecs,callback=None,cbContext=0\nAuthenticate with the server"),
PYTHON_METHOD(ptNetClientComm, getPlayerList, "Params: callback=None,cbContext=0\nGets a list of players and uses the callback"),
PYTHON_METHOD(ptNetClientComm, setActivePlayer, "Params: playerID,playerName,callback=None,cbContext=0\nSets the current active player"),
PYTHON_METHOD(ptNetClientComm, createPlayer, "Params: playerName,avatarShape,createFlags,callback=None,cbContext=0\nCreates a new player"),
PYTHON_METHOD(ptNetClientComm, findAge, "Params: ageLink,callback=None,cbContext=0\nFinds an age based on a ptAgeLinkStruct"),
PYTHON_METHOD(ptNetClientComm, joinAge, "Params: callback=None,cbContext=0\nUNKNOWN"),
PYTHON_METHOD(ptNetClientComm, leave, "Params: reason,callback=None,cbContext=0\nLeaves the lobby"),
PYTHON_METHOD(ptNetClientComm, ping, "Params: serverType,timeoutSecs=0,callback=None,cbContext=0\nPings a server"),
PYTHON_METHOD(ptNetClientComm, setTimeout, "Params: timeoutSecs,callback=None,cbContext=0\nSets the timeout duration"),
PYTHON_METHOD(ptNetClientComm, setLog, "Params: name,flags=0\nUNKNOWN"),
PYTHON_METHOD_NOARGS(ptNetClientComm, getLog, "UNKNOWN"),
PYTHON_METHOD(ptNetClientComm, setLogLevel, "Params: level\nSets the logging level"),
PYTHON_METHOD(ptNetClientComm, setServerSilenceTime, "Params: secs\nUNKNOWN"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptNetClientComm, "UNKNOWN");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptNetClientComm, pyNetClientComm)
PYTHON_CLASS_CHECK_IMPL(ptNetClientComm, pyNetClientComm)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptNetClientComm, pyNetClientComm)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyNetClientComm::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptNetClientComm);
PYTHON_CLASS_IMPORT_END(m);
PYTHON_ENUM_START(PtCreatePlayerFlags);
PYTHON_ENUM_ELEMENT(PtCreatePlayerFlags, kDefaultFlags, plCreatePlayerFlags::kDefaultFlags);
PYTHON_ENUM_ELEMENT(PtCreatePlayerFlags, kNoNeighborhood, plCreatePlayerFlags::kNoNeighborhood);
PYTHON_ENUM_ELEMENT(PtCreatePlayerFlags, kNoCityLink, plCreatePlayerFlags::kNoCityLink);
PYTHON_ENUM_END(m, PtCreatePlayerFlags);
}