mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-17 17:41:23 +00:00
Add PARAM_STATE_NOT_NULL for the A_Jump* functions
- Now that state jumps are handled by returning a state, we still need a way for them to jump to a NULL state. If the parameter processed by this macro turns out to be NULL, Actor's 'Null' state will be substituted instead, since that's something that can be jumped to.
This commit is contained in:
parent
5e298173f7
commit
cab39973df
2 changed files with 72 additions and 62 deletions
|
@ -825,6 +825,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump)
|
|||
{
|
||||
int jumpnum = (count == 1 ? 0 : (pr_cajump() % count));
|
||||
PARAM_STATE_AT(paramnum + jumpnum, jumpto);
|
||||
if (jumpto == NULL)
|
||||
{ // Remap NULL state to the 'Null' state found in Actor, since
|
||||
// returning NULL would not jump.
|
||||
jumpto = RUNTIME_CLASS(AActor)->FindState(NAME_Null);
|
||||
}
|
||||
ACTION_RETURN_STATE(jumpto);
|
||||
}
|
||||
ACTION_RETURN_STATE(NULL);
|
||||
|
@ -839,7 +844,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_INT (health);
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_INT_OPT (ptr_selector) { ptr_selector = AAPTR_DEFAULT; }
|
||||
|
||||
AActor *measured;
|
||||
|
@ -861,7 +866,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
if (!self->CheckMeleeRange())
|
||||
{
|
||||
|
@ -878,7 +883,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
if (self->CheckMeleeRange())
|
||||
{
|
||||
|
@ -896,7 +901,7 @@ static int DoJumpIfCloser(AActor *target, VM_ARGS)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_FIXED (dist);
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_BOOL_OPT (noz) { noz = false; }
|
||||
|
||||
if (!target)
|
||||
|
@ -953,7 +958,7 @@ int DoJumpIfInventory(AActor *owner, AActor *self, AActor *stateowner, FState *c
|
|||
int paramnum = NAP-1;
|
||||
PARAM_CLASS (itemtype, AInventory);
|
||||
PARAM_INT (itemamount);
|
||||
PARAM_STATE (label);
|
||||
PARAM_STATE_NOT_NULL(label);
|
||||
PARAM_INT_OPT (setowner) { setowner = AAPTR_DEFAULT; }
|
||||
|
||||
if (itemtype == NULL)
|
||||
|
@ -1006,7 +1011,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfArmorType)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_NAME (type);
|
||||
PARAM_STATE (label);
|
||||
PARAM_STATE_NOT_NULL(label);
|
||||
PARAM_INT_OPT (amount) { amount = 1; }
|
||||
|
||||
ABasicArmor *armor = (ABasicArmor *)self->FindInventory(NAME_BasicArmor);
|
||||
|
@ -1462,7 +1467,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
if (!ACTION_CALL_FROM_WEAPON())
|
||||
{
|
||||
|
@ -3029,7 +3034,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
|
@ -3098,7 +3103,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_FLOAT (range);
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_BOOL_OPT (twodi) { twodi = false; }
|
||||
|
||||
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
|
||||
|
@ -3163,7 +3168,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckRange)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_FLOAT (range);
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_BOOL_OPT (twodi) { twodi = false; }
|
||||
|
||||
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
|
||||
|
@ -3246,7 +3251,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_BOOL (condition);
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
ACTION_RETURN_STATE(condition ? jump : NULL);
|
||||
}
|
||||
|
@ -3349,7 +3354,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
if (self->Z() <= self->floorz)
|
||||
{
|
||||
|
@ -3368,7 +3373,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
if (self->Top() >= self->ceilingz) // Height needs to be counted
|
||||
{
|
||||
|
@ -3504,7 +3509,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
if (self->player != NULL &&
|
||||
skins[self->player->userinfo.GetSkin()].othergame)
|
||||
|
@ -3687,7 +3692,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
|
|||
fixed_t vx, vy, vz;
|
||||
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_INT_OPT (flags) { flags = 0; }
|
||||
PARAM_FIXED_OPT (range) { range = 0; }
|
||||
PARAM_FIXED_OPT (minrange) { minrange = 0; }
|
||||
|
@ -3887,7 +3892,7 @@ enum JLOS_flags
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_ANGLE_OPT (fov) { fov = 0; }
|
||||
PARAM_INT_OPT (flags) { flags = 0; }
|
||||
PARAM_FIXED_OPT (dist_max) { dist_max = 0; }
|
||||
|
@ -4022,7 +4027,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_ANGLE_OPT (fov) { fov = 0; }
|
||||
PARAM_INT_OPT (flags) { flags = 0; }
|
||||
PARAM_FIXED_OPT (dist_max) { dist_max = 0; }
|
||||
|
@ -4110,7 +4115,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload)
|
|||
ACTION_RETURN_STATE(NULL);
|
||||
}
|
||||
PARAM_INT (count);
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_BOOL_OPT (dontincrement) { dontincrement = false; }
|
||||
|
||||
if (numret > 0)
|
||||
|
@ -4274,7 +4279,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STRING (flagname);
|
||||
PARAM_STATE (jumpto);
|
||||
PARAM_STATE_NOT_NULL(jumpto);
|
||||
PARAM_INT_OPT (checkpointer) { checkpointer = AAPTR_DEFAULT; }
|
||||
|
||||
AActor *owner = COPY_AAPTR(self, checkpointer);
|
||||
|
@ -4381,7 +4386,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire)
|
|||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_INT (prob);
|
||||
PARAM_STATE (jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
|
||||
A_FaceTarget(self);
|
||||
|
||||
|
@ -5210,7 +5215,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp)
|
|||
|
||||
if (P_Thing_Warp(self, reference, xofs, yofs, zofs, angle, flags, heightoffset, radiusoffset, pitch))
|
||||
{
|
||||
if (success_state)
|
||||
if (success_state != NULL)
|
||||
{
|
||||
// Jumps should never set the result for inventory state chains!
|
||||
// in this case, you have the statejump to help you handle all the success anyway.
|
||||
|
@ -5554,7 +5559,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSpecies)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_NAME_OPT (species) { species = NAME_None; }
|
||||
PARAM_INT_OPT (ptr) { ptr = AAPTR_DEFAULT; }
|
||||
|
||||
|
@ -6354,8 +6359,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ResetHealth)
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(high);
|
||||
PARAM_STATE(low);
|
||||
PARAM_STATE_NOT_NULL(high);
|
||||
PARAM_STATE_NOT_NULL(low);
|
||||
PARAM_FIXED_OPT (offsethigh) { offsethigh = 0; }
|
||||
PARAM_FIXED_OPT (offsetlow) { offsetlow = 0; }
|
||||
PARAM_BOOL_OPT (includeHeight) { includeHeight = true; }
|
||||
|
@ -6495,7 +6500,7 @@ enum CPXFflags
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(jump);
|
||||
PARAM_STATE_NOT_NULL(jump);
|
||||
PARAM_CLASS(classname, AActor);
|
||||
PARAM_FIXED(distance);
|
||||
PARAM_INT_OPT(count) { count = 1; }
|
||||
|
@ -6650,7 +6655,7 @@ enum CBF
|
|||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_STATE(block)
|
||||
PARAM_STATE_NOT_NULL(block);
|
||||
PARAM_INT_OPT(flags) { flags = 0; }
|
||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
|
||||
|
||||
|
|
|
@ -951,4 +951,9 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
|
|||
#define PARAM_OBJECT_OPT(x,type) ++paramnum; PARAM_OBJECT_OPT_AT(paramnum,x,type)
|
||||
#define PARAM_CLASS_OPT(x,base) ++paramnum; PARAM_CLASS_OPT_AT(paramnum,x,base)
|
||||
|
||||
// For use in the A_Jump* family of functions. If the function is passed a NULL state,
|
||||
// it still needs to be able to jump (and destroy the actor), so map it to Actor's
|
||||
// 'Null' state.
|
||||
#define PARAM_STATE_NOT_NULL(x) PARAM_STATE(x); do { if (x == NULL) { x = RUNTIME_CLASS(AActor)->FindState(NAME_Null); } } while(0)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue