mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Fix Age.SetSDL commands...
- General code cleanups - Don't send the entire SDL blob. This is wasteful. - Actually update the doggone state immediately. Don't screw around!
This commit is contained in:
@ -5932,6 +5932,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;
|
||||
@ -6003,72 +6005,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();
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user