diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2d0be11c7..a520f47a8 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -802,6 +802,7 @@ set (PCH_SOURCES core/raze_sound.cpp core/palette.cpp core/zcompile.cpp + core/statusbar.cpp core/2d/screentext.cpp diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 5d5b637f1..0af3a4ba3 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define actors_c_ -#include "duke3d_ed.h" +#include "duke3d.h" BEGIN_DUKE_NS @@ -1111,6 +1111,23 @@ static int P_Submerge(int, int, DukePlayer_t *, int, int); static int P_Emerge(int, int, DukePlayer_t *, int, int); static void P_FinishWaterChange(int, DukePlayer_t *, int, int, int); +static fix16_t P_GetQ16AngleDeltaForTic(DukePlayer_t const *pPlayer) +{ + auto oldAngle = pPlayer->oq16ang; + auto newAngle = pPlayer->q16ang; + + if (klabs(fix16_sub(oldAngle, newAngle)) < F16(1024)) + return fix16_sub(newAngle, oldAngle); + + if (newAngle > F16(1024)) + newAngle = fix16_sub(newAngle, F16(2048)); + + if (oldAngle > F16(1024)) + oldAngle = fix16_sub(oldAngle, F16(2048)); + + return fix16_sub(newAngle, oldAngle); +} + ACTOR_STATIC void G_MovePlayers(void) { int spriteNum = headspritestat[STAT_PLAYER]; @@ -1164,7 +1181,7 @@ ACTOR_STATIC void G_MovePlayers(void) if (G_HaveActor(sprite[spriteNum].picnum)) A_Execute(spriteNum, P_GetP(pSprite), otherPlayerDist); - pPlayer->q16angvel = G_GetQ16AngleDelta(pPlayer->oq16ang, pPlayer->q16ang); + pPlayer->q16angvel = P_GetQ16AngleDeltaForTic(pPlayer); pPlayer->oq16ang = pPlayer->q16ang; pPlayer->oq16horiz = pPlayer->q16horiz; pPlayer->oq16horizoff = pPlayer->q16horizoff; @@ -1211,7 +1228,7 @@ ACTOR_STATIC void G_MovePlayers(void) if (pPlayer->wackedbyactor >= 0 && sprite[pPlayer->wackedbyactor].statnum < MAXSTATUS) { - pPlayer->q16ang += fix16_from_int(G_GetAngleDelta(fix16_to_int(pPlayer->q16ang), + pPlayer->q16ang += fix16_to_int(G_GetAngleDelta(pPlayer->q16ang, getangle(sprite[pPlayer->wackedbyactor].x - pPlayer->pos.x, sprite[pPlayer->wackedbyactor].y - pPlayer->pos.y)) >> 1); diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index f3e50906f..53a181425 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -40,6 +40,7 @@ BEGIN_DUKE_NS #define ACTOR_MAXFALLINGZVEL 6144 #define ACTOR_ONWATER_ADDZ (24<<8) +// KEEPINSYNC lunatic/con_lang.lua #define STAT_DEFAULT 0 #define STAT_ACTOR 1 #define STAT_ZOMBIEACTOR 2 @@ -117,6 +118,8 @@ enum actionflags AF_VIEWPOINT = 1u<<0u, }; +// Select an actor's actiontics and movflags locations depending on +// whether we compile the Lunatic build. // : sprite pointer // : actor_t pointer # define AC_ACTIONTICS(spr, a) ((spr)->lotag) @@ -176,6 +179,7 @@ typedef struct } tiledata_t; +// KEEPINSYNC lunatic/con_lang.lua enum sflags_t { SFLAG_SHADOW = 0x00000001, diff --git a/source/games/duke/src/anim.cpp b/source/games/duke/src/anim.cpp index 96b4eede6..0cbc03462 100644 --- a/source/games/duke/src/anim.cpp +++ b/source/games/duke/src/anim.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "baselayer.h" #include "baselayer.h" -#include "duke3d_ed.h" +#include "duke3d.h" #include "animlib.h" #include "compat.h" #include "cmdlib.h" @@ -480,7 +480,7 @@ int32_t Anim_Play(const char *fn) { AnimTextures animtex; - animtex.SetSize(320, 200); + animtex.SetSize(AnimTexture::Paletted, 320, 200); do { @@ -562,7 +562,6 @@ int32_t Anim_Play(const char *fn) end_anim_restore_gl: gl_texture_filter = ogltexfiltermode; - gltexapplyprops(); end_anim: inputState.ClearAllInput(); anim->animbuf = nullptr; diff --git a/source/games/duke/src/anim.h b/source/games/duke/src/anim.h index 49241f4b6..a113f4fef 100644 --- a/source/games/duke/src/anim.h +++ b/source/games/duke/src/anim.h @@ -25,7 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS -struct animsound_t { +struct animsound_t +{ uint16_t frame = 0; int16_t sound = 0; }; diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index 0a515e922..f0ef4919b 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "osdcmds.h" #include "cheats.h" #include "mapinfo.h" @@ -428,9 +428,9 @@ void G_DoCheats(void) { case CHEAT_WEAPONS: { - int const weaponLimit = (VOLUMEONE) ? 6 : 0; + int const weaponLimit = (VOLUMEONE) ? SHRINKER_WEAPON : MAX_WEAPONS; - for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < MAX_WEAPONS-weaponLimit; weaponNum++) + for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < weaponLimit; weaponNum++) { P_AddAmmo(pPlayer, weaponNum, pPlayer->max_ammo_amount[weaponNum]); pPlayer->gotweapon |= (1<gotweapon |= (1<gotweapon |= (1 << weaponNum); - for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < MAX_WEAPONS-weaponLimit; weaponNum++) + for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < weaponLimit; weaponNum++) P_AddAmmo(pPlayer, weaponNum, pPlayer->max_ammo_amount[weaponNum]); if (RRRA) diff --git a/source/games/duke/src/cmdline.cpp b/source/games/duke/src/cmdline.cpp index deb9a9590..bd09600fd 100644 --- a/source/games/duke/src/cmdline.cpp +++ b/source/games/duke/src/cmdline.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "demo.h" #include "screens.h" #include "baselayer.h" diff --git a/source/games/duke/src/config.cpp b/source/games/duke/src/config.cpp index 6d426c5d4..ca2622fc3 100644 --- a/source/games/duke/src/config.cpp +++ b/source/games/duke/src/config.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "osdcmds.h" #include "baselayer.h" #include "cmdline.h" @@ -42,7 +42,7 @@ int32_t CONFIG_ReadSetup(void) ud.camera_time = 0;//4; ud.screen_tilting = 1; - ud.statusbarflags = STATUSBAR_NOSHRINK; + ud.statusbarflags = 0;// STATUSBAR_NOSHRINK; playerteam = 0; ud.angleinterpolation = 0; diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 5c7c8ef62..c3d988954 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "cheats.h" #include "compat.h" #include "demo.h" -#include "duke3d_ed.h" +#include "duke3d.h" #include "menus.h" #include "osdcmds.h" @@ -326,7 +326,7 @@ void Menu_DHLeaonardHeadDisplay(vec2_t pos) // //---------------------------------------------------------------------------- -class Duke3dListMenu : public DListMenu +class DukeListMenu : public DListMenu { using Super = DListMenu; protected: @@ -369,17 +369,17 @@ protected: } }; -class Duke3dMainMenu : public Duke3dListMenu +class DukeMainMenu : public DukeListMenu { virtual void Init(DMenu* parent = NULL, FListMenuDescriptor* desc = NULL) override { - Duke3dListMenu::Init(parent, desc); + DukeListMenu::Init(parent, desc); Menu_DHLeaonardHeadReset(); } void PreDraw() override { - Duke3dListMenu::PreDraw(); + DukeListMenu::PreDraw(); if (DEER) { vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) }; @@ -405,11 +405,11 @@ class Duke3dMainMenu : public Duke3dListMenu }; -class Duke3dHuntMenu : public Duke3dListMenu +class DukeHuntMenu : public DukeListMenu { void PreDraw() override { - Duke3dListMenu::PreDraw(); + DukeListMenu::PreDraw(); vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) }; int t1, t2; short ang; @@ -443,11 +443,11 @@ class Duke3dHuntMenu : public Duke3dListMenu } }; -class Duke3dTargetMenu : public Duke3dListMenu +class DukeTargetMenu : public DukeListMenu { void PreDraw() override { - Duke3dListMenu::PreDraw(); + DukeListMenu::PreDraw(); vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) }; int t1, t2; short ang; @@ -472,11 +472,11 @@ class Duke3dTargetMenu : public Duke3dListMenu } }; -class Duke3dWeaponMenu : public Duke3dListMenu +class DukeWeaponMenu : public DukeListMenu { void PreDraw() override { - Duke3dListMenu::PreDraw(); + DukeListMenu::PreDraw(); vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) }; int t1, t2; switch (mDesc->mSelectedItem) @@ -508,11 +508,11 @@ class Duke3dWeaponMenu : public Duke3dListMenu } }; -class Duke3dTrophiesMenu : public Duke3dListMenu +class DukeTrophiesMenu : public DukeListMenu { void PreDraw() override { - Duke3dListMenu::PreDraw(); + DukeListMenu::PreDraw(); vec2_t forigin = { int(origin.X * 65536), int(origin.Y * 65536) }; if (g_player[myconnectindex].ps->gm & MODE_GAME) { @@ -580,7 +580,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, double xpos, doub void GameInterface::MenuOpened() { - S_PauseSound(true, false); + S_PauseSounds(true); if ((!g_netServer && ud.multimode < 2)) { ready2send = 0; @@ -646,7 +646,7 @@ void GameInterface::MenuClosed() } G_UpdateScreenArea(); - S_ResumeSound(false); + S_PauseSounds(false); } } @@ -775,13 +775,13 @@ END_DUKE_NS //---------------------------------------------------------------------------- -static TMenuClassDescriptor _mm("Duke3d.MainMenu"); -static TMenuClassDescriptor _lm("Duke3d.ListMenu"); -static TMenuClassDescriptor _dhm("Duke3d.HuntMenu"); -static TMenuClassDescriptor _dtm("Duke3d.TargetMenu"); -static TMenuClassDescriptor _dwm("Duke3d.WeaponMenu"); -static TMenuClassDescriptor _dttm("Duke3d.TrophiesMenu"); -static TMenuClassDescriptor _ism("Duke3d.ImageScrollerMenu"); // does not implement a new class, we only need the descriptor. +static TMenuClassDescriptor _mm("Duke.MainMenu"); +static TMenuClassDescriptor _lm("Duke.ListMenu"); +static TMenuClassDescriptor _dhm("Duke.HuntMenu"); +static TMenuClassDescriptor _dtm("Duke.TargetMenu"); +static TMenuClassDescriptor _dwm("Duke.WeaponMenu"); +static TMenuClassDescriptor _dttm("Duke.TrophiesMenu"); +static TMenuClassDescriptor _ism("Duke.ImageScrollerMenu"); // does not implement a new class, we only need the descriptor. void RegisterDuke3dMenus() { diff --git a/source/games/duke/src/demo.cpp b/source/games/duke/src/demo.cpp index e08758417..b4ba9b6a3 100644 --- a/source/games/duke/src/demo.cpp +++ b/source/games/duke/src/demo.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! #include "demo.h" -#include "duke3d_ed.h" +#include "duke3d.h" #include "menus.h" #include "savegame.h" @@ -120,7 +120,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine gFullMap = false; ud.god = ud.cashman = ud.eog = 0; - ud.noclip = ud.scrollmode = ud.overhead_on = 0; //= paused = 0; + ud.noclip = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0; totalclock = ototalclock = lockclock = 0; @@ -591,7 +591,7 @@ RECHECK: Demo_FinishProfile(); while (totalclock >= (lockclock+TICSPERFRAME) - // || (ud.reccnt > REALGAMETICSPERSEC*2 && paused) + // || (ud.reccnt > REALGAMETICSPERSEC*2 && ud.pause_on) || (g_demo_goalCnt>0 && g_demo_cnt 0 || videoGetRenderMode() >= REND_POLYMOST) // JBF 20040101: redraw background always { - videoClearScreen(0); + //videoClearScreen(0); #ifndef EDUKE32_TOUCH_DEVICES if (ud.screen_size >= 8) #endif @@ -850,7 +849,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) videoSetCorrectedAspect(); } - if (paused || pPlayer->on_crane > -1) + if (ud.pause_on || pPlayer->on_crane > -1) smoothRatio = 65536; else smoothRatio = calc_smoothratio(totalclock, ototalclock); @@ -918,14 +917,14 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) )) { #ifdef USE_OPENGL - renderSetRollAngle(fix16_to_float(pPlayer->q16rotscrnang)); + renderSetRollAngle(pPlayer->orotscrnang + mulscale16(((pPlayer->rotscrnang - pPlayer->orotscrnang + 1024)&2047)-1024, smoothRatio)); #endif - pPlayer->oq16rotscrnang = pPlayer->q16rotscrnang; + pPlayer->orotscrnang = pPlayer->rotscrnang; } if (RRRA && pPlayer->drug_mode > 0) { - while (pPlayer->drug_timer < totalclock && !(pPlayer->gm & MODE_MENU) && !paused && !System_WantGuiCapture()) + while (pPlayer->drug_timer < totalclock && !(pPlayer->gm & MODE_MENU) && !ud.pause_on && !System_WantGuiCapture()) { int aspect; if (pPlayer->drug_stat[0] == 0) @@ -1016,7 +1015,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) omypos.z + mulscale16(mypos.z - omypos.z, smoothRatio) }; CAMERA(pos) = camVect; - CAMERA(q16ang) = myang + pPlayer->q16look_ang; + CAMERA(q16ang) = myang + fix16_from_int(pPlayer->look_ang); CAMERA(q16horiz) = myhoriz + myhorizoff; CAMERA(sect) = mycursectnum; } @@ -1026,21 +1025,9 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) pPlayer->opos.y + mulscale16(pPlayer->pos.y - pPlayer->opos.y, smoothRatio), pPlayer->opos.z + mulscale16(pPlayer->pos.z - pPlayer->opos.z, smoothRatio) }; - CAMERA(pos) = camVect; - - if (pPlayer->wackedbyactor >= 0) - { - CAMERA(q16ang) = pPlayer->oq16ang - + mulscale16(((pPlayer->q16ang + F16(1024) - pPlayer->oq16ang) & 0x7FFFFFF) - F16(1024), smoothRatio) - + pPlayer->q16look_ang; - CAMERA(q16horiz) = pPlayer->oq16horiz + pPlayer->oq16horizoff - + mulscale16((pPlayer->q16horiz + pPlayer->q16horizoff - pPlayer->oq16horiz - pPlayer->oq16horizoff), smoothRatio); - } - else - { - CAMERA(q16ang) = pPlayer->q16ang + pPlayer->q16look_ang; - CAMERA(q16horiz) = pPlayer->q16horiz + pPlayer->q16horizoff; - } + CAMERA(pos) = camVect; + CAMERA(q16ang) = pPlayer->q16ang + fix16_from_int(pPlayer->look_ang); + CAMERA(q16horiz) = pPlayer->q16horiz + pPlayer->q16horizoff; } if (cl_viewbob) @@ -1070,7 +1057,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) // looking through viewscreen CAMERA(pos) = camVect; - CAMERA(q16ang) = pPlayer->q16ang + pPlayer->q16look_ang; + CAMERA(q16ang) = pPlayer->q16ang + fix16_from_int(pPlayer->look_ang); CAMERA(q16horiz) = fix16_from_int(100 + sprite[pPlayer->newowner].shade); CAMERA(sect) = sprite[pPlayer->newowner].sectnum; } @@ -3180,8 +3167,7 @@ rr_badguy: } else changespritestat(newSprite, STAT_ZOMBIEACTOR); - if (RR && spriteNum >= 0) - pSprite->shade = sprite[spriteNum].shade; + pSprite->shade = sprite[spriteNum].shade; } break; @@ -5026,7 +5012,7 @@ default_case1: spritesortcnt++; } - if (g_player[playerNum].input->extbits & (1 << 7) && !paused && spritesortcnt < maxspritesonscreen) + if (g_player[playerNum].input->extbits & (1 << 7) && !ud.pause_on && spritesortcnt < maxspritesonscreen) { tspritetype *const playerTyping = t; @@ -5280,11 +5266,11 @@ default_case2: if ((unsigned)scrofs_action + ACTION_VIEWTYPE >= (unsigned)g_scriptSize) goto skip; - l = apScript[scrofs_action + ACTION_VIEWTYPE]; + int viewtype = apScript[scrofs_action + ACTION_VIEWTYPE]; uint16_t const action_flags = apScript[scrofs_action + ACTION_FLAGS]; - int const invertp = l < 0; - l = klabs(l); + int const invertp = viewtype < 0; + l = klabs(viewtype); #ifdef USE_OPENGL if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) @@ -6598,12 +6584,6 @@ static inline void G_CheckGametype(void) ud.m_respawn_items = ud.m_respawn_inventory = 1; } -static void G_PostLoadPalette(void) -{ - //if (!(duke3d_globalflags & DUKE3D_NO_HARDCODED_FOGPALS)) - // paletteSetupDefaultFog(); -} - #define SETFLAG(Tilenum, Flag) g_tile[Tilenum].flags |= Flag // Has to be after setting the dynamic names (e.g. SHARK). @@ -7123,8 +7103,6 @@ int GameInterface::app_main() enginePostInit(); - G_PostLoadPalette(); - tileDelete(MIRROR); skiptile = W_FORCEFIELD + 1; @@ -7296,59 +7274,49 @@ MAIN_LOOP_RESTART: char gameUpdate = false; double const gameUpdateStartTime = timerGetHiTicks(); - - updatePauseStatus(); - - if (paused) + + while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME) { - ototalclock = totalclock - TICSPERFRAME; - buttonMap.ResetButtonStates(); - } - else - { - while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && (int)(totalclock - ototalclock) >= TICSPERFRAME) + ototalclock += TICSPERFRAME; + + if (RRRA && g_player[myconnectindex].ps->on_motorcycle) + P_GetInputMotorcycle(myconnectindex); + else if (RRRA && g_player[myconnectindex].ps->on_boat) + P_GetInputBoat(myconnectindex); + else + P_GetInput(myconnectindex); + + // this is where we fill the input_t struct that is actually processed by P_ProcessInput() + auto const pPlayer = g_player[myconnectindex].ps; + auto const q16ang = fix16_to_int(pPlayer->q16ang); + auto & input = inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex]; + + input = localInput; + input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) + + mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]) + + pPlayer->fric.x; + input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) + + mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]) + + pPlayer->fric.y; + localInput = {}; + + g_player[myconnectindex].movefifoend++; + + if (((!System_WantGuiCapture() && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && + (g_player[myconnectindex].ps->gm&MODE_GAME)) { - if (RRRA && g_player[myconnectindex].ps->on_motorcycle) - P_GetInputMotorcycle(myconnectindex); - else if (RRRA && g_player[myconnectindex].ps->on_boat) - P_GetInputBoat(myconnectindex); - else - P_GetInput(myconnectindex); - - // this is where we fill the input_t struct that is actually processed by P_ProcessInput() - auto const pPlayer = g_player[myconnectindex].ps; - auto const q16ang = fix16_to_int(pPlayer->q16ang); - auto & input = inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex]; - - input = localInput; - input.fvel = mulscale9(localInput.fvel, sintable[(q16ang + 2560) & 2047]) + - mulscale9(localInput.svel, sintable[(q16ang + 2048) & 2047]) + - pPlayer->fric.x; - input.svel = mulscale9(localInput.fvel, sintable[(q16ang + 2048) & 2047]) + - mulscale9(localInput.svel, sintable[(q16ang + 1536) & 2047]) + - pPlayer->fric.y; - localInput = {}; - - g_player[myconnectindex].movefifoend++; - - ototalclock += TICSPERFRAME; - - if (paused == 0 && (!System_WantGuiCapture() || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && - (g_player[myconnectindex].ps->gm&MODE_GAME)) - { - G_MoveLoop(); - } + G_MoveLoop(); } - - gameUpdate = true; - g_gameUpdateTime = timerGetHiTicks()-gameUpdateStartTime; - if (g_gameUpdateAvgTime < 0.f) - g_gameUpdateAvgTime = g_gameUpdateTime; - g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES); - - G_DoCheats(); } + gameUpdate = true; + g_gameUpdateTime = timerGetHiTicks()-gameUpdateStartTime; + if (g_gameUpdateAvgTime < 0.f) + g_gameUpdateAvgTime = g_gameUpdateTime; + g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES-1.f)*g_gameUpdateAvgTime+g_gameUpdateTime)/((float) GAMEUPDATEAVGTIMENUMSAMPLES); + + G_DoCheats(); + if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART)) { switch (G_EndOfLevel()) @@ -7531,8 +7499,11 @@ int G_DoMoveThings(void) everyothertime++; if (g_earthquakeTime > 0) g_earthquakeTime--; + if (ud.pause_on == 0) + { g_globalRandom = krand2(); A_MoveDummyPlayers();//ST 13 + } for (bssize_t TRAVERSE_CONNECT(i)) { @@ -7554,11 +7525,15 @@ int G_DoMoveThings(void) if (!DEER) P_HandleSharedKeys(i); + if (ud.pause_on == 0) + { P_ProcessInput(i); if (!DEER) P_CheckSectors(i); } + } + if (ud.pause_on == 0) G_MoveWorld(); Net_CorrectPrediction(); diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index ec2adcdad..f6cf21666 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif #include "fix16.h" -#include "gamedefs.h" #include "gamedef.h" #include "net.h" #include "mmulti.h" @@ -123,6 +122,8 @@ void A_DeleteSprite(int spriteNum); #define MAX_RETURN_VALUES 6 +// KEEPINSYNC lunatic/_defs_game.lua + typedef struct { vec3_t camerapos; int32_t const_visibility,uw_framerate; @@ -312,7 +313,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk if (!(((!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || (g_netServer || ud.multimode > 1) || ud.recstat == 2) || - paused) + ud.pause_on) { return 65536; } diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index c94f62ea7..ed43c9240 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "namesdyn.h" #include "gamedef.h" #include "gameexec.h" diff --git a/source/games/duke/src/gamedef.h b/source/games/duke/src/gamedef.h index 22b5d28a2..56de09e0b 100644 --- a/source/games/duke/src/gamedef.h +++ b/source/games/duke/src/gamedef.h @@ -348,6 +348,7 @@ enum ScriptKeywords_t CON_IFPUPWIND, // 166 CON_END }; +// KEEPINSYNC with the keyword list in lunatic/con_lang.lua END_DUKE_NS diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 9c1268ce7..5b944d02e 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" -#include "duke3d_ed.h" +#include "duke3d.h" #include "anim.h" @@ -261,8 +261,8 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *pPlayer) pPlayer->q16horiz += F16(64); pPlayer->return_to_center = 9; - pPlayer->q16rotscrnang = fix16_from_int(nAngle >> 1); - pPlayer->q16look_ang = pPlayer->q16rotscrnang; + pPlayer->rotscrnang = nAngle >> 1; + pPlayer->look_ang = pPlayer->rotscrnang; } // wow, this function sucks @@ -492,20 +492,6 @@ int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle) return newAngle-currAngle; } -fix16_t __fastcall G_GetQ16AngleDelta(fix16_t oldAngle, fix16_t newAngle) -{ - if (fix16_abs(fix16_sub(oldAngle, newAngle)) < fix16_from_int(1024)) - return fix16_sub(newAngle, oldAngle); - - if (newAngle > fix16_from_int(1024)) - newAngle = fix16_sub(newAngle, fix16_from_int(2048)); - - if (oldAngle > fix16_from_int(1024)) - oldAngle = fix16_sub(oldAngle, fix16_from_int(2048)); - - return fix16_sub(newAngle, oldAngle); -} - GAMEEXEC_STATIC void VM_AlterAng(int32_t const moveFlags) { int const elapsedTics = (AC_COUNT(vm.pData))&31; @@ -1916,8 +1902,14 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; } insptr++; - if (!RR || ((g_spriteExtra[vm.spriteNum] < 1 || g_spriteExtra[vm.spriteNum] == 128) && A_CheckSpriteFlags(vm.spriteNum, SFLAG_KILLCOUNT))) + if (RR) + { + // This check does not exist in Duke Nukem. + if ((g_spriteExtra[vm.spriteNum] < 1 || g_spriteExtra[vm.spriteNum] == 128) + && (!RR || A_CheckSpriteFlags(vm.spriteNum, SFLAG_KILLCOUNT))) P_AddKills(pPlayer, *insptr); + } + else P_AddKills(pPlayer, *insptr); insptr++; vm.pActor->actorstayput = -1; continue; diff --git a/source/games/duke/src/gameexec.h b/source/games/duke/src/gameexec.h index 53e207e49..e3654eeb7 100644 --- a/source/games/duke/src/gameexec.h +++ b/source/games/duke/src/gameexec.h @@ -74,7 +74,6 @@ void A_Fall(int spriteNum); int32_t A_GetFurthestAngle(int spriteNum, int angDiv); void A_GetZLimits(int spriteNum); int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle); -fix16_t __fastcall G_GetQ16AngleDelta(fix16_t oldAngle, fix16_t newAngle); //void G_RestoreMapState(); //void G_SaveMapState(); diff --git a/source/games/duke/src/gamevars.cpp b/source/games/duke/src/gamevars.cpp index c1f590ad3..6cd4a3e92 100644 --- a/source/games/duke/src/gamevars.cpp +++ b/source/games/duke/src/gamevars.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "menus.h" #include "savegame.h" #include "namesdyn.h" @@ -654,18 +654,32 @@ static int32_t G_StaticToDynamicSound(int32_t const sound) } } -// Initialize WEAPONx_* gamevars. In C-CON, a new CON variable is defined together with +// Initialize WEAPONx_* gamevars. Since for Lunatic, they reside on the C side, +// they're set directly. In C-CON, a new CON variable is defined together with // its initial value. +#ifdef LUNATIC +# define ADDWEAPONVAR(Weapidx, Membname) do { \ + int32_t j; \ + for (j=0; jq16look_ang)) / 9; + int const fistY = klabs(pPlayer->look_ang) / 9; int const fistZoom = clamp(65536 - (sintable[(512 + (fistInc << 6)) & 2047] << 2), 40920, 90612); int const fistYOffset = 194 + (sintable[((6 + fistInc) << 7) & 2047] >> 9); int const fistPal = P_GetHudPal(pPlayer); @@ -1610,10 +1609,10 @@ static int P_DisplayKnee(int kneeShade) if (ps->knee_incs >= ARRAY_SIZE(knee_y) || sprite[ps->i].extra <= 0) return 0; - int const kneeY = knee_y[ps->knee_incs] + (klabs(fix16_to_int(ps->q16look_ang)) / 9) - (ps->hard_landing << 3); + int const kneeY = knee_y[ps->knee_incs] + (klabs(ps->look_ang) / 9) - (ps->hard_landing << 3); int const kneePal = P_GetKneePal(ps); - G_DrawTileScaled(105+(fix16_to_int(g_player[screenpeek].input->q16avel)>>5)-(fix16_to_int(ps->q16look_ang)>>1)+(knee_y[ps->knee_incs]>>2), + G_DrawTileScaled(105+(fix16_to_int(g_player[screenpeek].input->q16avel)>>5)-(ps->look_ang>>1)+(knee_y[ps->knee_incs]>>2), kneeY+280-(fix16_to_int(ps->q16horiz-ps->q16horizoff)>>4),KNEE,kneeShade,4+DRAWEAP_CENTER,kneePal); return 1; @@ -1633,10 +1632,10 @@ static int P_DisplayKnuckles(int knuckleShade) if ((unsigned) (pPlayer->knuckle_incs>>1) >= ARRAY_SIZE(knuckleFrames) || sprite[pPlayer->i].extra <= 0) return 0; - int const knuckleY = (klabs(fix16_to_int(pPlayer->q16look_ang)) / 9) - (pPlayer->hard_landing << 3); + int const knuckleY = (klabs(pPlayer->look_ang) / 9) - (pPlayer->hard_landing << 3); int const knucklePal = P_GetHudPal(pPlayer); - G_DrawTileScaled(160 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawTileScaled(160 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (pPlayer->look_ang >> 1), knuckleY + 180 - (fix16_to_int(pPlayer->q16horiz - pPlayer->q16horizoff) >> 4), CRACKKNUCKLES + knuckleFrames[pPlayer->knuckle_incs >> 1], knuckleShade, 4 + DRAWEAP_CENTER, knucklePal); @@ -1804,13 +1803,13 @@ static int P_DisplayTip(int tipShade) if ((unsigned)pPlayer->tipincs >= ARRAY_SIZE(access_tip_y)) return 1; - int const tipY = (klabs(fix16_to_int(pPlayer->q16look_ang)) / 9) - (pPlayer->hard_landing << 3); + int const tipY = (klabs(pPlayer->look_ang) / 9) - (pPlayer->hard_landing << 3); int const tipPal = P_GetHudPal(pPlayer); int const tipYOffset = access_tip_y[pPlayer->tipincs] >> 1; guniqhudid = 201; - G_DrawTileScaled(170 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawTileScaled(170 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (pPlayer->look_ang >> 1), tipYOffset + tipY + 240 - (fix16_to_int(pPlayer->q16horiz - pPlayer->q16horizoff) >> 4), TIP + ((26 - pPlayer->tipincs) >> 4), tipShade, DRAWEAP_CENTER, tipPal); @@ -1830,20 +1829,20 @@ static int P_DisplayAccess(int accessShade) return 1; int const accessX = access_tip_y[pSprite->access_incs] >> 2; - int const accessY = access_tip_y[pSprite->access_incs] + (klabs(fix16_to_int(pSprite->q16look_ang)) / 9) - (pSprite->hard_landing << 3); + int const accessY = access_tip_y[pSprite->access_incs] + (klabs(pSprite->look_ang) / 9) - (pSprite->hard_landing << 3); int const accessPal = (pSprite->access_spritenum >= 0) ? sprite[pSprite->access_spritenum].pal : 0; guniqhudid = 200; if ((pSprite->access_incs - 3) > 0 && (pSprite->access_incs - 3) >> 3) { - G_DrawTileScaled(170 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (fix16_to_int(pSprite->q16look_ang) >> 1) + accessX, + G_DrawTileScaled(170 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (pSprite->look_ang >> 1) + accessX, accessY + 266 - (fix16_to_int(pSprite->q16horiz - pSprite->q16horizoff) >> 4), HANDHOLDINGLASER + (pSprite->access_incs >> 3), accessShade, DRAWEAP_CENTER, accessPal); } else { - G_DrawTileScaled(170 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (fix16_to_int(pSprite->q16look_ang) >> 1) + accessX, + G_DrawTileScaled(170 + (fix16_to_int(g_player[screenpeek].input->q16avel) >> 5) - (pSprite->look_ang >> 1) + accessX, accessY + 266 - (fix16_to_int(pSprite->q16horiz - pSprite->q16horizoff) >> 4), HANDHOLDINGACCESS, accessShade, 4 + DRAWEAP_CENTER, accessPal); } @@ -1892,7 +1891,7 @@ void P_DisplayWeapon(void) return; int weaponX = (160) - 90; - int weaponY = klabs(fix16_to_int(pPlayer->q16look_ang)) / 9; + int weaponY = klabs(pPlayer->look_ang) / 9; int weaponYOffset = 80 - (pPlayer->weapon_pos * pPlayer->weapon_pos); int weaponShade = (RR && pPlayer->cursectnum >= 0 && g_shadedSector[pPlayer->cursectnum]) ? 16 : (sprite[pPlayer->i].shade <= 24 ? sprite[pPlayer->i].shade : 24); @@ -1926,7 +1925,7 @@ void P_DisplayWeapon(void) hudweap.gunposx = weaponX; hudweap.shade = weaponShade; hudweap.count = *weaponFrame; - hudweap.lookhalfang = fix16_to_int(pPlayer->q16look_ang) >> 1; + hudweap.lookhalfang = pPlayer->look_ang >> 1; quickKickFrame = 14 - pPlayer->quick_kick; @@ -1937,10 +1936,10 @@ void P_DisplayWeapon(void) guniqhudid = 100; if (quickKickFrame < 6 || quickKickFrame > 12) - G_DrawTileScaled(weaponX + 80 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 250 - weaponYOffset, KNEE, weaponShade, + G_DrawTileScaled(weaponX + 80 - (pPlayer->look_ang >> 1), weaponY + 250 - weaponYOffset, KNEE, weaponShade, weaponBits | 4 | DRAWEAP_CENTER, weaponPal); else - G_DrawTileScaled(weaponX + 160 - 16 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 214 - weaponYOffset, KNEE + 1, + G_DrawTileScaled(weaponX + 160 - 16 - (pPlayer->look_ang >> 1), weaponY + 214 - weaponYOffset, KNEE + 1, weaponShade, weaponBits | 4 | DRAWEAP_CENTER, weaponPal); guniqhudid = 0; } @@ -1983,7 +1982,7 @@ void P_DisplayWeapon(void) int const weaponPal = P_GetHudPal(pPlayer); - G_DrawTileScaled(160-(fix16_to_int(pPlayer->q16look_ang)>>1), 174, motoTile, weaponShade, 2 | DRAWEAP_CENTER, + G_DrawTileScaled(160-(pPlayer->look_ang>>1), 174, motoTile, weaponShade, 2 | DRAWEAP_CENTER, weaponPal, 34816, pPlayer->tilt_status * 5 + (pPlayer->tilt_status < 0 ? 2047 : 0)); return; } @@ -2050,7 +2049,7 @@ void P_DisplayWeapon(void) else weaponY = 170 + (*weaponFrame>>2); - G_DrawTileScaled(160-(fix16_to_int(pPlayer->q16look_ang)>>1), weaponY, boatTile, weaponShade, 2 | DRAWEAP_CENTER, + G_DrawTileScaled(160-(pPlayer->look_ang>>1), weaponY, boatTile, weaponShade, 2 | DRAWEAP_CENTER, weaponPal, 66048, pPlayer->tilt_status + (pPlayer->tilt_status < 0 ? 2047 : 0)); return; } @@ -2071,10 +2070,10 @@ void P_DisplayWeapon(void) currentWeapon = weaponX; weaponX += sintable[(fistPos)&2047] >> 10; - G_DrawTileScaled(weaponX + 250 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 258 - (klabs(sintable[(fistPos)&2047] >> 8)), + G_DrawTileScaled(weaponX + 250 - (pPlayer->look_ang >> 1), weaponY + 258 - (klabs(sintable[(fistPos)&2047] >> 8)), FIST, weaponShade, weaponBits, weaponPal); weaponX = currentWeapon - (sintable[(fistPos)&2047] >> 10); - G_DrawTileScaled(weaponX + 40 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 200 + (klabs(sintable[(fistPos)&2047] >> 8)), FIST, + G_DrawTileScaled(weaponX + 40 - (pPlayer->look_ang >> 1), weaponY + 200 + (klabs(sintable[(fistPos)&2047] >> 8)), FIST, weaponShade, weaponBits | 4, weaponPal); } else @@ -2093,8 +2092,8 @@ void P_DisplayWeapon(void) if (!RR && currentWeapon == KNEE_WEAPON && *weaponFrame == 0) goto enddisplayweapon; - int const doAnim = !(sprite[pPlayer->i].pal == 1 || paused || g_player[myconnectindex].ps->gm & MODE_MENU); - int const halfLookAng = fix16_to_int(pPlayer->q16look_ang) >> 1; + int const doAnim = !(sprite[pPlayer->i].pal == 1 || ud.pause_on || g_player[myconnectindex].ps->gm & MODE_MENU); + int const halfLookAng = pPlayer->look_ang >> 1; int const weaponPal = P_GetHudPal(pPlayer); @@ -2353,16 +2352,16 @@ void P_DisplayWeapon(void) switch (*weaponFrame) { case 0: - G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (fix16_to_int(pPlayer->q16look_ang) >> 1) + 30, weaponY + 233 - weaponYOffset + 5, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (pPlayer->look_ang >> 1) + 30, weaponY + 233 - weaponYOffset + 5, CHAINGUN, weaponShade, weaponBits, weaponPal, 32768); break; default: if (*weaponFrame < 8) - G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (fix16_to_int(pPlayer->q16look_ang) >> 1) + 30, weaponY + 233 - weaponYOffset + 5, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (pPlayer->look_ang >> 1) + 30, weaponY + 233 - weaponYOffset + 5, CHAINGUN + 1, 0, weaponBits, weaponPal, 32768); else - G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (fix16_to_int(pPlayer->q16look_ang) >> 1) + 30, weaponY + 233 - weaponYOffset + 5, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (pPlayer->look_ang >> 1) + 30, weaponY + 233 - weaponYOffset + 5, CHAINGUN + 2, weaponShade, weaponBits, weaponPal, 32768); break; @@ -2380,7 +2379,7 @@ void P_DisplayWeapon(void) if (frame) weaponShade = 0; - G_DrawWeaponTileWithID(currentWeapon, offsetX[frame] - 12 + weaponX - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + offsetY[frame] - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, offsetX[frame] - 12 + weaponX - (pPlayer->look_ang >> 1), weaponY + offsetY[frame] - weaponYOffset, FIRSTGUN + frame, weaponShade, weaponBits, weaponPal, 36700); break; @@ -2485,11 +2484,11 @@ void P_DisplayWeapon(void) { static uint8_t freezerFrames[] = { 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - G_DrawWeaponTileWithID(currentWeapon, weaponX + 260 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 215 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 260 - (pPlayer->look_ang >> 1), weaponY + 215 - weaponYOffset, FREEZE + freezerFrames[*weaponFrame], -32, weaponBits, weaponPal, 32768); } else - G_DrawWeaponTileWithID(currentWeapon, weaponX + 260 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 215 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 260 - (pPlayer->look_ang >> 1), weaponY + 215 - weaponYOffset, FREEZE, weaponShade, weaponBits, weaponPal, 32768); break; @@ -2787,7 +2786,7 @@ void P_DisplayWeapon(void) switch (*weaponFrame) { case 0: - G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 233 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (pPlayer->look_ang >> 1), weaponY + 233 - weaponYOffset, CHAINGUN + 1, weaponShade, weaponBits, weaponPal); break; @@ -2795,11 +2794,11 @@ void P_DisplayWeapon(void) if (*weaponFrame > 4 && *weaponFrame < 12) { int randomOffset = doAnim ? rand()&7 : 0; - G_DrawWeaponTileWithID(currentWeapon << 2, randomOffset + weaponX - 4 + 140 - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawWeaponTileWithID(currentWeapon << 2, randomOffset + weaponX - 4 + 140 - (pPlayer->look_ang >> 1), randomOffset + weaponY - ((*weaponFrame) >> 1) + 208 - weaponYOffset, CHAINGUN + 5 + ((*weaponFrame - 4) / 5), weaponShade, weaponBits, weaponPal); if (doAnim) randomOffset = rand()&7; - G_DrawWeaponTileWithID(currentWeapon << 2, randomOffset + weaponX - 4 + 184 - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawWeaponTileWithID(currentWeapon << 2, randomOffset + weaponX - 4 + 184 - (pPlayer->look_ang >> 1), randomOffset + weaponY - ((*weaponFrame) >> 1) + 208 - weaponYOffset, CHAINGUN + 5 + ((*weaponFrame - 4) / 5), weaponShade, weaponBits, weaponPal); } @@ -2807,20 +2806,20 @@ void P_DisplayWeapon(void) if (*weaponFrame < 8) { int const randomOffset = doAnim ? rand()&7 : 0; - G_DrawWeaponTileWithID(currentWeapon << 2, randomOffset + weaponX - 4 + 162 - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawWeaponTileWithID(currentWeapon << 2, randomOffset + weaponX - 4 + 162 - (pPlayer->look_ang >> 1), randomOffset + weaponY - ((*weaponFrame) >> 1) + 208 - weaponYOffset, CHAINGUN + 5 + ((*weaponFrame - 2) / 5), weaponShade, weaponBits, weaponPal); - G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 233 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (pPlayer->look_ang >> 1), weaponY + 233 - weaponYOffset, CHAINGUN + 1 + ((*weaponFrame) >> 1), weaponShade, weaponBits, weaponPal); } else - G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 233 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 178 - (pPlayer->look_ang >> 1), weaponY + 233 - weaponYOffset, CHAINGUN + 1, weaponShade, weaponBits, weaponPal); break; } - G_DrawWeaponTileWithID(currentWeapon << 1, weaponX + 168 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 260 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon << 1, weaponX + 168 - (pPlayer->look_ang >> 1), weaponY + 260 - weaponYOffset, CHAINGUN, weaponShade, weaponBits, weaponPal); break; @@ -2833,7 +2832,7 @@ void P_DisplayWeapon(void) if ((*weaponFrame) == 2) pistolOffset -= 3; - G_DrawWeaponTileWithID(currentWeapon, (pistolOffset - (fix16_to_int(pPlayer->q16look_ang) >> 1)), (weaponY + 244 - weaponYOffset), + G_DrawWeaponTileWithID(currentWeapon, (pistolOffset - (pPlayer->look_ang >> 1)), (weaponY + 244 - weaponYOffset), FIRSTGUN + pistolFrames[*weaponFrame > 2 ? 0 : *weaponFrame], weaponShade, 2, weaponPal); @@ -2844,41 +2843,41 @@ void P_DisplayWeapon(void) weaponBits |= 512; if ((*weaponFrame) < 10) - G_DrawWeaponTileWithID(currentWeapon, 194 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 230 - weaponYOffset, FIRSTGUN + 4, + G_DrawWeaponTileWithID(currentWeapon, 194 - (pPlayer->look_ang >> 1), weaponY + 230 - weaponYOffset, FIRSTGUN + 4, weaponShade, weaponBits, weaponPal); else if ((*weaponFrame) < 15) { - G_DrawWeaponTileWithID(currentWeapon << 1, 244 - ((*weaponFrame) << 3) - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawWeaponTileWithID(currentWeapon << 1, 244 - ((*weaponFrame) << 3) - (pPlayer->look_ang >> 1), weaponY + 130 - weaponYOffset + ((*weaponFrame) << 4), FIRSTGUN + 6, weaponShade, weaponBits, weaponPal); - G_DrawWeaponTileWithID(currentWeapon, 224 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 220 - weaponYOffset, FIRSTGUN + 5, + G_DrawWeaponTileWithID(currentWeapon, 224 - (pPlayer->look_ang >> 1), weaponY + 220 - weaponYOffset, FIRSTGUN + 5, weaponShade, weaponBits, weaponPal); } else if ((*weaponFrame) < 20) { - G_DrawWeaponTileWithID(currentWeapon << 1, 124 + ((*weaponFrame) << 1) - (fix16_to_int(pPlayer->q16look_ang) >> 1), + G_DrawWeaponTileWithID(currentWeapon << 1, 124 + ((*weaponFrame) << 1) - (pPlayer->look_ang >> 1), weaponY + 430 - weaponYOffset - ((*weaponFrame) << 3), FIRSTGUN + 6, weaponShade, weaponBits, weaponPal); - G_DrawWeaponTileWithID(currentWeapon, 224 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 220 - weaponYOffset, FIRSTGUN + 5, + G_DrawWeaponTileWithID(currentWeapon, 224 - (pPlayer->look_ang >> 1), weaponY + 220 - weaponYOffset, FIRSTGUN + 5, weaponShade, weaponBits, weaponPal); } else if ((*weaponFrame) < (WW2GI ? PWEAPON(screenpeek, PISTOL_WEAPON, Reload) - 12 : (NAM ? 38 : 23))) { - G_DrawWeaponTileWithID(currentWeapon << 2, 184 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 235 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon << 2, 184 - (pPlayer->look_ang >> 1), weaponY + 235 - weaponYOffset, FIRSTGUN + 8, weaponShade, weaponBits, weaponPal); - G_DrawWeaponTileWithID(currentWeapon, 224 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 210 - weaponYOffset, FIRSTGUN + 5, + G_DrawWeaponTileWithID(currentWeapon, 224 - (pPlayer->look_ang >> 1), weaponY + 210 - weaponYOffset, FIRSTGUN + 5, weaponShade, weaponBits, weaponPal); } else if ((*weaponFrame) < (WW2GI ? PWEAPON(screenpeek, PISTOL_WEAPON, Reload) - 6 : (NAM ? 44 : 25))) { - G_DrawWeaponTileWithID(currentWeapon << 2, 164 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 245 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon << 2, 164 - (pPlayer->look_ang >> 1), weaponY + 245 - weaponYOffset, FIRSTGUN + 8, weaponShade, weaponBits, weaponPal); - G_DrawWeaponTileWithID(currentWeapon, 224 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 220 - weaponYOffset, FIRSTGUN + 5, + G_DrawWeaponTileWithID(currentWeapon, 224 - (pPlayer->look_ang >> 1), weaponY + 220 - weaponYOffset, FIRSTGUN + 5, weaponShade, weaponBits, weaponPal); } else if ((*weaponFrame) < (WW2GI ? PWEAPON(screenpeek, PISTOL_WEAPON, Reload) : (NAM ? 50 : 27))) - G_DrawWeaponTileWithID(currentWeapon, 194 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 235 - weaponYOffset, FIRSTGUN + 5, + G_DrawWeaponTileWithID(currentWeapon, 194 - (pPlayer->look_ang >> 1), weaponY + 235 - weaponYOffset, FIRSTGUN + 5, weaponShade, weaponBits, weaponPal); break; @@ -3051,13 +3050,13 @@ void P_DisplayWeapon(void) weaponY += rand() & 3; } weaponYOffset -= 16; - G_DrawWeaponTileWithID(currentWeapon << 1, weaponX + 210 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 261 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon << 1, weaponX + 210 - (pPlayer->look_ang >> 1), weaponY + 261 - weaponYOffset, FREEZE + 2, -32, weaponBits, weaponPal); - G_DrawWeaponTileWithID(currentWeapon, weaponX + 210 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 235 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 210 - (pPlayer->look_ang >> 1), weaponY + 235 - weaponYOffset, FREEZE + 3 + freezerFrames[*weaponFrame % 6], -32, weaponBits, weaponPal); } else - G_DrawWeaponTileWithID(currentWeapon, weaponX + 210 - (fix16_to_int(pPlayer->q16look_ang) >> 1), weaponY + 261 - weaponYOffset, + G_DrawWeaponTileWithID(currentWeapon, weaponX + 210 - (pPlayer->look_ang >> 1), weaponY + 261 - weaponYOffset, FREEZE, weaponShade, weaponBits, weaponPal); break; @@ -3156,16 +3155,17 @@ enddisplayweapon: P_DisplaySpit(); } -#define TURBOTURNTIME (TICRATE/8) // 7 -#define NORMALTURN 15 -#define PREAMBLETURN 5 -#define NORMALKEYMOVE 40 -#define MAXVEL ((NORMALKEYMOVE*2)+10) -#define MAXSVEL ((NORMALKEYMOVE*2)+10) -#define MAXANGVEL 1024 -#define MAXHORIZVEL 256 -#define ONEEIGHTYSCALE 4 -#define MAXVELMOTO 120 +#define TURBOTURNTIME (TICRATE/8) // 7 +#define NORMALTURN 15 +#define PREAMBLETURN 5 +#define NORMALKEYMOVE 40 +#define MAXVEL ((NORMALKEYMOVE*2)+10) +#define MAXSVEL ((NORMALKEYMOVE*2)+10) +#define MAXANGVEL 1024 +#define MAXHORIZVEL 256 + +#define MOTOTURN 20 +#define MAXVELMOTO 120 int32_t g_myAimStat = 0, g_oldAimStat = 0; int32_t mouseyaxismode = -1; @@ -3181,8 +3181,7 @@ enum inputlock_t static int P_CheckLockedMovement(int const playerNum) { - auto &thisPlayer = g_player[playerNum]; - auto const pPlayer = thisPlayer.ps; + auto const pPlayer = g_player[playerNum].ps; if (pPlayer->on_crane >= 0) return IL_NOMOVE|IL_NOANGLE; @@ -3190,9 +3189,6 @@ static int P_CheckLockedMovement(int const playerNum) if (pPlayer->newowner != -1) return IL_NOANGLE|IL_NOHORIZ; - if (pPlayer->return_to_center > 0 || thisPlayer.horizRecenter) - return IL_NOHORIZ; - if (pPlayer->dead_flag || pPlayer->fist_incs || pPlayer->transporter_hold > 2 || pPlayer->hard_landing || pPlayer->access_incs > 0 || pPlayer->knee_incs > 0 || (PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == TRIPBOMB_WEAPON && pPlayer->kickback_pic > 1 @@ -3206,18 +3202,9 @@ void P_GetInput(int const playerNum) { auto &thisPlayer = g_player[playerNum]; auto const pPlayer = thisPlayer.ps; - auto const pSprite = &sprite[pPlayer->i]; ControlInfo info; - auto const currentHiTicks = timerGetHiTicks(); - double const elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; - - thisPlayer.lastInputTicks = currentHiTicks; - - if (elapsedInputTicks == currentHiTicks) - return; - - if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || paused) + if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) { if (!(pPlayer->gm&MODE_MENU)) CONTROL_GetInput(&info); @@ -3266,7 +3253,7 @@ void P_GetInput(int const playerNum) else { input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw * analogTurnAmount / (analogExtent >> 1))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw / analogExtent * (analogTurnAmount << 1))); } if (mouseaim) @@ -3280,6 +3267,12 @@ void P_GetInput(int const playerNum) input.svel -= info.dx * keyMove / analogExtent; input.fvel -= info.dz * keyMove / analogExtent; + static double lastInputTicks; + auto const currentHiTicks = timerGetHiTicks(); + double const elapsedInputTicks = currentHiTicks - lastInputTicks; + + lastInputTicks = currentHiTicks; + auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); }; if (buttonMap.ButtonDown(gamefunc_Strafe)) @@ -3504,11 +3497,6 @@ void P_GetInput(int const playerNum) { localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; - - if (input.q16avel) - { - pPlayer->one_eighty_count = 0; - } } if (!(movementLocked & IL_NOHORIZ)) @@ -3518,54 +3506,6 @@ void P_GetInput(int const playerNum) } } - // don't adjust rotscrnang and look_ang if dead. - if (pSprite->extra > 0) - { - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_sdiv(pPlayer->q16rotscrnang, fix16_from_int(2)))))); - - if (pPlayer->q16rotscrnang && !fix16_sdiv(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(2)))) - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(ksgn(fix16_to_int(pPlayer->q16rotscrnang))))); - - pPlayer->q16look_ang = fix16_ssub(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_sdiv(pPlayer->q16look_ang, fix16_from_int(4)))))); - - if (pPlayer->q16look_ang && !fix16_sdiv(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(4)))) - pPlayer->q16look_ang = fix16_ssub(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(ksgn(fix16_to_int(pPlayer->q16look_ang))))); - - if (thisPlayer.lookLeft) - { - pPlayer->q16look_ang = fix16_ssub(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(152))); - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - if (thisPlayer.lookRight) - { - pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(152))); - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - - if (pPlayer->one_eighty_count < 0) - { - pPlayer->one_eighty_count = -fix16_to_int(fix16_abs(G_GetQ16AngleDelta(pPlayer->one_eighty_target, pPlayer->q16ang))); - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(-pPlayer->one_eighty_count / ONEEIGHTYSCALE)))) & 0x7FFFFFF; - } - - if (RRRA && pPlayer->sea_sick) - { - if (pPlayer->sea_sick < 250) - { - if (pPlayer->sea_sick >= 180) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 130) - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 70) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 20) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - if (pPlayer->sea_sick < 250) - pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval((krand2()&255)-128))); - } - } - // A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units if (thisPlayer.horizAngleAdjust) @@ -3576,16 +3516,15 @@ void P_GetInput(int const playerNum) } else if (pPlayer->return_to_center > 0 || thisPlayer.horizRecenter) { - pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_from_dbl(66.535) - fix16_sdiv(pPlayer->q16horiz, fix16_from_dbl(1.505)))))); + pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_from_dbl(200 / 3) - fix16_sdiv(pPlayer->q16horiz, F16(1.5)))))); - if (pPlayer->q16horiz >= F16(99) && pPlayer->q16horiz <= F16(101)) + if ((!pPlayer->return_to_center && thisPlayer.horizRecenter) || (pPlayer->q16horiz >= F16(99.9) && pPlayer->q16horiz <= F16(100.1))) { pPlayer->q16horiz = F16(100); - pPlayer->return_to_center = 0; thisPlayer.horizRecenter = false; } - if (pPlayer->q16horizoff >= F16(-1) && pPlayer->q16horizoff <= F16(1)) + if (pPlayer->q16horizoff >= F16(-0.1) && pPlayer->q16horizoff <= F16(0.1)) pPlayer->q16horizoff = 0; } @@ -3619,7 +3558,7 @@ void P_GetInput(int const playerNum) } if (thisPlayer.horizSkew) - pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(thisPlayer.horizSkew))); + pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(thisPlayer.horizSkew)))); pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX)); } @@ -3628,18 +3567,9 @@ void P_GetInputMotorcycle(int playerNum) { auto &thisPlayer = g_player[playerNum]; auto const pPlayer = thisPlayer.ps; - auto const pSprite = &sprite[pPlayer->i]; ControlInfo info; - auto const currentHiTicks = timerGetHiTicks(); - double const elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; - - thisPlayer.lastInputTicks = currentHiTicks; - - if (elapsedInputTicks == currentHiTicks) - return; - - if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || paused) + if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) { if (!(pPlayer->gm&MODE_MENU)) CONTROL_GetInput(&info); @@ -3673,11 +3603,17 @@ void P_GetInputMotorcycle(int playerNum) input_t input {}; input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw * analogTurnAmount / (analogExtent >> 1))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw / analogExtent * (analogTurnAmount << 1))); input.svel -= info.dx * keyMove / analogExtent; input.fvel -= info.dz * keyMove / analogExtent; + static double lastInputTicks; + auto const currentHiTicks = timerGetHiTicks(); + double const elapsedInputTicks = currentHiTicks - lastInputTicks; + + lastInputTicks = currentHiTicks; + auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); }; pPlayer->crouch_toggle = 0; @@ -3713,18 +3649,22 @@ void P_GetInputMotorcycle(int playerNum) localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; + int turnAmount; int const turn = input.q16avel / 32; int turnLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left); int turnRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right); int avelScale = F16((turnLeft || turnRight) ? 1 : 0); if (turn) { + turnAmount = (MOTOTURN << 1); avelScale = fix16_max(avelScale, fix16_clamp(fix16_mul(turn, turn),0,F16(1))); if (turn < 0) turnLeft = 1; else if (turn > 0) turnRight = 1; } + else + turnAmount = MOTOTURN; input.svel = input.fvel = input.q16avel = 0; @@ -3741,13 +3681,13 @@ void P_GetInputMotorcycle(int playerNum) { if (turnLeft) { - pPlayer->tilt_status -= scaleAdjustmentToInterval(1); + pPlayer->tilt_status--; if (pPlayer->tilt_status < -10) pPlayer->tilt_status = -10; } else if (turnRight) { - pPlayer->tilt_status += scaleAdjustmentToInterval(1); + pPlayer->tilt_status++; if (pPlayer->tilt_status > 10) pPlayer->tilt_status = 10; } @@ -3757,43 +3697,43 @@ void P_GetInputMotorcycle(int playerNum) if (turnLeft || pPlayer->moto_drink < 0) { turnHeldTime += elapsedTics; - pPlayer->tilt_status -= scaleAdjustmentToInterval(1); + pPlayer->tilt_status--; if (pPlayer->tilt_status < -10) pPlayer->tilt_status = -10; if (turnHeldTime >= TURBOTURNTIME && pPlayer->moto_speed > 0) { if (moveBack) - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); else - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); } else { if (moveBack) - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 20 : 6))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / (8 / 3)))); else - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 20 : 6))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / (8 / 3)))); } } else if (turnRight || pPlayer->moto_drink > 0) { turnHeldTime += elapsedTics; - pPlayer->tilt_status += scaleAdjustmentToInterval(1); + pPlayer->tilt_status++; if (pPlayer->tilt_status > 10) pPlayer->tilt_status = 10; if (turnHeldTime >= TURBOTURNTIME && pPlayer->moto_speed > 0) { if (moveBack) - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); else - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); } else { if (moveBack) - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 20 : 6))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / (8 / 3)))); else - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 20 : 6))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / (8 / 3)))); } } else @@ -3801,15 +3741,12 @@ void P_GetInputMotorcycle(int playerNum) turnHeldTime = 0; if (pPlayer->tilt_status > 0) - pPlayer->tilt_status -= scaleAdjustmentToInterval(1); + pPlayer->tilt_status--; else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status += scaleAdjustmentToInterval(1); + pPlayer->tilt_status++; } } - if (pPlayer->tilt_status > -0.025 && pPlayer->tilt_status < 0.025) - pPlayer->tilt_status = 0; - if (pPlayer->moto_underwater) { pPlayer->moto_speed = 0; @@ -3821,56 +3758,10 @@ void P_GetInputMotorcycle(int playerNum) localInput.bits |= buttonMap.ButtonDown(gamefunc_Run) << SK_CROUCH; } - input.fvel += pPlayer->moto_speed; - input.q16avel = fix16_mul(input.q16avel, avelScale); - - int const movementLocked = P_CheckLockedMovement(playerNum); - - if ((ud.scrollmode && ud.overhead_on) || (movementLocked & IL_NOTHING) == IL_NOTHING) - { - if (ud.scrollmode && ud.overhead_on) - { - ud.folfvel = input.fvel; - ud.folavel = fix16_to_int(input.q16avel); - } - - localInput.fvel = localInput.svel = 0; - localInput.q16avel = localInput.q16horz = 0; - } - else - { - if (!(movementLocked & IL_NOMOVE)) - { - localInput.fvel = clamp(input.fvel, -(MAXVELMOTO / 8), MAXVELMOTO); - } - - if (!(movementLocked & IL_NOANGLE)) - { - localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; - } - } - - // don't adjust rotscrnang and look_ang if dead. - if (pSprite->extra > 0) - { - if (RRRA && pPlayer->sea_sick) - { - if (pPlayer->sea_sick < 250) - { - if (pPlayer->sea_sick >= 180) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 130) - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 70) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 20) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - if (pPlayer->sea_sick < 250) - pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval((krand2()&255)-128))); - } - } + input.q16avel = fix16_mul(input.q16avel, avelScale); + localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); + pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; + localInput.fvel = clamp((input.fvel += pPlayer->moto_speed), -(MAXVELMOTO / 8), MAXVELMOTO); if (TEST_SYNC_KEY(localInput.bits, SK_JUMP)) { @@ -3882,18 +3773,9 @@ void P_GetInputBoat(int playerNum) { auto &thisPlayer = g_player[playerNum]; auto const pPlayer = thisPlayer.ps; - auto const pSprite = &sprite[pPlayer->i]; ControlInfo info; - auto const currentHiTicks = timerGetHiTicks(); - double const elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; - - thisPlayer.lastInputTicks = currentHiTicks; - - if (elapsedInputTicks == currentHiTicks) - return; - - if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || paused) + if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) { if (!(pPlayer->gm&MODE_MENU)) CONTROL_GetInput(&info); @@ -3927,11 +3809,17 @@ void P_GetInputBoat(int playerNum) input_t input {}; input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), F16(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw * analogTurnAmount / (analogExtent >> 1))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw / analogExtent * (analogTurnAmount << 1))); input.svel -= info.dx * keyMove / analogExtent; input.fvel -= info.dz * keyMove / analogExtent; + static double lastInputTicks; + auto const currentHiTicks = timerGetHiTicks(); + double const elapsedInputTicks = currentHiTicks - lastInputTicks; + + lastInputTicks = currentHiTicks; + auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); }; pPlayer->crouch_toggle = 0; @@ -3967,18 +3855,22 @@ void P_GetInputBoat(int playerNum) localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Left) || (input.svel > 0)) << 2; localInput.extbits |= (buttonMap.ButtonDown(gamefunc_Strafe_Right) || (input.svel < 0)) << 3; + int turnAmount; int const turn = input.q16avel / 32; int turnLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left); int turnRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right); int avelScale = F16((turnLeft || turnRight) ? 1 : 0); if (turn) { + turnAmount = (MOTOTURN << 1); avelScale = fix16_max(avelScale, fix16_clamp(fix16_mul(turn, turn),0,F16(1))); if (turn < 0) turnLeft = 1; else if (turn > 0) turnRight = 1; } + else + turnAmount = MOTOTURN; input.svel = input.fvel = input.q16avel = 0; @@ -4000,47 +3892,47 @@ void P_GetInputBoat(int playerNum) turnHeldTime += elapsedTics; if (!pPlayer->not_on_water) { - pPlayer->tilt_status -= scaleAdjustmentToInterval(1); + pPlayer->tilt_status--; if (pPlayer->tilt_status < -10) pPlayer->tilt_status = -10; if (turnHeldTime >= TURBOTURNTIME) - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); else - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / (10 / 3)))); } else if (turnHeldTime >= TURBOTURNTIME) - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / 3))); else - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 4 : 2))); + input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval((turnAmount / (10 / 3)) / 3))); } else if (turnRight || pPlayer->moto_drink > 0) { turnHeldTime += elapsedTics; if (!pPlayer->not_on_water) { - pPlayer->tilt_status += scaleAdjustmentToInterval(1); + pPlayer->tilt_status++; if (pPlayer->tilt_status > 10) pPlayer->tilt_status = 10; if (turnHeldTime >= TURBOTURNTIME) - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); else - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / (10 / 3)))); } else if (turnHeldTime >= TURBOTURNTIME) - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount / 3))); else - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 4 : 2))); + input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval((turnAmount / (10 / 3)) / 3))); } else if (!pPlayer->not_on_water) { turnHeldTime = 0; if (pPlayer->tilt_status > 0) - pPlayer->tilt_status -= scaleAdjustmentToInterval(1); + pPlayer->tilt_status--; else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status += scaleAdjustmentToInterval(1); + pPlayer->tilt_status++; } } else if (!pPlayer->not_on_water) @@ -4048,64 +3940,15 @@ void P_GetInputBoat(int playerNum) turnHeldTime = 0; if (pPlayer->tilt_status > 0) - pPlayer->tilt_status -= scaleAdjustmentToInterval(1); + pPlayer->tilt_status--; else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status += scaleAdjustmentToInterval(1); + pPlayer->tilt_status++; } - if (pPlayer->tilt_status > -0.025 && pPlayer->tilt_status < 0.025) - pPlayer->tilt_status = 0; - - input.fvel += pPlayer->moto_speed; - input.q16avel = fix16_mul(input.q16avel, avelScale); - - int const movementLocked = P_CheckLockedMovement(playerNum); - - if ((ud.scrollmode && ud.overhead_on) || (movementLocked & IL_NOTHING) == IL_NOTHING) - { - if (ud.scrollmode && ud.overhead_on) - { - ud.folfvel = input.fvel; - ud.folavel = fix16_to_int(input.q16avel); - } - - localInput.fvel = localInput.svel = 0; - localInput.q16avel = localInput.q16horz = 0; - } - else - { - if (!(movementLocked & IL_NOMOVE)) - { - localInput.fvel = clamp(input.fvel, -(MAXVELMOTO / 8), MAXVELMOTO); - } - - if (!(movementLocked & IL_NOANGLE)) - { - localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; - } - } - - // don't adjust rotscrnang and look_ang if dead. - if (pSprite->extra > 0) - { - if (RRRA && pPlayer->sea_sick) - { - if (pPlayer->sea_sick < 250) - { - if (pPlayer->sea_sick >= 180) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 130) - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 70) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - else if (pPlayer->sea_sick >= 20) - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - if (pPlayer->sea_sick < 250) - pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval((krand2()&255)-128))); - } - } + input.q16avel = fix16_mul(input.q16avel, avelScale); + localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); + pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; + localInput.fvel = clamp((input.fvel += pPlayer->moto_speed), -(MAXVELMOTO / 8), MAXVELMOTO); } int dword_A99D4, dword_A99D8, dword_A99DC, dword_A99E0; @@ -4131,18 +3974,9 @@ void P_DHGetInput(int const playerNum) { auto &thisPlayer = g_player[playerNum]; auto const pPlayer = thisPlayer.ps; - auto const pSprite = &sprite[pPlayer->i]; ControlInfo info; - auto const currentHiTicks = timerGetHiTicks(); - double const elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; - - thisPlayer.lastInputTicks = currentHiTicks; - - if (elapsedInputTicks == currentHiTicks) - return; - - if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || paused) + if ((pPlayer->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !inputState.GetKeyStatus(sc_Pause))) { if (!(pPlayer->gm&MODE_MENU)) CONTROL_GetInput(&info); @@ -4197,6 +4031,12 @@ void P_DHGetInput(int const playerNum) input.svel -= info.dx * keyMove / analogExtent; input.fvel -= info.dz * keyMove / analogExtent; + static double lastInputTicks; + auto const currentHiTicks = timerGetHiTicks(); + double const elapsedInputTicks = currentHiTicks - lastInputTicks; + + lastInputTicks = currentHiTicks; + auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); }; if (buttonMap.ButtonDown(gamefunc_Strafe)) @@ -4286,37 +4126,6 @@ void P_DHGetInput(int const playerNum) if (pPlayer->cursectnum >= 0 && sector[pPlayer->cursectnum].hitag == 2003) input.fvel >>= 1; - // don't adjust rotscrnang and look_ang if dead. - if (pSprite->extra > 0) - { - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_sdiv(pPlayer->q16rotscrnang, fix16_from_int(2)))))); - - if (pPlayer->q16rotscrnang && !fix16_sdiv(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(2)))) - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(ksgn(fix16_to_int(pPlayer->q16rotscrnang))))); - - pPlayer->q16look_ang = fix16_ssub(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_sdiv(pPlayer->q16look_ang, fix16_from_int(4)))))); - - if (pPlayer->q16look_ang && !fix16_sdiv(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(4)))) - pPlayer->q16look_ang = fix16_ssub(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(ksgn(fix16_to_int(pPlayer->q16look_ang))))); - - if (thisPlayer.lookLeft) - { - pPlayer->q16look_ang = fix16_ssub(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(152))); - pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - if (thisPlayer.lookRight) - { - pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval(152))); - pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24))); - } - - if (pPlayer->one_eighty_count < 0) - { - pPlayer->one_eighty_count = -fix16_to_int(fix16_abs(G_GetQ16AngleDelta(pPlayer->one_eighty_target, pPlayer->q16ang))); - pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(-pPlayer->one_eighty_count / ONEEIGHTYSCALE)))) & 0x7FFFFFF; - } - } - // A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units if (thisPlayer.horizAngleAdjust) @@ -4351,7 +4160,7 @@ void P_DHGetInput(int const playerNum) } if (thisPlayer.horizSkew) - pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(thisPlayer.horizSkew))); + pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(thisPlayer.horizSkew)))); pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX)); @@ -6959,8 +6768,8 @@ void P_UpdatePosWhenViewingCam(DukePlayer_t *pPlayer) pPlayer->vel.x = 0; pPlayer->vel.y = 0; sprite[pPlayer->i].xvel = 0; - pPlayer->q16look_ang = 0; - pPlayer->q16rotscrnang = 0; + pPlayer->look_ang = 0; + pPlayer->rotscrnang = 0; } static void P_DoWater(int const playerNum, int const playerBits, int const floorZ, int const ceilZ) @@ -7035,8 +6844,6 @@ static void P_DoJetpack(int const playerNum, int const playerBits, int const pla pPlayer->pycount &= 2047; pPlayer->pyoff = sintable[pPlayer->pycount] >> 7; - g_player[playerNum].horizSkew = 0; - if (pPlayer->jetpack_on < 11) { pPlayer->jetpack_on++; @@ -7117,7 +6924,7 @@ static void P_Dead(int const playerNum, int const sectorLotag, int const floorZ, pushmove((vec3_t *) pPlayer, &pPlayer->cursectnum, 128L, (4L<<8), (20L<<8), CLIPMASK0); if (floorZ > ceilZ + ZOFFSET2 && pSprite->pal != 1) - pPlayer->q16rotscrnang = fix16_from_int((pPlayer->dead_flag + ((floorZ+pPlayer->pos.z)>>7)))&0x7FFFFFF; + pPlayer->rotscrnang = (pPlayer->dead_flag + ((floorZ+pPlayer->pos.z)>>7))&2047; pPlayer->on_warping_sector = 0; } @@ -7132,6 +6939,9 @@ void P_ProcessInput(int playerNum) { auto &thisPlayer = g_player[playerNum]; + thisPlayer.horizAngleAdjust = 0; + thisPlayer.horizSkew = 0; + if (DEER) { P_DHProcessInput(playerNum); @@ -7140,9 +6950,6 @@ void P_ProcessInput(int playerNum) if (thisPlayer.playerquitflag == 0) return; - thisPlayer.horizAngleAdjust = 0; - thisPlayer.horizSkew = 0; - auto const pPlayer = thisPlayer.ps; auto const pSprite = &sprite[pPlayer->i]; @@ -7955,21 +7762,24 @@ check_enemy_sprite: return; } + pPlayer->rotscrnang -= (pPlayer->rotscrnang >> 1); + + if (pPlayer->rotscrnang && !(pPlayer->rotscrnang >> 1)) + pPlayer->rotscrnang -= ksgn(pPlayer->rotscrnang); + + pPlayer->look_ang -= (pPlayer->look_ang >> 2); + + if (pPlayer->look_ang && !(pPlayer->look_ang >> 2)) + pPlayer->look_ang -= ksgn(pPlayer->look_ang); + if (TEST_SYNC_KEY(playerBits, SK_LOOK_LEFT) && (!RRRA || !pPlayer->on_motorcycle)) { // look_left if (VM_OnEvent(EVENT_LOOKLEFT,pPlayer->i,playerNum) == 0) { - thisPlayer.lookLeft = true; + pPlayer->look_ang -= 152; + pPlayer->rotscrnang += 24; } - else - { - thisPlayer.lookLeft = false; - } - } - else - { - thisPlayer.lookLeft = false; } if (TEST_SYNC_KEY(playerBits, SK_LOOK_RIGHT) && (!RRRA || !pPlayer->on_motorcycle)) @@ -7977,16 +7787,26 @@ check_enemy_sprite: // look_right if (VM_OnEvent(EVENT_LOOKRIGHT,pPlayer->i,playerNum) == 0) { - thisPlayer.lookRight = true; - } - else - { - thisPlayer.lookRight = false; + pPlayer->look_ang += 152; + pPlayer->rotscrnang -= 24; } } - else + + if (RRRA && pPlayer->sea_sick) { - thisPlayer.lookRight = false; + if (pPlayer->sea_sick < 250) + { + if (pPlayer->sea_sick >= 180) + pPlayer->rotscrnang += 24; + else if (pPlayer->sea_sick >= 130) + pPlayer->rotscrnang -= 24; + else if (pPlayer->sea_sick >= 70) + pPlayer->rotscrnang += 24; + else if (pPlayer->sea_sick >= 20) + pPlayer->rotscrnang += 24; + } + if (pPlayer->sea_sick < 250) + pPlayer->look_ang += (krand2()&255)-128; } int velocityModifier = TICSPERFRAME; @@ -8028,6 +7848,12 @@ check_enemy_sprite: pPlayer->opos.z = pPlayer->pos.z; pPlayer->opyoff = pPlayer->pyoff; + if (pPlayer->one_eighty_count < 0) + { + pPlayer->one_eighty_count += 128; + pPlayer->q16ang += F16(128); + } + // Shrinking code if (RR) @@ -8223,6 +8049,7 @@ check_enemy_sprite: pPlayer->moto_turb = 12; } } + pPlayer->on_ground = 1; } else pPlayer->on_ground = 0; @@ -8700,10 +8527,9 @@ HORIZONLY:; { if (numplayers == 1) { - int tilt_status = pPlayer->tilt_status; vec3_t const vect = { - sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>8, - sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>8,sprite[spriteNum].zvel + sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>8, + sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>8,sprite[spriteNum].zvel }; A_MoveSprite(spriteNum,&vect,CLIPMASK0); @@ -8754,10 +8580,9 @@ HORIZONLY:; { if (numplayers == 1) { - int tilt_status = pPlayer->tilt_status; vec3_t const vect = { - sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>9, - sintable[(tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>9,sprite[spriteNum].zvel + sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>9, + sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>9,sprite[spriteNum].zvel }; A_MoveSprite(spriteNum,&vect,CLIPMASK0); @@ -8883,10 +8708,7 @@ HORIZONLY:; if (TEST_SYNC_KEY(playerBits, SK_CENTER_VIEW) || pPlayer->hard_landing) if (VM_OnEvent(EVENT_RETURNTOCENTER, pPlayer->i,playerNum) == 0) - { pPlayer->return_to_center = 9; - thisPlayer.horizRecenter = true; - } if (TEST_SYNC_KEY(playerBits, SK_LOOK_UP)) { @@ -8932,7 +8754,7 @@ HORIZONLY:; if (pPlayer->hard_landing > 0) { - thisPlayer.horizSkew = -(pPlayer->hard_landing << 4); + thisPlayer.horizSkew = fix16_from_int(-(pPlayer->hard_landing << 4)); pPlayer->hard_landing--; } @@ -8962,7 +8784,7 @@ HORIZONLY:; if (pPlayer->knee_incs > 0) { - thisPlayer.horizSkew = -48; + thisPlayer.horizSkew = F16(-48); thisPlayer.horizRecenter = true; pPlayer->return_to_center = 9; @@ -9048,12 +8870,12 @@ void P_DHProcessInput(int playerNum) { auto &thisPlayer = g_player[playerNum]; - if (thisPlayer.playerquitflag == 0) - return; - thisPlayer.horizAngleAdjust = 0; thisPlayer.horizSkew = 0; + if (thisPlayer.playerquitflag == 0) + return; + auto const pPlayer = thisPlayer.ps; auto const pSprite = &sprite[pPlayer->i]; @@ -9191,24 +9013,28 @@ void P_DHProcessInput(int playerNum) return; } + pPlayer->rotscrnang -= (pPlayer->rotscrnang >> 1); + + if (pPlayer->rotscrnang && !(pPlayer->rotscrnang >> 1)) + pPlayer->rotscrnang -= ksgn(pPlayer->rotscrnang); + + pPlayer->look_ang -= (pPlayer->look_ang >> 2); + + if (pPlayer->look_ang && !(pPlayer->look_ang >> 2)) + pPlayer->look_ang -= ksgn(pPlayer->look_ang); + if (TEST_SYNC_KEY(playerBits, SK_LOOK_LEFT) && !pPlayer->on_motorcycle) { // look_left - thisPlayer.lookLeft = true; - } - else - { - thisPlayer.lookLeft = false; + pPlayer->look_ang -= 152; + pPlayer->rotscrnang += 24; } if (TEST_SYNC_KEY(playerBits, SK_LOOK_RIGHT) && !pPlayer->on_motorcycle) { // look_right - thisPlayer.lookRight = true; - } - else - { - thisPlayer.lookRight = false; + pPlayer->look_ang += 152; + pPlayer->rotscrnang -= 24; } int velocityModifier = TICSPERFRAME; @@ -9247,6 +9073,12 @@ void P_DHProcessInput(int playerNum) pPlayer->opos.z = pPlayer->pos.z; pPlayer->opyoff = pPlayer->pyoff; + if (pPlayer->one_eighty_count < 0) + { + pPlayer->one_eighty_count += 128; + pPlayer->q16ang += F16(128); + } + // Shrinking code if (sectorLotag == ST_2_UNDERWATER) @@ -9525,10 +9357,7 @@ void P_DHProcessInput(int playerNum) pPlayer->return_to_center--; if (TEST_SYNC_KEY(playerBits, SK_CENTER_VIEW) || pPlayer->hard_landing) - { pPlayer->return_to_center = 9; - thisPlayer.horizRecenter = true; - } if (TEST_SYNC_KEY(playerBits, SK_LOOK_UP)) { @@ -9562,7 +9391,7 @@ void P_DHProcessInput(int playerNum) if (pPlayer->hard_landing > 0) { - thisPlayer.horizSkew = -(pPlayer->hard_landing << 4); + thisPlayer.horizSkew = fix16_from_int(-(pPlayer->hard_landing << 4)); pPlayer->hard_landing--; } diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 11db93abb..392f77c61 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -132,6 +132,7 @@ typedef struct { // * char --> int8_t // Need to carefully think about implications! // TODO: rearrange this if the opportunity arises! +// KEEPINSYNC lunatic/_defs_game.lua typedef struct { vec3_t pos, opos, vel, npos; vec2_t bobpos, fric; @@ -151,10 +152,9 @@ typedef struct { int16_t loogiex[64], loogiey[64], sbs, sound_pitch; - int16_t cursectnum, last_extra, subweapon; + int16_t cursectnum, look_ang, last_extra, subweapon; int16_t max_ammo_amount[MAX_WEAPONS], ammo_amount[MAX_WEAPONS], inv_amount[GET_MAX]; int16_t wackedbyactor, pyoff, opyoff; - fix16_t q16look_ang; int16_t newowner, jumping_counter, airleft; int16_t fta, ftq, access_wallnum, access_spritenum; @@ -163,12 +163,10 @@ typedef struct { int16_t random_club_frame, one_eighty_count; int16_t dummyplayersprite, extra_extra8; int16_t actorsqu, timebeforeexit, customexitsound, last_pissed_time; - fix16_t one_eighty_target; int16_t weaprecs[MAX_WEAPON_RECS], weapon_sway, crack_time, bobcounter; - int16_t dead_flag; - fix16_t oq16rotscrnang, q16rotscrnang; // JBF 20031220: added orotscrnang + int16_t orotscrnang, rotscrnang, dead_flag; // JBF 20031220: added orotscrnang int16_t holoduke_on, pycount; int16_t transporter_hold/*, clipdist*/; @@ -212,7 +210,7 @@ typedef struct { int16_t drink_amt, eat_amt, drink_ang, eat_ang; int32_t drink_timer, eat_timer; int16_t level_end_timer; - int16_t moto_speed, moto_drink; + int16_t moto_speed, tilt_status, moto_drink; uint8_t on_motorcycle, on_boat, moto_underwater, not_on_water, moto_on_ground; uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; int16_t moto_bump, moto_bump_target, moto_turb; @@ -222,7 +220,6 @@ typedef struct { int32_t drug_timer; int32_t sea_sick; uint8_t hurt_delay2, nocheat; - double tilt_status; int32_t dhat60f, dhat613, dhat617, dhat61b, dhat61f; @@ -230,6 +227,7 @@ typedef struct { int8_t padding_[3]; } DukePlayer_t; +// KEEPINSYNC lunatic/_defs_game.lua typedef struct { DukePlayer_t *ps; @@ -237,10 +235,7 @@ typedef struct bool horizRecenter; float horizAngleAdjust; - int8_t horizSkew; - bool lookLeft; - bool lookRight; - double lastInputTicks; + fix16_t horizSkew; int32_t movefifoend, syncvalhead, myminlag; int32_t pcolor, pteam; @@ -253,6 +248,7 @@ typedef struct } playerdata_t; #pragma pack(pop) +// KEEPINSYNC lunatic/con_lang.lua typedef struct { // NOTE: the member names must be identical to aplWeapon* suffixes. @@ -274,6 +270,10 @@ typedef struct int32_t FlashColor; // Muzzle flash color } weapondata_t; +#ifdef LUNATIC +# define PWEAPON(Player, Weapon, Wmember) (g_playerWeapon[Player][Weapon].Wmember) +extern weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS]; +#else # define PWEAPON(Player, Weapon, Wmember) (aplWeapon ## Wmember [Weapon][Player]) extern intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in clip extern intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) @@ -291,7 +291,9 @@ extern intptr_t *aplWeaponFireSound[MAX_WEAPONS]; // Sound made wh extern intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time extern intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID extern intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Color for polymer muzzle flash +#endif +// KEEPINSYNC lunatic/_defs_game.lua typedef struct { int32_t cur, count; // "cur" is the only member that is *used* int32_t gunposx, lookhalfang; // weapon_xoffset, ps->look_ang>>1 diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 23e006085..b2cfdaad1 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "anim.h" #include "menus.h" #include "demo.h" @@ -812,7 +812,7 @@ void P_ResetPlayer(int playerNum) pPlayer->fta = 0; pPlayer->ftq = 0; pPlayer->vel.x = pPlayer->vel.y = 0; - if (!RR) pPlayer->q16rotscrnang = 0; + if (!RR) pPlayer->rotscrnang = 0; pPlayer->runspeed = g_playerFriction; pPlayer->falling_counter = 0; @@ -904,9 +904,9 @@ void P_ResetStatus(int playerNum) pPlayer->heat_on = 0; pPlayer->jetpack_on = 0; pPlayer->holoduke_on = -1; - pPlayer->q16look_ang = fix16_from_int(512 - ((ud.level_number & 1) << 10)); - pPlayer->q16rotscrnang = 0; - pPlayer->oq16rotscrnang = fix16_one; // JBF 20031220 + pPlayer->look_ang = 512 - ((ud.level_number & 1) << 10); + pPlayer->rotscrnang = 0; + pPlayer->orotscrnang = 1; // JBF 20031220 pPlayer->newowner = -1; pPlayer->jumping_counter = 0; pPlayer->hard_landing = 0; @@ -932,10 +932,6 @@ void P_ResetStatus(int playerNum) pPlayer->movement_lock = 0; pPlayer->frag_ps = playerNum; - g_player[playerNum].horizRecenter = 0; - g_player[playerNum].horizSkew = 0; - g_player[playerNum].horizAngleAdjust = 0; - P_UpdateScreenPal(pPlayer); if (RR) @@ -1150,7 +1146,7 @@ static void resetprestat(int playerNum, int gameMode) g_animateCnt = 0; parallaxtype = 0; randomseed = 17; - paused = 0; + ud.pause_on = 0; ud.camerasprite = -1; ud.eog = 0; tempwallptr = 0; @@ -2289,7 +2285,7 @@ int G_EnterLevel(int gameMode) //if (g_networkMode != NET_DEDICATED_SERVER) { - S_ResumeSound(false); + S_PauseSounds(false); FX_StopAllSounds(); S_ClearSoundLocks(); FX_SetReverb(0); @@ -2464,9 +2460,6 @@ int G_EnterLevel(int gameMode) P_UpdateScreenPal(g_player[myconnectindex].ps); renderFlushPerms(); - // reset lastInputTicks. - g_player[myconnectindex].lastInputTicks = 0; - everyothertime = 0; g_globalRandom = 0; diff --git a/source/games/duke/src/rrdh.cpp b/source/games/duke/src/rrdh.cpp index 54e011a06..f5af1bfc2 100644 --- a/source/games/duke/src/rrdh.cpp +++ b/source/games/duke/src/rrdh.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "baselayer.h" -#include "duke3d_ed.h" +#include "duke3d.h" #include "sounds.h" #include "i_time.h" #include "files.h" diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index d22ef103b..41da274db 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "premap.h" #include "prlights.h" #include "savegame.h" @@ -183,7 +183,7 @@ int32_t G_LoadPlayer(const char *path) // some setup first ud.multimode = h.numplayers; - S_PauseSound(true, false); + S_PauseSounds(true); if (numplayers > 1) { @@ -834,7 +834,7 @@ static const dataspec_t svgm_udnetw[] = { DS_NOCHK, &ud.ffire, sizeof(ud.ffire), 1 }, { DS_NOCHK, &ud.noexits, sizeof(ud.noexits), 1 }, { DS_NOCHK, &ud.playerai, sizeof(ud.playerai), 1 }, - { 0, &paused, sizeof(paused), 1 }, + { 0, &ud.pause_on, sizeof(ud.pause_on), 1 }, { 0, connectpoint2, sizeof(connectpoint2), 1 }, { 0, &randomseed, sizeof(randomseed), 1 }, { 0, &g_globalRandom, sizeof(g_globalRandom), 1 }, diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index 0b4c8ef14..901d587f5 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -21,13 +21,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! +#include #include "v_font.h" #include "duke3d_ed.h" #include "compat.h" #include "sbar.h" +#include "statusbar.h" +#include "texturemanager.h" BEGIN_DUKE_NS +static FFont* IndexFont; +static FFont* DigiFont; +//========================================================================== +// +// Font init should go elsewhere later. +// +//========================================================================== void InitFonts() { @@ -72,6 +82,7 @@ void InitFonts() if (tile && tile->GetTexelWidth() > 0 && tile->GetTexelHeight() > 0) fontdata.Insert('!' + i, tile); } + fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. SmallFont2 = new ::FFont("SmallFont2", nullptr, "defsmallfont2", 0, 0, 0, -1, -1, false, false, false, &fontdata); fontdata.Clear(); @@ -79,573 +90,52 @@ void InitFonts() for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE + i)); fontdata.Insert(':', tileGetTexture(THREEBYFIVE + 10)); fontdata.Insert('/', tileGetTexture(THREEBYFIVE + 11)); - new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); + fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!')); + fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); + + fontdata.Clear(); + + // digital font + for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(DIGITALNUM + i)); + fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); } -static int32_t sbarx(int32_t x) -{ - if (ud.screen_size == 4) return sbarsc(x<<16); - return (((320<<16) - sbarsc(320<<16)) >> 1) + sbarsc(x<<16); -} +//========================================================================== +// +// Helpers +// +//========================================================================== -static int32_t sbarxr(int32_t x) -{ - if (ud.screen_size == 4) return (320<<16) - sbarsc(x<<16); - return (((320<<16) - sbarsc(320<<16)) >> 1) + sbarsc(x<<16); -} - -static int32_t sbary(int32_t y) -{ - if (hud_position == 1 && ud.screen_size == 4 && ud.althud == 1) return sbarsc(y << 16); - else return (200<<16) - sbarsc(200<<16) + sbarsc(y<<16); -} - -int32_t sbarx16(int32_t x) -{ - if (ud.screen_size == 4) return sbarsc(x); - return (((320<<16) - sbarsc(320<<16)) >> 1) + sbarsc(x); -} - -int32_t sbarxr16(int32_t x) -{ - if (ud.screen_size == 4) return (320<<16) - sbarsc(x); - return (((320<<16) - sbarsc(320<<16)) >> 1) + sbarsc(x); -} - -#if 0 // enable if ever needed -static int32_t sbarxr16(int32_t x) -{ - if (ud.screen_size == 4) return (320<<16) - sbarsc(x); - return (((320<<16) - sbarsc(320<<16)) >> 1) + sbarsc(x); -} -#endif - -int32_t sbary16(int32_t y) -{ - return (200<<16) - sbarsc(200<<16) + sbarsc(y); -} - -static void G_PatchStatusBar(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t aspectCorrect = 1) -{ - int32_t const scl = sbarsc(RR ? 32768 : 65536); - int32_t const tx = sbarx16((160<<16) - (tilesiz[BOTTOMSTATUSBAR].x<<(RR ? 14 : 15))); // centered - int32_t const ty = sbary(200-(tilesiz[BOTTOMSTATUSBAR].y>>(RR ? 1 : 0))); - // Assumed to be 4:3 aspect ratio - int32_t const xdimcorrect = aspectCorrect ? (4 * ydim) / 3 : xdim; - - int32_t const clx1 = sbarsc(scale(x1, xdimcorrect, 320)), cly1 = sbarsc(scale(y1, ydim, 200)); - int32_t const clx2 = sbarsc(scale(x2, xdimcorrect, 320)), cly2 = sbarsc(scale(y2, ydim, 200)); - int32_t const clofx = (xdim - sbarsc(xdimcorrect)) >> 1, clofy = (ydim - sbarsc(ydim)); - - rotatesprite(tx, ty, scl, 0, BOTTOMSTATUSBAR, 4, 0, 10+16+64, clx1+clofx, cly1+clofy, clx2+clofx-1, cly2+clofy-1); -} - -static void G_PatchStatusBar2(int32_t x1, int32_t y1, int32_t x2, int32_t y2) -{ - if (!RR) - return; - int32_t const scl = sbarsc(32768); - int32_t const tx = sbarx16((160<<16) - (tilesiz[WEAPONBAR].x<<14)); // centered - int32_t const ty = sbary(200-tilesiz[BOTTOMSTATUSBAR].y/2-tilesiz[WEAPONBAR].y/2); - // Assumed to be 4:3 aspect ratio - int32_t const xdimcorrect = (4 * ydim) / 3; - - int32_t const clx1 = sbarsc(scale(x1, xdimcorrect, 320)), cly1 = sbarsc(scale(y1, ydim, 200)); - int32_t const clx2 = sbarsc(scale(x2, xdimcorrect, 320)), cly2 = sbarsc(scale(y2, ydim, 200)); - int32_t const clofx = (xdim - sbarsc(xdimcorrect)) >> 1, clofy = (ydim - sbarsc(ydim)); - - rotatesprite(tx, ty, scl, 0, WEAPONBAR, 4, 0, 10+16+64, clx1+clofx, cly1+clofy, clx2+clofx-1, cly2+clofy-1); -} - -#define POLYMOSTTRANS (1) -#define POLYMOSTTRANS2 (1|32) - -// Draws inventory numbers in the HUD for both the full and mini status bars. -// yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords. -static void G_DrawInvNum(int32_t x, int32_t yofs, int32_t y, char num1, char ha, int32_t sbits) -{ - char dabuf[16]; - int32_t shd = (x < 0); - - const int32_t sbscale = sbarsc(RR ? 32768 : 65536); - const int32_t sby = yofs+sbary(y), sbyp1 = yofs+sbary(y+1), sbym1 = yofs+sbary(y-1); - - if (shd) x = -x; - - Bsprintf(dabuf, "%d", num1); - - if (sbits & RS_ALIGN_R) - { - if (num1 > 99) - { - if (shd && ud.screen_size == 4 && videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - { - rotatesprite_fs(sbarxr(x+4+1), RR ? sby : sbyp1, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', 127, 4, POLYMOSTTRANS|sbits); - rotatesprite_fs(sbarxr(x-1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', 127, 4, POLYMOSTTRANS|sbits); - rotatesprite_fs(sbarxr(x-4+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[2]-'0', 127, 4, POLYMOSTTRANS|sbits); - } - - rotatesprite_fs(sbarxr(x+4), RR ? sbym1 : sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, sbits); - rotatesprite_fs(sbarxr(x), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, sbits); - rotatesprite_fs(sbarxr(x-4), sby, sbscale, 0, THREEBYFIVE+dabuf[2]-'0', ha, 0, sbits); - return; - } - - if (num1 > 9) - { - if (shd && ud.screen_size == 4 && videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - { - rotatesprite_fs(sbarxr(x+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', 127, 4, POLYMOSTTRANS|sbits); - rotatesprite_fs(sbarxr(x-4-1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', 127, 4, POLYMOSTTRANS|sbits); - } - - rotatesprite_fs(sbarxr(x), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, sbits); - rotatesprite_fs(sbarxr(x-4), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, sbits); - return; - } - - rotatesprite_fs(sbarxr(x-4+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 4, sbits); - rotatesprite_fs(sbarxr(x-4), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, sbits); - return; - } - - if (num1 > 99) - { - if (shd && ud.screen_size == 4 && videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - { - rotatesprite_fs(sbarx(x-4+1), RR ? sby : sbyp1, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', 127, 4, POLYMOSTTRANS|sbits); - rotatesprite_fs(sbarx(x+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', 127, 4, POLYMOSTTRANS|sbits); - rotatesprite_fs(sbarx(x+4+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[2]-'0', 127, 4, POLYMOSTTRANS|sbits); - } - - rotatesprite_fs(sbarx(x-4), RR ? sbym1 : sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, sbits); - rotatesprite_fs(sbarx(x), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, sbits); - rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[2]-'0', ha, 0, sbits); - return; - } - - if (num1 > 9) - { - if (shd && ud.screen_size == 4 && videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - { - rotatesprite_fs(sbarx(x+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', 127, 4, POLYMOSTTRANS|sbits); - rotatesprite_fs(sbarx(x+4+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', 127, 4, POLYMOSTTRANS|sbits); - } - - rotatesprite_fs(sbarx(x), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, sbits); - rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, sbits); - return; - } - - rotatesprite_fs(sbarx(x+4+1), sbyp1, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 4, sbits); - rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, sbits); -} - -static void G_DrawWeapNum(int16_t ind, int32_t x, int32_t y, int32_t num1, int32_t num2, int32_t ha) -{ - char dabuf[16]; - - const int32_t sbscale = sbarsc(65536); - const int32_t sby = sbary(y); - - rotatesprite_fs(sbarx(x-7), sby, sbscale, 0, THREEBYFIVE+ind+1, ha-10, 7, 10); - rotatesprite_fs(sbarx(x-3), sby, sbscale, 0, THREEBYFIVE+10, ha, 0, 10); - - if (VOLUMEONE && (ind > HANDBOMB_WEAPON || ind < 0)) - { - minitextshade(x+1, y-4, "ORDER", 20, 11, 2+8+16+ROTATESPRITE_MAX); - return; - } - - rotatesprite_fs(sbarx(x+9), sby, sbscale, 0, THREEBYFIVE+11, ha, 0, 10); - - if (num1 > 99) num1 = 99; - if (num2 > 99) num2 = 99; - - Bsprintf(dabuf, "%d", num1); - if (num1 > 9) - { - rotatesprite_fs(sbarx(x), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, 10); - } - else rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - - Bsprintf(dabuf, "%d", num2); - if (num2 > 9) - { - rotatesprite_fs(sbarx(x+13), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+17), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, 10); - return; - } - rotatesprite_fs(sbarx(x+13), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); -} - -static void G_DrawWeapNum2(char ind, int32_t x, int32_t y, int32_t num1, int32_t num2, char ha) -{ - char dabuf[16]; - - const int32_t sbscale = sbarsc(65536); - const int32_t sby = sbary(y); - - rotatesprite_fs(sbarx(x-7), sby, sbscale, 0, THREEBYFIVE+ind+1, ha-10, 7, 10); - rotatesprite_fs(sbarx(x-4), sby, sbscale, 0, THREEBYFIVE+10, ha, 0, 10); - rotatesprite_fs(sbarx(x+13), sby, sbscale, 0, THREEBYFIVE+11, ha, 0, 10); - - Bsprintf(dabuf, "%d", num1); - if (num1 > 99) - { - rotatesprite_fs(sbarx(x), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+8), sby, sbscale, 0, THREEBYFIVE+dabuf[2]-'0', ha, 0, 10); - } - else if (num1 > 9) - { - rotatesprite_fs(sbarx(x+4), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+8), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, 10); - } - else rotatesprite_fs(sbarx(x+8), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - - Bsprintf(dabuf, "%d", num2); - if (num2 > 99) - { - rotatesprite_fs(sbarx(x+17), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+21), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+25), sby, sbscale, 0, THREEBYFIVE+dabuf[2]-'0', ha, 0, 10); - } - else if (num2 > 9) - { - rotatesprite_fs(sbarx(x+17), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); - rotatesprite_fs(sbarx(x+21), sby, sbscale, 0, THREEBYFIVE+dabuf[1]-'0', ha, 0, 10); - return; - } - else - rotatesprite_fs(sbarx(x+25), sby, sbscale, 0, THREEBYFIVE+dabuf[0]-'0', ha, 0, 10); -} - -static void G_DrawWeapAmounts(const DukePlayer_t *p, int32_t x, int32_t y, int32_t u) -{ - int32_t cw = p->curr_weapon; - - if (u&4) - { - if (u != -1) G_PatchStatusBar(88, 178, 88+37, 178+6); //original code: (96,178,96+12,178+6); - G_DrawWeapNum2(PISTOL_WEAPON, x, y, - p->ammo_amount[PISTOL_WEAPON], p->max_ammo_amount[PISTOL_WEAPON], - 12-20*(cw == PISTOL_WEAPON)); - } - if (u&8) - { - if (u != -1) G_PatchStatusBar(88, 184, 88+37, 184+6); //original code: (96,184,96+12,184+6); - G_DrawWeapNum2(SHOTGUN_WEAPON, x, y+6, - p->ammo_amount[SHOTGUN_WEAPON], p->max_ammo_amount[SHOTGUN_WEAPON], - (((p->gotweapon & (1<ammo_amount[CHAINGUN_WEAPON], p->max_ammo_amount[CHAINGUN_WEAPON], - (((p->gotweapon & (1<ammo_amount[RPG_WEAPON], p->max_ammo_amount[RPG_WEAPON], - (((p->gotweapon & (1<ammo_amount[HANDBOMB_WEAPON], p->max_ammo_amount[HANDBOMB_WEAPON], - (((!p->ammo_amount[HANDBOMB_WEAPON])|((p->gotweapon & (1<subweapon&(1<ammo_amount[GROW_WEAPON], p->max_ammo_amount[GROW_WEAPON], - (((p->gotweapon & (1<ammo_amount[SHRINKER_WEAPON], p->max_ammo_amount[SHRINKER_WEAPON], - (((p->gotweapon & (1<ammo_amount[DEVISTATOR_WEAPON], p->max_ammo_amount[DEVISTATOR_WEAPON], - (((p->gotweapon & (1<ammo_amount[TRIPBOMB_WEAPON], p->max_ammo_amount[TRIPBOMB_WEAPON], - (((p->gotweapon & (1<ammo_amount[FREEZE_WEAPON], p->max_ammo_amount[FREEZE_WEAPON], - (((p->gotweapon & (1<=0; k--) - { - p = althud_numbertile + b[k]-'0'; - j += (tilesiz[p].x>>(RR?1:0))+1; - } - c = x-(j>>1); - - if (rev) - { - for (k=0; k= REND_POLYMOST && althud_shadows) - rotatesprite_fs(sbarxr(c+j-1), sbary(y+1), sbscale, 0, p, 127, 4, cs|POLYMOSTTRANS2); - rotatesprite_fs(sbarxr(c+j), sbary(y), sbscale, 0, p, s, althud_numberpal, cs); - j -= (tilesiz[p].x>>(RR?1:0))+1; - } - return; - } - - j = 0; - for (k=0; k= REND_POLYMOST && althud_shadows) - rotatesprite_fs(sbarx(c+j+1), sbary(y+1), sbscale, 0, p, 127, 4, cs|POLYMOSTTRANS2); - rotatesprite_fs(sbarx(c+j), sbary(y), sbscale, 0, p, s, althud_numberpal, cs); - j += (tilesiz[p].x>>(RR?1:0))+1; - } -} - -static int32_t invensc(int32_t maximum) // used to reposition the inventory icon selector as the HUD scales -{ - return scale(maximum << 16, ud.statusbarscale - 36, 100 - 36); -} - -void G_DrawInventory(const DukePlayer_t *p) -{ - int32_t n, j = 0, x = 0, y; - - n = (p->inv_amount[GET_JETPACK] > 0)<<3; - if (n&8) j++; - n |= (p->inv_amount[GET_SCUBA] > 0)<<5; - if (n&32) j++; - n |= (p->inv_amount[GET_STEROIDS] > 0)<<1; - if (n&2) j++; - n |= (p->inv_amount[GET_HOLODUKE] > 0)<<2; - if (n&4) j++; - n |= (p->inv_amount[GET_FIRSTAID] > 0); - if (n&1) j++; - n |= (p->inv_amount[GET_HEATS] > 0)<<4; - if (n&16) j++; - n |= (p->inv_amount[GET_BOOTS] > 0)<<6; - if (n&64) j++; - - x = (160-(j*11))<<16; // nearly center - - j = 0; - - if (ud.screen_size < 8) // mini-HUDs or no HUD - { - y = RR ? 180<<16 : 172<<16; - - if (ud.screen_size == 4 && ud.althud == 1) // modern mini-HUD - y -= invensc(tilesiz[BIGALPHANUM].y+10); // slide on the y-axis - } - else // full HUD - { - y = (200<<16) - (sbarsc(tilesiz[BOTTOMSTATUSBAR].y<<(RR ? 15 : 16)) + (RR ? (6<<16) : (12<<16)) + (tilesiz[BOTTOMSTATUSBAR].y<<((RR ? 15 : 16)-1))); - - if (!ud.statusbarmode) // original non-overlay mode - y += sbarsc(tilesiz[BOTTOMSTATUSBAR].y<<(RR ? 15 : 16))>>1; // account for the viewport y-size as the HUD scales - } - - if (ud.screen_size == 4 && !ud.althud) // classic mini-HUD - x += invensc(ud.multimode > 1 ? 56 : 65); // slide on the x-axis - - while (j <= 9) - { - const int iconscale = RR ? 32768 : 65536; - if (n&(1<inven_icon == j+1) - rotatesprite_win(x-(2<<16), y+(19<<16), iconscale, 1024, ARROW, -32, 0, 2+16); - } - - j++; - } -} - -void G_DrawFrags(void) -{ - if (ud.statusbarflags & STATUSBAR_NOFRAGBAR) - return; - - int32_t i, j = 0; - const int32_t orient = 2+8+16+64; - - for (TRAVERSE_CONNECT(i)) - if (i > j) - j = i; - - for (i=0; i<=(j>>2); i++) - rotatesprite_fs(0, (8*i)<<16, RR ? 32800 : 65600, 0, FRAGBAR, 0, 0, orient); - - for (TRAVERSE_CONNECT(i)) - { - const DukePlayer_t *ps = g_player[i].ps; - minitext(21+(73*(i&3)), 2+((i&28)<<1), g_player[i].user_name, ps->palookup, 2+8+16); - Bsprintf(tempbuf, "%d", ps->frag-ps->fraggedself); - minitext(17+50+(73*(i&3)), 2+((i&28)<<1), tempbuf, ps->palookup, 2+8+16); - } -} - -static int32_t G_GetInvAmount(const DukePlayer_t *p) +static int32_t G_GetInvAmount(const DukePlayer_t* p) { switch (p->inven_icon) { case ICON_FIRSTAID: return p->inv_amount[GET_FIRSTAID]; case ICON_STEROIDS: - return (p->inv_amount[GET_STEROIDS]+3)>>2; + return (p->inv_amount[GET_STEROIDS] + 3) >> 2; case ICON_HOLODUKE: - if (RR) return p->inv_amount[GET_HOLODUKE]/400; - return (p->inv_amount[GET_HOLODUKE]+15)/24; + if (RR) return p->inv_amount[GET_HOLODUKE] / 400; + return (p->inv_amount[GET_HOLODUKE] + 15) / 24; case ICON_JETPACK: - if (RR) return p->inv_amount[GET_JETPACK]/100; - return (p->inv_amount[GET_JETPACK]+15)>>4; + if (RR) return p->inv_amount[GET_JETPACK] / 100; + return (p->inv_amount[GET_JETPACK] + 15) >> 4; case ICON_HEATS: - return p->inv_amount[GET_HEATS]/12; + return p->inv_amount[GET_HEATS] / 12; case ICON_SCUBA: - return (p->inv_amount[GET_SCUBA]+63)>>6; + return (p->inv_amount[GET_SCUBA] + 63) >> 6; case ICON_BOOTS: - if (RR) return (p->inv_amount[GET_BOOTS]/10)>>1; - return p->inv_amount[GET_BOOTS]>>1; + if (RR) return (p->inv_amount[GET_BOOTS] / 10) >> 1; + return p->inv_amount[GET_BOOTS] >> 1; } return -1; } -static void G_DrawWeaponBar(const DukePlayer_t *p) -{ - const int32_t sbscale = sbarsc(32800); - const int32_t SBY = (200-tilesiz[BOTTOMSTATUSBAR].y/2); - rotatesprite_fs(sbarx(0), sbary(158), sbscale, 0, WEAPONBAR, 0, 0, 10+16+64); - for (int i = 0; i < 9; i++) { - if (RRRA && i == 4 && p->curr_weapon == CHICKEN_WEAPON) - { - rotatesprite_fs(sbarx(18+i*32), sbary(SBY-6), sbscale, 0, AMMO_ICON + 10, 0, 0, 10+16+64); - G_DrawInvNum(38+i*32, 0, 162, (char)p->ammo_amount[CHICKEN_WEAPON], 0, 10); - } - else - { - if (p->gotweapon&(1 << (i + 1))) { - rotatesprite_fs(sbarx(18+i*32), sbary(SBY-6), sbscale, 0, AMMO_ICON + i, 0, 0, 10+16+64); - } - G_DrawInvNum(38+i*32, 0, SBY-4, (char)p->ammo_amount[i+1], 0, 10); - } - } -} - -static int32_t G_GetInvOn(const DukePlayer_t *p) +static int32_t G_GetInvOn(const DukePlayer_t* p) { switch (p->inven_icon) { @@ -660,882 +150,844 @@ static int32_t G_GetInvOn(const DukePlayer_t *p) return 0x80000000; } -static int32_t G_GetMorale(int32_t p_i, int32_t snum) +static int32_t GetMoraleOrShield(DukePlayer_t *p, int32_t snum) { - return Gv_GetVarByLabel("PLR_MORALE", -1, p_i, snum); + // WW2GI + int lAmount = Gv_GetVarByLabel("PLR_MORALE", -1, p->i, snum); + if (lAmount == -1) lAmount = p->inv_amount[GET_SHIELD]; + return lAmount; } -static inline void rotatesprite_althud(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat){ - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - rotatesprite_(sbarx(sx+1), sbary(sy+1), z, a, picnum, 127, 4, dastat + POLYMOSTTRANS2, 0, 0, 0, 0, xdim - 1, ydim - 1); - rotatesprite_(sbarx(sx), sbary(sy), z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0, 0, xdim - 1, ydim - 1); -} +//========================================================================== +// +// very much a dummy to access the methods. +// The goal is to export this to a script. +// +//========================================================================== -static inline void rotatesprite_althudr(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat) +class DukeStatusBar : public DBaseStatusBar { - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - rotatesprite_(sbarxr(sx + 1), sbary(sy + 1), z, a, picnum, 127, 4, dastat + POLYMOSTTRANS2, 0, 0, 0, 0, xdim - 1, ydim - 1); - rotatesprite_(sbarxr(sx), sbary(sy), z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0, 0, xdim - 1, ydim - 1); -} + DHUDFont numberFont; + DHUDFont indexFont; + DHUDFont miniFont; + DHUDFont digiFont; + double scale; + std::array ammo_sprites; + std::array item_icons = { 0, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; -void G_DrawStatusBar(int32_t snum) -{ - DukePlayer_t *const p = g_player[snum].ps; - int32_t i, j, o, u; - int32_t permbit = 0; - -#ifdef SPLITSCREEN_MOD_HACKS - const int32_t ss = g_fakeMultiMode ? 4 : ud.screen_size; - const int32_t althud = g_fakeMultiMode ? 0 : ud.althud; -#else - const int32_t ss = ud.screen_size; - const int32_t althud = ud.althud; -#endif - - const int32_t SBY = (200-(tilesiz[BOTTOMSTATUSBAR].y >> (RR ? 1 : 0))); - - const int32_t sb15 = sbarsc(32768), sb15h = sbarsc(49152); - const int32_t sb16 = sbarsc(65536); - - static int32_t item_icons[8]; - - if (ss < 4) - return; - - if (item_icons[0] == 0) +public: + DukeStatusBar() + : numberFont(BigFont, 1, Off, 1, 1), + indexFont(IndexFont, 4, CellRight, 1, 1), + miniFont(SmallFont2, 1, Off, 1, 1), + digiFont(DigiFont, 1 , Off, 1, 1) { - int32_t iicons[8] = { -1, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, - JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; - Bmemcpy(item_icons, iicons, sizeof(item_icons)); - } + // optionally draw at the top of the screen. + SetSize(tilesiz[BOTTOMSTATUSBAR].y); + drawOffset.Y = hud_position ? -168 : 0; + scale = (g_gameType & GAMEFLAG_RRALL) ? 0.5 : 1; - if (videoGetRenderMode() >= REND_POLYMOST) pus = NUMPAGES; // JBF 20040101: always redraw in GL - - if ((g_netServer || ud.multimode > 1) && ((g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR))) - { - if (pus) - G_DrawFrags(); + if (!(g_gameType & GAMEFLAG_RRALL)) + { + ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, RPGAMMO, HBOMBAMMO, CRYSTALAMMO, DEVISTATORAMMO, TRIPBOMBSPRITE, FREEZEAMMO + 1, HBOMBAMMO, GROWAMMO/*, FLAMETHROWERAMMO + 1*/ }; + } else { - for (TRAVERSE_CONNECT(i)) - if (g_player[i].ps->frag != sbar.frag[i]) + ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, HBOMBAMMO, HBOMBAMMO, RRTILE43, DEVISTATORAMMO, TRIPBOMBSPRITE, GROWSPRITEICON, HBOMBAMMO, -1, + BOWLINGBALLSPRITE, MOTOAMMO, BOATAMMO, -1, RPG2SPRITE }; + } + } + + + //========================================================================== + // + // Frag bar - todo + // + //========================================================================== +#if 0 + void displayfragbar(void) + { + if (ud.statusbarflags & STATUSBAR_NOFRAGBAR) + return; + + + short i, j; + + j = 0; + + for (i = connecthead; i >= 0; i = connectpoint2[i]) + if (i > j) j = i; + + rotatesprite(0, 0, 65600L, 0, FRAGBAR, 0, 0, 2 + 8 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + if (j >= 4) rotatesprite(319, (8) << 16, 65600L, 0, FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + if (j >= 8) rotatesprite(319, (16) << 16, 65600L, 0, FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + if (j >= 12) rotatesprite(319, (24) << 16, 65600L, 0, FRAGBAR, 0, 0, 10 + 16 + 64 + 128, 0, 0, xdim - 1, ydim - 1); + + for (i = connecthead; i >= 0; i = connectpoint2[i]) + { + minitext(21 + (73 * (i & 3)), 2 + ((i & 28) << 1), &ud.user_name[i][0], sprite[ps[i].i].pal, 2 + 8 + 16 + 128); + sprintf(tempbuf, "%d", ps[i].frag - ps[i].fraggedself); + minitext(17 + 50 + (73 * (i & 3)), 2 + ((i & 28) << 1), tempbuf, sprite[ps[i].i].pal, 2 + 8 + 16 + 128); + } + } +#endif + //========================================================================== + // + // Common inventory icon code for all styles + // + //========================================================================== + + std::pair ontext(DukePlayer_t *p) + { + std::pair retval(nullptr, CR_RED); + int onstate = G_GetInvOn(p); + // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. + if ((unsigned)onstate != 0x80000000 && !(g_gameType & (GAMEFLAG_WW2GI|GAMEFLAG_RRALL))) + { + retval.second = onstate > 0 ? CR_LIGHTBLUE : CR_RED; + retval.first = onstate > 0 ? "ON" : "OFF"; + } + if (p->inven_icon >= ICON_SCUBA) + { + retval.second = CR_ORANGE; + retval.first = "AUTO"; + } + return retval; + } + + //========================================================================== + // + // draws the inventory selector + // + //========================================================================== + + void DrawInventory(const DukePlayer_t* p, double x, double y, int align) + { + if (p->invdisptime <= 0)return; + + int n = 0, j = 0; + if (p->inv_amount[GET_FIRSTAID] > 0) n |= 1, j++; + if (p->inv_amount[GET_STEROIDS] > 0) n |= 2, j++; + if (p->inv_amount[GET_HOLODUKE] > 0) n |= 4, j++; + if (p->inv_amount[GET_JETPACK] > 0) n |= 8, j++; + if (p->inv_amount[GET_HEATS] > 0) n |= 16, j++; + if (p->inv_amount[GET_SCUBA] > 0) n |= 32, j++; + if (p->inv_amount[GET_BOOTS] > 0) n |= 64, j++; + + x -= (j * 11); + y -= 6; + + ; align |= DI_ITEM_CENTER; + for(int i = 1; i < 128; i<<=1) + { + if (n & i) + { + int select = 1 << (p->inven_icon - 1); + double alpha = select == i ? 1.0 : 0.7; + switch (i) { - G_DrawFrags(); + case 1: + DrawGraphic(tileGetTexture(FIRSTAID_ICON), x, y, align, alpha, 0, 0, scale, scale); + break; + case 2: + DrawGraphic(tileGetTexture(STEROIDS_ICON), x, y, align, alpha, 0, 0, scale, scale); + break; + case 4: + DrawGraphic(tileGetTexture(HOLODUKE_ICON), x, y, align, alpha, 0, 0, scale, scale); + break; + case 8: + DrawGraphic(tileGetTexture(JETPACK_ICON), x, y, align, alpha, 0, 0, scale, scale); + break; + case 16: + DrawGraphic(tileGetTexture(HEAT_ICON), x, y, align, alpha, 0, 0, scale, scale); + break; + case 32: + DrawGraphic(tileGetTexture(AIRTANK_ICON), x, y, align, alpha, 0, 0, scale, scale); + break; + case 64: + DrawGraphic(tileGetTexture(BOOT_ICON), x, y, align, alpha, 0, 0, scale, scale); break; } - + if (select == i) DrawGraphic(tileGetTexture(ARROW), x, y, align, alpha, 0, 0, scale, scale); + x += 22; + } } - for (TRAVERSE_CONNECT(i)) - if (i != myconnectindex) - sbar.frag[i] = g_player[i].ps->frag; } - if (ss == 4) //DRAW MINI STATUS BAR: + //========================================================================== + // + // Fullscreen HUD variant #1 + // + //========================================================================== + + void FullscreenHUD1(DukePlayer_t* p, int32_t snum) { - if (althud) + // + // Health + // + DrawGraphic(tileGetTexture(COLA), 2, -2, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, 0.75, 0.75); + + FString format; + if (!althud_flashing || p->last_extra > (p->max_player_health >> 2) || ((int32_t)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) { - // ALTERNATIVE STATUS BAR + int s = -8; + if (althud_flashing && p->last_extra > p->max_player_health) + s += (sintable[((int)totalclock << 5) & 2047] >> 10); + int intens = clamp(255 - 4 * s, 0, 255); + auto pe = PalEntry(255, intens, intens, intens); + format.Format("%d", p->last_extra); + SBar_DrawString(this, &numberFont, format, 40, -BigFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } - if (RR) + // + // Armor + // + DrawGraphic(tileGetTexture(SHIELD), 62, -2, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, 0.75, 0.75); + + format.Format("%d", GetMoraleOrShield(p, snum)); + SBar_DrawString(this, &numberFont, format, 105, -numberFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + + // + // Weapon + // + + int wicon = ammo_sprites[p->curr_weapon]; + if (wicon > 0) + { + auto img = tileGetTexture(wicon); + auto scale = img && img->GetDisplayHeight() >= 50 ? 0.25 : 0.5; + DrawGraphic(img, -57, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + } + + int weapon = p->curr_weapon; + if (weapon == HANDREMOTE_WEAPON) weapon = HANDBOMB_WEAPON; + + if (p->curr_weapon != KNEE_WEAPON && (!althud_flashing || (int32_t)totalclock & 32 || p->ammo_amount[weapon] > (p->max_ammo_amount[weapon] / 10))) + { + format.Format("%d", p->ammo_amount[weapon]); + SBar_DrawString(this, &numberFont, format, -22, -numberFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + + // + // Selected inventory item + // + + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = 131; + + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); + + int percentv = G_GetInvAmount(p); + format.Format("%3d%%", percentv); + EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; + SBar_DrawString(this, &indexFont, format, x + 35, -indexFont.mFont->GetHeight() - 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 35, -miniFont.mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + } + + // + // keys + // + if (p->got_access & 1) DrawGraphic(tileGetTexture(ACCESSCARD), -29, -30, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + if (p->got_access & 4) DrawGraphic(tileGetTexture(ACCESSCARD), -24, -28, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->got_access & 2) DrawGraphic(tileGetTexture(ACCESSCARD), -19, -26, DI_ITEM_CENTER, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + } + + + //========================================================================== + // + // Fullscreen HUD variant #2 + // + //========================================================================== + + void FullscreenHUD2(DukePlayer_t *p) + { + // + // health + // + DrawGraphic(tileGetTexture(HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + FStringf format("%d", health); + SBar_DrawString(this, &digiFont, format, 19, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // ammo + // + DrawGraphic(tileGetTexture(AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wp]); + SBar_DrawString(this, &digiFont, format, 53, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // inventory + // + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = 73; + DrawGraphic(tileGetTexture(INVENTORYBOX), 69, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -14, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, -1, -1, scale, scale); + + int percentv = G_GetInvAmount(p); + format.Format("%3d%%", percentv); + EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; + SBar_DrawString(this, &indexFont, format, x + 34, -indexFont.mFont->GetHeight() - 5.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, -miniFont.mFont->GetHeight() - 14.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + + } + } + + //========================================================================== + // + // Fullscreen HUD variant #1 for RR + // + //========================================================================== + + void FullscreenHUD1RR(DukePlayer_t* p, int32_t snum) + { + + // + // Health + // + + DrawGraphic(tileGetTexture(SPINNINGNUKEICON+1), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 10000. / 65536., 10000. / 65536.); + + FString format; + if (!althud_flashing || p->last_extra > (p->max_player_health >> 2) || ((int32_t)totalclock & 32) || (sprite[p->i].pal == 1 && p->last_extra < 2)) + { + int s = -8; + if (althud_flashing && p->last_extra > p->max_player_health) + s += (sintable[((int)totalclock << 5) & 2047] >> 10); + int intens = clamp(255 - 4 * s, 0, 255); + auto pe = PalEntry(255, intens, intens, intens); + format.Format("%d", p->last_extra); + SBar_DrawString(this, &numberFont, format, 44, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + // + // drink + // + DrawGraphic(tileGetTexture(COLA), 70, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 10000. / 65536., 10000. / 65536.); + format.Format("%d", p->drink_amt); + SBar_DrawString(this, &numberFont, format, 98, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // eat + // + DrawGraphic(tileGetTexture(JETPACK), 122, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 20000. / 65536., 20000. / 65536.); + format.Format("%d", p->eat_amt); + SBar_DrawString(this, &numberFont, format, 175, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // selected weapon + // + int wicon = ammo_sprites[p->curr_weapon]; + if (wicon > 0) + { + auto img = tileGetTexture(wicon); + auto myscale = img && img->GetDisplayHeight() >= 50 ? 0.25 : 0.5; + DrawGraphic(img, -50, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, myscale, myscale); + } + + int weapon = p->curr_weapon; + if (weapon == HANDREMOTE_WEAPON) weapon = HANDBOMB_WEAPON; + + if (p->curr_weapon != KNEE_WEAPON && p->curr_weapon != SLINGBLADE_WEAPON && (!althud_flashing || (int32_t)totalclock & 32 || p->ammo_amount[weapon] > (p->max_ammo_amount[weapon] / 10))) + { + format.Format("%d", p->ammo_amount[weapon]); + SBar_DrawString(this, &numberFont, format, -20, -numberFont.mFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + // + // Selected inventory item + // + + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = -122; + + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + + int percentv = G_GetInvAmount(p); + if (icon <= 2) format.Format("%3d%%", percentv); + else format.Format("%3d ", percentv); + SBar_DrawString(this, &miniFont, format, x + 35, -miniFont.mFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 35, -miniFont.mFont->GetHeight() * scale - 9.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + if (p->keys[1]) DrawGraphic(tileGetTexture(ACCESSCARD), -29, -32, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + if (p->keys[3]) DrawGraphic(tileGetTexture(ACCESSCARD), -24, -30, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->keys[2]) DrawGraphic(tileGetTexture(ACCESSCARD), -19, -28, DI_ITEM_BOTTOM, 1, -1, -1, 0.5, 0.5, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + } + + + //========================================================================== + // + // Fullscreen HUD variant #2 for RR + // + //========================================================================== + + void FullscreenHUD2RR(DukePlayer_t* p) + { + // + // health + // + DrawGraphic(tileGetTexture(HEALTHBOX), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + FStringf format("%d", health); + SBar_DrawString(this, &digiFont, format, 17, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // ammo + // + DrawGraphic(tileGetTexture(AMMOBOX), 41, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wp]); + SBar_DrawString(this, &digiFont, format, 57, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + // + // inventory + // + unsigned icon = p->inven_icon; + if (icon > 0) + { + int x = 81; + DrawGraphic(tileGetTexture(INVENTORYBOX), 77, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, -14, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); + + int percentv = G_GetInvAmount(p); + if (icon <= 2) format.Format("%3d%%", percentv); + else format.Format("%3d ", percentv); + SBar_DrawString(this, &miniFont, format, x + 34, -miniFont.mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + } + + //========================================================================== + // + // Fullscreen HUD drawer + // + //========================================================================== + + void DrawHud(int32_t snum, int style) + { + auto p = g_player[snum].ps; + BeginHUD(320, 200, 1.f, true); + bool rr = !!(g_gameType & GAMEFLAG_RRALL); + if (style == 1) + { + if (!rr) { - int32_t hudoffset = hud_position == 1 ? 32 : 200; - static int32_t ammo_sprites[MAX_WEAPONS]; - - if (EDUKE32_PREDICT_FALSE(ammo_sprites[0] == 0)) - { - /* this looks stupid but it lets us initialize static memory to dynamic values - these values can be changed from the CONs with dynamic tile remapping - but we don't want to have to recreate the values in memory every time - the HUD is drawn */ - - int32_t asprites[MAX_WEAPONS] = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, - HBOMBAMMO, HBOMBAMMO, RRTILE43, DEVISTATORAMMO, - TRIPBOMBSPRITE, GROWSPRITEICON, HBOMBAMMO, -1, BOWLINGBALLSPRITE, - MOTOAMMO, BOATAMMO, -1, RPG2SPRITE - }; - Bmemcpy(ammo_sprites, asprites, sizeof(ammo_sprites)); - // Hardcoded for now - althud_numbertile = BIGALPHANUM-10; - } - - // rotatesprite_fs(sbarx(5+1),sbary(200-25+1),sb15h,0,SIXPAK,0,4,10+16+1+32); - // rotatesprite_fs(sbarx(5),sbary(200-25),sb15h,0,SIXPAK,0,0,10+16); - rotatesprite_althud(2, hudoffset-26, sbarsc(10000), 0, SPINNINGNUKEICON+1, 0, 0, 10+16+256); - - 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) - { - int32_t s = -8; - if (althud_flashing && p->last_extra > p->max_player_health) - s += (sintable[((int32_t) totalclock<<5)&2047]>>10); - G_DrawAltDigiNum(44, -(hudoffset-22), p->last_extra, s, 10+16+256); - } - - rotatesprite_althud(70, hudoffset-22, sbarsc(10000), 0, COLA, 0, 0, 10+16+256); - G_DrawAltDigiNum(98, -(hudoffset-22), p->drink_amt, -8, 10+16+256); - - rotatesprite_althud(122, hudoffset-22, sbarsc(19000), 0, JETPACK, 0, 0, 10+16+256); - G_DrawAltDigiNum(175, -(hudoffset-22), p->eat_amt, -8, 10+16+256); - - if (ammo_sprites[p->curr_weapon] >= 0) - { - i = (tilesiz[ammo_sprites[p->curr_weapon]].y >= 50) ? 16384 : 32768; - if (p->curr_weapon == TRIPBOMB_WEAPON) - rotatesprite_althudr(57, hudoffset-30, sbarsc(i), 0, ammo_sprites[p->curr_weapon], 0, 0, 10+512); - else - rotatesprite_althudr(57, hudoffset-15, sbarsc(i), 0, ammo_sprites[p->curr_weapon], 0, 0, 10+512); - } - - if (p->curr_weapon== HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; - 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))) - G_DrawAltDigiNum(-20, -(hudoffset-22), p->ammo_amount[i], -16, 10+16+512); - - o = 102; - permbit = 0; - - if (p->inven_icon) - { - const int32_t orient = 10+16+permbit+512; - - i = ((unsigned) p->inven_icon < ICON_MAX) ? item_icons[p->inven_icon] : -1; - - if (i >= 0) - rotatesprite_althudr(320-(231-o+85), hudoffset-21-2, sb15, 0, i, 0, 0, orient); - - if (p->inven_icon == 1 || p->inven_icon == 2) - { - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - minitextshade(320-(292-30-o+1+85), hudoffset-10-3+1, "%", 127, 4, POLYMOSTTRANS+orient+ROTATESPRITE_MAX); - minitext(320-(292-30-o+85), hudoffset-10-3, "%", 0, orient+ROTATESPRITE_MAX); - } - - i = G_GetInvAmount(p); - - G_DrawInvNum(320-(284-30-o+85), 0, hudoffset-6-3, (uint8_t) i, 0, 10+permbit+512); - - if (p->inven_icon >= ICON_SCUBA) - { - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - minitextshade(320-(284-35-o+1+85), hudoffset-20-3+1, "Auto", 127, 4, POLYMOSTTRANS+orient+ROTATESPRITE_MAX); - minitext(320-(284-35-o+85), hudoffset-20-3, "Auto", 2, orient+ROTATESPRITE_MAX); - } - } - - if (hud_position == 1) - hudoffset += 40; - - if (p->keys[1]) rotatesprite_althudr(39, hudoffset-43, sb15, 0, ACCESSCARD, 0, 0, 10+16+512); - if (p->keys[3]) rotatesprite_althudr(34, hudoffset-41, sb15, 0, ACCESSCARD, 0, 23, 10+16+512); - if (p->keys[2]) rotatesprite_althudr(29, hudoffset-39, sb15, 0, ACCESSCARD, 0, 21, 10+16+512); + DrawInventory(p, 0, -46, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD1(p, snum); } else { - int32_t hudoffset = hud_position == 1 ? 32 : 200; - static int32_t ammo_sprites[MAX_WEAPONS]; - - if (EDUKE32_PREDICT_FALSE(ammo_sprites[0] == 0)) - { - /* this looks stupid but it lets us initialize static memory to dynamic values - these values can be changed from the CONs with dynamic tile remapping - but we don't want to have to recreate the values in memory every time - the HUD is drawn */ - - int32_t asprites[MAX_WEAPONS] = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, - RPGAMMO, HBOMBAMMO, CRYSTALAMMO, DEVISTATORAMMO, - TRIPBOMBSPRITE, FREEZEAMMO+1, HBOMBAMMO, GROWAMMO - }; - Bmemcpy(ammo_sprites, asprites, sizeof(ammo_sprites)); - // Hardcoded for now - althud_numbertile = BIGALPHANUM-10; - } - - // rotatesprite_fs(sbarx(5+1),sbary(200-25+1),sb15h,0,SIXPAK,0,4,10+16+1+32); - // rotatesprite_fs(sbarx(5),sbary(200-25),sb15h,0,SIXPAK,0,0,10+16); - rotatesprite_althud(2, hudoffset-21, sb15h, 0, COLA, 0, 0, 10+16+256); - - 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) - { - int32_t s = -8; - if (althud_flashing && p->last_extra > p->max_player_health) - s += (sintable[((int32_t) totalclock<<5)&2047]>>10); - G_DrawAltDigiNum(40, -(hudoffset-22), p->last_extra, s, 10+16+256); - } - - rotatesprite_althud(62, hudoffset-25, sb15h, 0, SHIELD, 0, 0, 10+16+256); - - { - int32_t lAmount = G_GetMorale(p->i, snum); - if (lAmount == -1) - lAmount = p->inv_amount[GET_SHIELD]; - G_DrawAltDigiNum(105, -(hudoffset-22), lAmount, -16, 10+16+256); - } - - if (ammo_sprites[p->curr_weapon] >= 0) - { - i = (tilesiz[ammo_sprites[p->curr_weapon]].y >= 50) ? 16384 : 32768; - rotatesprite_althudr(57, hudoffset-15, sbarsc(i), 0, ammo_sprites[p->curr_weapon], 0, 0, 10+512); - } - - if (p->curr_weapon== HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; - 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))) - G_DrawAltDigiNum(-20, -(hudoffset-22), p->ammo_amount[i], -16, 10+16+512); - - o = 102; - permbit = 0; - - if (p->inven_icon) - { - const int32_t orient = 10+16+permbit+256; - - i = ((unsigned) p->inven_icon < ICON_MAX) ? item_icons[p->inven_icon] : -1; - - if (i >= 0) - rotatesprite_althud(231-o, hudoffset-21-2, sb16, 0, i, 0, 0, orient); - - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - minitextshade(292-30-o+1, hudoffset-10-3+1, "%", 127, 4, POLYMOSTTRANS+orient+ROTATESPRITE_MAX); - minitext(292-30-o, hudoffset-10-3, "%", 6, orient+ROTATESPRITE_MAX); - - i = G_GetInvAmount(p); - j = G_GetInvOn(p); - - G_DrawInvNum(-(284-30-o), 0, hudoffset-6-3, (uint8_t) i, 0, 10+permbit+256); - - if (!WW2GI) - { - if (j > 0) - { - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - minitextshade(288-30-o+1, hudoffset-20-3+1, "On", 127, 4, POLYMOSTTRANS+orient+ROTATESPRITE_MAX); - minitext(288-30-o, hudoffset-20-3, "On", 0, orient+ROTATESPRITE_MAX); - } - else if ((uint32_t) j != 0x80000000) - { - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - minitextshade(284-30-o+1, hudoffset-20-3+1, "Off", 127, 4, POLYMOSTTRANS+orient+ROTATESPRITE_MAX); - minitext(284-30-o, hudoffset-20-3, "Off", 2, orient+ROTATESPRITE_MAX); - } - } - - if (p->inven_icon >= ICON_SCUBA) - { - if (videoGetRenderMode() >= REND_POLYMOST && althud_shadows) - minitextshade(284-35-o+1, hudoffset-20-3+1, "Auto", 127, 4, POLYMOSTTRANS+orient+ROTATESPRITE_MAX); - minitext(284-35-o, hudoffset-20-3, "Auto", 2, orient+ROTATESPRITE_MAX); - } - } - - if (hud_position == 1) - hudoffset += 40; - - if (p->got_access&1) rotatesprite_althudr(39, hudoffset-43, sb15, 0, ACCESSCARD, 0, 0, 10+16+512); - if (p->got_access&4) rotatesprite_althudr(34, hudoffset-41, sb15, 0, ACCESSCARD, 0, 23, 10+16+512); - if (p->got_access&2) rotatesprite_althudr(29, hudoffset-39, sb15, 0, ACCESSCARD, 0, 21, 10+16+512); + double y = -40; + if (ud.multimode > 1) + y -= 4; + if (ud.multimode > 4) + y -= 4; + DrawInventory(p, 0, y, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD1RR(p, snum); + } + } + else if (style == 2) + { + if (!rr) + { + DrawInventory(p, (ud.multimode > 1) ? 56 : 65, -28, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD2(p); + } + else + { + DrawInventory(p, 56, -20, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD2RR(p); } } else { - // ORIGINAL MINI STATUS BAR - int32_t orient = 2+8+16+256, yofssh=0; + DrawInventory(p, 0, rr? -20 : -28, DI_SCREEN_CENTER_BOTTOM); + } + } -#ifdef SPLITSCREEN_MOD_HACKS - int32_t yofs=0; - if (g_fakeMultiMode) + //========================================================================== + // + // Helper + // + //========================================================================== + + PalEntry LightForShade(int shade) + { + int ll = clamp((numshades - shade) * 255 / numshades, 0, 255); + return PalEntry(255, ll, ll, ll); + } + + //========================================================================== + // + // Helper for weapon display + // + //========================================================================== + + void DrawWeaponNum(int index, int x, int y, int num1, int num2, int shade, int numdigits) + { + /* + if (VOLUMEONE && (ind > HANDBOMB_WEAPON || ind < 0)) + { + minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX); + return; + } + */ + FString format; + + if (numdigits == 2) + { + if (num1 > 99) num1 = 99; + if (num2 > 99) num2 = 99; + format.Format("%2d/%d", num1, num2); + } + else + { + if (num1 > 999) num1 = 999; + if (num2 > 999) num2 = 999; + format.Format("%3d/%d", num1, num2); + } + y--; + DrawGraphic(tileGetTexture(THREEBYFIVE + index), x - 7, y, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, 0, 0, 1, 1, LightForShade(shade - 10), TRANSLATION(Translation_Remap, 7)); + auto pe = LightForShade(shade); + DrawGraphic(tileGetTexture(THREEBYFIVE + 10), x - 3, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, pe); + for (size_t i = 0; i < format.Len(); i++) + { + if (format[i] != ' ') { - const int32_t sidebyside = (ud.screen_size!=0); - - if (sidebyside && snum==1) - { - orient |= RS_CENTERORIGIN; - } - else if (!sidebyside && snum==0) - { - yofs = -100; - yofssh = yofs<<16; - } - } -#endif - - if (RR) - { - rotatesprite_fs(sbarx(2), yofssh+sbary(200-28), sb15, 0, HEALTHBOX, 0, 21, orient); - if (p->inven_icon) - rotatesprite_fs(sbarx(77), yofssh+sbary(200-30), sb15, 0, INVENTORYBOX, 0, 21, orient); - - // health - { - int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - G_DrawDigiNum_(20, yofssh, 200-17, health, -16, orient); - } - - rotatesprite_fs(sbarx(41), yofssh+sbary(200-28), sb15, 0, AMMOBOX, 0, 21, orient); - - if (p->curr_weapon == HANDREMOTE_WEAPON) - i = HANDBOMB_WEAPON; - else - i = p->curr_weapon; - G_DrawDigiNum_(59, yofssh, 200-17, p->ammo_amount[i], -16, orient); - - o = 158; - permbit = 0; - if (p->inven_icon) - { - // orient |= permbit; - - i = ((unsigned) p->inven_icon < ICON_MAX) ? item_icons[p->inven_icon] : -1; - if (i >= 0) - rotatesprite_fs(sbarx(231-o+10), yofssh+sbary(200-21), sb15, 0, i, 0, 0, orient); - - // scale by status bar size - orient |= ROTATESPRITE_MAX; - - minitext_yofs = yofssh; - if (p->inven_icon == 1 || p->inven_icon == 2) - minitext(292-30-o+10, 190, "%", 0, orient); - i = G_GetInvAmount(p); - - G_DrawInvNum(284-30-o+8, yofssh, 200-6, (uint8_t) i, 0, orient&~16); - - minitext_yofs = 0; - } - } - else - { - rotatesprite_fs(sbarx(5), yofssh+sbary(200-28), sb16, 0, HEALTHBOX, 0, 21, orient); - if (p->inven_icon) - rotatesprite_fs(sbarx(69), yofssh+sbary(200-30), sb16, 0, INVENTORYBOX, 0, 21, orient); - - // health - { - int32_t health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - G_DrawDigiNum_(20, yofssh, 200-17, health, -16, orient); - } - - rotatesprite_fs(sbarx(37), yofssh+sbary(200-28), sb16, 0, AMMOBOX, 0, 21, orient); - - if (p->curr_weapon == HANDREMOTE_WEAPON) - i = HANDBOMB_WEAPON; - else - i = p->curr_weapon; - G_DrawDigiNum_(53, yofssh, 200-17, p->ammo_amount[i], -16, orient); - - o = 158; - permbit = 0; - if (p->inven_icon) - { - // orient |= permbit; - - i = ((unsigned) p->inven_icon < ICON_MAX) ? item_icons[p->inven_icon] : -1; - if (i >= 0) - rotatesprite_fs(sbarx(231-o), yofssh+sbary(200-21), sb16, 0, i, 0, 0, orient); - - // scale by status bar size - orient |= ROTATESPRITE_MAX; - - minitext_yofs = yofssh; - minitext(292-30-o, 190, "%", 6, orient); - - i = G_GetInvAmount(p); - j = G_GetInvOn(p); - - G_DrawInvNum(284-30-o, yofssh, 200-6, (uint8_t) i, 0, orient&~16); - - if (!WW2GI) - { - if (j > 0) - minitext(288-30-o, 180, GStrings("OPTVAL_ON"), 0, orient); - else if ((uint32_t) j != 0x80000000) - minitext(284-30-o, 180, GStrings("OPTVAL_OFF"), 2, orient); - } - - if (p->inven_icon >= ICON_SCUBA) - minitext(284-35-o, 180, GStrings("OPTVAL_AUTO"), 2, orient); - - minitext_yofs = 0; - } + char c = format[i] == '/' ? 11 : format[i] - '0'; + DrawGraphic(tileGetTexture(THREEBYFIVE + c), x + 4 * i, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, pe); } } - - return; } - //DRAW/UPDATE FULL STATUS BAR: + //========================================================================== + // + // Weapon display + // + //========================================================================== - if (pus) + void DrawWeaponAmounts(const DukePlayer_t* p, int32_t x, int32_t y) { - pus = 0; - u = -1; - } - else u = 0; + int32_t cw = p->curr_weapon; - if (sbar.frag[myconnectindex] != p->frag) - { - sbar.frag[myconnectindex] = p->frag; - u |= 32768; - } - if (sbar.got_access != p->got_access) - { - sbar.got_access = p->got_access; - u |= 16384; - } - - if (sbar.last_extra != p->last_extra) - { - sbar.last_extra = p->last_extra; - u |= 1; - } - - { - int32_t lAmount = G_GetMorale(p->i, snum); - if (lAmount == -1) - lAmount = p->inv_amount[GET_SHIELD]; - if (sbar.inv_amount[GET_SHIELD] != lAmount) + auto ShadeForWeapon = [=](int weapon, int optweapon = -1) { - sbar.inv_amount[GET_SHIELD] = lAmount; - u |= 2; - } - } - - if (sbar.curr_weapon != p->curr_weapon) - { - sbar.curr_weapon = p->curr_weapon; - u |= (4+8+16+32+64+128+256+512+1024+65536L); - } - - for (i=1; iammo_amount[i]) - { - sbar.ammo_amount[i] = p->ammo_amount[i]; - if (i < 9) - u |= ((2<gotweapon & (1<gotweapon & (1<inven_icon) - { - sbar.inven_icon = p->inven_icon; - u |= (2048+4096+8192); - } - if (sbar.holoduke_on != p->holoduke_on) - { - sbar.holoduke_on = p->holoduke_on; - u |= (4096+8192); - } - if (sbar.jetpack_on != p->jetpack_on) - { - sbar.jetpack_on = p->jetpack_on; - u |= (4096+8192); - } - if (sbar.heat_on != p->heat_on) - { - sbar.heat_on = p->heat_on; - u |= (4096+8192); - } - - { - static const int32_t check_items [] = { - GET_FIRSTAID, GET_STEROIDS, GET_HOLODUKE, GET_JETPACK, - GET_HEATS, GET_SCUBA, GET_BOOTS + // Headache-inducing math at play here. + return (((!p->ammo_amount[weapon]) | ((p->gotweapon & (1 << weapon)) == 0)) * 9) + 12 - 18 * ((cw == weapon) || (optweapon != -1 && cw == optweapon)); }; - for (i=0; i<(int32_t)sizeof(check_items)/(int32_t)sizeof(check_items[0]); i++) - { - int32_t item = check_items[i]; - - if (sbar.inv_amount[item] != p->inv_amount[item]) - { - sbar.inv_amount[item] = p->inv_amount[item]; - u |= 8192; - } - } + DrawWeaponNum(2, x, y, p->ammo_amount[PISTOL_WEAPON], p->max_ammo_amount[PISTOL_WEAPON], 12 - 20 * (cw == PISTOL_WEAPON), 3); + DrawWeaponNum(3, x, y + 6, p->ammo_amount[SHOTGUN_WEAPON], p->max_ammo_amount[SHOTGUN_WEAPON], ShadeForWeapon(SHOTGUN_WEAPON), 3); + DrawWeaponNum(4, x, y + 12, p->ammo_amount[CHAINGUN_WEAPON], p->max_ammo_amount[CHAINGUN_WEAPON], ShadeForWeapon(CHAINGUN_WEAPON), 3); + DrawWeaponNum(5, x + 39, y, p->ammo_amount[RPG_WEAPON], p->max_ammo_amount[RPG_WEAPON], ShadeForWeapon(RPG_WEAPON), 2); + DrawWeaponNum(6, x + 39, y + 6, p->ammo_amount[HANDBOMB_WEAPON], p->max_ammo_amount[HANDBOMB_WEAPON], ShadeForWeapon(HANDBOMB_WEAPON, HANDREMOTE_WEAPON), 2); + if (p->subweapon & (1 << GROW_WEAPON)) // original code says: if(!p->ammo_amount[SHRINKER_WEAPON] || cw == GROW_WEAPON) + DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[GROW_WEAPON], p->max_ammo_amount[GROW_WEAPON], ShadeForWeapon(GROW_WEAPON), 2); + else + DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[SHRINKER_WEAPON], p->max_ammo_amount[SHRINKER_WEAPON], ShadeForWeapon(SHRINKER_WEAPON), 2); + DrawWeaponNum(8, x + 70, y, p->ammo_amount[DEVISTATOR_WEAPON], p->max_ammo_amount[DEVISTATOR_WEAPON], ShadeForWeapon(DEVISTATOR_WEAPON), 2); + DrawWeaponNum(9, x + 70, y + 6, p->ammo_amount[TRIPBOMB_WEAPON], p->max_ammo_amount[TRIPBOMB_WEAPON], ShadeForWeapon(TRIPBOMB_WEAPON), 2); + DrawWeaponNum(0, x + 70, y + 12, p->ammo_amount[FREEZE_WEAPON], p->max_ammo_amount[FREEZE_WEAPON], ShadeForWeapon(FREEZE_WEAPON), 2); } -#if 0 - if (u == 0) - return; -#else - // FIXME: full status bar draws rectangles in the wrong places when it's - // updated partially. - u = -1; -#endif - //0 - update health - //1 - update armor - //2 - update PISTOL_WEAPON ammo - //3 - update SHOTGUN_WEAPON ammo - //4 - update CHAINGUN_WEAPON ammo - //5 - update RPG_WEAPON ammo - //6 - update HANDBOMB_WEAPON ammo - //7 - update SHRINKER_WEAPON ammo - //8 - update DEVISTATOR_WEAPON ammo - //9 - update TRIPBOMB_WEAPON ammo - //10 - update ammo display - //11 - update inventory icon - //12 - update inventory on/off - //13 - update inventory % - //14 - update keys - //15 - update kills - //16 - update FREEZE_WEAPON ammo + //========================================================================== + // + // Status bar drawer + // + //========================================================================== - if (u == -1) + void Statusbar(int32_t snum) { - G_PatchStatusBar(0, 0, 320, 200, 0); + auto p = g_player[snum].ps; + int h = tilesiz[BOTTOMSTATUSBAR].y; + int top = 200 - h; + BeginStatusBar(320, 200, h, true); + DrawInventory(p, 160, 154, 0); + DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); + + FString format; + if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) - rotatesprite_fs(sbarx(277+1), sbary(SBY+7-1), sb16, 0, KILLSICON, 0, 0, 10+16); + { + DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); + format.Format("%d", max(p->frag - p->fraggedself, 0)); + SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + else + { + auto key = tileGetTexture(ACCESS_ICON); + if (p->got_access & 4) DrawGraphic(key, 275, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->got_access & 2) DrawGraphic(key, 288, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + if (p->got_access & 1) DrawGraphic(key, 281, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, 0xffffffff, TRANSLATION(Translation_Remap, 0)); + } + DrawWeaponAmounts(p, 96, top + 16); + + int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + format.Format("%d", num); + SBar_DrawString(this, &digiFont, format, 32, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + format.Format("%d", GetMoraleOrShield(p, snum)); + SBar_DrawString(this, &digiFont, format, 64, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + + if (p->curr_weapon != KNEE_WEAPON) + { + int wep = (p->curr_weapon == HANDREMOTE_WEAPON)? HANDBOMB_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wep]); + SBar_DrawString(this, &digiFont, format, 208, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); + } + + int icon = p->inven_icon; + if (icon) + { + int x = 231; + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, 1, 1); + + int percentv = G_GetInvAmount(p); + format.Format("%3d%%", percentv); + EColorRange color = percentv > 50 ? CR_GREEN : percentv > 25 ? CR_GOLD : CR_RED; + SBar_DrawString(this, &indexFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1); + + auto text = ontext(p); + if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); + } + } + + + //========================================================================== + // + // Status bar drawer (RR) + // + //========================================================================== + + void DrawWeaponBar(const DukePlayer_t* p, int top) + { + double sbscale = 32800. / 65536.; + + DrawGraphic(tileGetTexture(WEAPONBAR), 0, 158, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); + + FString format; + for (int i = 0; i < 9; i++) + { + if ((g_gameType & GAMEFLAG_RRRA) && i == 4 && p->curr_weapon == CHICKEN_WEAPON) + { + DrawGraphic(tileGetTexture(AMMO_ICON + 10), 18 + i * 32, top - 6, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); + format.Format("%d", p->ammo_amount[CHICKEN_WEAPON]); + } + else + { + if (p->gotweapon & (1 << (i + 1))) { + DrawGraphic(tileGetTexture(AMMO_ICON + i), 18 + i * 32, top - 6, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); + } + format.Format("%d", p->ammo_amount[i+1]); + } + SBar_DrawString(this, &miniFont, format, 38 + i * 32, 162 - miniFont.mFont->GetHeight() * scale * 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + } + + + //========================================================================== + // + // Status bar drawer (RR) + // + //========================================================================== + + void StatusbarRR(int32_t snum) + { + auto p = g_player[snum].ps; + double h = tilesiz[BOTTOMSTATUSBAR].y * scale; + double top = 200 - h; + BeginStatusBar(320, 200, h, true); + DrawInventory(p, 160, 154, 0); + if (ud.screen_size > 8) - G_DrawWeaponBar(p); - } + DrawWeaponBar(p, top); - if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) - { - if (u&32768) + DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); + + FString format; + + if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) { - if (u != -1) G_PatchStatusBar(276, SBY+17, 299, SBY+17+10); - G_DrawDigiNum(287, SBY+17, max(p->frag-p->fraggedself, 0), -16, 10+16); + DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); + format.Format("%d", max(p->frag - p->fraggedself, 0)); + SBar_DrawString(this, &digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); } - } - else - { - if (u&16384) + else { - if (RR) - { - if (u != -1) G_PatchStatusBar(136, SBY+16, 164, SBY+16+12); - if (p->keys[3]) rotatesprite_fs(sbarx(140), sbary(SBY+16), sb15, 0, ACCESS_ICON, 0, 23, 10+16); - if (p->keys[2]) rotatesprite_fs(sbarx(153), sbary(SBY+16), sb15, 0, ACCESS_ICON, 0, 21, 10+16); - if (p->keys[1]) rotatesprite_fs(sbarx(146), sbary(SBY+23), sb15, 0, ACCESS_ICON, 0, 0, 10+16); - } - else - { - if (u != -1) G_PatchStatusBar(275, SBY+18, 299, SBY+18+12); - if (p->got_access&4) rotatesprite_fs(sbarx(275), sbary(SBY+16), sb16, 0, ACCESS_ICON, 0, 23, 10+16); - if (p->got_access&2) rotatesprite_fs(sbarx(288), sbary(SBY+16), sb16, 0, ACCESS_ICON, 0, 21, 10+16); - if (p->got_access&1) rotatesprite_fs(sbarx(281), sbary(SBY+23), sb16, 0, ACCESS_ICON, 0, 0, 10+16); - } - } - } - - if (!RR && (u&(4+8+16+32+64+128+256+512+65536L))) - G_DrawWeapAmounts(p, 96, SBY+16, u); - - if (u&1) - { - if (u != -1) G_PatchStatusBar(RR ? 52 : 20, SBY+17, RR ? 77 : 43, SBY+17+11); - if (sprite[p->i].pal == 1 && p->last_extra < 2) - G_DrawDigiNum(RR ? 64 : 32, SBY+17, 1, -16, 10+16); - else G_DrawDigiNum(RR ? 64 : 32, SBY+17, p->last_extra, -16, 10+16); - } - if (!RR && (u&2)) - { - if (u != -1) - G_PatchStatusBar(52, SBY+17, 75, SBY+17+11); - - G_DrawDigiNum(64, SBY+17, p->inv_amount[GET_SHIELD], -16, 10+16); - } - - if (u&1024) - { - if (u != -1) G_PatchStatusBar(RR ? 95 : 196, SBY+17, RR ? 120 : 219, SBY+17+11); - if (p->curr_weapon != KNEE_WEAPON && (!RRRA || p->curr_weapon != SLINGBLADE_WEAPON)) - { - if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; - else i = p->curr_weapon; - G_DrawDigiNum(RR ? 107 : (230-22), SBY+17, p->ammo_amount[i], -16, 10+16); - if (RR && ud.screen_size > 8) - { - if (p->curr_weapon == RPG_WEAPON || p->curr_weapon == HANDBOMB_WEAPON) - { - G_PatchStatusBar2(126, SBY-8, 142, SBY-8+16); - G_DrawInvNum(134, 0, SBY-4, p->ammo_amount[HANDBOMB_WEAPON], 0, 10); - G_PatchStatusBar2(158, SBY-8, 174, SBY-8+16); - G_DrawInvNum(166, 0, SBY-4, p->ammo_amount[RPG_WEAPON], 0, 10); - } - else if (RRRA && p->curr_weapon == CHICKEN_WEAPON) - { - G_PatchStatusBar2(158, SBY-8, 174, SBY-8+16); - G_DrawInvNum(166, 0, SBY-4, p->ammo_amount[CHICKEN_WEAPON], 0, 10); - } - else if (p->curr_weapon <= DEVISTATOR_WEAPON) - { - G_PatchStatusBar2(p->curr_weapon * 32 - 2, SBY-8, p->curr_weapon * 32 + 14, SBY-8+16); - G_DrawInvNum(p->curr_weapon * 32 + 6, 0, SBY-4, p->ammo_amount[p->curr_weapon], 0, 10); - } - /*for (i = 1; i < 10; i++) - { - if (RRRA && i == 4 && p->curr_weapon == CHICKEN_WEAPON) - { - if (!p->ammo_amount[CHICKEN_WEAPON] && (p->gotweapon&(1<< CHICKEN_WEAPON))) - { - G_PatchStatusBar2(i * 32 - 2, SBY-8, i * 32 + 14, SBY-8+16); - G_DrawInvNum(i * 32 + 6, 0, SBY-4, p->ammo_amount[CHICKEN_WEAPON], 0, 10); - } - } - else if (!p->ammo_amount[i] && (p->gotweapon&(1<ammo_amount[i], 0, 10); - } - }*/ - } - } - } - - if (u&(2048+4096+8192)) - { - if (u != -1) - { - if (RR) - { - if (u&(2048+4096)) - G_PatchStatusBar(177, SBY+10, 222, SBY+10+21); - else - G_PatchStatusBar(201, SBY+24, 216, SBY+24+10); - } - else - { - if (u&(2048+4096)) - G_PatchStatusBar(231, SBY+13, 265, SBY+13+18); - else - G_PatchStatusBar(250, SBY+24, 261, SBY+24+6); - } + auto key = tileGetTexture(ACCESS_ICON); + if (p->keys[3]) DrawGraphic(key, 140, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 23)); + if (p->keys[2]) DrawGraphic(key, 153, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 21)); + if (p->keys[1]) DrawGraphic(key, 146, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, 0xffffffff, TRANSLATION(Translation_Remap, 0)); } - if (p->inven_icon) + int num = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; + format.Format("%d", num); + SBar_DrawString(this, &digiFont, format, 64, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + if (p->curr_weapon != KNEE_WEAPON) { - o = 0; - // permbit = 128; - - if (u&(2048+4096)) - { - i = ((unsigned) p->inven_icon < ICON_MAX) ? item_icons[p->inven_icon] : -1; - // XXX: i < 0? - if (RR) - { - if (i == FIRSTAID_ICON || i == STEROIDS_ICON) - minitext(214-o+2, SBY+24, "%", 0, 10+16+permbit + ROTATESPRITE_MAX); - if (i == AIRTANK_ICON) - rotatesprite_fs(sbarx(183-o), sbary(SBY+10), sb15, 0, i, 0, 0, 10+16+permbit); - else if (i == FIRSTAID_ICON || i == BOOT_ICON || i == STEROIDS_ICON) - rotatesprite_fs(sbarx(183-o), sbary(SBY+12), sb15, 0, i, 0, 0, 10+16+permbit); - else - rotatesprite_fs(sbarx(183-o), sbary(SBY+13), sb15, 0, i, 0, 0, 10+16+permbit); - if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS) - minitext(201-o, SBY+14, "Auto", 2, 10+16+permbit + ROTATESPRITE_MAX); - } - else - { - rotatesprite_fs(sbarx(231-o), sbary(SBY+13), sb16, 0, i, 0, 0, 10+16+permbit); - minitext(292-30-o, SBY+24, "%", 6, 10+16+permbit + ROTATESPRITE_MAX); - if (p->inven_icon >= ICON_SCUBA) minitext(284-35-o, SBY+14, GStrings("OPTVAL_AUTO"), 2, 10+16+permbit + ROTATESPRITE_MAX); - } - } - - if (u&(2048+4096) && !WW2GI) - { - j = G_GetInvOn(p); - - if (!RR) - { - if (j > 0) minitext(288-30-o, SBY+14, GStrings("OPTVAL_ON"), 0, 10+16+permbit + ROTATESPRITE_MAX); - else if ((uint32_t) j != 0x80000000) minitext(284-30-o, SBY+14, GStrings("OPTVAL_OFF"), 2, 10+16+permbit + ROTATESPRITE_MAX); - } - } - - if (u&8192) - { - i = G_GetInvAmount(p); - G_DrawInvNum((RR ? 206 : (284-30))-o, 0, SBY+28, (uint8_t) i, 0, 10+permbit); - } + int wep = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; + format.Format("%d", p->ammo_amount[wep]); + SBar_DrawString(this, &digiFont, format, 107, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); } - } - // Gut meter - if (RR) - { - G_PatchStatusBar(240,SBY+2,310,SBY+33); - p->drink_ang = ((p->drink_amt*8)+1647)&2047; + int icon = p->inven_icon; + if (icon) + { + int x = 183; + if (icon < ICON_MAX) + DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); + + int percentv = G_GetInvAmount(p); + if (icon <= 2) format.Format("%3d%%", percentv); + else format.Format("%3d ", percentv); + SBar_DrawString(this, &miniFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + + if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS) + SBar_DrawString(this, &miniFont, "AUTO", x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + } + + p->drink_ang = ((p->drink_amt * 8) + 1647) & 2047; if (p->drink_amt >= 100) { p->drink_amt = 100; p->drink_ang = 400; } - rotatesprite_fs(sbarx(257),sbary(SBY+15),sb15,p->drink_ang,GUTMETER,0,0,10); - rotatesprite_fs(sbarx(293),sbary(SBY+15),sb15,p->eat_ang,GUTMETER,0,0,10); - o = 9; + DrawGraphic(tileGetTexture(GUTMETER), 257, top + 24, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, 0 /*, p->drink_ang * 360. / 2048 */ ); + DrawGraphic(tileGetTexture(GUTMETER), 293, top + 24, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, 0xffffffff, 0 /*, p->eat_ang * 360. / 2048 */); + if (p->drink_amt >= 0 && p->drink_amt <= 30) { - rotatesprite_fs(sbarx(239),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT1,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT1), 239, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } else if (p->drink_amt >= 31 && p->drink_amt <= 65) { - rotatesprite_fs(sbarx(248),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT2,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT2), 248, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } else if (p->drink_amt >= 66 && p->drink_amt <= 87) { - rotatesprite_fs(sbarx(256),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT3,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT3), 256, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } else { - rotatesprite_fs(sbarx(265),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT4,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT4), 265, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } if (p->eat_amt >= 0 && p->eat_amt <= 30) { - rotatesprite_fs(sbarx(276),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT1,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT1), 276, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } else if (p->eat_amt >= 31 && p->eat_amt <= 65) { - rotatesprite_fs(sbarx(285),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT2,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT2), 285, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } else if (p->eat_amt >= 66 && p->eat_amt <= 87) { - rotatesprite_fs(sbarx(294),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT3,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT3), 294, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } else { - rotatesprite_fs(sbarx(302),sbary((SBY+15+o)),sb15,0,GUTMETER_LIGHT4,0,0,10+16); + DrawGraphic(tileGetTexture(GUTMETER_LIGHT4), 302, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); + } + + } + +}; + +void G_DrawStatusBar(int32_t snum) +{ + //if (!RR) + { + DukeStatusBar dsb; + if (ud.screen_size <= 4) + { + dsb.DrawHud(snum, ud.screen_size < 4 ? 0 : ud.althud ? 1 : 2); + } + else + { + if (!RR) dsb.Statusbar(snum); + else dsb.StatusbarRR(snum); } } } +//========================================================================== +// +// Draws the background +// todo: split up to have dedicated functions for both cases. +// +//========================================================================== + void G_DrawBackground(void) { - int32_t x, y, x1, x2; - - renderFlushPerms(); - - int32_t y1=0, y2=ydim; - if ((g_player[myconnectindex].ps->gm&MODE_GAME) == 0 && ud.recstat != 2) { - const int32_t MENUTILE = DEER ? 7040 : MENUSCREEN; - const int32_t fstilep = tilesiz[MENUTILE].x>=320 && tilesiz[MENUTILE].y==200; - int32_t bgtile = (fstilep ? MENUTILE : (RRRA ? RRTILE7629 : BIGHOLE)); - - videoClearScreen(0); - - // when not rendering a game, fullscreen wipe - // Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1); - // MENU_TILE: is the menu tile tileable? - if (!fstilep) - { - const int32_t tileScale = RR ? 32768L : 65536L; - const int32_t tileShade = RR ? 18 : 8; - if ((unsigned) bgtile < MAXTILES) - for (y=y1; yClearScreen(); + auto tex = tileGetTexture((g_gameType & GAMEFLAG_DEER) ? 7040 : MENUSCREEN); + PalEntry color = (g_gameType & GAMEFLAG_DEER) ? 0xffffffff : 0xff808080; + if (!hud_bgstretch) + DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, 3, DTA_Color, color, TAG_DONE); + else + DrawTexture(twod, tex, 0, 0, DTA_VirtualWidth, twod->GetWidth(), DTA_VirtualHeight, twod->GetHeight(), DTA_KeepRatio, true, DTA_Color, color, TAG_DONE); return; } - int32_t const dapicnum = (RRRA ? RRTILE7629 : BIGHOLE); - - // XXX: if dapicnum is not available, this might leave the menu background - // not drawn, leading to "HOM". - if ((dapicnum >= 0 && tilesiz[dapicnum].x == 0) || (dapicnum >= 0 && tilesiz[dapicnum].y == 0) || - (windowxy1.x-1 <= 0 && windowxy2.x >= xdim-1 && windowxy1.y-1 <= 0 && windowxy2.y >= ydim-1) || - dapicnum < 0) - { - pus = pub = NUMPAGES; - return; - } - - y1 = fragbarheight(); - if (y1 != 0) - { - y1 = scale(ydim, y1, 200); - y1 -= ((tilesiz[dapicnum].y / y1) +1) * tilesiz[dapicnum].y; - } - - if (windowxy1.y > 0) - { - for (y=y1; y 0 || windowxy2.x < xdim) - { - const int32_t rx = windowxy2.x-windowxy2.x%tilesiz[dapicnum].x; - for (y=y1+windowxy1.y-windowxy1.y%tilesiz[dapicnum].y; y 0) - rotatesprite(x<<16, y<<16, 65536L, 0, dapicnum, 8, 0, 8+16+64, 0, windowxy1.y-1, windowxy1.x-2, windowxy2.y); // left - if (windowxy2.x < xdim) - rotatesprite((x+rx)<<16, y<<16, 65536L, 0, dapicnum, 8, 0, 8+16+64, windowxy2.x+1, windowxy1.y-1, xdim-1, windowxy2.y); // right - } - } - - if (windowxy2.y < ydim) - { - for (y=y1+windowxy2.y-(windowxy2.y%tilesiz[dapicnum].y); y 0 || windowxy2.x < xdim) - for (y=y1+4; y 0) - rotatesprite(x1<<16, y<<16, 65536L, 0, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // left - if (windowxy2.x < xdim) - rotatesprite((x2+1)<<16, (y+64)<<16, 65536L, 1024, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // right - } - - if (windowxy1.y > 0 || windowxy2.y < ydim) - for (x=x1+4; xisValid()) { if (windowxy1.y > 0) - rotatesprite((x+64)<<16, y1<<16, 65536L, 512, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // top - if (windowxy2.y < ydim) - rotatesprite(x<<16, (y2+1)<<16, 65536L, 1536, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // bottom + { + twod->AddFlatFill(0, 0, twod->GetWidth(), windowxy1.y, tex, false, 1); + } + if (windowxy2.y + 1 < twod->GetHeight()) + { + twod->AddFlatFill(0, windowxy2.y + 1, twod->GetWidth(), twod->GetHeight(), tex, false, 1); + } + if (windowxy1.x > 0) + { + twod->AddFlatFill(0, windowxy1.y, windowxy1.x, windowxy2.y + 1, tex, false, 1); + } + if (windowxy2.x + 1 < twod->GetWidth()) + { + twod->AddFlatFill(windowxy2.x + 1, windowxy1.y, twod->GetWidth(), windowxy2.y + 1, tex, false, 1); + } + auto vb = tileGetTexture(VIEWBORDER); + auto ve = tileGetTexture(VIEWBORDER + 1); + int x1 = windowxy1.x - 4; + int y1 = windowxy1.y - 4; + int x2 = windowxy2.x + 5; + int y2 = windowxy2.y + 5; + twod->AddFlatFill(x1, y1, x2, y1 + 4, vb, 5); + twod->AddFlatFill(x1, y2 - 4, x2, y2, vb, 6); + twod->AddFlatFill(x1, y1, x1 + 4, y2, vb, 1); + twod->AddFlatFill(x2 - 4, y1, x2, y2, vb, 3); + twod->AddFlatFill(x1, y1, x1 + 4, y1 + 4, ve, 1); + twod->AddFlatFill(x2 - 4, y1, x2, y1 + 4, ve, 3); + twod->AddFlatFill(x1, y2 - 4, x1 + 4, y2, ve, 2); + twod->AddFlatFill(x2 - 4, y2 - 4, x2, y2, ve, 4); + } + else + { + // If we got no frame just clear the screen. + twod->ClearScreen(); } - - if (windowxy1.x > 0 && windowxy1.y > 0) - rotatesprite(x1<<16, y1<<16, 65536L, 0, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // top left - if (windowxy2.x < xdim && windowxy1.y > 0) - rotatesprite((x2+1)<<16, y1<<16, 65536L, 512, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // top right - if (windowxy2.x < xdim && windowxy2.y < ydim) - rotatesprite((x2+1)<<16, (y2+1)<<16, 65536L, 1024, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // bottom right - if (windowxy1.x > 0 && windowxy2.y < ydim) - rotatesprite(x1<<16, (y2+1)<<16, 65536L, 1536, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // bottom left - - pus = pub = NUMPAGES; } END_DUKE_NS diff --git a/source/games/duke/src/sbar.h b/source/games/duke/src/sbar.h index cd6034deb..6ba18dae0 100644 --- a/source/games/duke/src/sbar.h +++ b/source/games/duke/src/sbar.h @@ -30,9 +30,6 @@ static FORCE_INLINE int32_t sbarsc(int32_t sc) return scale(sc, ud.statusbarscale, 100); } -int32_t sbarx16(int32_t x); -int32_t sbarxr16(int32_t x); -int32_t sbary16(int32_t y); void G_DrawInventory(const DukePlayer_t *p); void G_DrawStatusBar(int32_t snum); diff --git a/source/games/duke/src/screens.cpp b/source/games/duke/src/screens.cpp index 564d18748..69167293f 100644 --- a/source/games/duke/src/screens.cpp +++ b/source/games/duke/src/screens.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "compat.h" #include "screens.h" @@ -765,7 +765,7 @@ void G_DisplayRest(int32_t smoothratio) if (ud.scrollmode == 0) { - if (pp->newowner == -1 && !paused) + if (pp->newowner == -1 && !ud.pause_on) { if (screenpeek == myconnectindex && numplayers > 1) { @@ -789,7 +789,7 @@ void G_DisplayRest(int32_t smoothratio) } else { - if (!paused) + if (!ud.pause_on) { ud.fola += ud.folavel>>3; ud.folx += (ud.folfvel*sintable[(512+2048-ud.fola)&2047])>>14; @@ -822,7 +822,6 @@ void G_DisplayRest(int32_t smoothratio) } } - if (pp->invdisptime > 0) G_DrawInventory(pp); //if (VM_OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek) == 0) G_DrawStatusBar(screenpeek); @@ -844,12 +843,12 @@ void G_DisplayRest(int32_t smoothratio) if (!DEER && g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && cl_crosshair && ud.camerasprite == -1) { int32_t a = CROSSHAIR; - //ud.returnvar[0] = (160<<16) - (fix16_to_int(g_player[myconnectindex].ps->q16look_ang)<<15); + //ud.returnvar[0] = (160<<16) - (g_player[myconnectindex].ps->look_ang<<15); //ud.returnvar[1] = 100<<16; //int32_t a = VM_OnEventWithReturn(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, CROSSHAIR); if ((unsigned) a < MAXTILES) { - vec2_t crosshairpos = { (160<<16) - (fix16_to_int(g_player[myconnectindex].ps->q16look_ang)<<15), 100<<16 }; + vec2_t crosshairpos = { (160<<16) - (g_player[myconnectindex].ps->look_ang<<15), 100<<16 }; //vec2_t crosshairpos = { ud.returnvar[0], ud.returnvar[1] }; uint32_t crosshair_o = 1|2; uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100); @@ -869,10 +868,10 @@ void G_DisplayRest(int32_t smoothratio) } */ - if (paused==1 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) + if (ud.pause_on==1 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) menutext_center(100, GStrings("Game Paused")); - mdpause = (paused || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2)); + mdpause = (ud.pause_on || (ud.recstat==2 && (g_demo_paused && g_demo_goalCnt==0)) || (g_player[myconnectindex].ps->gm&MODE_MENU && numplayers < 2)); // JBF 20040124: display level stats in screen corner if (ud.overhead_on != 2 && hud_stats) // && VM_OnEvent(EVENT_DISPLAYLEVELSTATS, g_player[screenpeek].ps->i, screenpeek) == 0) diff --git a/source/games/duke/src/sector.cpp b/source/games/duke/src/sector.cpp index f3f269198..611187dca 100644 --- a/source/games/duke/src/sector.cpp +++ b/source/games/duke/src/sector.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define sector_c_ -#include "duke3d_ed.h" +#include "duke3d.h" #include "secrets.h" #include "v_video.h" @@ -503,21 +503,26 @@ int SetAnimation(int sectNum, int32_t *animPtr, int goalVal, int animVel) static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio) { - vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio); + vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio); int const saveMirror = display_mirror; - renderSetTarget(tileNum, tilesiz[tileNum].y, tilesiz[tileNum].x); + auto canvas = renderSetTarget(tileNum); + if (!canvas) return; - yax_preparedrawrooms(); - drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); - yax_drawrooms(G_DoSpriteAnimations, SECT(spriteNum), 0, smoothRatio); + screen->RenderTextureView(canvas, [=](IntRect& rect) + { + yax_preparedrawrooms(); + drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); + yax_drawrooms(G_DoSpriteAnimations, SECT(spriteNum), 0, smoothRatio); - display_mirror = 3; - G_DoSpriteAnimations(camera.x, camera.y, camera.z, SA(spriteNum), smoothRatio); - display_mirror = saveMirror; - renderDrawMasks(); + display_mirror = 3; + G_DoSpriteAnimations(camera.x, camera.y, camera.z, SA(spriteNum), smoothRatio); + display_mirror = saveMirror; + renderDrawMasks(); + }); renderRestoreTarget(); + } void G_AnimateCamSprite(int smoothRatio) @@ -3647,7 +3652,29 @@ void P_HandleSharedKeys(int playerNum) { pPlayer->interface_toggle_flag = 1; - if (paused) return; + if (TEST_SYNC_KEY(playerBits, SK_PAUSE)) + { + inputState.ClearKeyStatus(sc_Pause); + if (ud.pause_on) + ud.pause_on = 0; + else ud.pause_on = 1+SHIFTS_IS_PRESSED; + if (ud.pause_on) + { + Mus_SetPaused(true); + S_PauseSounds(true); + } + else + { + Mus_SetPaused(false); + + S_PauseSounds(false); + + pub = NUMPAGES; + pus = NUMPAGES; + } + } + + if (ud.pause_on) return; if (sprite[pPlayer->i].extra <= 0) return; // if dead... @@ -4225,10 +4252,7 @@ rrtripbomb_case: if (TEST_SYNC_KEY(playerBits, SK_TURNAROUND) && pPlayer->one_eighty_count == 0) if (VM_OnEvent(EVENT_TURNAROUND,pPlayer->i,playerNum) == 0) - { - pPlayer->one_eighty_count = -1024; - pPlayer->one_eighty_target = fix16_sadd(pPlayer->q16ang, -fix16_from_int(pPlayer->one_eighty_count)) & 0x7FFFFFF; - } + pPlayer->one_eighty_count = -1024; } } diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index bec5c221c..5086849d8 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" -#include "duke3d_ed.h" +#include "duke3d.h" #include "raze_music.h" #include "mapinfo.h" #include "raze_sound.h" @@ -79,6 +79,17 @@ TArray DukeSoundEngine::ReadSound(int lumpnum) // //========================================================================== +void S_PauseSounds(bool paused) +{ + soundEngine->SetPaused(paused); +} + +//========================================================================== +// +// +// +//========================================================================== + void cacheAllSounds(void) { auto& sfx = soundEngine->GetSounds(); @@ -86,6 +97,8 @@ void cacheAllSounds(void) for(auto &snd : sfx) { soundEngine->CacheSound(&snd); + if (((++i)&31) == 0) + G_HandleAsync(); } } diff --git a/source/games/duke/src/sounds.h b/source/games/duke/src/sounds.h index e5a8d2e2a..a8e4976aa 100644 --- a/source/games/duke/src/sounds.h +++ b/source/games/duke/src/sounds.h @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS +// KEEPINSYNC lunatic/con_lang.lua #define MAXSOUNDS 4096 #define LOUDESTVOLUME 111 @@ -56,6 +57,8 @@ inline int S_CheckSoundPlaying(int sprnum, int soundNum) { return S_CheckSoundPl inline void S_ClearSoundLocks(void) {} void cacheAllSounds(void); void S_MenuSound(void); +void S_PauseMusic(bool paused); +void S_PauseSounds(bool paused); void S_PlayLevelMusicOrNothing(unsigned int); int S_TryPlaySpecialMusic(unsigned int); void S_PlaySpecialMusicOrNothing(unsigned int); diff --git a/source/games/duke/src/text.cpp b/source/games/duke/src/text.cpp index 55c99d9c5..9b8dbeba5 100644 --- a/source/games/duke/src/text.cpp +++ b/source/games/duke/src/text.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" // Must come before everything else! -#include "duke3d_ed.h" +#include "duke3d.h" #include "compat.h" #include "sbar.h" #include "menus.h" @@ -112,6 +112,23 @@ vec2_t mpgametextsize(const char *t, int32_t f) return G_ScreenTextSize(MF_Bluefont.tilenum, 0, 0, textsc(MF_Bluefont.zoom), 0, t, 2|8|16|ROTATESPRITE_FULL16, MF_Bluefont.emptychar.x, MF_Bluefont.emptychar.y, MF_Bluefont.between.x, MF_Bluefont.between.y, MF_Bluefont.textflags|f, 0, 0, xdim-1, ydim-1); } +static int32_t sbarx16(int32_t x) +{ + if (ud.screen_size == 4) return sbarsc(x); + return (((320 << 16) - sbarsc(320 << 16)) >> 1) + sbarsc(x); +} + +static int32_t sbarxr16(int32_t x) +{ + if (ud.screen_size == 4) return (320 << 16) - sbarsc(x); + return (((320 << 16) - sbarsc(320 << 16)) >> 1) + sbarsc(x); +} + +static int32_t sbary16(int32_t y) +{ + return (100 << 16) - sbarsc(200 << 16) + sbarsc(y); +} + // minitext_yofs: in hud_scale-independent, (<<16)-scaled, 0-200-normalized y coords, // (sb&ROTATESPRITE_MAX) only. int32_t minitext_yofs = 0; diff --git a/wadsrc/static/graphics/tinyblak.png b/wadsrc/static/graphics/tinyblak.png new file mode 100644 index 000000000..6c3cc1269 Binary files /dev/null and b/wadsrc/static/graphics/tinyblak.png differ