mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
Allow setting string user variables in ACS
This commit is contained in:
parent
4494b18e8a
commit
bd7791ad9c
3 changed files with 13 additions and 9 deletions
|
@ -5065,10 +5065,10 @@ bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType *
|
||||||
}
|
}
|
||||||
addr = baddr;
|
addr = baddr;
|
||||||
// We don't want Int subclasses like Name or Color to be accessible here.
|
// We don't want Int subclasses like Name or Color to be accessible here.
|
||||||
if (!type->isInt() && !type->isFloat() && type != TypeBool)
|
if (!type->isInt() && !type->isFloat() && type != TypeBool && type != TypeString)
|
||||||
{
|
{
|
||||||
// For reading, we also support Name and String types.
|
// For reading, we also support Name types.
|
||||||
if (readonly && (type == TypeName || type == TypeString))
|
if (readonly && (type == TypeName))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5084,13 +5084,18 @@ static void SetUserVariable(AActor *self, FName varname, int index, int value)
|
||||||
|
|
||||||
if (GetVarAddrType(self, varname, index, addr, type, false))
|
if (GetVarAddrType(self, varname, index, addr, type, false))
|
||||||
{
|
{
|
||||||
if (!type->isFloat())
|
if (type == TypeString)
|
||||||
{
|
{
|
||||||
type->SetValue(addr, value);
|
FString str = FBehavior::StaticLookupString(value);
|
||||||
|
type->InitializeValue(addr, &str);
|
||||||
|
}
|
||||||
|
else if (type->isFloat())
|
||||||
|
{
|
||||||
|
type->SetValue(addr, ACSToDouble(value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
type->SetValue(addr, ACSToDouble(value));
|
type->SetValue(addr, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1658,7 +1658,7 @@ static void SetMapThingUserData(AActor *actor, unsigned udi)
|
||||||
else
|
else
|
||||||
{ // Set the value of the specified user variable.
|
{ // Set the value of the specified user variable.
|
||||||
void *addr = reinterpret_cast<uint8_t *>(actor) + var->Offset;
|
void *addr = reinterpret_cast<uint8_t *>(actor) + var->Offset;
|
||||||
if (var->Type->isString())
|
if (var->Type == TypeString)
|
||||||
{
|
{
|
||||||
var->Type->InitializeValue(addr, &MapThingsUserData[udi].StringVal);
|
var->Type->InitializeValue(addr, &MapThingsUserData[udi].StringVal);
|
||||||
}
|
}
|
||||||
|
@ -1666,7 +1666,7 @@ static void SetMapThingUserData(AActor *actor, unsigned udi)
|
||||||
{
|
{
|
||||||
var->Type->SetValue(addr, MapThingsUserData[udi].FloatVal);
|
var->Type->SetValue(addr, MapThingsUserData[udi].FloatVal);
|
||||||
}
|
}
|
||||||
else if (var->Type->isIntCompatible())
|
else if (var->Type->isInt() || var->Type == TypeBool)
|
||||||
{
|
{
|
||||||
var->Type->SetValue(addr, MapThingsUserData[udi].IntVal);
|
var->Type->SetValue(addr, MapThingsUserData[udi].IntVal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,6 @@ public:
|
||||||
bool isStruct() const { return TypeTableType == NAME_Struct; }
|
bool isStruct() const { return TypeTableType == NAME_Struct; }
|
||||||
bool isClass() const { return TypeTableType == NAME_Object; }
|
bool isClass() const { return TypeTableType == NAME_Object; }
|
||||||
bool isPrototype() const { return TypeTableType == NAME_Prototype; }
|
bool isPrototype() const { return TypeTableType == NAME_Prototype; }
|
||||||
bool isString() const { return TypeTableType == NAME_String; }
|
|
||||||
|
|
||||||
PContainerType *toContainer() { return isContainer() ? (PContainerType*)this : nullptr; }
|
PContainerType *toContainer() { return isContainer() ? (PContainerType*)this : nullptr; }
|
||||||
PPointer *toPointer() { return isPointer() ? (PPointer*)this : nullptr; }
|
PPointer *toPointer() { return isPointer() ? (PPointer*)this : nullptr; }
|
||||||
|
|
Loading…
Reference in a new issue