diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 8749dc56f..64a629406 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1701,7 +1701,7 @@ drawscreen(PLAYERp pp, double smoothratio) // TODO: It'd be better to check pp->input.q16angvel instead, problem is that // it's been repurposed for the q16ang diff while tying input to framerate if (PedanticMode || (pp != Player+myconnectindex) || - (TEST(pp->Flags, PF_DEAD) && (loc.q16angvel == 0))) + (TEST(pp->Flags, PF_DEAD) && (loc.q16avel == 0))) { tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) - fix16_from_int(1024), smoothratio)); tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio)); diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 7ea787ada..239b48516 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -921,28 +921,17 @@ enum }; -#pragma pack(push,1) -typedef struct -{ - int16_t vel; - int16_t svel; - int8_t angvel; - int8_t aimvel; - int32_t bits; -} OLD_SW_PACKET; - // TODO: Support compatible read/write of struct for big-endian -typedef struct +struct SW_PACKET { - int16_t vel; + int16_t fvel; int16_t svel; - fix16_t q16angvel; + fix16_t q16avel; fix16_t q16aimvel; fix16_t q16ang; - fix16_t q16horiz; + fix16_t q16horz; int32_t bits; -} SW_PACKET; -#pragma pack(pop) +}; extern SW_PACKET loc; diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index b62193c68..f12849d27 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -296,12 +296,12 @@ getinput(SW_PACKET *loc, SWBOOL tied) pp->oq16horiz += pp->camq16horiz - prevcamq16horiz; } - loc->vel += vel; + loc->fvel += vel; loc->svel += svel; if (!tied) { - vel = clamp(loc->vel, -MAXVEL, MAXVEL); + vel = clamp(loc->fvel, -MAXVEL, MAXVEL); svel = clamp(loc->svel, -MAXSVEL, MAXSVEL); momx = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 512)]); @@ -310,11 +310,11 @@ getinput(SW_PACKET *loc, SWBOOL tied) momx += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]); momy += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 1536)]); - loc->vel = momx; + loc->fvel = momx; loc->svel = momy; } - loc->q16angvel += q16angvel; + loc->q16avel += q16angvel; loc->q16aimvel += q16aimvel; if (!CommEnabled) diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index 3ab185ca6..7ce1226ec 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -73,16 +73,16 @@ extern char sync_first[MAXSYNCBYTES][60]; extern int sync_found; // -// Tic Duplication - so you can move multiple times per packet +// Tic Duplication - so you can move multiple times per packet. This is SW_PACKET with the 16 bit values extended to 32 bit. // typedef struct { - int32_t vel; + int32_t fvel; int32_t svel; - fix16_t q16angvel; + fix16_t q16avel; fix16_t q16aimvel; fix16_t q16ang; - fix16_t q16horiz; + fix16_t q16horz; int32_t bits; } SW_AVERAGE_PACKET; @@ -198,12 +198,12 @@ UpdateInputs(void) getinput(&loc, FALSE); - AveragePacket.vel += loc.vel; + AveragePacket.fvel += loc.fvel; AveragePacket.svel += loc.svel; - AveragePacket.q16angvel += loc.q16angvel; + AveragePacket.q16avel += loc.q16avel; AveragePacket.q16aimvel += loc.q16aimvel; AveragePacket.q16ang = Player[myconnectindex].camq16ang; - AveragePacket.q16horiz = Player[myconnectindex].camq16horiz; + AveragePacket.q16horz = Player[myconnectindex].camq16horiz; SET(AveragePacket.bits, loc.bits); Bmemset(&loc, 0, sizeof(loc)); @@ -220,12 +220,12 @@ UpdateInputs(void) return; } - loc.vel = AveragePacket.vel / MovesPerPacket; + loc.fvel = AveragePacket.fvel / MovesPerPacket; loc.svel = AveragePacket.svel / MovesPerPacket; - loc.q16angvel = fix16_div(AveragePacket.q16angvel, fix16_from_int(MovesPerPacket)); + loc.q16avel = fix16_div(AveragePacket.q16avel, fix16_from_int(MovesPerPacket)); loc.q16aimvel = fix16_div(AveragePacket.q16aimvel, fix16_from_int(MovesPerPacket)); loc.q16ang = AveragePacket.q16ang; - loc.q16horiz = AveragePacket.q16horiz; + loc.q16horz = AveragePacket.q16horz; loc.bits = AveragePacket.bits; memset(&AveragePacket, 0, sizeof(AveragePacket)); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 8e26b0ed7..91c6df1ff 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1663,7 +1663,7 @@ DoPlayerTurnBoat(PLAYERp pp) if (sop->drive_angspeed) { int drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16angvel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide; @@ -1672,7 +1672,7 @@ DoPlayerTurnBoat(PLAYERp pp) } else { - angvel = fix16_to_int(pp->input.q16angvel) * PLAYER_TURN_SCALE; + angvel = fix16_to_int(pp->input.q16avel) * PLAYER_TURN_SCALE; angvel += angvel - DIV4(angvel); angvel = DIV32(angvel * synctics); } @@ -1695,7 +1695,7 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) int angslide; int drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16angvel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide; @@ -1704,7 +1704,7 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) } else { - angvel = DIV8(fix16_to_int(pp->input.q16angvel) * synctics); + angvel = DIV8(fix16_to_int(pp->input.q16avel) * synctics); } if (angvel != 0) @@ -1728,7 +1728,7 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) int angslide; int drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16angvel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide; @@ -1737,7 +1737,7 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) } else { - angvel = DIV8(fix16_to_int(pp->input.q16angvel) * synctics); + angvel = DIV8(fix16_to_int(pp->input.q16avel) * synctics); } if (angvel != 0) @@ -1766,9 +1766,9 @@ DoPlayerTurnTurret(PLAYERp pp) fifo_ndx = (movefifoplc-2) & (MOVEFIFOSIZ - 1); last_input = pp->inputfifo[fifo_ndx]; - if (pp->input.q16angvel && !last_input.q16angvel) + if (pp->input.q16avel && !last_input.q16avel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); - else if (!pp->input.q16angvel && last_input.q16angvel) + else if (!pp->input.q16avel && last_input.q16avel) PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); } @@ -1777,7 +1777,7 @@ DoPlayerTurnTurret(PLAYERp pp) int angslide; int drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16angvel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (drive_oangvel*(angslide-1)))/angslide; @@ -1786,7 +1786,7 @@ DoPlayerTurnTurret(PLAYERp pp) } else { - angvel = DIV4(fix16_to_int(pp->input.q16angvel) * synctics); + angvel = DIV4(fix16_to_int(pp->input.q16avel) * synctics); } if (angvel != 0) @@ -1922,7 +1922,7 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel) if (!PedanticMode && (pq16horiz == &pp->q16horiz)) { SET(pp->Flags2, PF2_INPUT_CAN_AIM); - pp->q16horiz = pp->input.q16horiz; + pp->q16horiz = pp->input.q16horz; if ((pp == &Player[myconnectindex]) || (pp == ppp)) // No coop view? pp->oq16horiz = pp->q16horiz; return; @@ -2596,7 +2596,7 @@ DoPlayerMove(PLAYERp pp) SlipSlope(pp); - DoPlayerTurn(pp, &pp->q16ang, pp->input.q16angvel); + DoPlayerTurn(pp, &pp->q16ang, pp->input.q16avel); pp->oldposx = pp->posx; pp->oldposy = pp->posy; @@ -2613,7 +2613,7 @@ DoPlayerMove(PLAYERp pp) pp->oxvect = pp->xvect; pp->oyvect = pp->yvect; - pp->xvect += ((pp->input.vel*synctics*2)<<6); + pp->xvect += ((pp->input.fvel*synctics*2)<<6); pp->yvect += ((pp->input.svel*synctics*2)<<6); friction = pp->friction; @@ -2871,9 +2871,9 @@ DoPlayerMoveBoat(PLAYERp pp) fifo_ndx = (movefifoplc-2) & (MOVEFIFOSIZ - 1); last_input = pp->inputfifo[fifo_ndx]; - if (labs(pp->input.vel|pp->input.svel) && !labs(last_input.vel|last_input.svel)) + if (labs(pp->input.fvel|pp->input.svel) && !labs(last_input.fvel|last_input.svel)) PlaySOsound(pp->sop->mid_sector,SO_DRIVE_SOUND); - else if (!labs(pp->input.vel|pp->input.svel) && labs(last_input.vel|last_input.svel)) + else if (!labs(pp->input.fvel|pp->input.svel) && labs(last_input.fvel|last_input.svel)) PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND); } @@ -2889,7 +2889,7 @@ DoPlayerMoveBoat(PLAYERp pp) if (sop->drive_speed) { - pp->xvect = mulscale6(pp->input.vel, sop->drive_speed); + pp->xvect = mulscale6(pp->input.fvel, sop->drive_speed); pp->yvect = mulscale6(pp->input.svel, sop->drive_speed); // does sliding/momentum @@ -2898,7 +2898,7 @@ DoPlayerMoveBoat(PLAYERp pp) } else { - pp->xvect += ((pp->input.vel*synctics*2)<<6); + pp->xvect += ((pp->input.fvel*synctics*2)<<6); pp->yvect += ((pp->input.svel*synctics*2)<<6); pp->xvect = mulscale16(pp->xvect, BOAT_FRICTION); @@ -3063,7 +3063,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) return; // not moving - don't crush - if ((pp->xvect|pp->yvect) == 0 && pp->input.q16angvel == 0) + if ((pp->xvect|pp->yvect) == 0 && pp->input.q16avel == 0) return; // main sector @@ -3235,9 +3235,9 @@ DoPlayerMoveTank(PLAYERp pp) fifo_ndx = (movefifoplc-2) & (MOVEFIFOSIZ - 1); last_input = pp->inputfifo[fifo_ndx]; - if (labs(pp->input.vel|pp->input.svel) && !labs(last_input.vel|last_input.svel)) + if (labs(pp->input.fvel|pp->input.svel) && !labs(last_input.fvel|last_input.svel)) PlaySOsound(pp->sop->mid_sector,SO_DRIVE_SOUND); - else if (!labs(pp->input.vel|pp->input.svel) && labs(last_input.vel|last_input.svel)) + else if (!labs(pp->input.fvel|pp->input.svel) && labs(last_input.fvel|last_input.svel)) PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND); } @@ -3251,7 +3251,7 @@ DoPlayerMoveTank(PLAYERp pp) if (sop->drive_speed) { - pp->xvect = mulscale6(pp->input.vel, sop->drive_speed); + pp->xvect = mulscale6(pp->input.fvel, sop->drive_speed); pp->yvect = mulscale6(pp->input.svel, sop->drive_speed); // does sliding/momentum @@ -3260,7 +3260,7 @@ DoPlayerMoveTank(PLAYERp pp) } else { - pp->xvect += ((pp->input.vel*synctics*2)<<6); + pp->xvect += ((pp->input.fvel*synctics*2)<<6); pp->yvect += ((pp->input.svel*synctics*2)<<6); pp->xvect = mulscale16(pp->xvect, TANK_FRICTION); @@ -3841,7 +3841,7 @@ DoPlayerClimb(PLAYERp pp) if (Prediction) return; - pp->xvect += ((pp->input.vel*synctics*2)<<6); + pp->xvect += ((pp->input.fvel*synctics*2)<<6); pp->yvect += ((pp->input.svel*synctics*2)<<6); pp->xvect = mulscale16(pp->xvect, PLAYER_CLIMB_FRICTION); pp->yvect = mulscale16(pp->yvect, PLAYER_CLIMB_FRICTION); @@ -5771,7 +5771,7 @@ DoPlayerBeginOperate(PLAYERp pp) switch (sop->track) { case SO_TANK: - if (pp->input.vel|pp->input.svel) + if (pp->input.fvel|pp->input.svel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5780,7 +5780,7 @@ DoPlayerBeginOperate(PLAYERp pp) break; case SO_TURRET_MGUN: case SO_TURRET: - if (pp->input.q16angvel) + if (pp->input.q16avel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5788,7 +5788,7 @@ DoPlayerBeginOperate(PLAYERp pp) DoPlayerBeginOperateTurret(pp); break; case SO_SPEED_BOAT: - if (pp->input.vel|pp->input.svel) + if (pp->input.fvel|pp->input.svel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5859,7 +5859,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop) switch (sop->track) { case SO_TANK: - if (pp->input.vel|pp->input.svel) + if (pp->input.fvel|pp->input.svel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5868,7 +5868,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop) break; case SO_TURRET_MGUN: case SO_TURRET: - if (pp->input.q16angvel) + if (pp->input.q16avel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5876,7 +5876,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop) DoPlayerBeginOperateTurret(pp); break; case SO_SPEED_BOAT: - if (pp->input.vel|pp->input.svel) + if (pp->input.fvel|pp->input.svel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -6609,9 +6609,9 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) if (TEST(pp->Flags, PF_DEAD_HEAD|PF_HEAD_CONTROL)) SET(pp->Flags2, PF2_INPUT_CAN_TURN); - if ((TEST(pp->Flags, PF_DEAD_HEAD) && pp->input.q16angvel != 0) || TEST(pp->Flags, PF_HEAD_CONTROL)) + if ((TEST(pp->Flags, PF_DEAD_HEAD) && pp->input.q16avel != 0) || TEST(pp->Flags, PF_HEAD_CONTROL)) { - DoPlayerTurn(pp, &pp->q16ang, pp->input.q16angvel); + DoPlayerTurn(pp, &pp->q16ang, pp->input.q16avel); return; } @@ -7426,7 +7426,7 @@ void ChopsCheck(PLAYERp pp) { if (!M_Active() && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1) { - if ((pp->input.bits|pp->input.vel|pp->input.svel|pp->input.q16angvel|pp->input.q16aimvel) || + if ((pp->input.bits|pp->input.fvel|pp->input.svel|pp->input.q16avel|pp->input.q16aimvel) || TEST(pp->Flags, PF_CLIMBING|PF_FALLING|PF_DIVING)) { // Hit a input key or other reason to stop chops