Allow ACS's GetUserVariable to access non-user variables

- Since DECORATE already allows reading all declared variables in a class,
  where's the utility in keeping this restriction in ACS?
- Variables must still be numeric types.
- SetUserVariable is still restricted to user variables only.
This commit is contained in:
Randy Heit 2016-03-29 22:36:26 -05:00
parent 35121544b4
commit b37ef48e99

View file

@ -4529,12 +4529,12 @@ int DLevelScript::LineFromID(int id)
}
}
bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *&type)
bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *&type, bool allownative)
{
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
PArray *arraytype;
if (var == NULL || (var->Flags & VARF_Native))
if (var == NULL || (!allownative && (var->Flags & VARF_Native)))
{
return false;
}
@ -4557,6 +4557,12 @@ bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *
return false;
}
addr = baddr;
// We don't want Int subclasses like Name or Color to be accessible,
// but we do want to support Float subclasses like Fixed.
if (!type->IsA(RUNTIME_CLASS(PInt)) || !type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
return false;
}
return true;
}
@ -4565,7 +4571,7 @@ static void SetUserVariable(AActor *self, FName varname, int index, int value)
void *addr;
PType *type;
if (GetVarAddrType(self, varname, index, addr, type))
if (GetVarAddrType(self, varname, index, addr, type, false))
{
if (!type->IsKindOf(RUNTIME_CLASS(PFloat)))
{
@ -4583,7 +4589,7 @@ static int GetUserVariable(AActor *self, FName varname, int index)
void *addr;
PType *type;
if (GetVarAddrType(self, varname, index, addr, type))
if (GetVarAddrType(self, varname, index, addr, type, true))
{
if (!type->IsKindOf(RUNTIME_CLASS(PFloat)))
{