diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 277b99e71..e85431bd3 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -187,29 +187,26 @@ void ctrlGetInput(void) CONTROL_GetInput(&info); -#if 0 - // these don't seem to have an on switch if (MouseDeadZone) { - if (info.mousey > 0) - info.mousey = max(info.mousey - MouseDeadZone, 0); - else if (info.mousey < 0) - info.mousey = min(info.mousey + MouseDeadZone, 0); + if (info.mousey > 0) + info.mousey = max(info.mousey - MouseDeadZone, 0); + else if (info.mousey < 0) + info.mousey = min(info.mousey + MouseDeadZone, 0); - if (info.mousex > 0) - info.mousex = max(info.mousex - MouseDeadZone, 0); - else if (info.mousex < 0) - info.mousex = min(info.mousex + MouseDeadZone, 0); + if (info.mousex > 0) + info.mousex = max(info.mousex - MouseDeadZone, 0); + else if (info.mousex < 0) + info.mousex = min(info.mousex + MouseDeadZone, 0); } if (MouseBias) { - if (klabs(info.mousex) > klabs(info.mousey)) - info.mousey = tabledivide32_noinline(info.mousey, MouseBias); - else - info.mousex = tabledivide32_noinline(info.mousex, MouseBias); + if (klabs(info.mousex) > klabs(info.mousey)) + info.mousey = tabledivide32_noinline(info.mousey, MouseBias); + else + info.mousex = tabledivide32_noinline(info.mousex, MouseBias); } -#endif if (gQuitRequest) gInput.keyFlags.quit = 1; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index a23964ccc..1de1ecb85 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -2929,16 +2929,17 @@ int viewFPSLimit(void) if (!r_maxfps) return 1; - static double nextPageDelay; - static double lastFrameTicks; + static double nextPageDelay; + static uint64_t lastFrameTicks; - double const frameTicks = timerGetTicksU64(); - double const elapsedTime = frameTicks-lastFrameTicks; + uint64_t const frameTicks = timerGetTicksU64(); + uint64_t const elapsedTime = frameTicks - lastFrameTicks; + double const dElapsedTime = elapsedTime; - if (elapsedTime >= nextPageDelay) + if (dElapsedTime >= floor(nextPageDelay)) { - if (elapsedTime <= nextPageDelay+g_frameDelay) - nextPageDelay += g_frameDelay-elapsedTime; + if (dElapsedTime <= nextPageDelay+g_frameDelay) + nextPageDelay += g_frameDelay-dElapsedTime; lastFrameTicks = frameTicks; diff --git a/source/rr/src/actors.cpp b/source/rr/src/actors.cpp index ad91d0281..8a518e83e 100644 --- a/source/rr/src/actors.cpp +++ b/source/rr/src/actors.cpp @@ -3308,7 +3308,7 @@ ACTOR_STATIC void G_MoveTransports(void) if (onFloor == 0 && klabs(SZ(spriteNum) - pPlayer->pos.z) < 6144) if (!pPlayer->jetpack_on || TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_JUMP) - || TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_CROUCH)) + || (TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_CROUCH) ^ pPlayer->crouch_toggle)) { pPlayer->pos.x += sprite[OW(spriteNum)].x - SX(spriteNum); pPlayer->pos.y += sprite[OW(spriteNum)].y - SY(spriteNum); @@ -3505,6 +3505,7 @@ default_case: actor[sectSprite].lasttransport = ((int32_t)totalclock & UINT8_MAX); + if (sectLotag == ST_1_ABOVE_WATER || sectLotag == ST_2_UNDERWATER) { sprite[sectSprite].x += sprite[OW(spriteNum)].x - SX(spriteNum); diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index a04e59eec..534cc0be7 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -535,7 +535,7 @@ int32_t Anim_Play(const char *fn) g_restorePalette = 0; } - frametime = (int32_t)totalclock; + frametime = (int32_t) totalclock; videoClearScreen(0); diff --git a/source/rr/src/demo.cpp b/source/rr/src/demo.cpp index 951dffc24..613f3e823 100644 --- a/source/rr/src/demo.cpp +++ b/source/rr/src/demo.cpp @@ -669,7 +669,7 @@ RECHECK: lastsyncofs = ktell(g_demo_recFilePtr); initsyncofs = lastsyncofs; lastsynctic = g_demo_cnt; - lastsyncclock = (int32_t)totalclock; + lastsyncclock = (int32_t) totalclock; outofsync = 0; #if KRANDDEBUG krd_enable(2); @@ -822,7 +822,7 @@ RECHECK: { lastsyncofs = ktell(g_demo_recFilePtr); lastsynctic = g_demo_cnt; - lastsyncclock = (int32_t)totalclock; + lastsyncclock = (int32_t) totalclock; if (kread(g_demo_recFilePtr, tmpbuf, 4) != 4) CORRUPT(7); diff --git a/source/rr/src/function.h b/source/rr/src/function.h index 57906b7cd..ba69a65e0 100644 --- a/source/rr/src/function.h +++ b/source/rr/src/function.h @@ -103,6 +103,7 @@ enum GameFunction_t gamefunc_Last_Weapon, gamefunc_Quick_Save, gamefunc_Quick_Load, + gamefunc_Toggle_Crouch, // TODO: Implement properly for mp }; #ifdef __cplusplus } diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 191dfa809..bd0807b03 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -227,7 +227,7 @@ void G_GameQuit(void) if (g_gameQuit == 0) { g_gameQuit = 1; - g_quitDeadline = (int32_t)totalclock + 120; + g_quitDeadline = (int32_t) totalclock+120; //g_netDisconnect = 1; } @@ -500,8 +500,8 @@ static int32_t G_DoThirdPerson(const DukePlayer_t *pp, vec3_t *vect, int16_t *vs vect->y += mulscale16(n.y,CAMERADIST); vect->z += mulscale16(n.z,CAMERADIST); - CAMERADIST = min(CAMERADIST + (((int32_t)totalclock - CAMERACLOCK) << 10), 65536); - CAMERACLOCK = (int32_t)totalclock; + CAMERADIST = min(CAMERADIST+(((int32_t) totalclock-CAMERACLOCK)<<10),65536); + CAMERACLOCK = (int32_t) totalclock; updatesectorz(vect->x,vect->y,vect->z,vsectnum); @@ -1573,7 +1573,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) } pPlayer->visibility += visinc; - lastvist = (int32_t)totalclock; + lastvist = (int32_t) totalclock; } } @@ -4772,7 +4772,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura if (t->lotag == SE_27_DEMO_CAM && ud.recstat == 1) { - t->picnum = 11 + (((int32_t)totalclock >> 3) & 1); + t->picnum = 11+(((int) totalclock>>3)&1); t->cstat |= 128; } else @@ -4956,7 +4956,7 @@ default_case1: case RESPAWNMARKERYELLOW__STATICRR: case RESPAWNMARKERGREEN__STATICRR: if (!RR) goto default_case2; - t->picnum = 861 + (((int32_t)totalclock >> 4) & 13); + t->picnum = 861 + (((int32_t) totalclock >> 4) & 13); if (pSprite->picnum == RESPAWNMARKERRED) t->pal = 0; else if (pSprite->picnum == RESPAWNMARKERYELLOW) @@ -5040,7 +5040,7 @@ default_case1: t->z -= ZOFFSET6; break; case CRYSTALAMMO__STATIC: - t->shade = (sintable[((int32_t)totalclock << 4) & 2047] >> 10); + t->shade = (sintable[((int32_t) totalclock<<4)&2047]>>10); if (RR) break; continue; case VIEWSCREEN__STATIC: @@ -5087,33 +5087,33 @@ default_case1: { if (RRRA && (sprite[pSprite->owner].picnum == CHEER || sprite[pSprite->owner].picnum == CHEERSTAYPUT)) { - t->picnum = CHEERBLADE + (((int32_t)totalclock >> 4) & 3); + t->picnum = CHEERBLADE + (((int32_t) totalclock >> 4) & 3); t->shade = -127; } else - t->picnum = SHRINKSPARK + (((int32_t)totalclock >> 4) & 7); + t->picnum = SHRINKSPARK + (((int32_t) totalclock >> 4) & 7); } else - t->picnum = SHRINKSPARK + (((int32_t)totalclock >> 4) & 3); + t->picnum = SHRINKSPARK+(((int32_t) totalclock>>4)&3); break; case CHEERBOMB__STATICRR: if (!RRRA) goto default_case2; - t->picnum = CHEERBOMB + (((int32_t)totalclock >> 4) & 3); + t->picnum = CHEERBOMB+( ((int32_t) totalclock>>4)&3 ); break; case GROWSPARK__STATIC: if (RR) goto default_case2; - t->picnum = GROWSPARK + (((int32_t)totalclock >> 4) & 3); + t->picnum = GROWSPARK+(((int32_t) totalclock>>4)&3); break; case SPIT__STATIC: if (!RR) goto default_case2; - t->picnum = SPIT + (((int32_t)totalclock >> 4) & 3); + t->picnum = SPIT + (((int32_t) totalclock >> 4) & 3); if (RRRA) { if (sprite[pSprite->owner].picnum == MINION && sprite[pSprite->owner].pal == 8) - t->picnum = RRTILE3500 + (((int32_t)totalclock >> 4) % 6); + t->picnum = RRTILE3500 + (((int32_t) totalclock >> 4) % 6); else if (sprite[pSprite->owner].picnum == MINION && sprite[pSprite->owner].pal == 19) { - t->picnum = RRTILE5090 + (((int32_t)totalclock >> 4) & 3); + t->picnum = RRTILE5090 + (((int32_t) totalclock >> 4) & 3); t->shade = -127; } else if (sprite[pSprite->owner].picnum == MAMA) @@ -5757,7 +5757,7 @@ rrcoolexplosion1: t->pal = 0; } else if (RR && t->picnum == FIRELASER) - t->picnum = FIRELASER + (((int32_t)totalclock >> 2) & 5); + t->picnum = FIRELASER+(((int32_t) totalclock>>2)&5); t->shade = -127; t->cstat |= 8192+1024; break; @@ -5872,11 +5872,11 @@ rrcoolexplosion1: t->shade = -127; break; case RRTILE2034__STATICRR: - t->picnum = RRTILE2034 + ((int32_t)totalclock & 1); + t->picnum = RRTILE2034 + ((int32_t) totalclock & 1); break; case RRTILE2944__STATICRR: t->shade = -127; - t->picnum = RRTILE2944 + (((int32_t)totalclock >> 2) & 4); + t->picnum = RRTILE2944 + (((int32_t) totalclock >> 2) & 4); break; case PLAYERONWATER__STATIC: #ifdef USE_OPENGL @@ -6487,7 +6487,7 @@ FAKE_F3: g_player[myconnectindex].ps->over_shoulder_on = !g_player[myconnectindex].ps->over_shoulder_on; CAMERADIST = 0; - CAMERACLOCK = (int32_t)totalclock; + CAMERACLOCK = (int32_t) totalclock; P_DoQuote(QUOTE_VIEW_MODE_OFF + g_player[myconnectindex].ps->over_shoulder_on, g_player[myconnectindex].ps); } @@ -6553,7 +6553,7 @@ FAKE_F3: if (ud.overhead_on != 0) { - int const timerOffset = ((int32_t)totalclock - nonsharedtimer); + int const timerOffset = ((int) totalclock - nonsharedtimer); nonsharedtimer += timerOffset; if (BUTTON(gamefunc_Enlarge_Screen)) @@ -8363,7 +8363,7 @@ MAIN_LOOP_RESTART: ototalclock += TICSPERFRAME; - int const moveClock = (int32_t)totalclock; + int const moveClock = (int) totalclock; if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && (g_player[myconnectindex].ps->gm&MODE_GAME)) @@ -8413,12 +8413,7 @@ MAIN_LOOP_RESTART: } else */if (G_FPSLimit() || g_saveRequested) { - int const smoothRatio - = ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm & MODE_MENU)) - || (g_netServer || ud.multimode > 1) - || ud.recstat == 2) - ? calc_smoothratio((int32_t)totalclock, (int32_t)ototalclock) - : 65536; + int const smoothRatio = calc_smoothratio(totalclock, ototalclock); G_DrawRooms(screenpeek, smoothRatio); if (videoGetRenderMode() >= REND_POLYMOST) diff --git a/source/rr/src/game.h b/source/rr/src/game.h index acb4cae96..109cade56 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamedefs.h" #include "gamedef.h" #include "net.h" +#include "mmulti.h" #ifdef __cplusplus extern "C" { @@ -414,9 +415,28 @@ static inline void G_HandleAsync(void) Net_GetPackets(); } -static inline int32_t calc_smoothratio(int32_t totalclk, int32_t ototalclk) +static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk) { - return clamp((totalclk-ototalclk)*(65536/TICSPERFRAME), 0, 65536); + int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60); + uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE); +#if 0 + //POGO: additional debug info for testing purposes + OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq)); +#endif + return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536); +} + +static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) +{ + if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || + (g_netServer || ud.multimode > 1) || + ud.recstat == 2) || + ud.pause_on) + { + return 65536; + } + + return calc_smoothratio_demo(totalclk, ototalclk); } // sector effector lotags diff --git a/source/rr/src/gameexec.cpp b/source/rr/src/gameexec.cpp index c0a885f5f..08f786e66 100644 --- a/source/rr/src/gameexec.cpp +++ b/source/rr/src/gameexec.cpp @@ -1090,7 +1090,7 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags) if (playerNum == myconnectindex) { CAMERADIST = 0; - CAMERACLOCK = (int32_t)totalclock; + CAMERACLOCK = (int32_t) totalclock; } //if (g_fakeMultiMode) @@ -2231,7 +2231,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) int const playerXVel = sprite[pPlayer->i].xvel; int const syncBits = g_player[vm.playerNum].inputBits->bits; - if (((moveFlags & pducking) && pPlayer->on_ground && TEST_SYNC_KEY(syncBits, SK_CROUCH)) + if (((moveFlags & pducking) && pPlayer->on_ground && (TEST_SYNC_KEY(syncBits, SK_CROUCH) ^ vm.pPlayer->crouch_toggle)) || ((moveFlags & pfalling) && pPlayer->jumping_counter == 0 && !pPlayer->on_ground && pPlayer->vel.z > 2048) || ((moveFlags & pjumping) && pPlayer->jumping_counter > 348) || ((moveFlags & pstanding) && playerXVel >= 0 && playerXVel < 8) diff --git a/source/rr/src/global.h b/source/rr/src/global.h index b559d8a93..667a332d6 100644 --- a/source/rr/src/global.h +++ b/source/rr/src/global.h @@ -155,7 +155,7 @@ G_EXTERN int32_t g_animateVel[MAXANIMATES]; G_EXTERN int16_t g_cloudSect[256]; G_EXTERN int16_t g_cloudX; G_EXTERN int16_t g_cloudY; -G_EXTERN int32_t g_cloudClock; +G_EXTERN ClockTicks g_cloudClock; G_EXTERN int16_t SpriteDeletionQueue[1024]; G_EXTERN int16_t g_cyclers[MAXCYCLERS][6]; @@ -163,7 +163,7 @@ G_EXTERN int16_t g_mirrorSector[64]; G_EXTERN int16_t g_mirrorWall[64]; G_EXTERN int32_t *labelcode; G_EXTERN int32_t *labeltype; -G_EXTERN int32_t lockclock; +G_EXTERN ClockTicks lockclock; G_EXTERN ClockTicks ototalclock; G_EXTERN int32_t g_wupass; diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index e8d9f515a..a4adea4d2 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -136,7 +136,7 @@ static void Menu_DrawTopBarCaption(const char *caption, const vec2_t origin) static FORCE_INLINE int32_t Menu_CursorShade(void) { - return 4-(sintable[((int32_t)totalclock<<4)&2047]>>11); + return 4-(sintable[((int32_t) totalclock<<4)&2047]>>11); } static void Menu_DrawCursorCommon(int32_t x, int32_t y, int32_t z, int32_t picnum, int32_t ydim_upper = 0, int32_t ydim_lower = ydim-1) { @@ -145,12 +145,12 @@ static void Menu_DrawCursorCommon(int32_t x, int32_t y, int32_t z, int32_t picnu static void Menu_DrawCursorLeft(int32_t x, int32_t y, int32_t z) { const int frames = RR ? 16 : 7; - Menu_DrawCursorCommon(x, y, z, SPINNINGNUKEICON + (((int32_t)totalclock >> 3) % frames)); + Menu_DrawCursorCommon(x, y, z, SPINNINGNUKEICON+(((int32_t) totalclock>>3)%frames)); } static void Menu_DrawCursorRight(int32_t x, int32_t y, int32_t z) { const int frames = RR ? 16 : 7; - Menu_DrawCursorCommon(x, y, z, SPINNINGNUKEICON + frames - 1 - ((frames - 1 + ((int32_t)totalclock >> 3)) % frames)); + Menu_DrawCursorCommon(x, y, z, SPINNINGNUKEICON+frames-1-((frames-1+((int32_t) totalclock>>3))%frames)); } static void Menu_DrawCursorTextTile(int32_t x, int32_t y, int32_t h, int32_t picnum, vec2_16_t const & siz, int32_t ydim_upper = 0, int32_t ydim_lower = ydim-1) { @@ -168,7 +168,7 @@ static void Menu_DrawCursorText(int32_t x, int32_t y, int32_t h, int32_t ydim_up return; } - Menu_DrawCursorTextTile(x, y, h, SPINNINGNUKEICON + (((int32_t)totalclock >> 3) % frames), siz, ydim_upper, ydim_lower); + Menu_DrawCursorTextTile(x, y, h, SPINNINGNUKEICON+(((int32_t) totalclock>>3)%frames), siz, ydim_upper, ydim_lower); } @@ -2254,7 +2254,7 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) { rotatesprite_fs(origin.x + (MENU_MARGIN_CENTER<<16), origin.y + ((28+l)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+100)<<16), origin.y + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t)totalclock<<4)&2047]>>11),0,2+8); + rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+100)<<16), origin.y + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); } break; @@ -2264,9 +2264,9 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) case MENU_PLAYER: if (RR) - rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>2))<<16), 24576L,0,3845+36-((((8-((int32_t)totalclock>>4)))&7)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); + rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>2))<<16), 24576L,0,3845+36-((((8-((int32_t) totalclock>>4)))&7)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); else - rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t)totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); + rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); break; case MENU_MACROS: @@ -4396,19 +4396,19 @@ MenuAnimation_t m_animation; int32_t Menu_Anim_SinOutRight(MenuAnimation_t *animdata) { - return sintable[divscale10((int32_t)totalclock - animdata->start, animdata->length) + 512] - 16384; + return sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] - 16384; } int32_t Menu_Anim_SinInRight(MenuAnimation_t *animdata) { - return sintable[divscale10((int32_t)totalclock - animdata->start, animdata->length) + 512] + 16384; + return sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] + 16384; } int32_t Menu_Anim_SinOutLeft(MenuAnimation_t *animdata) { - return -sintable[divscale10((int32_t)totalclock - animdata->start, animdata->length) + 512] + 16384; + return -sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] + 16384; } int32_t Menu_Anim_SinInLeft(MenuAnimation_t *animdata) { - return -sintable[divscale10((int32_t)totalclock - animdata->start, animdata->length) + 512] - 16384; + return -sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] - 16384; } void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype) @@ -4423,7 +4423,7 @@ void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype) { m_animation.out = Menu_Anim_SinOutRight; m_animation.in = Menu_Anim_SinInRight; - m_animation.start = (int32_t)totalclock; + m_animation.start = (int32_t) totalclock; m_animation.length = 30; m_animation.previous = previousMenu; @@ -4440,7 +4440,7 @@ void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype) { m_animation.out = Menu_Anim_SinOutLeft; m_animation.in = Menu_Anim_SinInLeft; - m_animation.start = (int32_t)totalclock; + m_animation.start = (int32_t) totalclock; m_animation.length = 30; m_animation.previous = previousMenu; @@ -4862,7 +4862,7 @@ void Menu_Close(uint8_t playerID) { ready2send = 1; totalclock = ototalclock; - CAMERACLOCK =(int32_t) totalclock; + CAMERACLOCK = (int32_t) totalclock; CAMERADIST = 65536; m_animation.start = 0; m_animation.length = 0; @@ -4870,7 +4870,7 @@ void Menu_Close(uint8_t playerID) // Reset next-viewscreen-redraw counter. // XXX: are there any other cases like that in need of handling? if (g_curViewscreen >= 0) - actor[g_curViewscreen].t_data[0] = (int32_t)totalclock; + actor[g_curViewscreen].t_data[0] = (int32_t) totalclock; } walock[TILE_SAVESHOT] = 199; @@ -4917,7 +4917,7 @@ enum MenuTextFlags_t static void Menu_GetFmt(const MenuFont_t *font, uint8_t const status, int32_t *s) { if (status & MT_Selected) - *s = sintable[((int32_t)totalclock << 5) & 2047] >> 12; + *s = sintable[((int32_t) totalclock<<5)&2047]>>12; else *s = font->shade_deselected; // sum shade values @@ -5986,7 +5986,7 @@ static void Menu_Run_MouseReturn(Menu_t *cm, const vec2_t origin) uint32_t const posx = tilesiz[SELECTDIR].y * SELECTDIR_z; rotatesprite_(origin.x + posx, 0, SELECTDIR_z, 512, SELECTDIR, - Menu_RunInput_MouseReturn_status ? 4 - (sintable[((int32_t)totalclock << 4) & 2047] >> 11) : 6, 0, + Menu_RunInput_MouseReturn_status ? 4 - (sintable[((int32_t) totalclock << 4) & 2047] >> 11) : 6, 0, 2 | 8 | 16 | RS_ALIGN_L, MOUSEALPHA, 0, xdim_from_320_16(origin.x + x_widescreen_left()), 0, xdim_from_320_16(origin.x + x_widescreen_left() + (posx>>1)), ydim - 1); } @@ -7686,7 +7686,7 @@ void M_DisplayMenus(void) if (MOUSEACTIVECONDITIONAL(mouseAdvanceClickState()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y) { m_prevmousepos = m_mousepos; - m_mouselastactivity = (int32_t)totalclock; + m_mouselastactivity = (int32_t) totalclock; } #if !defined EDUKE32_TOUCH_DEVICES else @@ -7729,7 +7729,7 @@ void M_DisplayMenus(void) if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { G_UpdateScreenArea(); - CAMERACLOCK = (int32_t)totalclock; + CAMERACLOCK = (int32_t) totalclock; CAMERADIST = 65536; } } diff --git a/source/rr/src/menus.h b/source/rr/src/menus.h index 82ed9b610..22a98c00b 100644 --- a/source/rr/src/menus.h +++ b/source/rr/src/menus.h @@ -513,9 +513,9 @@ extern int32_t m_mousewake_watchpoint, m_menuchange_watchpoint; // alpha increments of 3 --> 255 / 3 = 85 --> round up to power of 2 --> 128 --> divide by 2 --> 64 alphatabs required // use 16 anyway :P # define MOUSEUSEALPHA (videoGetRenderMode() != REND_CLASSIC || numalphatabs >= 15) -#define MOUSEALPHA (MOUSEUSEALPHA ? clamp(((int32_t)totalclock - m_mouselastactivity - 90) * 3, 0, 255) : 0) -#define CURSORALPHA (MOUSEUSEALPHA ? clamp(((int32_t)totalclock - m_mouselastactivity - 90) * 2 + (255 / 3), (255 / 3), 255) : 255 / 3) -# define MOUSEACTIVECONDITION (totalclock - m_mouselastactivity < M_MOUSETIMEOUT) +# define MOUSEALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*3, 0, 255) : 0) +# define CURSORALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) +# define MOUSEACTIVECONDITION ((int32_t) totalclock - m_mouselastactivity < M_MOUSETIMEOUT) # define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) # define MOUSEINACTIVECONDITIONAL(condition) (!MOUSEACTIVECONDITION && (condition)) # define MOUSEWATCHPOINTCONDITIONAL(condition) ((condition) || m_mousewake_watchpoint || m_menuchange_watchpoint == 3) diff --git a/source/rr/src/net.cpp b/source/rr/src/net.cpp index d6e81800d..a4ce6c69d 100644 --- a/source/rr/src/net.cpp +++ b/source/rr/src/net.cpp @@ -3701,7 +3701,7 @@ void Net_SendMessage(void) int32_t const text_x = fullwidth >= (320<<16) ? (320<<16) - fullwidth : mpgametext_x; mpgametext(text_x, y, typebuf, 1, 2|8|16|ROTATESPRITE_FULL16, 0, TEXT_YCENTER|TEXT_LITERALESCAPE); int32_t const cursor_x = text_x + width + textsc((tilesiz[SPINNINGNUKEICON].x<<14)+(1<<16)); - rotatesprite_fs(cursor_x, y, textsc(32768), 0, SPINNINGNUKEICON+(((int32_t)totalclock>>3)%7), 4-(sintable[((int32_t)totalclock<<4)&2047]>>11), 0, 2|8); + rotatesprite_fs(cursor_x, y, textsc(32768), 0, SPINNINGNUKEICON+(((int32_t) totalclock>>3)%7), 4-(sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2|8); if (hitstate == 1) { diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index 76c8e31c4..b76dfd418 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -1611,7 +1611,7 @@ void P_DisplayScuba(void) if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) { - G_DrawTileScaled(320 - (tilesiz[SCUBAMASK].x >> 1) - 15, 200 - (tilesiz[SCUBAMASK].y >> 1) + (sintable[(int32_t)totalclock & 2047] >> 10), + G_DrawTileScaled(320 - (tilesiz[SCUBAMASK].x >> 1) - 15, 200 - (tilesiz[SCUBAMASK].y >> 1) + (sintable[(int32_t) totalclock & 2047] >> 10), SCUBAMASK, 0, 2 + 16 + DRAWEAP_CENTER+512, scubaPal,49152); G_DrawTileScaled(320 - tilesiz[SCUBAMASK+4].x, 200 - tilesiz[SCUBAMASK+4].y, SCUBAMASK+4, 0, 2 + 16 + DRAWEAP_CENTER + 1024, scubaPal); G_DrawTileScaled(tilesiz[SCUBAMASK+4].x, 200 - tilesiz[SCUBAMASK+4].y, SCUBAMASK+4, 0, 2 + 4 + 16 + DRAWEAP_CENTER + 1024, scubaPal); @@ -1624,7 +1624,7 @@ void P_DisplayScuba(void) } else { - G_DrawTileScaled(320 - (tilesiz[SCUBAMASK].x >> 1) - 15, 200 - (tilesiz[SCUBAMASK].y >> 1) + (sintable[(int32_t)totalclock & 2047] >> 10), + G_DrawTileScaled(320 - (tilesiz[SCUBAMASK].x >> 1) - 15, 200 - (tilesiz[SCUBAMASK].y >> 1) + (sintable[(int32_t) totalclock & 2047] >> 10), SCUBAMASK, 0, 2 + 16 + DRAWEAP_CENTER, scubaPal,49152); G_DrawTileScaled(320 - tilesiz[SCUBAMASK+4].x, 200 - tilesiz[SCUBAMASK+4].y, SCUBAMASK+4, 0, 2 + 16 + DRAWEAP_CENTER, scubaPal); G_DrawTileScaled(tilesiz[SCUBAMASK+4].x, 200 - tilesiz[SCUBAMASK+4].y, SCUBAMASK+4, 0, 2 + 4 + 16 + DRAWEAP_CENTER, scubaPal); @@ -2731,20 +2731,19 @@ enddisplayweapon: #define NORMALKEYMOVE 40 #define MAXVEL ((NORMALKEYMOVE*2)+10) #define MAXSVEL ((NORMALKEYMOVE*2)+10) -#define MAXANGVEL 255 -#define MAXHORIZ 127 +#define MAXANGVEL 1024 +#define MAXHORIZ 256 int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; int32_t mouseyaxismode = -1; -int32_t g_emuJumpTics = 0; void P_GetInput(int const playerNum) { - auto const pPlayer = g_player[playerNum].ps; + auto const pPlayer = g_player[playerNum].ps; ControlInfo info; if ((pPlayer->gm & (MODE_MENU | MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) { - if (!(pPlayer->gm & MODE_MENU)) + if (!(pPlayer->gm&MODE_MENU)) CONTROL_GetInput(&info); Bmemset(&localInput, 0, sizeof(input_t)); @@ -2796,10 +2795,10 @@ void P_GetInput(int const playerNum) // JBF: Run key behaviour is selectable int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run)); - int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; + int const turnAmount = playerRunning ? (NORMALTURN << 1) : NORMALTURN; constexpr int const analogTurnAmount = (NORMALTURN << 1); - int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; - constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp + int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; + constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp input_t input {}; @@ -2823,8 +2822,7 @@ void P_GetInput(int const playerNum) else input.fvel = -(info.mousey >> 6); - if (ud.mouseflip) - input.q16horz = -input.q16horz; + if (ud.mouseflip) input.q16horz = -input.q16horz; input.q16horz -= fix16_from_int(info.dpitch) / analogExtent * analogTurnAmount; input.svel -= info.dx * keyMove / analogExtent; @@ -2832,19 +2830,19 @@ void P_GetInput(int const playerNum) if (BUTTON(gamefunc_Strafe)) { - if (BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock & 4)) + if (BUTTON(gamefunc_Turn_Left) && !(pPlayer->movement_lock&4)) input.svel -= -keyMove; - if (BUTTON(gamefunc_Turn_Right) && !(pPlayer->movement_lock & 8)) + if (BUTTON(gamefunc_Turn_Right) && !(pPlayer->movement_lock&8)) input.svel -= keyMove; } else { static int32_t turnHeldTime = 0; static int32_t lastInputClock = 0; // MED - int32_t const elapsedTics = (int32_t)totalclock - lastInputClock; + int32_t const elapsedTics = (int32_t) totalclock - lastInputClock; - lastInputClock = (int32_t)totalclock; + lastInputClock = (int32_t) totalclock; if (BUTTON(gamefunc_Turn_Left)) { @@ -2907,11 +2905,11 @@ void P_GetInput(int const playerNum) } else { - if (BUTTON(gamefunc_Move_Forward) && !(pPlayer->movement_lock & 1)) - input.fvel += keyMove; + if (BUTTON(gamefunc_Move_Forward) && !(g_player[playerNum].ps->movement_lock & 1)) + input.fvel += keyMove; - if (BUTTON(gamefunc_Move_Backward) && !(pPlayer->movement_lock & 2)) - input.fvel += -keyMove; + if (BUTTON(gamefunc_Move_Backward) && !(g_player[playerNum].ps->movement_lock & 2)) + input.fvel += -keyMove; } input.fvel = clamp(input.fvel, -MAXVEL, MAXVEL); @@ -2931,82 +2929,89 @@ void P_GetInput(int const playerNum) } } - if (weaponSelection == gamefunc_Weapon_1-1) - weaponSelection = 0; - - if (BUTTON(gamefunc_Previous_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel < 0)) - weaponSelection = 11; - - if (BUTTON(gamefunc_Next_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) - weaponSelection = 12; - - if (BUTTON(gamefunc_Alt_Weapon)) - weaponSelection = 13; - if (BUTTON(gamefunc_Last_Weapon)) weaponSelection = 14; + else if (BUTTON(gamefunc_Alt_Weapon)) + weaponSelection = 13; + else if (BUTTON(gamefunc_Next_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel > 0)) + weaponSelection = 12; + else if (BUTTON(gamefunc_Previous_Weapon) || (BUTTON(gamefunc_Dpad_Select) && input.fvel < 0)) + weaponSelection = 11; + else if (weaponSelection == gamefunc_Weapon_1-1) + weaponSelection = 0; - if (BUTTON(gamefunc_Jump) && pPlayer->on_ground) - g_emuJumpTics = 4; + localInput.bits = (weaponSelection << SK_WEAPON_BITS) | (BUTTON(gamefunc_Fire) << SK_FIRE); + localInput.bits |= (BUTTON(gamefunc_Open) << SK_OPEN); - localInput.bits = (g_emuJumpTics > 0 || BUTTON(gamefunc_Jump))<cursectnum != -1 ? sector[pPlayer->cursectnum].lotag : 0; + int const crouchable = sectorLotag != 2 && (sectorLotag != 1 || pPlayer->spritebridge); - if (g_emuJumpTics > 0) - g_emuJumpTics--; + if (BUTTON(gamefunc_Toggle_Crouch)) + { + pPlayer->crouch_toggle = !pPlayer->crouch_toggle && crouchable; + + if (crouchable) + CONTROL_ClearButton(gamefunc_Toggle_Crouch); + } + + if (BUTTON(gamefunc_Crouch) || BUTTON(gamefunc_Jump) || pPlayer->jetpack_on || (!crouchable && pPlayer->on_ground)) + pPlayer->crouch_toggle = 0; + + int const crouching = BUTTON(gamefunc_Crouch) || BUTTON(gamefunc_Toggle_Crouch) || pPlayer->crouch_toggle; + + localInput.bits |= (BUTTON(gamefunc_Jump) << SK_JUMP) | (crouching << SK_CROUCH); - localInput.bits |= BUTTON(gamefunc_Crouch) << SK_CROUCH; - if (RR && TEST_SYNC_KEY(localInput.bits, SK_CROUCH)) - localInput.bits &= ~(1<< SK_JUMP); - localInput.bits |= BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits |= (BUTTON(gamefunc_Aim_Up) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel > 0)) << SK_AIM_UP; localInput.bits |= (BUTTON(gamefunc_Aim_Down) || (BUTTON(gamefunc_Dpad_Aiming) && input.fvel < 0)) << SK_AIM_DOWN; - localInput.bits |= ((ud.runkey_mode) ? (ud.auto_run | BUTTON(gamefunc_Run)) : (BUTTON(gamefunc_Run) ^ ud.auto_run)) << SK_RUN; - localInput.bits |= BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT; - if (RR && pPlayer->drink_amt > 88) - localInput.bits |= 1 << SK_LOOK_LEFT; - localInput.bits |= BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT; - localInput.bits |= weaponSelection << SK_WEAPON_BITS; - localInput.bits |= BUTTON(gamefunc_Steroids) << SK_STEROIDS; - localInput.bits |= BUTTON(gamefunc_Look_Up) << SK_LOOK_UP; - localInput.bits |= BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN; - if (RR && pPlayer->drink_amt > 99) - localInput.bits |= 1 << SK_LOOK_DOWN; - localInput.bits |= BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; - localInput.bits |= BUTTON(gamefunc_MedKit) << SK_MEDKIT; - localInput.bits |= BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW; + localInput.bits |= (BUTTON(gamefunc_Center_View) << SK_CENTER_VIEW); + + localInput.bits |= (BUTTON(gamefunc_Look_Left) << SK_LOOK_LEFT) | (BUTTON(gamefunc_Look_Right) << SK_LOOK_RIGHT); + localInput.bits |= (BUTTON(gamefunc_Look_Up) << SK_LOOK_UP) | (BUTTON(gamefunc_Look_Down) << SK_LOOK_DOWN); + + localInput.bits |= (playerRunning << SK_RUN); + + localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || (BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; + localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || (BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; + localInput.bits |= (BUTTON(gamefunc_Inventory) << SK_INVENTORY); + + localInput.bits |= (BUTTON(gamefunc_Steroids) << SK_STEROIDS) | (BUTTON(gamefunc_NightVision) << SK_NIGHTVISION); + localInput.bits |= (BUTTON(gamefunc_MedKit) << SK_MEDKIT) | (BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE); + localInput.bits |= (BUTTON(gamefunc_Jetpack) << SK_JETPACK); + localInput.bits |= BUTTON(gamefunc_Holster_Weapon) << SK_HOLSTER; - localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || - (BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; - localInput.bits |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= BUTTON(gamefunc_Quick_Kick) << SK_QUICK_KICK; - localInput.bits |= g_myAimMode << SK_AIMMODE; - localInput.bits |= BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; - localInput.bits |= BUTTON(gamefunc_Jetpack) << SK_JETPACK; - localInput.bits |= (g_gameQuit << SK_GAMEQUIT); - localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || - (BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= BUTTON(gamefunc_TurnAround) << SK_TURNAROUND; - localInput.bits |= BUTTON(gamefunc_Open) << SK_OPEN; - localInput.bits |= BUTTON(gamefunc_Inventory) << SK_INVENTORY; + + localInput.bits |= (g_myAimMode << SK_AIMMODE); + localInput.bits |= (g_gameQuit << SK_GAMEQUIT); + localInput.bits |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; + if (RR) + { + if (TEST_SYNC_KEY(localInput.bits, SK_CROUCH)) + localInput.bits &= ~(1 << SK_JUMP); + if (pPlayer->drink_amt > 88) + localInput.bits |= 1 << SK_LOOK_LEFT; + if (pPlayer->drink_amt > 99) + localInput.bits |= 1 << SK_LOOK_DOWN; + } + if (BUTTON(gamefunc_Dpad_Select)) { - input.fvel = 0; - input.svel = 0; + input.fvel = 0; + input.svel = 0; input.q16avel = 0; } - if (BUTTON(gamefunc_Dpad_Aiming)) + else if (BUTTON(gamefunc_Dpad_Aiming)) input.fvel = 0; - localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; - localInput.extbits |= BUTTON(gamefunc_Turn_Left) << 4; - localInput.extbits |= BUTTON(gamefunc_Turn_Right) << 5; - //localInput.extbits |= BUTTON(gamefunc_Alt_Fire) << 6; + localInput.extbits |= BUTTON(gamefunc_Turn_Left)<<4; + localInput.extbits |= BUTTON(gamefunc_Turn_Right)<<5; if (ud.scrollmode && ud.overhead_on) { @@ -3024,11 +3029,13 @@ void P_GetInput(int const playerNum) int16_t const q16ang = fix16_to_int(pPlayer->q16ang); - localInput.fvel = mulscale9(input.fvel, sintable[(q16ang + 2560) & 2047]) + mulscale9(input.svel, sintable[(q16ang + 2048) & 2047]) - + (pPlayer->fric.x); + localInput.fvel = mulscale9(input.fvel, sintable[(q16ang + 2560) & 2047]) + + mulscale9(input.svel, sintable[(q16ang + 2048) & 2047]) + + pPlayer->fric.x; - localInput.svel = mulscale9(input.fvel, sintable[(q16ang + 2048) & 2047]) + mulscale9(input.svel, sintable[(q16ang + 1536) & 2047]) - + (pPlayer->fric.y); + localInput.svel = mulscale9(input.fvel, sintable[(q16ang + 2048) & 2047]) + + mulscale9(input.svel, sintable[(q16ang + 1536) & 2047]) + + pPlayer->fric.y; localInput.q16avel = input.q16avel; localInput.q16horz = input.q16horz; @@ -3036,21 +3043,17 @@ void P_GetInput(int const playerNum) void P_GetInputMotorcycle(int playerNum) { - static ControlInfo info[2]; - static int32_t turnHeldTime = 0; // MED - static int32_t lastControlInput = 0; // MED - DukePlayer_t * pPlayer = g_player[playerNum].ps; - static input_t staticInput; + auto const pPlayer = g_player[playerNum].ps; + ControlInfo info; if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) { if (!(pPlayer->gm&MODE_MENU)) - CONTROL_GetInput(&info[0]); + CONTROL_GetInput(&info); Bmemset(&localInput, 0, sizeof(input_t)); localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT); - localInput.extbits = (g_player[playerNum].pteam != g_player[playerNum].ps->team) << 6; localInput.extbits |= (1 << 7); return; @@ -3072,93 +3075,88 @@ void P_GetInputMotorcycle(int playerNum) } } - int32_t const aimMode = (g_myAimMode) ? (int32_t)analog_lookingupanddown : ud.config.MouseAnalogueAxes[1]; - - if (aimMode != mouseyaxismode) - { - CONTROL_MapAnalogAxis(1, aimMode, controldevice_mouse); - mouseyaxismode = aimMode; - } - - CONTROL_GetInput(&info[0]); + CONTROL_GetInput(&info); if (ud.config.MouseDeadZone) { - if (info[0].dpitch > 0) - info[0].dpitch = (info[0].dpitch > ud.config.MouseDeadZone) ? info[0].dpitch - ud.config.MouseDeadZone : 0; - else if (info[0].dpitch < 0) - info[0].dpitch = (info[0].dpitch < -ud.config.MouseDeadZone) ? info[0].dpitch + ud.config.MouseDeadZone : 0; + if (info.mousey > 0) + info.mousey = max(info.mousey - ud.config.MouseDeadZone, 0); + else if (info.mousey < 0) + info.mousey = min(info.mousey + ud.config.MouseDeadZone, 0); - if (info[0].dyaw > 0) - info[0].dyaw = (info[0].dyaw > ud.config.MouseDeadZone) ? info[0].dyaw - ud.config.MouseDeadZone : 0; - else if (info[0].dyaw < 0) - info[0].dyaw = (info[0].dyaw < -ud.config.MouseDeadZone) ? info[0].dyaw + ud.config.MouseDeadZone : 0; + if (info.mousex > 0) + info.mousex = max(info.mousex - ud.config.MouseDeadZone, 0); + else if (info.mousex < 0) + info.mousex = min(info.mousex + ud.config.MouseDeadZone, 0); } if (ud.config.MouseBias) { - if (klabs(info[0].dyaw) > klabs(info[0].dpitch)) - info[0].dpitch = tabledivide32_noinline(info[0].dpitch, ud.config.MouseBias); - else info[0].dyaw = tabledivide32_noinline(info[0].dyaw, ud.config.MouseBias); + if (klabs(info.mousex) > klabs(info.mousey)) + info.mousey = tabledivide32_noinline(info.mousey, ud.config.MouseBias); + else + info.mousex = tabledivide32_noinline(info.mousex, ud.config.MouseBias); } - int const elapsedTics = (int32_t)totalclock - lastControlInput; - lastControlInput = (int32_t)totalclock; + // JBF: Run key behaviour is selectable + int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run)); + constexpr int const analogTurnAmount = (NORMALTURN << 1); + int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; + constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp - staticInput.svel = staticInput.fvel = staticInput.q16avel = staticInput.q16horz = 0; + input_t input {}; - staticInput.q16avel = fix16_div(fix16_from_int(info[0].dyaw), F16(32)); + input.q16avel = fix16_div(fix16_from_int(info.mousex), F16(32)); + input.q16avel += fix16_from_int(info.dyaw) / analogExtent * (analogTurnAmount << 1); - staticInput.q16horz = fix16_div(fix16_from_int(info[0].dpitch), F16(256)); + input.q16horz = fix16_div(fix16_from_int(info.mousey), F16(64)); - if (ud.mouseflip) staticInput.q16horz = -staticInput.q16horz; + if (ud.mouseflip) input.q16horz = -input.q16horz; - staticInput.svel -= info[0].dx; - staticInput.fvel = -info[0].dz >> 6; + input.q16horz -= fix16_from_int(info.dpitch) / analogExtent * analogTurnAmount; + input.svel -= info.dx * keyMove / analogExtent; + input.fvel -= info.dz * keyMove / analogExtent; - // OSD_Printf("running: %d\n", running); + input.fvel = clamp(input.fvel, -MAXVEL, MAXVEL); + input.svel = clamp(input.svel, -MAXSVEL, MAXSVEL); - staticInput.fvel = clamp(staticInput.fvel, -MAXVEL, MAXVEL); - staticInput.svel = clamp(staticInput.svel, -MAXSVEL, MAXSVEL); - staticInput.q16avel = fix16_clamp(staticInput.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); - staticInput.q16horz = fix16_clamp(staticInput.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); - + input.q16avel = fix16_clamp(input.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); + input.q16horz = fix16_clamp(input.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); + + pPlayer->crouch_toggle = 0; localInput.bits = BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits |= BUTTON(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= BUTTON(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || - (BUTTON(gamefunc_Dpad_Select) && (staticInput.svel > 0 || staticInput.q16avel < 0))) << SK_INV_LEFT; + (BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; localInput.bits |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= BUTTON(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || - (BUTTON(gamefunc_Dpad_Select) && (staticInput.svel < 0 || staticInput.q16avel > 0))) << SK_INV_RIGHT; + (BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= BUTTON(gamefunc_Open) << SK_OPEN; localInput.bits |= BUTTON(gamefunc_Inventory) << SK_INVENTORY; localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; if (BUTTON(gamefunc_Dpad_Select)) { - staticInput.fvel = 0; - staticInput.svel = 0; - staticInput.q16avel = 0; + input.fvel = 0; + input.svel = 0; + input.q16avel = 0; } if (BUTTON(gamefunc_Dpad_Aiming)) - staticInput.fvel = 0; + input.fvel = 0; + + localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); + localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; + localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; + localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; - localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (staticInput.fvel > 0)); - localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (staticInput.fvel < 0))<<1; - localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (staticInput.svel > 0))<<2; - localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (staticInput.svel < 0))<<3; - - // used for changing team - localInput.extbits |= (g_player[playerNum].pteam != g_player[playerNum].ps->team)<<6; - - int const turn = staticInput.q16avel / 32; + int const turn = input.q16avel / 32; int turnLeft = BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left); int turnRight = BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right); int avelScale = F16((turnLeft || turnRight) ? 1 : 0); @@ -3171,7 +3169,7 @@ void P_GetInputMotorcycle(int playerNum) turnRight = 1; } - staticInput.svel = staticInput.fvel = staticInput.q16avel = staticInput.q16horz = 0; + input.svel = input.fvel = input.q16avel = input.q16horz = 0; if (!pPlayer->moto_underwater) { @@ -3183,6 +3181,10 @@ void P_GetInputMotorcycle(int playerNum) localInput.bits |= turnLeft << SK_AIM_DOWN; localInput.bits |= turnRight << SK_LOOK_LEFT; + static int32_t turnHeldTime = 0; + static int32_t lastInputClock = 0; // MED + int32_t const elapsedTics = (int32_t) totalclock - lastInputClock; + int const moveBack = BUTTON(gamefunc_Move_Backward) && pPlayer->moto_speed <= 0; if (pPlayer->moto_speed == 0 || !pPlayer->on_ground) @@ -3213,16 +3215,16 @@ void P_GetInputMotorcycle(int playerNum) if (moveBack) { if (turn) - staticInput.q16avel += fix16_from_int(20*2); + input.q16avel += fix16_from_int(20*2); else - staticInput.q16avel += fix16_from_int(10*2); + input.q16avel += fix16_from_int(10*2); } else { if (turn) - staticInput.q16avel -= fix16_from_int(20*2); + input.q16avel -= fix16_from_int(20*2); else - staticInput.q16avel -= fix16_from_int(10*2); + input.q16avel -= fix16_from_int(10*2); } } else @@ -3230,16 +3232,16 @@ void P_GetInputMotorcycle(int playerNum) if (moveBack) { if (turn) - staticInput.q16avel += fix16_from_int(10*2); + input.q16avel += fix16_from_int(10*2); else - staticInput.q16avel += fix16_from_int(3*2); + input.q16avel += fix16_from_int(3*2); } else { if (turn) - staticInput.q16avel -= fix16_from_int(10*2); + input.q16avel -= fix16_from_int(10*2); else - staticInput.q16avel -= fix16_from_int(3*2); + input.q16avel -= fix16_from_int(3*2); } } } @@ -3254,16 +3256,16 @@ void P_GetInputMotorcycle(int playerNum) if (moveBack) { if (turn) - staticInput.q16avel -= fix16_from_int(20*2); + input.q16avel -= fix16_from_int(20*2); else - staticInput.q16avel -= fix16_from_int(10*2); + input.q16avel -= fix16_from_int(10*2); } else { if (turn) - staticInput.q16avel += fix16_from_int(20*2); + input.q16avel += fix16_from_int(20*2); else - staticInput.q16avel += fix16_from_int(10*2); + input.q16avel += fix16_from_int(10*2); } } else @@ -3271,16 +3273,16 @@ void P_GetInputMotorcycle(int playerNum) if (moveBack) { if (turn) - staticInput.q16avel -= fix16_from_int(10*2); + input.q16avel -= fix16_from_int(10*2); else - staticInput.q16avel -= fix16_from_int(3*2); + input.q16avel -= fix16_from_int(3*2); } else { if (turn) - staticInput.q16avel += fix16_from_int(10*2); + input.q16avel += fix16_from_int(10*2); else - staticInput.q16avel += fix16_from_int(3*2); + input.q16avel += fix16_from_int(3*2); } } } @@ -3298,19 +3300,19 @@ void P_GetInputMotorcycle(int playerNum) if (pPlayer->moto_underwater) pPlayer->moto_speed = 0; - staticInput.q16avel = fix16_mul(staticInput.q16avel, avelScale); + input.q16avel = fix16_mul(input.q16avel, avelScale); - staticInput.fvel += pPlayer->moto_speed; + input.fvel += pPlayer->moto_speed; - staticInput.fvel = clamp(staticInput.fvel, -15, 120); - staticInput.svel = clamp(staticInput.svel, -MAXSVEL, MAXSVEL); - staticInput.q16avel = fix16_clamp(staticInput.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); - staticInput.q16horz = fix16_clamp(staticInput.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); + input.fvel = clamp(input.fvel, -15, 120); + input.svel = clamp(input.svel, -MAXSVEL, MAXSVEL); + input.q16avel = fix16_clamp(input.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); + input.q16horz = fix16_clamp(input.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); if (ud.scrollmode && ud.overhead_on) { - ud.folfvel = staticInput.fvel; - ud.folavel = fix16_to_int(staticInput.q16avel); + ud.folfvel = input.fvel; + ud.folavel = fix16_to_int(input.q16avel); localInput.fvel = 0; localInput.svel = 0; localInput.q16avel = 0; @@ -3320,16 +3322,16 @@ void P_GetInputMotorcycle(int playerNum) int16_t const q16ang = fix16_to_int(pPlayer->q16ang); - localInput.fvel = mulscale9(staticInput.fvel, sintable[(q16ang + 2560) & 2047]) + - mulscale9(staticInput.svel, sintable[(q16ang + 2048) & 2047]) + + localInput.fvel = mulscale9(input.fvel, sintable[(q16ang + 2560) & 2047]) + + mulscale9(input.svel, sintable[(q16ang + 2048) & 2047]) + pPlayer->fric.x; - localInput.svel = mulscale9(staticInput.fvel, sintable[(q16ang + 2048) & 2047]) + - mulscale9(staticInput.svel, sintable[(q16ang + 1536) & 2047]) + + localInput.svel = mulscale9(input.fvel, sintable[(q16ang + 2048) & 2047]) + + mulscale9(input.svel, sintable[(q16ang + 1536) & 2047]) + pPlayer->fric.y; - localInput.q16avel = staticInput.q16avel; - localInput.q16horz = staticInput.q16horz; + localInput.q16avel = input.q16avel; + localInput.q16horz = input.q16horz; if (TEST_SYNC_KEY(localInput.bits, SK_JUMP)) { @@ -3339,21 +3341,17 @@ void P_GetInputMotorcycle(int playerNum) void P_GetInputBoat(int playerNum) { - static ControlInfo info[2]; - static int32_t turnHeldTime = 0; // MED - static int32_t lastControlInput = 0; // MED - DukePlayer_t * pPlayer = g_player[playerNum].ps; - static input_t staticInput; + auto const pPlayer = g_player[playerNum].ps; + ControlInfo info; if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) { if (!(pPlayer->gm&MODE_MENU)) - CONTROL_GetInput(&info[0]); + CONTROL_GetInput(&info); Bmemset(&localInput, 0, sizeof(input_t)); localInput.bits = (((int32_t)g_gameQuit) << SK_GAMEQUIT); - localInput.extbits = (g_player[playerNum].pteam != g_player[playerNum].ps->team) << 6; localInput.extbits |= (1 << 7); return; @@ -3375,93 +3373,88 @@ void P_GetInputBoat(int playerNum) } } - int32_t const aimMode = (g_myAimMode) ? (int32_t)analog_lookingupanddown : ud.config.MouseAnalogueAxes[1]; - - if (aimMode != mouseyaxismode) - { - CONTROL_MapAnalogAxis(1, aimMode, controldevice_mouse); - mouseyaxismode = aimMode; - } - - CONTROL_GetInput(&info[0]); + CONTROL_GetInput(&info); if (ud.config.MouseDeadZone) { - if (info[0].dpitch > 0) - info[0].dpitch = (info[0].dpitch > ud.config.MouseDeadZone) ? info[0].dpitch - ud.config.MouseDeadZone : 0; - else if (info[0].dpitch < 0) - info[0].dpitch = (info[0].dpitch < -ud.config.MouseDeadZone) ? info[0].dpitch + ud.config.MouseDeadZone : 0; + if (info.mousey > 0) + info.mousey = max(info.mousey - ud.config.MouseDeadZone, 0); + else if (info.mousey < 0) + info.mousey = min(info.mousey + ud.config.MouseDeadZone, 0); - if (info[0].dyaw > 0) - info[0].dyaw = (info[0].dyaw > ud.config.MouseDeadZone) ? info[0].dyaw - ud.config.MouseDeadZone : 0; - else if (info[0].dyaw < 0) - info[0].dyaw = (info[0].dyaw < -ud.config.MouseDeadZone) ? info[0].dyaw + ud.config.MouseDeadZone : 0; + if (info.mousex > 0) + info.mousex = max(info.mousex - ud.config.MouseDeadZone, 0); + else if (info.mousex < 0) + info.mousex = min(info.mousex + ud.config.MouseDeadZone, 0); } if (ud.config.MouseBias) { - if (klabs(info[0].dyaw) > klabs(info[0].dpitch)) - info[0].dpitch = tabledivide32_noinline(info[0].dpitch, ud.config.MouseBias); - else info[0].dyaw = tabledivide32_noinline(info[0].dyaw, ud.config.MouseBias); + if (klabs(info.mousex) > klabs(info.mousey)) + info.mousey = tabledivide32_noinline(info.mousey, ud.config.MouseBias); + else + info.mousex = tabledivide32_noinline(info.mousex, ud.config.MouseBias); } - int const elapsedTics = (int32_t)totalclock - lastControlInput; - lastControlInput = (int32_t)totalclock; + // JBF: Run key behaviour is selectable + int const playerRunning = (ud.runkey_mode) ? (BUTTON(gamefunc_Run) | ud.auto_run) : (ud.auto_run ^ BUTTON(gamefunc_Run)); + constexpr int const analogTurnAmount = (NORMALTURN << 1); + int const keyMove = playerRunning ? (NORMALKEYMOVE << 1) : NORMALKEYMOVE; + constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp - staticInput.svel = staticInput.fvel = staticInput.q16avel = staticInput.q16horz = 0; + input_t input {}; - staticInput.q16avel = fix16_div(fix16_from_int(info[0].dyaw), F16(32)); + input.q16avel = fix16_div(fix16_from_int(info.mousex), F16(32)); + input.q16avel += fix16_from_int(info.dyaw) / analogExtent * (analogTurnAmount << 1); - staticInput.q16horz = fix16_div(fix16_from_int(info[0].dpitch), F16(256)); + input.q16horz = fix16_div(fix16_from_int(info.mousey), F16(64)); - if (ud.mouseflip) staticInput.q16horz = -staticInput.q16horz; + if (ud.mouseflip) input.q16horz = -input.q16horz; - staticInput.svel -= info[0].dx; - staticInput.fvel = -info[0].dz >> 6; + input.q16horz -= fix16_from_int(info.dpitch) / analogExtent * analogTurnAmount; + input.svel -= info.dx * keyMove / analogExtent; + input.fvel -= info.dz * keyMove / analogExtent; - // OSD_Printf("running: %d\n", running); + input.fvel = clamp(input.fvel, -MAXVEL, MAXVEL); + input.svel = clamp(input.svel, -MAXSVEL, MAXSVEL); - staticInput.fvel = clamp(staticInput.fvel, -MAXVEL, MAXVEL); - staticInput.svel = clamp(staticInput.svel, -MAXSVEL, MAXSVEL); - staticInput.q16avel = fix16_clamp(staticInput.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); - staticInput.q16horz = fix16_clamp(staticInput.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); - + input.q16avel = fix16_clamp(input.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); + input.q16horz = fix16_clamp(input.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); + + pPlayer->crouch_toggle = 0; localInput.bits = BUTTON(gamefunc_Fire) << SK_FIRE; localInput.bits |= BUTTON(gamefunc_Steroids) << SK_STEROIDS; localInput.bits |= BUTTON(gamefunc_NightVision) << SK_NIGHTVISION; localInput.bits |= BUTTON(gamefunc_MedKit) << SK_MEDKIT; localInput.bits |= (BUTTON(gamefunc_Inventory_Left) || - (BUTTON(gamefunc_Dpad_Select) && (staticInput.svel > 0 || staticInput.q16avel < 0))) << SK_INV_LEFT; + (BUTTON(gamefunc_Dpad_Select) && (input.svel > 0 || input.q16avel < 0))) << SK_INV_LEFT; localInput.bits |= KB_KeyPressed(sc_Pause) << SK_PAUSE; localInput.bits |= BUTTON(gamefunc_Holo_Duke) << SK_HOLODUKE; localInput.bits |= BUTTON(gamefunc_Jetpack) << SK_JETPACK; localInput.bits |= (g_gameQuit << SK_GAMEQUIT); localInput.bits |= (BUTTON(gamefunc_Inventory_Right) || - (BUTTON(gamefunc_Dpad_Select) && (staticInput.svel < 0 || staticInput.q16avel > 0))) << SK_INV_RIGHT; + (BUTTON(gamefunc_Dpad_Select) && (input.svel < 0 || input.q16avel > 0))) << SK_INV_RIGHT; localInput.bits |= BUTTON(gamefunc_Open) << SK_OPEN; localInput.bits |= BUTTON(gamefunc_Inventory) << SK_INVENTORY; localInput.bits |= ((uint32_t)KB_KeyPressed(sc_Escape)) << SK_ESCAPE; if (BUTTON(gamefunc_Dpad_Select)) { - staticInput.fvel = 0; - staticInput.svel = 0; - staticInput.q16avel = 0; + input.fvel = 0; + input.svel = 0; + input.q16avel = 0; } if (BUTTON(gamefunc_Dpad_Aiming)) - staticInput.fvel = 0; + input.fvel = 0; + + localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (input.fvel > 0)); + localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (input.fvel < 0)) << 1; + localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; + localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; - localInput.extbits = (BUTTON(gamefunc_Move_Forward) || (staticInput.fvel > 0)); - localInput.extbits |= (BUTTON(gamefunc_Move_Backward) || (staticInput.fvel < 0))<<1; - localInput.extbits |= (BUTTON(gamefunc_Strafe_Left) || (staticInput.svel > 0))<<2; - localInput.extbits |= (BUTTON(gamefunc_Strafe_Right) || (staticInput.svel < 0))<<3; - - // used for changing team - localInput.extbits |= (g_player[playerNum].pteam != g_player[playerNum].ps->team)<<6; - - int const turn = staticInput.q16avel / 32; + int const turn = input.q16avel / 32; int turnLeft = BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left); int turnRight = BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right); int avelScale = F16((turnLeft || turnRight) ? 1 : 0); @@ -3474,7 +3467,7 @@ void P_GetInputBoat(int playerNum) turnRight = 1; } - staticInput.svel = staticInput.fvel = staticInput.q16avel = staticInput.q16horz = 0; + input.svel = input.fvel = input.q16avel = input.q16horz = 0; localInput.bits |= (BUTTON(gamefunc_Move_Forward) || BUTTON(gamefunc_Strafe)) << SK_JUMP; localInput.bits |= BUTTON(gamefunc_Move_Backward) << SK_AIM_UP; @@ -3483,6 +3476,10 @@ void P_GetInputBoat(int playerNum) localInput.bits |= turnLeft << SK_AIM_DOWN; localInput.bits |= turnRight << SK_LOOK_LEFT; + static int32_t turnHeldTime = 0; + static int32_t lastInputClock = 0; // MED + int32_t const elapsedTics = (int32_t) totalclock - lastInputClock; + if (pPlayer->moto_speed != 0) { if (turnLeft || pPlayer->moto_drink < 0) @@ -3499,16 +3496,16 @@ void P_GetInputBoat(int playerNum) if (pPlayer->not_on_water) { if (turn) - staticInput.q16avel -= fix16_from_int(6*2); + input.q16avel -= fix16_from_int(6*2); else - staticInput.q16avel -= fix16_from_int(3*2); + input.q16avel -= fix16_from_int(3*2); } else { if (turn) - staticInput.q16avel -= fix16_from_int(20*2); + input.q16avel -= fix16_from_int(20*2); else - staticInput.q16avel -= fix16_from_int(10*2); + input.q16avel -= fix16_from_int(10*2); } } else @@ -3516,16 +3513,16 @@ void P_GetInputBoat(int playerNum) if (pPlayer->not_on_water) { if (turn) - staticInput.q16avel -= fix16_from_int(2*2); + input.q16avel -= fix16_from_int(2*2); else - staticInput.q16avel -= fix16_from_int(1*2); + input.q16avel -= fix16_from_int(1*2); } else { if (turn) - staticInput.q16avel -= fix16_from_int(6*2); + input.q16avel -= fix16_from_int(6*2); else - staticInput.q16avel -= fix16_from_int(3*2); + input.q16avel -= fix16_from_int(3*2); } } } @@ -3543,16 +3540,16 @@ void P_GetInputBoat(int playerNum) if (pPlayer->not_on_water) { if (turn) - staticInput.q16avel += fix16_from_int(6*2); + input.q16avel += fix16_from_int(6*2); else - staticInput.q16avel += fix16_from_int(3*2); + input.q16avel += fix16_from_int(3*2); } else { if (turn) - staticInput.q16avel += fix16_from_int(20*2); + input.q16avel += fix16_from_int(20*2); else - staticInput.q16avel += fix16_from_int(10*2); + input.q16avel += fix16_from_int(10*2); } } else @@ -3560,16 +3557,16 @@ void P_GetInputBoat(int playerNum) if (pPlayer->not_on_water) { if (turn) - staticInput.q16avel += fix16_from_int(2*2); + input.q16avel += fix16_from_int(2*2); else - staticInput.q16avel += fix16_from_int(1*2); + input.q16avel += fix16_from_int(1*2); } else { if (turn) - staticInput.q16avel += fix16_from_int(6*2); + input.q16avel += fix16_from_int(6*2); else - staticInput.q16avel += fix16_from_int(3*2); + input.q16avel += fix16_from_int(3*2); } } } @@ -3593,19 +3590,19 @@ void P_GetInputBoat(int playerNum) pPlayer->tilt_status++; } - staticInput.fvel += pPlayer->moto_speed; + input.fvel += pPlayer->moto_speed; - staticInput.q16avel = fix16_mul(staticInput.q16avel, avelScale); + input.q16avel = fix16_mul(input.q16avel, avelScale); - staticInput.fvel = clamp(staticInput.fvel, -15, 120); - staticInput.svel = clamp(staticInput.svel, -MAXSVEL, MAXSVEL); - staticInput.q16avel = fix16_clamp(staticInput.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); - staticInput.q16horz = fix16_clamp(staticInput.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); + input.fvel = clamp(input.fvel, -15, 120); + input.svel = clamp(input.svel, -MAXSVEL, MAXSVEL); + input.q16avel = fix16_clamp(input.q16avel, F16(-MAXANGVEL), F16(MAXANGVEL)); + input.q16horz = fix16_clamp(input.q16horz, F16(-MAXHORIZ), F16(MAXHORIZ)); if (ud.scrollmode && ud.overhead_on) { - ud.folfvel = staticInput.fvel; - ud.folavel = fix16_to_int(staticInput.q16avel); + ud.folfvel = input.fvel; + ud.folavel = fix16_to_int(input.q16avel); localInput.fvel = 0; localInput.svel = 0; localInput.q16avel = 0; @@ -3615,16 +3612,16 @@ void P_GetInputBoat(int playerNum) int16_t const q16ang = fix16_to_int(pPlayer->q16ang); - localInput.fvel = mulscale9(staticInput.fvel, sintable[(q16ang + 2560) & 2047]) + - mulscale9(staticInput.svel, sintable[(q16ang + 2048) & 2047]) + + localInput.fvel = mulscale9(input.fvel, sintable[(q16ang + 2560) & 2047]) + + mulscale9(input.svel, sintable[(q16ang + 2048) & 2047]) + pPlayer->fric.x; - localInput.svel = mulscale9(staticInput.fvel, sintable[(q16ang + 2048) & 2047]) + - mulscale9(staticInput.svel, sintable[(q16ang + 1536) & 2047]) + + localInput.svel = mulscale9(input.fvel, sintable[(q16ang + 2048) & 2047]) + + mulscale9(input.svel, sintable[(q16ang + 1536) & 2047]) + pPlayer->fric.y; - localInput.q16avel = staticInput.q16avel; - localInput.q16horz = staticInput.q16horz; + localInput.q16avel = input.q16avel; + localInput.q16horz = input.q16horz; } void P_MadeNoise(int playerNum) @@ -4946,7 +4943,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->noise_radius = 8192; P_MadeNoise(playerNum); - lastvisinc = (int32_t)totalclock+32; + lastvisinc = (int32_t) totalclock+32; pPlayer->visibility = 0; flashColor = 255+(95<<8); if (sectorLotag != 857) @@ -5016,7 +5013,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->noise_radius = 8192; P_MadeNoise(playerNum); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); } @@ -5124,7 +5121,7 @@ static void P_ProcessWeapon(int playerNum) A_Shoot(pPlayer->i, CHAINGUN); pPlayer->noise_radius = 8192; P_MadeNoise(playerNum); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); if (sectorLotag != 857) @@ -5194,7 +5191,7 @@ static void P_ProcessWeapon(int playerNum) { pPlayer->visibility = 0; flashColor = 255 + (95 << 8); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; A_PlaySound(CHAINGUN_FIRE, pPlayer->i); A_Shoot(pPlayer->i, SHOTSPARK1); pPlayer->noise_radius = 16384; @@ -5223,7 +5220,7 @@ static void P_ProcessWeapon(int playerNum) { pPlayer->visibility = 0; flashColor = 255 + (95 << 8); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; A_PlaySound(CHAINGUN_FIRE, pPlayer->i); A_Shoot(pPlayer->i, CHAINGUN); pPlayer->noise_radius = 16384; @@ -5284,7 +5281,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->ammo_amount[FREEZE_WEAPON]--; pPlayer->visibility = 0; flashColor = 72 + (88 << 8) + (140 << 16); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; P_CheckWeapon(pPlayer); } else if ((*weaponFrame) == 12) @@ -5394,7 +5391,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->ammo_amount[RPG_WEAPON]--; if (pPlayer->ammo_amount[HANDBOMB_WEAPON]) pPlayer->ammo_amount[HANDBOMB_WEAPON]--; - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); A_Shoot(pPlayer->i, RPG); @@ -5413,7 +5410,7 @@ static void P_ProcessWeapon(int playerNum) if (++(*weaponFrame) == 4) { pPlayer->ammo_amount[CHICKEN_WEAPON]--; - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); A_Shoot(pPlayer->i, RPG2); @@ -5530,7 +5527,7 @@ static void P_ProcessWeapon(int playerNum) { A_Shoot(pPlayer->i, SHOTSPARK1); A_PlaySound(PISTOL_FIRE, pPlayer->i); - lastvisinc = (int32_t)totalclock+32; + lastvisinc = (int32_t) totalclock+32; pPlayer->visibility = 0; flashColor = 255+(95<<8); } @@ -5582,7 +5579,7 @@ static void P_ProcessWeapon(int playerNum) A_PlaySound(SHOTGUN_FIRE, pPlayer->i); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); } @@ -5632,7 +5629,7 @@ static void P_ProcessWeapon(int playerNum) A_PlaySound(CHAINGUN_FIRE, pPlayer->i); A_Shoot(pPlayer->i, CHAINGUN); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); P_CheckWeapon(pPlayer); @@ -5680,7 +5677,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->visibility = 0; flashColor = 216+(52<<8)+(20<<16); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; P_CheckWeapon(pPlayer); } else if (!NAM) @@ -5694,7 +5691,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->visibility = 0; flashColor = 216+(52<<8)+(20<<16); - lastvisinc = totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; P_CheckWeapon(pPlayer); P_CheckWeapon(pPlayer); } @@ -5719,7 +5716,7 @@ static void P_ProcessWeapon(int playerNum) { pPlayer->visibility = 0; flashColor = 176+(252<<8)+(120<<16); - lastvisinc = totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; P_CheckWeapon(pPlayer); } } @@ -5728,7 +5725,7 @@ static void P_ProcessWeapon(int playerNum) (*weaponFrame) = 0; pPlayer->visibility = 0; flashColor = 176+(252<<8)+(120<<16); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; P_CheckWeapon(pPlayer); } else @@ -5744,7 +5741,7 @@ static void P_ProcessWeapon(int playerNum) { pPlayer->visibility = 0; flashColor = 255+(95<<8); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; A_Shoot(pPlayer->i, RPG); pPlayer->ammo_amount[DEVISTATOR_WEAPON]--; P_CheckWeapon(pPlayer); @@ -5764,7 +5761,7 @@ static void P_ProcessWeapon(int playerNum) pPlayer->ammo_amount[FREEZE_WEAPON]--; pPlayer->visibility = 0; flashColor = 72+(88<<8)+(140<<16); - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; A_Shoot(pPlayer->i, FREEZEBLAST); P_CheckWeapon(pPlayer); } @@ -5836,7 +5833,7 @@ static void P_ProcessWeapon(int playerNum) if (++(*weaponFrame) == 4) { pPlayer->ammo_amount[RPG_WEAPON]--; - lastvisinc = (int32_t)totalclock + 32; + lastvisinc = (int32_t) totalclock + 32; pPlayer->visibility = 0; flashColor = 255+(95<<8); A_Shoot(pPlayer->i, RPG); @@ -7862,7 +7859,7 @@ HORIZONLY:; { sprite[spriteNum].pal = 0; pPlayer->drug_mode = 5; - pPlayer->drug_timer = (int32_t)totalclock; + pPlayer->drug_timer = (int32_t) totalclock; sprite[pPlayer->i].extra = pPlayer->max_player_health; } } diff --git a/source/rr/src/player.h b/source/rr/src/player.h index ffe85470a..d53111446 100644 --- a/source/rr/src/player.h +++ b/source/rr/src/player.h @@ -205,7 +205,8 @@ typedef struct { int32_t sea_sick; uint8_t hurt_delay2, nocheat; - int8_t padding_[4]; + int8_t crouch_toggle; + int8_t padding_[3]; } DukePlayer_t; // KEEPINSYNC lunatic/_defs_game.lua @@ -241,7 +242,6 @@ extern int32_t g_levelTextTime; extern int32_t g_myAimMode; extern int32_t g_numObituaries; extern int32_t g_numSelfObituaries; -extern int32_t g_emuJumpTics; extern int32_t mouseyaxismode; extern int32_t ticrandomseed; diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index b7a60acb7..a028c4930 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -595,7 +595,7 @@ void G_CacheMapData(void) G_CacheSpriteNum(j); } - tc = (int32_t)totalclock; + tc = (int32_t) totalclock; j = 0; int lpc = -1; @@ -674,14 +674,14 @@ void G_CacheMapData(void) if (totalclock - tc >= 1) { - tc = (int32_t)totalclock; + tc = (int32_t) totalclock; lpc++; } // OSD_Printf("percentage %d lpc %d\n", percentage, lpc); } - tc = (int32_t)totalclock; + tc = (int32_t) totalclock; } } @@ -2192,8 +2192,6 @@ void G_ClearFIFO(void) { Net_ClearFIFO(); - g_emuJumpTics = 0; - clearbufbyte(&localInput, sizeof(input_t), 0L); clearbufbyte(&inputfifo, sizeof(input_t) * MOVEFIFOSIZ * MAXPLAYERS, 0L); diff --git a/source/rr/src/savegame.cpp b/source/rr/src/savegame.cpp index 48cf48e27..0503b11ea 100644 --- a/source/rr/src/savegame.cpp +++ b/source/rr/src/savegame.cpp @@ -419,10 +419,10 @@ static struct { static void G_SaveTimers(void) { - g_timers.totalclock = (int32_t)totalclock; - g_timers.totalclocklock = (int32_t)totalclocklock; - g_timers.ototalclock = (int32_t)ototalclock; - g_timers.lockclock = lockclock; + g_timers.totalclock = (int32_t) totalclock; + g_timers.totalclocklock = (int32_t) totalclocklock; + g_timers.ototalclock = (int32_t) ototalclock; + g_timers.lockclock = (int32_t) lockclock; } static void G_RestoreTimers(void) diff --git a/source/rr/src/sbar.cpp b/source/rr/src/sbar.cpp index f4040b09c..048d48b1c 100644 --- a/source/rr/src/sbar.cpp +++ b/source/rr/src/sbar.cpp @@ -711,11 +711,11 @@ void G_DrawStatusBar(int32_t snum) if (sprite[p->i].pal == 1 && p->last_extra < 2) G_DrawAltDigiNum(44, -(hudoffset-22), 1, -16, 10+16+256); - else if (!althud_flashing || p->last_extra > (p->max_player_health >> 2) || (int32_t)totalclock & 32) + else if (!althud_flashing || p->last_extra >(p->max_player_health>>2) || (int32_t) totalclock&32) { int32_t s = -8; if (althud_flashing && p->last_extra > p->max_player_health) - s += (sintable[((int32_t)totalclock << 5) & 2047] >> 10); + s += (sintable[((int32_t) totalclock<<5)&2047]>>10); G_DrawAltDigiNum(44, -(hudoffset-22), p->last_extra, s, 10+16+256); } @@ -738,7 +738,7 @@ void G_DrawStatusBar(int32_t snum) else i = p->curr_weapon; if (p->curr_weapon != KNEE_WEAPON && p->curr_weapon != SLINGBLADE_WEAPON && - (!althud_flashing || (int32_t)totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) + (!althud_flashing || (int32_t) totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) G_DrawAltDigiNum(-20, -(hudoffset-22), p->ammo_amount[i], -16, 10+16+512); o = 102; @@ -806,11 +806,11 @@ void G_DrawStatusBar(int32_t snum) if (sprite[p->i].pal == 1 && p->last_extra < 2) G_DrawAltDigiNum(40, -(hudoffset-22), 1, -16, 10+16+256); - else if (!althud_flashing || p->last_extra > (p->max_player_health >> 2) || (int32_t)totalclock & 32) + else if (!althud_flashing || p->last_extra >(p->max_player_health>>2) || (int32_t) totalclock&32) { int32_t s = -8; if (althud_flashing && p->last_extra > p->max_player_health) - s += (sintable[((int32_t)totalclock << 5) & 2047] >> 10); + s += (sintable[((int32_t) totalclock<<5)&2047]>>10); G_DrawAltDigiNum(40, -(hudoffset-22), p->last_extra, s, 10+16+256); } @@ -827,7 +827,7 @@ void G_DrawStatusBar(int32_t snum) else i = p->curr_weapon; if (p->curr_weapon != KNEE_WEAPON && - (!althud_flashing || (int32_t)totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) + (!althud_flashing || (int32_t) totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) G_DrawAltDigiNum(-20, -(hudoffset-22), p->ammo_amount[i], -16, 10+16+512); o = 102; diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index ad487da11..7615ce190 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -273,12 +273,12 @@ static void G_DrawCameraText(int16_t i) rotatesprite_win(22<<16, 163<<16, 65536L, 512, CAMCORNER+1, 0, 0, 2+4); rotatesprite_win((310-10)<<16, 163<<16, 65536L, 512, CAMCORNER+1, 0, 0, 2); - if ((int32_t)totalclock & 16) + if ((int32_t) totalclock&16) rotatesprite_win(46<<16, 32<<16, 65536L, 0, CAMLIGHT, 0, 0, 2); } else { - int32_t flipbits = ((int32_t)totalclock << 1) & 48; + int32_t flipbits = ((int32_t) totalclock<<1)&48; for (bssize_t x=-64; x<394; x+=64) for (bssize_t y=0; y<200; y+=64) @@ -584,7 +584,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 if (p == screenpeek || GTFLAGS(GAMETYPE_OTHERPLAYERSINMAP)) { if (pSprite->xvel > 16 && pPlayer->on_ground) - i = APLAYERTOP + (((int32_t)totalclock >> 4) & 3); + i = APLAYERTOP+(((int32_t) totalclock>>4)&3); else i = APLAYERTOP; @@ -1367,8 +1367,8 @@ void G_FadePalette(int32_t r, int32_t g, int32_t b, int32_t e) videoFadePalette(r, g, b, e); videoNextPage(); - int32_t tc = (int32_t)totalclock; - while ((int32_t)totalclock < tc + 4) + int32_t tc = (int32_t) totalclock; + while (totalclock < tc + 4) G_HandleAsync(); } @@ -1676,7 +1676,7 @@ void G_DisplayLogo(void) soundanm++; S_PlaySound(PIPEBOMB_EXPLODE); } - rotatesprite_fs(160 << 16, 104 << 16, ((int32_t)totalclock - 120) << 10, 0, DUKENUKEM, 0, 0, 2 + 8); + rotatesprite_fs(160<<16, 104<<16, ((int32_t) totalclock-120)<<10, 0, DUKENUKEM, 0, 0, 2+8); } else if (totalclock >= (120+60)) rotatesprite_fs(160<<16, (104)<<16, 60<<10, 0, DUKENUKEM, 0, 0, 2+8); @@ -1690,7 +1690,7 @@ void G_DisplayLogo(void) } rotatesprite_fs(160<<16, (104)<<16, 60<<10, 0, DUKENUKEM, 0, 0, 2+8); - rotatesprite_fs(160 << 16, (129) << 16, ((int32_t)totalclock - 220) << 11, 0, THREEDEE, 0, 0, 2 + 8); + rotatesprite_fs(160<<16, (129)<<16, ((int32_t) totalclock - 220)<<11, 0, THREEDEE, 0, 0, 2+8); } else if (totalclock >= (220+30)) rotatesprite_fs(160<<16, (129)<<16, 30<<11, 0, THREEDEE, 0, 0, 2+8); @@ -1700,7 +1700,7 @@ void G_DisplayLogo(void) // JBF 20030804 if (totalclock >= 280 && totalclock < 395) { - rotatesprite_fs(160<<16, (151)<<16, (410-(int32_t)totalclock)<<12, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t)totalclock<<4)&2047]>>11), 0, 2+8); + rotatesprite_fs(160<<16, (151)<<16, (410-(int32_t) totalclock)<<12, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2+8); if (soundanm == 2) { soundanm++; @@ -1714,7 +1714,7 @@ void G_DisplayLogo(void) soundanm++; S_PlaySound(PIPEBOMB_EXPLODE); } - rotatesprite_fs(160<<16, (151)<<16, 30<<11, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t)totalclock<<4)&2047]>>11), 0, 2+8); + rotatesprite_fs(160<<16, (151)<<16, 30<<11, 0, PLUTOPAKSPRITE+1, (sintable[((int32_t) totalclock<<4)&2047]>>11), 0, 2+8); } } @@ -2383,7 +2383,7 @@ void G_BonusScreen(int32_t bonusonly) if (totalclock >= 1000000000 && totalclock < 1000000320) { - switch (((int32_t)totalclock >> 4) % 15) + switch (((int32_t) totalclock>>4)%15) { case 0: if (bonuscnt == 6) @@ -2423,7 +2423,7 @@ void G_BonusScreen(int32_t bonusonly) else if ((int32_t)totalclock > (10240+120L)) break; else { - switch (((int32_t)totalclock >> 5) & 3) + switch (((int32_t) totalclock>>5)&3) { case 1: case 3: @@ -2977,7 +2977,7 @@ void G_BonusScreenRRRA(int32_t bonusonly) if (totalclock >= 1000000000 && totalclock < 1000000320) { - switch (((uint32_t)totalclock>>4)%15) + switch (((int32_t) totalclock>>4)%15) { case 0: if (bonuscnt == 6) @@ -3013,7 +3013,7 @@ void G_BonusScreenRRRA(int32_t bonusonly) else if ((int32_t)totalclock > (10240+120L)) break; else { - switch (((int32_t)totalclock >> 5) & 3) + switch (((int32_t) totalclock>>5)&3) { case 1: case 3: @@ -3205,7 +3205,7 @@ void G_BonusScreenRRRA(int32_t bonusonly) P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2+1); while (1) { - switch (((int32_t)totalclock >> 4) & 1) + switch (((int32_t) totalclock >> 4) & 1) { case 0: rotatesprite(0,0,65536,0,RRTILE8677,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); diff --git a/source/rr/src/sector.cpp b/source/rr/src/sector.cpp index 5e89bef1d..1d471cfb0 100644 --- a/source/rr/src/sector.cpp +++ b/source/rr/src/sector.cpp @@ -552,7 +552,7 @@ void G_AnimateCamSprite(int smoothRatio) #endif } - T1(spriteNum) = (int32_t)totalclock; + T1(spriteNum) = (int32_t) totalclock; } } diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index f04cfca21..e37dfd294 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -278,7 +278,7 @@ void CheckSndData(char *file, int line) // void -SoundCallBack(unsigned int num) +SoundCallBack(intptr_t num) { VOC_INFOp vp;