// we'll allow this, just in case something goes weird
char*text=PyString_AsString(textObj);
wchar_t*wText=hsStringToWString(text);
boolretVal=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");
// 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;
}
doubleval=0;
if(PyFloat_Check(valueObj))
val=PyFloat_AsDouble(valueObj);
elseif(PyInt_Check(valueObj))
val=(double)PyInt_AsLong(valueObj);
elseif(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