diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 4a5645866..8149f2bc2 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -991,7 +991,6 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) return { top, 25 }; } - ::GameInterface* CreateInterface() { return new GameInterface; diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 41002d60e..5e9f88d7d 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -126,7 +126,7 @@ struct GameInterface : ::GameInterface FString GetCoordString() override; void clearlocalinputstate() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; - + GameStats getStats() override; }; diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index ae26ef6d3..00a2d8cae 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -210,7 +210,7 @@ void ctrlGetInput(void) hud_scale = hud_scale - 4; } } - if (gViewMode == 2 || gViewMode == 4) + if (gViewMode == 4) { gZoom = ClipLow(gZoom - (gZoom >> 4), 64); gViewMap.nZoom = gZoom; @@ -231,7 +231,8 @@ void ctrlGetInput(void) hud_scale = hud_scale + 4; } } - if (gViewMode == 2 || gViewMode == 4) + if ( + gViewMode == 4) { gZoom = ClipHigh(gZoom + (gZoom >> 4), 4096); gViewMap.nZoom = gZoom; diff --git a/source/core/console/c_console.cpp b/source/core/console/c_console.cpp index 70c5176f6..11ba8765f 100644 --- a/source/core/console/c_console.cpp +++ b/source/core/console/c_console.cpp @@ -94,7 +94,6 @@ static uint32_t conshade; static bool conline; extern int gametic; -extern bool automapactive; // in AM_map.c extern bool advancedemo; extern FBaseCVar *CVars; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index a7c3aabb1..702aab40d 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -100,6 +100,17 @@ static ClockTicks lastototalclk; static uint64_t elapsedTime; static uint64_t lastTime; +int automapMode; +bool automapFollow; + +CCMD(togglemap) +{ + automapMode++; + if (automapMode == am_count) automapMode = am_off; + if ((g_gameType & GAMEFLAG_BLOOD) && automapMode == am_overlay) automapMode = am_full; // todo: investigate if this can be re-enabled +} + + glcycle_t thinktime, actortime, gameupdatetime, drawtime; gamestate_t gamestate = GS_STARTUP; diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 9bfa72bbf..c76fc4d72 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -210,3 +210,18 @@ void updatePauseStatus(); void updatePauseStatus(bool state, bool multiplayer); extern int paused; extern int chatmodeon; + +enum AM_Mode +{ + am_off, + am_overlay, + am_full, + am_count +}; +extern int automapMode; +extern bool automapFollow; + +inline bool automapControlsActive() +{ + return automapMode != am_off; +} diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index bfc975dcb..b5f48fd83 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -63,7 +63,6 @@ struct GameInterface virtual void clearlocalinputstate() {} virtual void UpdateScreenSize() {} virtual void FreeGameData() {} - virtual bool automapActive() { return false; } virtual void PlayHudSound() {} virtual FString statFPS() { return "FPS display not available"; } virtual GameStats getStats() { return {}; } diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 3cecdfd70..ae0641fd3 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -307,8 +307,8 @@ struct GameInterface : ::GameInterface bool SaveGame(FSaveGameNode* sv) override; bool CanSave() override; ReservedSpace GetReservedScreenSpace(int viewsize) override { return { 0, 24 }; } - void clearlocalinputstate(); - + void clearlocalinputstate() override; + FString statFPS() override; ::GameStats getStats() override; }; diff --git a/source/exhumed/src/map.cpp b/source/exhumed/src/map.cpp index 62d761cb8..589cbcff0 100644 --- a/source/exhumed/src/map.cpp +++ b/source/exhumed/src/map.cpp @@ -414,7 +414,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 #if 0 for (TRAVERSE_CONNECT(p)) { - if (ud.scrollmode && p == screenpeek) continue; + if (automapFollow && p == screenpeek) continue; auto const pPlayer = &ps[p]; auto const pSprite = (uspriteptr_t)&sprite[pPlayer->i]; diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 0e1b87022..ed79b8a9c 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -277,6 +277,7 @@ enum EQuote QUOTE_MIGHTY_FOOT = 80 , QUOTE_WEAPON_MODE_OFF = 82 , QUOTE_MAP_FOLLOW_OFF = 83 , + QUOTE_MAP_FOLLOW_ON = 84 , QUOTE_RUN_MODE_OFF = 85 , QUOTE_JETPACK = 88 , QUOTE_SCUBA = 89 , diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 36d7b4fd1..1728bc3a0 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -39,7 +39,6 @@ struct GameInterface : public ::GameInterface void clearlocalinputstate() override; bool GenerateSavePic() override; void PlayHudSound() override; - bool automapActive() override; FString statFPS() override; GameStats getStats() override; void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override; @@ -58,7 +57,8 @@ struct GameInterface : public ::GameInterface bool CheatAllowed(bool printmsg) override; void ExitFromMenu() override; ReservedSpace GetReservedScreenSpace(int viewsize) override; - void DrawPlayerSprite(const DVector2& origin, bool onteam); + void DrawPlayerSprite(const DVector2& origin, bool onteam) override; + }; struct Dispatcher diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index cf8353f99..391b35006 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -282,7 +282,7 @@ void displayrest(double smoothratio) if (ud.camerasprite == -1) { - if (ud.overhead_on != 2) + if (automapMode != am_full) { if (!isRR() && pp->newowner >= 0) cameratext(pp->newowner); @@ -296,11 +296,11 @@ void displayrest(double smoothratio) moveclouds(); } - if (ud.overhead_on > 0) + if (automapMode != am_off) { dointerpolations(smoothratio); - if (ud.scrollmode == 0) + if (!automapFollow) { if (pp->newowner == -1 && playrunning()) { @@ -337,7 +337,7 @@ void displayrest(double smoothratio) cang = ud.fola; } - if (ud.overhead_on == 2) + if (automapMode == am_full) { twod->ClearScreen(); renderDrawMapView(cposx, cposy, pp->zoom, cang); @@ -352,7 +352,7 @@ void displayrest(double smoothratio) if (isRR()) drawstatusbar_r(screenpeek); else drawstatusbar_d(screenpeek); - if (ps[myconnectindex].newowner == -1 && ud.overhead_on == 0 && cl_crosshair && ud.camerasprite == -1) + if (ps[myconnectindex].newowner == -1 && automapMode == am_off && cl_crosshair && ud.camerasprite == -1) { int32_t a = TILE_CROSSHAIR; @@ -621,7 +621,7 @@ void drawoverheadmap(int cposx, int cposy, int czoom, int cang) for (p = connecthead; p >= 0; p = connectpoint2[p]) { - if (ud.scrollmode && p == screenpeek) continue; + if (automapFollow && p == screenpeek) continue; ox = sprite[ps[p].i].x - cposx; oy = sprite[ps[p].i].y - cposy; @@ -734,11 +734,6 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) return { 0, sbar }; } -bool GameInterface::automapActive() -{ - return ud.overhead_on != 0; -} - ::GameInterface* CreateInterface() { return new GameInterface; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 000875374..5c4977617 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -65,7 +65,7 @@ void nonsharedkeys(void) if (System_WantGuiCapture()) return; - if (!ALT_IS_PRESSED && ud.overhead_on == 0) + if (!ALT_IS_PRESSED && automapMode == am_off) { if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) { @@ -117,17 +117,17 @@ void nonsharedkeys(void) FTA(QUOTE_WEAPON_MODE_OFF - ud.showweapons, &ps[screenpeek]); } - if (ud.overhead_on && buttonMap.ButtonDown(gamefunc_Map_Follow_Mode)) + if (automapMode != am_off && buttonMap.ButtonDown(gamefunc_Map_Follow_Mode)) { buttonMap.ClearButton(gamefunc_Map_Follow_Mode); - ud.scrollmode = 1 - ud.scrollmode; - if (ud.scrollmode) + automapFollow = !automapFollow; + if (automapFollow) { ud.folx = ps[screenpeek].oposx; ud.foly = ps[screenpeek].oposy; ud.fola = ps[screenpeek].getoang(); } - FTA(QUOTE_MAP_FOLLOW_OFF + ud.scrollmode, &ps[myconnectindex]); + FTA(automapFollow? QUOTE_MAP_FOLLOW_ON : QUOTE_MAP_FOLLOW_OFF, &ps[myconnectindex]); } // Fixme: This really should be done via CCMD, not via hard coded key checks - but that needs alternative Shift and Alt bindings. @@ -181,7 +181,7 @@ void nonsharedkeys(void) } } - if (ud.overhead_on != 0) + if (automapMode != am_off) { int j; if (nonsharedtimer > 0 || totalclock < nonsharedtimer) @@ -203,22 +203,6 @@ void nonsharedkeys(void) ps[myconnectindex].zoom = clamp(ps[myconnectindex].zoom, 48, 2048); } } - - if (buttonMap.ButtonDown(gamefunc_Map)) - { - buttonMap.ClearButton(gamefunc_Map); - if (ud.last_overhead != ud.overhead_on && ud.last_overhead) - { - ud.overhead_on = ud.last_overhead; - ud.last_overhead = 0; - } - else - { - ud.overhead_on++; - if (ud.overhead_on == 3) ud.overhead_on = 0; - ud.last_overhead = ud.overhead_on; - } - } } //--------------------------------------------------------------------------- @@ -1152,9 +1136,9 @@ static void FinalizeInput(int playerNum, input_t& input, bool vehicle) auto p = &ps[playerNum]; bool blocked = movementBlocked(playerNum) || sprite[p->i].extra <= 0 || (p->dead_flag && !ud.god); - if ((ud.scrollmode && ud.overhead_on) || blocked) + if ((automapFollow && automapMode != am_off) || blocked) { - if (ud.scrollmode && ud.overhead_on) + if (automapFollow && automapMode != am_off) { ud.folfvel = input.fvel; ud.folavel = fix16_to_int(input.q16avel); diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 6825de04a..afa0b9d8c 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -472,7 +472,7 @@ void displayrooms(int snum, int smoothratio) p = &ps[snum]; - if (ud.overhead_on == 2 || p->cursectnum == -1) + if (automapMode == am_full || p->cursectnum == -1) return; // Do not light up the fog in RRRA's E2L1. Ideally this should apply to all foggy levels but all others use lookup table hacks for their fog. diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index 3c809b184..5c26fcff2 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -179,7 +179,7 @@ PalEntry DDukeCommonStatusBar::LightForShade(int shade) void DDukeCommonStatusBar::PrintLevelStats(int bottomy) { - if (ud.overhead_on == 2) + if (automapMode == am_full) { // Automap label printer moved here so that it is on top of the screen border. FString mapname; @@ -194,7 +194,7 @@ void DDukeCommonStatusBar::PrintLevelStats(int bottomy) font = isNamWW2GI() ? ConFont : SmallFont; if (isNamWW2GI()) color = CR_ORANGE; } - int top = am_nameontop ? 0 : 200 - Scale(bottomy < 0 ? RelTop : bottomy, hud_scale, 100) - isRR()? 25 : 20; + int top = am_nameontop ? 0 : ( 200 - Scale(bottomy < 0 ? RelTop : bottomy, hud_scale, 100) - (isRR()? 25 : 20)); if (!(currentLevel->flags & MI_USERMAP)) DrawText(twod, font, color, 5, top + 6, GStrings.localize(gVolumeNames[volfromlevelnum(currentLevel->levelNumber)]), DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index df49aa1a8..c7728812d 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -59,7 +59,7 @@ struct user_defs unsigned char god, cashman, eog; unsigned char show_help, scrollmode, clipping; char user_name[MAXPLAYERS][32]; - unsigned char overhead_on, last_overhead, showweapons; + unsigned char showweapons; unsigned char user_pals[MAXPLAYERS]; short from_bonus; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 9c0ef9ea6..1e2fef237 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2384,7 +2384,7 @@ struct GameInterface : ::GameInterface ReservedSpace GetReservedScreenSpace(int viewsize) override; void clearlocalinputstate() override; void QuitToTitle() override; - + FString statFPS() override; GameStats getStats() override; };