Revert "Add PARAM_STATE_NOT_NULL for the A_Jump* functions"

- This reverts commit cab39973df.
  I was wrong. DoJump never allowed jumping to NULL states.
This commit is contained in:
Randy Heit 2016-02-21 19:21:39 -06:00
parent 19af8a3a82
commit 70c663b253
2 changed files with 62 additions and 72 deletions

View file

@ -825,11 +825,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump)
{ {
int jumpnum = (count == 1 ? 0 : (pr_cajump() % count)); int jumpnum = (count == 1 ? 0 : (pr_cajump() % count));
PARAM_STATE_AT(paramnum + jumpnum, jumpto); 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(jumpto);
} }
ACTION_RETURN_STATE(NULL); ACTION_RETURN_STATE(NULL);
@ -843,9 +838,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_INT (health); PARAM_INT (health);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
PARAM_INT_OPT (ptr_selector) { ptr_selector = AAPTR_DEFAULT; } PARAM_INT_OPT (ptr_selector) { ptr_selector = AAPTR_DEFAULT; }
AActor *measured; AActor *measured;
@ -866,7 +861,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
if (!self->CheckMeleeRange()) if (!self->CheckMeleeRange())
{ {
@ -883,7 +878,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
if (self->CheckMeleeRange()) if (self->CheckMeleeRange())
{ {
@ -900,9 +895,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange)
static int DoJumpIfCloser(AActor *target, VM_ARGS) static int DoJumpIfCloser(AActor *target, VM_ARGS)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_FIXED (dist); PARAM_FIXED (dist);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
PARAM_BOOL_OPT (noz) { noz = false; } PARAM_BOOL_OPT(noz) { noz = false; }
if (!target) if (!target)
{ // No target - no jump { // No target - no jump
@ -956,10 +951,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfMasterCloser)
int DoJumpIfInventory(AActor *owner, AActor *self, AActor *stateowner, FState *callingstate, VMValue *param, int numparam, VMReturn *ret, int numret) int DoJumpIfInventory(AActor *owner, AActor *self, AActor *stateowner, FState *callingstate, VMValue *param, int numparam, VMReturn *ret, int numret)
{ {
int paramnum = NAP-1; int paramnum = NAP-1;
PARAM_CLASS (itemtype, AInventory); PARAM_CLASS (itemtype, AInventory);
PARAM_INT (itemamount); PARAM_INT (itemamount);
PARAM_STATE_NOT_NULL(label); PARAM_STATE (label);
PARAM_INT_OPT (setowner) { setowner = AAPTR_DEFAULT; } PARAM_INT_OPT (setowner) { setowner = AAPTR_DEFAULT; }
if (itemtype == NULL) if (itemtype == NULL)
{ {
@ -1010,9 +1005,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetInventory)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfArmorType) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfArmorType)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_NAME (type); PARAM_NAME (type);
PARAM_STATE_NOT_NULL(label); PARAM_STATE (label);
PARAM_INT_OPT (amount) { amount = 1; } PARAM_INT_OPT(amount) { amount = 1; }
ABasicArmor *armor = (ABasicArmor *)self->FindInventory(NAME_BasicArmor); ABasicArmor *armor = (ABasicArmor *)self->FindInventory(NAME_BasicArmor);
@ -1467,7 +1462,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
if (!ACTION_CALL_FROM_WEAPON()) if (!ACTION_CALL_FROM_WEAPON())
{ {
@ -3034,7 +3029,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
for (int i = 0; i < MAXPLAYERS; i++) for (int i = 0; i < MAXPLAYERS; i++)
{ {
@ -3102,9 +3097,9 @@ static bool DoCheckSightOrRange(AActor *self, AActor *camera, double range, bool
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_FLOAT (range); PARAM_FLOAT(range);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
PARAM_BOOL_OPT (twodi) { twodi = false; } PARAM_BOOL_OPT(twodi) { twodi = false; }
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
for (int i = 0; i < MAXPLAYERS; ++i) for (int i = 0; i < MAXPLAYERS; ++i)
@ -3167,9 +3162,9 @@ static bool DoCheckRange(AActor *self, AActor *camera, double range, bool twodi)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckRange) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckRange)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_FLOAT (range); PARAM_FLOAT(range);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
PARAM_BOOL_OPT (twodi) { twodi = false; } PARAM_BOOL_OPT(twodi) { twodi = false; }
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
for (int i = 0; i < MAXPLAYERS; ++i) for (int i = 0; i < MAXPLAYERS; ++i)
@ -3250,8 +3245,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetBlend)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_BOOL (condition); PARAM_BOOL (condition);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
ACTION_RETURN_STATE(condition ? jump : NULL); ACTION_RETURN_STATE(condition ? jump : NULL);
} }
@ -3354,7 +3349,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
if (self->Z() <= self->floorz) if (self->Z() <= self->floorz)
{ {
@ -3373,7 +3368,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
if (self->Top() >= self->ceilingz) // Height needs to be counted if (self->Top() >= self->ceilingz) // Height needs to be counted
{ {
@ -3509,7 +3504,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
if (self->player != NULL && if (self->player != NULL &&
skins[self->player->userinfo.GetSkin()].othergame) skins[self->player->userinfo.GetSkin()].othergame)
@ -3692,10 +3687,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
fixed_t vx, vy, vz; fixed_t vx, vy, vz;
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_FIXED_OPT (range) { range = 0; } PARAM_FIXED_OPT (range) { range = 0; }
PARAM_FIXED_OPT (minrange) { minrange = 0; } PARAM_FIXED_OPT (minrange) { minrange = 0; }
{ {
PARAM_ANGLE_OPT (angle) { angle = 0; } PARAM_ANGLE_OPT (angle) { angle = 0; }
PARAM_ANGLE_OPT (pitch) { pitch = 0; } PARAM_ANGLE_OPT (pitch) { pitch = 0; }
@ -3892,11 +3887,11 @@ enum JLOS_flags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
PARAM_ANGLE_OPT (fov) { fov = 0; } PARAM_ANGLE_OPT (fov) { fov = 0; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_FIXED_OPT (dist_max) { dist_max = 0; } PARAM_FIXED_OPT (dist_max) { dist_max = 0; }
PARAM_FIXED_OPT (dist_close) { dist_close = 0; } PARAM_FIXED_OPT (dist_close) { dist_close = 0; }
angle_t an; angle_t an;
AActor *target, *viewport; AActor *target, *viewport;
@ -4027,11 +4022,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
PARAM_ANGLE_OPT (fov) { fov = 0; } PARAM_ANGLE_OPT (fov) { fov = 0; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_FIXED_OPT (dist_max) { dist_max = 0; } PARAM_FIXED_OPT (dist_max) { dist_max = 0; }
PARAM_FIXED_OPT (dist_close) { dist_close = 0; } PARAM_FIXED_OPT (dist_close) { dist_close = 0; }
angle_t an; angle_t an;
AActor *target; AActor *target;
@ -4114,9 +4109,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload)
{ {
ACTION_RETURN_STATE(NULL); ACTION_RETURN_STATE(NULL);
} }
PARAM_INT (count); PARAM_INT (count);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
PARAM_BOOL_OPT (dontincrement) { dontincrement = false; } PARAM_BOOL_OPT (dontincrement) { dontincrement = false; }
if (numret > 0) if (numret > 0)
{ {
@ -4278,9 +4273,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STRING (flagname); PARAM_STRING (flagname);
PARAM_STATE_NOT_NULL(jumpto); PARAM_STATE (jumpto);
PARAM_INT_OPT (checkpointer) { checkpointer = AAPTR_DEFAULT; } PARAM_INT_OPT (checkpointer) { checkpointer = AAPTR_DEFAULT; }
AActor *owner = COPY_AAPTR(self, checkpointer); AActor *owner = COPY_AAPTR(self, checkpointer);
if (owner == NULL) if (owner == NULL)
@ -4385,8 +4380,8 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_FaceConsolePlayer)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_INT (prob); PARAM_INT (prob);
PARAM_STATE_NOT_NULL(jump); PARAM_STATE (jump);
A_FaceTarget(self); A_FaceTarget(self);
@ -5215,7 +5210,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp)
if (P_Thing_Warp(self, reference, xofs, yofs, zofs, angle, flags, heightoffset, radiusoffset, pitch)) if (P_Thing_Warp(self, reference, xofs, yofs, zofs, angle, flags, heightoffset, radiusoffset, pitch))
{ {
if (success_state != NULL) if (success_state)
{ {
// Jumps should never set the result for inventory state chains! // 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. // in this case, you have the statejump to help you handle all the success anyway.
@ -5559,9 +5554,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSpecies) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSpecies)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
PARAM_NAME_OPT (species) { species = NAME_None; } PARAM_NAME_OPT(species) { species = NAME_None; }
PARAM_INT_OPT (ptr) { ptr = AAPTR_DEFAULT; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
AActor *mobj = COPY_AAPTR(self, ptr); AActor *mobj = COPY_AAPTR(self, ptr);
@ -6359,12 +6354,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ResetHealth)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHigherOrLower)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(high); PARAM_STATE(high);
PARAM_STATE_NOT_NULL(low); PARAM_STATE(low);
PARAM_FIXED_OPT (offsethigh) { offsethigh = 0; } PARAM_FIXED_OPT(offsethigh) { offsethigh = 0; }
PARAM_FIXED_OPT (offsetlow) { offsetlow = 0; } PARAM_FIXED_OPT(offsetlow) { offsetlow = 0; }
PARAM_BOOL_OPT (includeHeight) { includeHeight = true; } PARAM_BOOL_OPT(includeHeight) { includeHeight = true; }
PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; } PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
AActor *mobj = COPY_AAPTR(self, ptr); AActor *mobj = COPY_AAPTR(self, ptr);
@ -6500,7 +6495,7 @@ enum CPXFflags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(jump); PARAM_STATE(jump);
PARAM_CLASS(classname, AActor); PARAM_CLASS(classname, AActor);
PARAM_FIXED(distance); PARAM_FIXED(distance);
PARAM_INT_OPT(count) { count = 1; } PARAM_INT_OPT(count) { count = 1; }
@ -6655,7 +6650,7 @@ enum CBF
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE_NOT_NULL(block); PARAM_STATE(block)
PARAM_INT_OPT(flags) { flags = 0; } PARAM_INT_OPT(flags) { flags = 0; }
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }

View file

@ -951,9 +951,4 @@ 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_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) #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 #endif