diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1dfb1145a..7cbfd69b4 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4216,28 +4216,7 @@ int DLevelScript::GetPlayerInput(int playernum, int inputnum) return 0; } - switch (inputnum) - { - case INPUT_OLDBUTTONS: return p->original_oldbuttons; break; - case INPUT_BUTTONS: return p->original_cmd.buttons; break; - case INPUT_PITCH: return p->original_cmd.pitch; break; - case INPUT_YAW: return p->original_cmd.yaw; break; - case INPUT_ROLL: return p->original_cmd.roll; break; - case INPUT_FORWARDMOVE: return p->original_cmd.forwardmove; break; - case INPUT_SIDEMOVE: return p->original_cmd.sidemove; break; - case INPUT_UPMOVE: return p->original_cmd.upmove; break; - - case MODINPUT_OLDBUTTONS: return p->oldbuttons; break; - case MODINPUT_BUTTONS: return p->cmd.ucmd.buttons; break; - case MODINPUT_PITCH: return p->cmd.ucmd.pitch; break; - case MODINPUT_YAW: return p->cmd.ucmd.yaw; break; - case MODINPUT_ROLL: return p->cmd.ucmd.roll; break; - case MODINPUT_FORWARDMOVE: return p->cmd.ucmd.forwardmove; break; - case MODINPUT_SIDEMOVE: return p->cmd.ucmd.sidemove; break; - case MODINPUT_UPMOVE: return p->cmd.ucmd.upmove; break; - - default: return 0; break; - } + return P_Thing_CheckInputNum(p, inputnum); } enum diff --git a/src/p_local.h b/src/p_local.h index 0d3035623..ac6b264d9 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -159,6 +159,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser); bool P_Thing_CanRaise(AActor *thing); PClassActor *P_GetSpawnableType(int spawnnum); void InitSpawnablesFromMapinfo(); +int P_Thing_CheckInputNum(player_t *p, int inputnum); int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, double zofs, DAngle angle, int flags, double heightoffset, double radiusoffset, DAngle pitch); bool P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int count, int flags, int ptr); diff --git a/src/p_things.cpp b/src/p_things.cpp index 98826268c..e19323542 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -666,7 +666,36 @@ void InitSpawnablesFromMapinfo() InitClassMap(SpawnableThings, SpawnablesFromMapinfo); InitClassMap(StrifeTypes, ConversationIDsFromMapinfo); } +int P_Thing_CheckInputNum(player_t *p, int inputnum) +{ + int renum = 0; + if (p) + { + switch (inputnum) + { + case INPUT_OLDBUTTONS: renum = p->original_oldbuttons; break; + case INPUT_BUTTONS: renum = p->original_cmd.buttons; break; + case INPUT_PITCH: renum = p->original_cmd.pitch; break; + case INPUT_YAW: renum = p->original_cmd.yaw; break; + case INPUT_ROLL: renum = p->original_cmd.roll; break; + case INPUT_FORWARDMOVE: renum = p->original_cmd.forwardmove; break; + case INPUT_SIDEMOVE: renum = p->original_cmd.sidemove; break; + case INPUT_UPMOVE: renum = p->original_cmd.upmove; break; + case MODINPUT_OLDBUTTONS: renum = p->oldbuttons; break; + case MODINPUT_BUTTONS: renum = p->cmd.ucmd.buttons; break; + case MODINPUT_PITCH: renum = p->cmd.ucmd.pitch; break; + case MODINPUT_YAW: renum = p->cmd.ucmd.yaw; break; + case MODINPUT_ROLL: renum = p->cmd.ucmd.roll; break; + case MODINPUT_FORWARDMOVE: renum = p->cmd.ucmd.forwardmove; break; + case MODINPUT_SIDEMOVE: renum = p->cmd.ucmd.sidemove; break; + case MODINPUT_UPMOVE: renum = p->cmd.ucmd.upmove; break; + + default: renum = 0; break; + } + } + return renum; +} bool P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int count, int flags, int ptr) { AActor *ref = COPY_AAPTR(self, ptr); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 491944253..b0979885a 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -569,31 +569,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetPlayerInput) } else { - player_t *p = mobj->player; - int renum = 0; - switch (inputnum) - { - case INPUT_OLDBUTTONS: renum = p->original_oldbuttons; break; - case INPUT_BUTTONS: renum = p->original_cmd.buttons; break; - case INPUT_PITCH: renum = p->original_cmd.pitch; break; - case INPUT_YAW: renum = p->original_cmd.yaw; break; - case INPUT_ROLL: renum = p->original_cmd.roll; break; - case INPUT_FORWARDMOVE: renum = p->original_cmd.forwardmove; break; - case INPUT_SIDEMOVE: renum = p->original_cmd.sidemove; break; - case INPUT_UPMOVE: renum = p->original_cmd.upmove; break; - - case MODINPUT_OLDBUTTONS: renum = p->oldbuttons; break; - case MODINPUT_BUTTONS: renum = p->cmd.ucmd.buttons; break; - case MODINPUT_PITCH: renum = p->cmd.ucmd.pitch; break; - case MODINPUT_YAW: renum = p->cmd.ucmd.yaw; break; - case MODINPUT_ROLL: renum = p->cmd.ucmd.roll; break; - case MODINPUT_FORWARDMOVE: renum = p->cmd.ucmd.forwardmove; break; - case MODINPUT_SIDEMOVE: renum = p->cmd.ucmd.sidemove; break; - case MODINPUT_UPMOVE: renum = p->cmd.ucmd.upmove; break; - - default: renum = 0; break; - } - ret->SetInt(renum); + ret->SetInt(P_Thing_CheckInputNum(mobj->player, inputnum)); } return 1; }