mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
@ -5931,6 +5931,8 @@ PF_CONSOLE_CMD( Mouse, ForceHide, "bool force", "Forces the mouse to be hidden (
|
||||
|
||||
PF_CONSOLE_GROUP( Age )
|
||||
|
||||
plPythonSDLModifier* ExternFindAgePySDL();
|
||||
|
||||
PF_CONSOLE_CMD(Age, ShowSDL, "", "Prints the age SDL values")
|
||||
{
|
||||
plStateDataRecord * rec = new plStateDataRecord;
|
||||
@ -6002,72 +6004,23 @@ PF_CONSOLE_CMD( Age, GetTimeOfDay, "string agedefnfile", "Gets the elapsed days
|
||||
|
||||
PF_CONSOLE_CMD( Age, SetSDLFloat, "string varName, float value, int index", "Set the value of an age global variable" )
|
||||
{
|
||||
int index = (int)params[2];
|
||||
|
||||
extern const plPythonSDLModifier *ExternFindAgePySDL();
|
||||
const plPythonSDLModifier *sdlMod = ExternFindAgePySDL();
|
||||
if (!sdlMod)
|
||||
return;
|
||||
|
||||
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char *)params[0]);
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
float v;
|
||||
var->Get(&v, index);
|
||||
var->Set((float)params[1], index);
|
||||
// set the variable in the pythonSDL also
|
||||
((plPythonSDLModifier*)sdlMod)->SetItemFromSDLVar(var);
|
||||
// set it back to original so that its different
|
||||
plSynchedObject* p = plSynchedObject::ConvertNoRef(((plSDLModifier*)sdlMod)->GetStateOwnerKey()->GetObjectPtr());
|
||||
if (p)
|
||||
p->DirtySynchState(sdlMod->GetSDLName(),plSynchedObject::kSendImmediately|plSynchedObject::kSkipLocalOwnershipCheck|plSynchedObject::kForceFullSend);
|
||||
plPythonSDLModifier* sdlMod = ExternFindAgePySDL();
|
||||
if (sdlMod)
|
||||
sdlMod->SetItem((const char*)params[0], (int)params[2], (float)params[1]);
|
||||
}
|
||||
|
||||
PF_CONSOLE_CMD( Age, SetSDLInt, "string varName, int value, int index", "Set the value of an age global variable" )
|
||||
{
|
||||
int index = (int)params[2];
|
||||
|
||||
extern const plPythonSDLModifier *ExternFindAgePySDL();
|
||||
const plPythonSDLModifier *sdlMod = ExternFindAgePySDL();
|
||||
if (!sdlMod)
|
||||
return;
|
||||
|
||||
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char *)params[0]);
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
int v;
|
||||
var->Get(&v, index);
|
||||
var->Set((int)params[1], index);
|
||||
// set the variable in the pythonSDL also
|
||||
((plPythonSDLModifier*)sdlMod)->SetItemFromSDLVar(var);
|
||||
plSynchedObject* p = plSynchedObject::ConvertNoRef(((plSDLModifier*)sdlMod)->GetStateOwnerKey()->GetObjectPtr());
|
||||
if (p)
|
||||
p->DirtySynchState(sdlMod->GetSDLName(),plSynchedObject::kSendImmediately|plSynchedObject::kSkipLocalOwnershipCheck|plSynchedObject::kForceFullSend);
|
||||
plPythonSDLModifier* sdlMod = ExternFindAgePySDL();
|
||||
if (sdlMod)
|
||||
sdlMod->SetItem((const char*)params[0], (int)params[2], (int)params[1]);
|
||||
}
|
||||
|
||||
PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set the value of an age global variable" )
|
||||
{
|
||||
int index = (int)params[2];
|
||||
|
||||
extern const plPythonSDLModifier *ExternFindAgePySDL();
|
||||
const plPythonSDLModifier *sdlMod = ExternFindAgePySDL();
|
||||
if (!sdlMod)
|
||||
return;
|
||||
|
||||
plSimpleStateVariable *var = sdlMod->GetStateCache()->FindVar((const char*)params[0]);
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
bool v;
|
||||
var->Get(&v, index);
|
||||
var->Set((bool)params[1], index);
|
||||
// set the variable in the pythonSDL also
|
||||
((plPythonSDLModifier*)sdlMod)->SetItemFromSDLVar(var);
|
||||
plSynchedObject* p = plSynchedObject::ConvertNoRef(((plSDLModifier*)sdlMod)->GetStateOwnerKey()->GetObjectPtr());
|
||||
if (p)
|
||||
p->DirtySynchState(sdlMod->GetSDLName(),plSynchedObject::kSendImmediately|plSynchedObject::kSkipLocalOwnershipCheck|plSynchedObject::kForceFullSend);
|
||||
plPythonSDLModifier* sdlMod = ExternFindAgePySDL();
|
||||
if (sdlMod)
|
||||
sdlMod->SetItem((const char*)params[0], (int)params[2], (bool)params[1]);
|
||||
}
|
||||
|
||||
#endif // LIMIT_CONSOLE_COMMANDS
|
||||
|
@ -166,18 +166,23 @@ void plPythonSDLModifier::SetItem(const plString& key, PyObject* value)
|
||||
IDirtySynchState(key);
|
||||
}
|
||||
|
||||
void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
|
||||
template<>
|
||||
void plPythonSDLModifier::SetItem(const plString& key, int index, bool value)
|
||||
{
|
||||
plString name = var->GetName();
|
||||
|
||||
// Get the SDL value in Python format
|
||||
PyObject* pyVar = ISDLVarToPython(var);
|
||||
|
||||
ISetItem(name, pyVar);
|
||||
Py_XDECREF(pyVar);
|
||||
// let the sender do the dirty sync state stuff
|
||||
SetItemIdx(key, index, PyBool_FromLong(value), true);
|
||||
}
|
||||
|
||||
template<>
|
||||
void plPythonSDLModifier::SetItem(const plString& key, int index, float value)
|
||||
{
|
||||
SetItemIdx(key, index, PyFloat_FromDouble(value), true);
|
||||
}
|
||||
|
||||
template<>
|
||||
void plPythonSDLModifier::SetItem(const plString& key, int index, int value)
|
||||
{
|
||||
SetItemIdx(key, index, PyLong_FromLong(value), true);
|
||||
}
|
||||
|
||||
void plPythonSDLModifier::SetDefault(const plString& key, PyObject* value)
|
||||
{
|
||||
@ -578,12 +583,12 @@ const plSDLModifier *ExternFindAgeSDL()
|
||||
return plPythonSDLModifier::FindAgeSDL();
|
||||
}
|
||||
|
||||
const plPythonSDLModifier *ExternFindAgePySDL()
|
||||
plPythonSDLModifier* ExternFindAgePySDL()
|
||||
{
|
||||
return plPythonSDLModifier::FindAgeSDL();
|
||||
}
|
||||
|
||||
const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
|
||||
plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
|
||||
{
|
||||
const char* ageName = cyMisc::GetAgeName();
|
||||
|
||||
@ -694,48 +699,48 @@ PyObject* pySDLModifier::GetAgeSDL()
|
||||
}
|
||||
|
||||
|
||||
void pySDLModifier::SetDefault(pySDLModifier& self, std::string key, PyObject* value)
|
||||
void pySDLModifier::SetDefault(pySDLModifier& self, const plString& key, PyObject* value)
|
||||
{
|
||||
self.fRecord->SetDefault(key.c_str(), value);
|
||||
self.fRecord->SetDefault(key, value);
|
||||
}
|
||||
|
||||
void pySDLModifier::SendToClients(pySDLModifier& self, std::string key)
|
||||
void pySDLModifier::SendToClients(pySDLModifier& self, const plString& key)
|
||||
{
|
||||
self.fRecord->SendToClients(key.c_str());
|
||||
self.fRecord->SendToClients(key);
|
||||
}
|
||||
|
||||
void pySDLModifier::SetNotify(pySDLModifier& self, pyKey& selfkey, std::string key, float tolerance)
|
||||
void pySDLModifier::SetNotify(pySDLModifier& self, pyKey& selfkey, const plString& key, float tolerance)
|
||||
{
|
||||
self.fRecord->SetNotify(selfkey, key.c_str(), tolerance);
|
||||
self.fRecord->SetNotify(selfkey, key, tolerance);
|
||||
}
|
||||
|
||||
PyObject* pySDLModifier::GetItem(pySDLModifier& self, std::string key)
|
||||
PyObject* pySDLModifier::GetItem(pySDLModifier& self, const plString& key)
|
||||
{
|
||||
return self.fRecord->GetItem(key.c_str());
|
||||
return self.fRecord->GetItem(key);
|
||||
}
|
||||
|
||||
void pySDLModifier::SetItem(pySDLModifier& self, std::string key, PyObject* value)
|
||||
void pySDLModifier::SetItem(pySDLModifier& self, const plString& key, PyObject* value)
|
||||
{
|
||||
self.fRecord->SetItem(key.c_str(), value);
|
||||
self.fRecord->SetItem(key, value);
|
||||
}
|
||||
|
||||
|
||||
void pySDLModifier::SetItemIdx(pySDLModifier& self, std::string key, int idx, PyObject* value)
|
||||
void pySDLModifier::SetItemIdx(pySDLModifier& self, const plString& key, int idx, PyObject* value)
|
||||
{
|
||||
self.fRecord->SetItemIdx(key.c_str(), idx, value);
|
||||
self.fRecord->SetItemIdx(key, idx, value);
|
||||
}
|
||||
|
||||
void pySDLModifier::SetItemIdxImmediate(pySDLModifier& self, std::string key, int idx, PyObject* value)
|
||||
void pySDLModifier::SetItemIdxImmediate(pySDLModifier& self, const plString& key, int idx, PyObject* value)
|
||||
{
|
||||
self.fRecord->SetItemIdx(key.c_str(), idx, value, true);
|
||||
self.fRecord->SetItemIdx(key, idx, value, true);
|
||||
}
|
||||
|
||||
void pySDLModifier::SetFlags(pySDLModifier& self, const char* name, bool sendImmediate, bool skipOwnershipCheck)
|
||||
void pySDLModifier::SetFlags(pySDLModifier& self, const plString& name, bool sendImmediate, bool skipOwnershipCheck)
|
||||
{
|
||||
self.fRecord->SetFlags(name,sendImmediate,skipOwnershipCheck);
|
||||
}
|
||||
|
||||
void pySDLModifier::SetTagString(pySDLModifier& self, const char* name, const char* tag)
|
||||
void pySDLModifier::SetTagString(pySDLModifier& self, const plString& name, const plString& tag)
|
||||
{
|
||||
self.fRecord->SetTagString(name,tag);
|
||||
}
|
||||
|
@ -99,11 +99,10 @@ public:
|
||||
GETINTERFACE_ANY(plPythonSDLModifier, plSDLModifier);
|
||||
|
||||
virtual const char* GetSDLName() const;
|
||||
virtual void SetItemFromSDLVar(plSimpleStateVariable* var);
|
||||
|
||||
static bool HasSDL(const plString& pythonFile);
|
||||
// find the Age global SDL guy... if there is one
|
||||
static const plPythonSDLModifier* FindAgeSDL();
|
||||
static plPythonSDLModifier* FindAgeSDL();
|
||||
static plKey FindAgeSDLTarget();
|
||||
|
||||
void SetDefault(const plString& key, PyObject* value);
|
||||
@ -111,7 +110,11 @@ public:
|
||||
void SetNotify(pyKey& selfkey, const plString& key, float tolerance);
|
||||
|
||||
PyObject* GetItem(const plString& key);
|
||||
|
||||
template<typename T>
|
||||
void SetItem(const plString& key, int index, T value);
|
||||
void SetItem(const plString& key, PyObject* value);
|
||||
|
||||
void SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate = false);
|
||||
void SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck);
|
||||
void SetTagString(const plString& name, const plString& tag);
|
||||
@ -139,16 +142,16 @@ public:
|
||||
// global function to get the GrandMaster Age SDL object
|
||||
static PyObject* GetAgeSDL();
|
||||
|
||||
static void SetDefault(pySDLModifier& self, std::string key, PyObject* value);
|
||||
static void SendToClients(pySDLModifier& self, std::string key);
|
||||
static void SetNotify(pySDLModifier& self, pyKey& selfkey, std::string key, float tolerance);
|
||||
static void SetDefault(pySDLModifier& self, const plString& key, PyObject* value);
|
||||
static void SendToClients(pySDLModifier& self, const plString& key);
|
||||
static void SetNotify(pySDLModifier& self, pyKey& selfkey, const plString& key, float tolerance);
|
||||
|
||||
static PyObject* GetItem(pySDLModifier& self, std::string key);
|
||||
static void SetItem(pySDLModifier& self, std::string key, PyObject* value);
|
||||
static void SetItemIdx(pySDLModifier& self, std::string key, int idx, PyObject* value);
|
||||
static void SetItemIdxImmediate(pySDLModifier& self, std::string key, int idx, PyObject* value);
|
||||
static void SetFlags(pySDLModifier& self, const char* name, bool sendImmediate, bool skipOwnershipCheck);
|
||||
static void SetTagString(pySDLModifier& self, const char* name, const char* tag);
|
||||
static PyObject* GetItem(pySDLModifier& self, const plString& key);
|
||||
static void SetItem(pySDLModifier& self, const plString& key, PyObject* value);
|
||||
static void SetItemIdx(pySDLModifier& self, const plString& key, int idx, PyObject* value);
|
||||
static void SetItemIdxImmediate(pySDLModifier& self, const plString& key, int idx, PyObject* value);
|
||||
static void SetFlags(pySDLModifier& self, const plString& name, bool sendImmediate, bool skipOwnershipCheck);
|
||||
static void SetTagString(pySDLModifier& self, const plString& name, const plString& tag);
|
||||
|
||||
};
|
||||
|
||||
|
@ -76,7 +76,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setIndexNow, args)
|
||||
char* key;
|
||||
int idx;
|
||||
PyObject* value = NULL;
|
||||
if (!PyArg_ParseTuple(args, "siO", &key, &idx, &value))
|
||||
if (!PyArg_ParseTuple(args, "etiO", "utf8", &key, &idx, &value))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setIndexNow expects a string, int, and an object");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -89,7 +89,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setDefault, args)
|
||||
{
|
||||
char* key;
|
||||
PyObject* value = NULL;
|
||||
if (!PyArg_ParseTuple(args, "sO", &key, &value))
|
||||
if (!PyArg_ParseTuple(args, "etO", "utf8", &key, &value))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setDefault expects a string and a tuple");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -106,7 +106,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setDefault, args)
|
||||
PYTHON_METHOD_DEFINITION(ptSDL, sendToClients, args)
|
||||
{
|
||||
char* key;
|
||||
if (!PyArg_ParseTuple(args, "s", &key))
|
||||
if (!PyArg_ParseTuple(args, "et", "utf8", &key))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "sendToClients expects a string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -120,7 +120,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setNotify, args)
|
||||
PyObject* selfKeyObj;
|
||||
char* key;
|
||||
float tolerance;
|
||||
if (!PyArg_ParseTuple(args, "Osf", &selfKeyObj, &key, &tolerance))
|
||||
if (!PyArg_ParseTuple(args, "Oetf", &selfKeyObj, "utf8", &key, &tolerance))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setNotify expects a ptKey, string, and float");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -139,7 +139,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setFlags, args)
|
||||
{
|
||||
char* key;
|
||||
char sendImmediate, skipOwnershipCheck;
|
||||
if (!PyArg_ParseTuple(args, "sbb", &key, &sendImmediate, &skipOwnershipCheck))
|
||||
if (!PyArg_ParseTuple(args, "etbb", "utf8", &key, &sendImmediate, &skipOwnershipCheck))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setFlags expects a string and two booleans");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -152,7 +152,7 @@ PYTHON_METHOD_DEFINITION(ptSDL, setTagString, args)
|
||||
{
|
||||
char* key;
|
||||
char* tag;
|
||||
if (!PyArg_ParseTuple(args, "ss", &key, &tag))
|
||||
if (!PyArg_ParseTuple(args, "etet", "utf8", &key, "utf8", &tag))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "setTagString expects two strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
@ -179,12 +179,12 @@ PYTHON_END_METHODS_TABLE;
|
||||
|
||||
PyObject* ptSDL_subscript(ptSDL* self, PyObject* key)
|
||||
{
|
||||
if (!PyString_Check(key))
|
||||
if (!PyString_CheckEx(key))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
char *keyStr = PyString_AsString(key);
|
||||
plString keyStr = PyString_AsStringEx(key);
|
||||
return pySDLModifier::GetItem(*(self->fThis), keyStr);
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ int ptSDL_ass_subscript(ptSDL* self, PyObject* key, PyObject* value)
|
||||
PyErr_SetString(PyExc_RuntimeError, "Cannot remove sdl records");
|
||||
return -1; // error return
|
||||
}
|
||||
if (!PyString_Check(key))
|
||||
if (!PyString_CheckEx(key))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
|
||||
return -1; // error return
|
||||
@ -205,7 +205,7 @@ int ptSDL_ass_subscript(ptSDL* self, PyObject* key, PyObject* value)
|
||||
PyErr_SetString(PyExc_TypeError, "SDL values must be tuples");
|
||||
return -1; // error return
|
||||
}
|
||||
char* keyStr = PyString_AsString(key);
|
||||
plString keyStr = PyString_AsStringEx(key);
|
||||
pySDLModifier::SetItem(*(self->fThis), keyStr, value);
|
||||
return 0; // success return
|
||||
}
|
||||
|
Reference in New Issue
Block a user