mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-30 04:50:55 +00:00
Merge branch 'movementchecks' into 'master'
Movement input checks See merge request KartKrew/Kart!122
This commit is contained in:
commit
860157a94b
6 changed files with 50 additions and 71 deletions
|
@ -3887,6 +3887,32 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
||||||
#undef SERVERONLY
|
#undef SERVERONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Checks ticcmd for "speed hacks"
|
||||||
|
*
|
||||||
|
* \param p Which player
|
||||||
|
* \return True if player is hacking
|
||||||
|
* \sa HandlePacketFromPlayer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static boolean CheckForSpeedHacks(UINT8 p)
|
||||||
|
{
|
||||||
|
if (netcmds[maketic%BACKUPTICS][p].forwardmove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][p].forwardmove < -MAXPLMOVE
|
||||||
|
|| netcmds[maketic%BACKUPTICS][p].sidemove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][p].sidemove < -MAXPLMOVE
|
||||||
|
|| netcmds[maketic%BACKUPTICS][p].driftturn > KART_FULLTURN || netcmds[maketic%BACKUPTICS][p].driftturn < -KART_FULLTURN)
|
||||||
|
{
|
||||||
|
XBOXSTATIC char buf[2];
|
||||||
|
CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), playernode[p]);
|
||||||
|
//D_Clearticcmd(k);
|
||||||
|
|
||||||
|
buf[0] = (char)p;
|
||||||
|
buf[1] = KICK_MSG_CON_FAIL;
|
||||||
|
SendNetXCmd(XD_KICK, &buf, 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Handles a packet received from a node that is in game
|
/** Handles a packet received from a node that is in game
|
||||||
*
|
*
|
||||||
* \param node The packet sender
|
* \param node The packet sender
|
||||||
|
@ -3981,19 +4007,8 @@ FILESTAMP
|
||||||
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
|
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
|
||||||
|
|
||||||
// Check ticcmd for "speed hacks"
|
// Check ticcmd for "speed hacks"
|
||||||
if (netcmds[maketic%BACKUPTICS][netconsole].forwardmove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].forwardmove < -MAXPLMOVE
|
if (CheckForSpeedHacks((UINT8)netconsole))
|
||||||
|| netcmds[maketic%BACKUPTICS][netconsole].sidemove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].sidemove < -MAXPLMOVE ||
|
|
||||||
netcmds[maketic%BACKUPTICS][netconsole].driftturn > KART_FULLTURN || netcmds[maketic%BACKUPTICS][netconsole].driftturn < -KART_FULLTURN)
|
|
||||||
{
|
|
||||||
XBOXSTATIC char buf[2];
|
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), netconsole);
|
|
||||||
//D_Clearticcmd(k);
|
|
||||||
|
|
||||||
buf[0] = (char)netconsole;
|
|
||||||
buf[1] = KICK_MSG_CON_FAIL;
|
|
||||||
SendNetXCmd(XD_KICK, &buf, 2);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// Splitscreen cmd
|
// Splitscreen cmd
|
||||||
if (((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS)
|
if (((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS)
|
||||||
|
@ -4003,6 +4018,9 @@ FILESTAMP
|
||||||
{
|
{
|
||||||
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
|
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
|
||||||
&netbuffer->u.client2pak.cmd2, 1);
|
&netbuffer->u.client2pak.cmd2, 1);
|
||||||
|
|
||||||
|
if (CheckForSpeedHacks((UINT8)nodetoplayer2[node]))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS)
|
if (((netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS)
|
||||||
|
@ -4011,6 +4029,9 @@ FILESTAMP
|
||||||
{
|
{
|
||||||
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
|
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
|
||||||
&netbuffer->u.client3pak.cmd3, 1);
|
&netbuffer->u.client3pak.cmd3, 1);
|
||||||
|
|
||||||
|
if (CheckForSpeedHacks((UINT8)nodetoplayer3[node]))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
|
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
|
||||||
|
@ -4018,6 +4039,9 @@ FILESTAMP
|
||||||
{
|
{
|
||||||
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
|
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
|
||||||
&netbuffer->u.client4pak.cmd4, 1);
|
&netbuffer->u.client4pak.cmd4, 1);
|
||||||
|
|
||||||
|
if (CheckForSpeedHacks((UINT8)nodetoplayer4[node]))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A delay before we check resynching
|
// A delay before we check resynching
|
||||||
|
|
26
src/g_game.c
26
src/g_game.c
|
@ -1354,11 +1354,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
{
|
{
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed]));
|
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed]));
|
||||||
cmd->driftturn = (INT16)(cmd->driftturn - (angleturn[tspeed]));
|
cmd->driftturn = (INT16)(cmd->driftturn - (angleturn[tspeed]));
|
||||||
|
side += sidemove[1];
|
||||||
}
|
}
|
||||||
else if (turnleft && !(turnright))
|
else if (turnleft && !(turnright))
|
||||||
{
|
{
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed]));
|
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed]));
|
||||||
cmd->driftturn = (INT16)(cmd->driftturn + (angleturn[tspeed]));
|
cmd->driftturn = (INT16)(cmd->driftturn + (angleturn[tspeed]));
|
||||||
|
side -= sidemove[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (analogjoystickmove && axis != 0)
|
if (analogjoystickmove && axis != 0)
|
||||||
|
@ -1366,6 +1368,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
// JOYAXISRANGE should be 1023 (divide by 1024)
|
// JOYAXISRANGE should be 1023 (divide by 1024)
|
||||||
cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG!
|
cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG!
|
||||||
cmd->driftturn = (INT16)(cmd->driftturn - (((axis * angleturn[1]) >> 10)));
|
cmd->driftturn = (INT16)(cmd->driftturn - (((axis * angleturn[1]) >> 10)));
|
||||||
|
side += ((axis * sidemove[0]) >> 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specator mouse turning
|
// Specator mouse turning
|
||||||
|
@ -1375,20 +1378,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8)));
|
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Speed bump strafing
|
|
||||||
if (!demoplayback && ((player->pflags & PF_FORCESTRAFE) || (player->kartstuff[k_pogospring])))
|
|
||||||
{
|
|
||||||
if (turnright)
|
|
||||||
side += sidemove[1];
|
|
||||||
if (turnleft)
|
|
||||||
side -= sidemove[1];
|
|
||||||
if (analogjoystickmove && axis != 0)
|
|
||||||
{
|
|
||||||
// JOYAXISRANGE is supposed to be 1023 (divide by 1024)
|
|
||||||
side += ((axis * sidemove[0]) >> 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls
|
if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls
|
||||||
{
|
{
|
||||||
axis = JoyAxis(AXISMOVE, ssplayer);
|
axis = JoyAxis(AXISMOVE, ssplayer);
|
||||||
|
@ -1531,15 +1520,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||||
else if (side < -MAXPLMOVE)
|
else if (side < -MAXPLMOVE)
|
||||||
side = -MAXPLMOVE;
|
side = -MAXPLMOVE;
|
||||||
|
|
||||||
// No additional acceleration when moving forward/backward and strafing simultaneously.
|
|
||||||
// do this AFTER we cap to MAXPLMOVE so people can't find ways to cheese around this.
|
|
||||||
// SRB2Kart: We don't need this; we WANT bounce strafing to plain stack on top of normal movement.
|
|
||||||
/*if (!bouncestrafe && forward && side)
|
|
||||||
{
|
|
||||||
forward = FixedMul(forward, 3*FRACUNIT/4);
|
|
||||||
side = FixedMul(side, 3*FRACUNIT/4);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (forward || side)
|
if (forward || side)
|
||||||
{
|
{
|
||||||
cmd->forwardmove = (SINT8)(cmd->forwardmove + forward);
|
cmd->forwardmove = (SINT8)(cmd->forwardmove + forward);
|
||||||
|
|
|
@ -677,16 +677,6 @@ static int lib_pGetPlayerSpinHeight(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lib_pGetPlayerControlDirection(lua_State *L)
|
|
||||||
{
|
|
||||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
|
||||||
//HUDSAFE
|
|
||||||
if (!player)
|
|
||||||
return LUA_ErrInvalid(L, "player_t");
|
|
||||||
lua_pushinteger(L, P_GetPlayerControlDirection(player));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lib_pAddPlayerScore(lua_State *L)
|
static int lib_pAddPlayerScore(lua_State *L)
|
||||||
{
|
{
|
||||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||||
|
@ -2576,7 +2566,6 @@ static luaL_Reg lib[] = {
|
||||||
// p_user
|
// p_user
|
||||||
{"P_GetPlayerHeight",lib_pGetPlayerHeight},
|
{"P_GetPlayerHeight",lib_pGetPlayerHeight},
|
||||||
{"P_GetPlayerSpinHeight",lib_pGetPlayerSpinHeight},
|
{"P_GetPlayerSpinHeight",lib_pGetPlayerSpinHeight},
|
||||||
{"P_GetPlayerControlDirection",lib_pGetPlayerControlDirection},
|
|
||||||
{"P_AddPlayerScore",lib_pAddPlayerScore},
|
{"P_AddPlayerScore",lib_pAddPlayerScore},
|
||||||
{"P_PlayerInPain",lib_pPlayerInPain},
|
{"P_PlayerInPain",lib_pPlayerInPain},
|
||||||
{"P_DoPlayerPain",lib_pDoPlayerPain},
|
{"P_DoPlayerPain",lib_pDoPlayerPain},
|
||||||
|
|
|
@ -1130,12 +1130,12 @@ void OP_ObjectplaceMovement(player_t *player)
|
||||||
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
|
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
|
||||||
player->mo->momx = player->mo->momy = 0;
|
player->mo->momx = player->mo->momy = 0;
|
||||||
}
|
}
|
||||||
if (cmd->sidemove != 0)
|
/*if (cmd->sidemove != 0) -- was disabled in practice anyways, since sidemove was suppressed
|
||||||
{
|
{
|
||||||
P_Thrust(player->mo, player->mo->angle-ANGLE_90, (cmd->sidemove*FRACUNIT/MAXPLMOVE)*cv_speed.value);
|
P_Thrust(player->mo, player->mo->angle-ANGLE_90, (cmd->sidemove*FRACUNIT/MAXPLMOVE)*cv_speed.value);
|
||||||
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
|
P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z);
|
||||||
player->mo->momx = player->mo->momy = 0;
|
player->mo->momx = player->mo->momy = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (player->mo->z > player->mo->ceilingz - player->mo->height)
|
if (player->mo->z > player->mo->ceilingz - player->mo->height)
|
||||||
player->mo->z = player->mo->ceilingz - player->mo->height;
|
player->mo->z = player->mo->ceilingz - player->mo->height;
|
||||||
|
|
|
@ -128,7 +128,6 @@ extern fixed_t t_cam4_dist, t_cam4_height, t_cam4_rotate;
|
||||||
|
|
||||||
fixed_t P_GetPlayerHeight(player_t *player);
|
fixed_t P_GetPlayerHeight(player_t *player);
|
||||||
fixed_t P_GetPlayerSpinHeight(player_t *player);
|
fixed_t P_GetPlayerSpinHeight(player_t *player);
|
||||||
INT32 P_GetPlayerControlDirection(player_t *player);
|
|
||||||
void P_AddPlayerScore(player_t *player, UINT32 amount);
|
void P_AddPlayerScore(player_t *player, UINT32 amount);
|
||||||
void P_ResetCamera(player_t *player, camera_t *thiscam);
|
void P_ResetCamera(player_t *player, camera_t *thiscam);
|
||||||
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
|
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam);
|
||||||
|
|
31
src/p_user.c
31
src/p_user.c
|
@ -4509,7 +4509,7 @@ boolean P_AnalogMove(player_t *player)
|
||||||
// 1 = pressing in the direction of movement
|
// 1 = pressing in the direction of movement
|
||||||
// 2 = pressing in the opposite direction of movement
|
// 2 = pressing in the opposite direction of movement
|
||||||
//
|
//
|
||||||
INT32 P_GetPlayerControlDirection(player_t *player)
|
/*INT32 P_GetPlayerControlDirection(player_t *player)
|
||||||
{
|
{
|
||||||
ticcmd_t *cmd = &player->cmd;
|
ticcmd_t *cmd = &player->cmd;
|
||||||
angle_t controllerdirection, controlplayerdirection;
|
angle_t controllerdirection, controlplayerdirection;
|
||||||
|
@ -4584,7 +4584,7 @@ INT32 P_GetPlayerControlDirection(player_t *player)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Control scheme for 2d levels.
|
// Control scheme for 2d levels.
|
||||||
/*static void P_2dMovement(player_t *player)
|
static void P_2dMovement(player_t *player)
|
||||||
{
|
{
|
||||||
ticcmd_t *cmd;
|
ticcmd_t *cmd;
|
||||||
INT32 topspeed, acceleration, thrustfactor;
|
INT32 topspeed, acceleration, thrustfactor;
|
||||||
|
@ -4794,24 +4794,11 @@ static void P_3dMovement(player_t *player)
|
||||||
cmd->forwardmove = cmd->sidemove = 0;
|
cmd->forwardmove = cmd->sidemove = 0;
|
||||||
if (player->kartstuff[k_sneakertimer])
|
if (player->kartstuff[k_sneakertimer])
|
||||||
cmd->forwardmove = 50;
|
cmd->forwardmove = 50;
|
||||||
if (player->pflags & PF_GLIDING)
|
|
||||||
{
|
|
||||||
if (!player->skidtime)
|
|
||||||
player->pflags &= ~PF_GLIDING;
|
|
||||||
else if (player->exiting || mapreset)
|
|
||||||
{
|
|
||||||
player->pflags &= ~PF_GLIDING;
|
|
||||||
P_SetPlayerMobjState(player->mo, S_KART_WALK1); // SRB2kart - was S_PLAY_RUN1
|
|
||||||
player->skidtime = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player->pflags & PF_SPINNING && !(player->exiting || mapreset))
|
|
||||||
{
|
|
||||||
player->pflags &= ~PF_SPINNING;
|
|
||||||
P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(player->pflags & PF_FORCESTRAFE) && !player->kartstuff[k_pogospring])
|
||||||
|
cmd->sidemove = 0;
|
||||||
|
|
||||||
if (analogmove)
|
if (analogmove)
|
||||||
{
|
{
|
||||||
movepushangle = (cmd->angleturn<<16 /* not FRACBITS */);
|
movepushangle = (cmd->angleturn<<16 /* not FRACBITS */);
|
||||||
|
@ -4819,9 +4806,7 @@ static void P_3dMovement(player_t *player)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (player->kartstuff[k_drift] != 0)
|
if (player->kartstuff[k_drift] != 0)
|
||||||
{
|
|
||||||
movepushangle = player->mo->angle-(ANGLE_45/5)*player->kartstuff[k_drift];
|
movepushangle = player->mo->angle-(ANGLE_45/5)*player->kartstuff[k_drift];
|
||||||
}
|
|
||||||
else
|
else
|
||||||
movepushangle = player->mo->angle;
|
movepushangle = player->mo->angle;
|
||||||
}
|
}
|
||||||
|
@ -5039,10 +5024,10 @@ static void P_SpectatorMovement(player_t *player)
|
||||||
// Quake-style flying spectators :D
|
// Quake-style flying spectators :D
|
||||||
player->mo->momz += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(player->aiming));
|
player->mo->momz += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(player->aiming));
|
||||||
}
|
}
|
||||||
if (cmd->sidemove != 0)
|
/*if (cmd->sidemove != 0) -- was disabled in practice anyways, since sidemove was suppressed
|
||||||
{
|
{
|
||||||
P_Thrust(player->mo, player->mo->angle-ANGLE_90, cmd->sidemove*mapobjectscale);
|
P_Thrust(player->mo, player->mo->angle-ANGLE_90, cmd->sidemove*mapobjectscale);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -7077,6 +7062,7 @@ static void P_MovePlayer(player_t *player)
|
||||||
//ANALOG CONTROL//
|
//ANALOG CONTROL//
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
|
#if 0
|
||||||
// This really looks like it should be moved to P_3dMovement. -Red
|
// This really looks like it should be moved to P_3dMovement. -Red
|
||||||
if (P_AnalogMove(player)
|
if (P_AnalogMove(player)
|
||||||
&& (cmd->forwardmove != 0 || cmd->sidemove != 0) && !player->climbing && !twodlevel && !(player->mo->flags2 & MF2_TWOD))
|
&& (cmd->forwardmove != 0 || cmd->sidemove != 0) && !player->climbing && !twodlevel && !(player->mo->flags2 & MF2_TWOD))
|
||||||
|
@ -7133,6 +7119,7 @@ static void P_MovePlayer(player_t *player)
|
||||||
else if (player == &players[fourthdisplayplayer])
|
else if (player == &players[fourthdisplayplayer])
|
||||||
localangle4 = player->mo->angle;
|
localangle4 = player->mo->angle;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
//BOMB SHIELD ACTIVATION,//
|
//BOMB SHIELD ACTIVATION,//
|
||||||
|
|
Loading…
Reference in a new issue