mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
Add A_SetUserVarFloat and A_SetUserArrayFloat
This commit is contained in:
parent
299019ea15
commit
b6e3358b1c
2 changed files with 70 additions and 18 deletions
|
@ -4681,22 +4681,46 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpecial)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
|
static PField *GetVar(AActor *self, FName varname)
|
||||||
{
|
{
|
||||||
PARAM_ACTION_PROLOGUE;
|
|
||||||
PARAM_NAME (varname);
|
|
||||||
PARAM_INT (value);
|
|
||||||
|
|
||||||
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
|
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
|
||||||
|
|
||||||
if (var == NULL || (var->Flags & VARF_Native) || !var->Type->IsKindOf(RUNTIME_CLASS(PBasicType)))
|
if (var == NULL || (var->Flags & VARF_Native) || !var->Type->IsKindOf(RUNTIME_CLASS(PBasicType)))
|
||||||
{
|
{
|
||||||
Printf("%s is not a user variable in class %s\n", varname.GetChars(),
|
Printf("%s is not a user variable in class %s\n", varname.GetChars(),
|
||||||
self->GetClass()->TypeName.GetChars());
|
self->GetClass()->TypeName.GetChars());
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
|
||||||
|
{
|
||||||
|
PARAM_ACTION_PROLOGUE;
|
||||||
|
PARAM_NAME (varname);
|
||||||
|
PARAM_INT (value);
|
||||||
|
|
||||||
// Set the value of the specified user variable.
|
// Set the value of the specified user variable.
|
||||||
var->Type->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset, value);
|
PField *var = GetVar(self, varname);
|
||||||
|
if (var != nullptr)
|
||||||
|
{
|
||||||
|
var->Type->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset, value);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVarFloat)
|
||||||
|
{
|
||||||
|
PARAM_ACTION_PROLOGUE;
|
||||||
|
PARAM_NAME (varname);
|
||||||
|
PARAM_FLOAT (value);
|
||||||
|
|
||||||
|
// Set the value of the specified user variable.
|
||||||
|
PField *var = GetVar(self, varname);
|
||||||
|
if (var != nullptr)
|
||||||
|
{
|
||||||
|
var->Type->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset, value);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4706,13 +4730,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
|
static PField *GetArrayVar(AActor *self, FName varname, int pos)
|
||||||
{
|
{
|
||||||
PARAM_ACTION_PROLOGUE;
|
|
||||||
PARAM_NAME (varname);
|
|
||||||
PARAM_INT (pos);
|
|
||||||
PARAM_INT (value);
|
|
||||||
|
|
||||||
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
|
PField *var = dyn_cast<PField>(self->GetClass()->Symbols.FindSymbol(varname, true));
|
||||||
|
|
||||||
if (var == NULL || (var->Flags & VARF_Native) ||
|
if (var == NULL || (var->Flags & VARF_Native) ||
|
||||||
|
@ -4721,17 +4740,48 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
|
||||||
{
|
{
|
||||||
Printf("%s is not a user array in class %s\n", varname.GetChars(),
|
Printf("%s is not a user array in class %s\n", varname.GetChars(),
|
||||||
self->GetClass()->TypeName.GetChars());
|
self->GetClass()->TypeName.GetChars());
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
PArray *arraytype = static_cast<PArray *>(var->Type);
|
if ((unsigned)pos >= static_cast<PArray *>(var->Type)->ElementCount)
|
||||||
if ((unsigned)pos >= arraytype->ElementCount)
|
|
||||||
{
|
{
|
||||||
Printf("%d is out of bounds in array %s in class %s\n", pos, varname.GetChars(),
|
Printf("%d is out of bounds in array %s in class %s\n", pos, varname.GetChars(),
|
||||||
self->GetClass()->TypeName.GetChars());
|
self->GetClass()->TypeName.GetChars());
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
|
||||||
|
{
|
||||||
|
PARAM_ACTION_PROLOGUE;
|
||||||
|
PARAM_NAME (varname);
|
||||||
|
PARAM_INT (pos);
|
||||||
|
PARAM_INT (value);
|
||||||
|
|
||||||
// Set the value of the specified user array at index pos.
|
// Set the value of the specified user array at index pos.
|
||||||
arraytype->ElementType->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset + arraytype->ElementSize * pos, value);
|
PField *var = GetArrayVar(self, varname, pos);
|
||||||
|
if (var != nullptr)
|
||||||
|
{
|
||||||
|
PArray *arraytype = static_cast<PArray *>(var->Type);
|
||||||
|
arraytype->ElementType->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset + arraytype->ElementSize * pos, value);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArrayFloat)
|
||||||
|
{
|
||||||
|
PARAM_ACTION_PROLOGUE;
|
||||||
|
PARAM_NAME (varname);
|
||||||
|
PARAM_INT (pos);
|
||||||
|
PARAM_FLOAT (value);
|
||||||
|
|
||||||
|
// Set the value of the specified user array at index pos.
|
||||||
|
PField *var = GetArrayVar(self, varname, pos);
|
||||||
|
if (var != nullptr)
|
||||||
|
{
|
||||||
|
PArray *arraytype = static_cast<PArray *>(var->Type);
|
||||||
|
arraytype->ElementType->SetValue(reinterpret_cast<BYTE *>(self) + var->Offset + arraytype->ElementSize * pos, value);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,8 @@ ACTOR Actor native //: Thinker
|
||||||
action native A_SetArg(int pos, int value);
|
action native A_SetArg(int pos, int value);
|
||||||
action native A_SetUserVar(name varname, int value);
|
action native A_SetUserVar(name varname, int value);
|
||||||
action native A_SetUserArray(name varname, int index, int value);
|
action native A_SetUserArray(name varname, int index, int value);
|
||||||
|
action native A_SetUserVarFloat(name varname, float value);
|
||||||
|
action native A_SetUserArrayFloat(name varname, int index, float value);
|
||||||
action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
|
action native A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0);
|
||||||
action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
|
action native A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
|
||||||
action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0);
|
action native A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0);
|
||||||
|
|
Loading…
Reference in a new issue