Moved access to ACS instance data out of ScriptUtil worker class

This is better done at a higher level.
This commit is contained in:
Christoph Oelckers 2019-01-07 17:04:16 +01:00
parent 848d9c3750
commit ed3bb2fd09
3 changed files with 9 additions and 8 deletions

View file

@ -677,6 +677,8 @@ public:
void Serialize(FSerializer &arc); void Serialize(FSerializer &arc);
int RunScript(); int RunScript();
PClass *GetClassForIndex(int index) const;
inline void SetState(EScriptState newstate) { state = newstate; } inline void SetState(EScriptState newstate) { state = newstate; }
inline EScriptState GetState() { return state; } inline EScriptState GetState() { return state; }
@ -6759,6 +6761,11 @@ static bool CharArrayParms(int &capacity, int &offset, int &a, FACSStackMemory&
return true; return true;
} }
PClass *DLevelScript::GetClassForIndex(int index) const
{
return PClass::FindActor(level.Behaviors.LookupString(index));
}
int DLevelScript::RunScript () int DLevelScript::RunScript ()
{ {
DACSThinker *controller = level.ACSThinker; DACSThinker *controller = level.ACSThinker;
@ -9618,7 +9625,7 @@ scriptwait:
break; break;
case PCD_SETWEAPON: case PCD_SETWEAPON:
STACK(1) = ScriptUtil::Exec(NAME_SetWeapon, ScriptUtil::Pointer, activator, ScriptUtil::ACSClass, STACK(1), ScriptUtil::End); STACK(1) = ScriptUtil::Exec(NAME_SetWeapon, ScriptUtil::Pointer, activator, ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
break; break;
case PCD_SETMARINEWEAPON: case PCD_SETMARINEWEAPON:
@ -9627,7 +9634,7 @@ scriptwait:
break; break;
case PCD_SETMARINESPRITE: case PCD_SETMARINESPRITE:
ScriptUtil::Exec(NAME_SetMarineSprite, ScriptUtil::Pointer, activator, ScriptUtil::Int, STACK(2), ScriptUtil::ACSClass, STACK(1), ScriptUtil::End); ScriptUtil::Exec(NAME_SetMarineSprite, ScriptUtil::Pointer, activator, ScriptUtil::Int, STACK(2), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
sp -= 2; sp -= 2;
break; break;

View file

@ -60,10 +60,6 @@ void ScriptUtil::BuildParameters(va_list ap)
case Float: case Float:
parameters.Push(VMValue(va_arg(ap, double))); parameters.Push(VMValue(va_arg(ap, double)));
break; break;
case ACSClass:
parameters.Push(VMValue(PClass::FindActor(level.Behaviors.LookupString(va_arg(ap, int)))));
break;
} }
} }
} }

View file

@ -19,8 +19,6 @@ public:
Float, Float,
String, String,
Class, Class,
ACSString, // convenience helpers taking an ACS string index instead of a string
ACSClass,
}; };
static int Exec(FName functionname, ...); static int Exec(FName functionname, ...);