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 )
|
PF_CONSOLE_GROUP( Age )
|
||||||
|
|
||||||
|
plPythonSDLModifier* ExternFindAgePySDL();
|
||||||
|
|
||||||
PF_CONSOLE_CMD(Age, ShowSDL, "", "Prints the age SDL values")
|
PF_CONSOLE_CMD(Age, ShowSDL, "", "Prints the age SDL values")
|
||||||
{
|
{
|
||||||
plStateDataRecord * rec = new plStateDataRecord;
|
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" )
|
PF_CONSOLE_CMD( Age, SetSDLFloat, "string varName, float value, int index", "Set the value of an age global variable" )
|
||||||
{
|
{
|
||||||
int index = (int)params[2];
|
plPythonSDLModifier* sdlMod = ExternFindAgePySDL();
|
||||||
|
if (sdlMod)
|
||||||
extern const plPythonSDLModifier *ExternFindAgePySDL();
|
sdlMod->SetItem((const char*)params[0], (int)params[2], (float)params[1]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PF_CONSOLE_CMD( Age, SetSDLInt, "string varName, int value, int index", "Set the value of an age global variable" )
|
PF_CONSOLE_CMD( Age, SetSDLInt, "string varName, int value, int index", "Set the value of an age global variable" )
|
||||||
{
|
{
|
||||||
int index = (int)params[2];
|
plPythonSDLModifier* sdlMod = ExternFindAgePySDL();
|
||||||
|
if (sdlMod)
|
||||||
extern const plPythonSDLModifier *ExternFindAgePySDL();
|
sdlMod->SetItem((const char*)params[0], (int)params[2], (int)params[1]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set the value of an age global variable" )
|
PF_CONSOLE_CMD( Age, SetSDLBool, "string varName, bool value, int index", "Set the value of an age global variable" )
|
||||||
{
|
{
|
||||||
int index = (int)params[2];
|
plPythonSDLModifier* sdlMod = ExternFindAgePySDL();
|
||||||
|
if (sdlMod)
|
||||||
extern const plPythonSDLModifier *ExternFindAgePySDL();
|
sdlMod->SetItem((const char*)params[0], (int)params[2], (bool)params[1]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // LIMIT_CONSOLE_COMMANDS
|
#endif // LIMIT_CONSOLE_COMMANDS
|
||||||
|
@ -166,18 +166,23 @@ void plPythonSDLModifier::SetItem(const plString& key, PyObject* value)
|
|||||||
IDirtySynchState(key);
|
IDirtySynchState(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plPythonSDLModifier::SetItemFromSDLVar(plSimpleStateVariable* var)
|
template<>
|
||||||
|
void plPythonSDLModifier::SetItem(const plString& key, int index, bool value)
|
||||||
{
|
{
|
||||||
plString name = var->GetName();
|
SetItemIdx(key, index, PyBool_FromLong(value), true);
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
void plPythonSDLModifier::SetDefault(const plString& key, PyObject* value)
|
||||||
{
|
{
|
||||||
@ -578,12 +583,12 @@ const plSDLModifier *ExternFindAgeSDL()
|
|||||||
return plPythonSDLModifier::FindAgeSDL();
|
return plPythonSDLModifier::FindAgeSDL();
|
||||||
}
|
}
|
||||||
|
|
||||||
const plPythonSDLModifier *ExternFindAgePySDL()
|
plPythonSDLModifier* ExternFindAgePySDL()
|
||||||
{
|
{
|
||||||
return plPythonSDLModifier::FindAgeSDL();
|
return plPythonSDLModifier::FindAgeSDL();
|
||||||
}
|
}
|
||||||
|
|
||||||
const plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
|
plPythonSDLModifier* plPythonSDLModifier::FindAgeSDL()
|
||||||
{
|
{
|
||||||
const char* ageName = cyMisc::GetAgeName();
|
const char* ageName = cyMisc::GetAgeName();
|
||||||
|
|
||||||
|
@ -99,11 +99,10 @@ public:
|
|||||||
GETINTERFACE_ANY(plPythonSDLModifier, plSDLModifier);
|
GETINTERFACE_ANY(plPythonSDLModifier, plSDLModifier);
|
||||||
|
|
||||||
virtual const char* GetSDLName() const;
|
virtual const char* GetSDLName() const;
|
||||||
virtual void SetItemFromSDLVar(plSimpleStateVariable* var);
|
|
||||||
|
|
||||||
static bool HasSDL(const plString& pythonFile);
|
static bool HasSDL(const plString& pythonFile);
|
||||||
// find the Age global SDL guy... if there is one
|
// find the Age global SDL guy... if there is one
|
||||||
static const plPythonSDLModifier* FindAgeSDL();
|
static plPythonSDLModifier* FindAgeSDL();
|
||||||
static plKey FindAgeSDLTarget();
|
static plKey FindAgeSDLTarget();
|
||||||
|
|
||||||
void SetDefault(const plString& key, PyObject* value);
|
void SetDefault(const plString& key, PyObject* value);
|
||||||
@ -111,7 +110,11 @@ public:
|
|||||||
void SetNotify(pyKey& selfkey, const plString& key, float tolerance);
|
void SetNotify(pyKey& selfkey, const plString& key, float tolerance);
|
||||||
|
|
||||||
PyObject* GetItem(const plString& key);
|
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 SetItem(const plString& key, PyObject* value);
|
||||||
|
|
||||||
void SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate = false);
|
void SetItemIdx(const plString& key, int idx, PyObject* value, bool sendImmediate = false);
|
||||||
void SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck);
|
void SetFlags(const plString& name, bool sendImmediate, bool skipOwnershipCheck);
|
||||||
void SetTagString(const plString& name, const plString& tag);
|
void SetTagString(const plString& name, const plString& tag);
|
||||||
|
Reference in New Issue
Block a user