mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
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:
parent
35121544b4
commit
b37ef48e99
1 changed files with 10 additions and 4 deletions
|
@ -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)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue