From 9300c0bdeb8f51b876a4e42598dae39ccb475b16 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Jul 2020 08:55:56 +0200 Subject: [PATCH] - stripped down the main menu loop to the minimum needed to be able to run it. --- source/games/duke/CMakeLists.txt | 1 - source/games/duke/src/d_menu.cpp | 1 - source/games/duke/src/game.h | 2 +- source/games/duke/src/game_misc.cpp | 2 +- source/games/duke/src/gameloop.cpp | 24 +++++ source/games/duke/src/global.h | 6 +- source/games/duke/src/zz_demo.cpp | 143 -------------------------- source/games/duke/src/zz_game.cpp | 6 +- source/games/duke/src/zz_global.cpp | 3 +- source/games/duke/src/zz_savegame.cpp | 4 +- 10 files changed, 35 insertions(+), 157 deletions(-) delete mode 100644 source/games/duke/src/zz_demo.cpp diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 03eae2795..a3f5478dd 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -44,7 +44,6 @@ set( PCH_SOURCES src/spawn_d.cpp src/spawn_r.cpp src/zz_common.cpp - src/zz_demo.cpp src/zz_game.cpp src/zz_global.cpp src/zz_net.cpp diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index e5f9bd965..6a6545798 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -257,7 +257,6 @@ void GameInterface::MenuSound(EMenuSounds snd) void GameInterface::MenuClosed() { - auto& gm = g_player[myconnectindex].ps->gm; if (gm & MODE_GAME) { diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index a54feab8b..7b7cc309c 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -241,7 +241,7 @@ inline bool wallswitchcheck(int s) #define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (actorinfo[iPicnum].flags & iType) != 0) #define S_StopSound(num) S_StopEnvSound(num, -1) -extern int G_StartRTS(int lumpNum, int localPlayer); +extern int startrts(int lumpNum, int localPlayer); extern void G_MaybeAllocPlayer(int32_t pnum); diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index c918c560a..bfad31ced 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -632,7 +632,7 @@ void cameratext(int i) // //--------------------------------------------------------------------------- -int G_StartRTS(int lumpNum, int localPlayer) +int startrts(int lumpNum, int localPlayer) { if (SoundEnabled() && RTS_IsInitialized() && rtsplaying == 0 && (snd_speech & (localPlayer ? 1 : 4))) diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index f85cdd639..f6ae99e6e 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -52,6 +52,30 @@ static inline int movefifoend(int myconnectindex) } */ +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int menuloop(void) +{ + FX_StopAllSounds(); + while (menuactive != MENU_Off) + { + handleevents(); + drawbackground(); + videoNextPage(); + } + return 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + static void fakedomovethings() { // prediction diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index ceacbf6a9..c3cd03ece 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -274,8 +274,7 @@ extern char CheatKeys[2]; extern char g_gametypeNames[MAXGAMETYPES][33]; extern int32_t respawnactortime; -extern int32_t g_bouncemineRadius; -#define bouncemineblastradius g_bouncemineRadius +extern int32_t bouncemineblastradius; extern int32_t g_deleteQueueSize; extern int32_t g_gametypeCnt; extern int32_t respawnitemtime; @@ -343,7 +342,8 @@ struct psaccess }; extern psaccess ps; -#define spriteqamount g_deleteQueueSize + +extern int spriteqamount; #define spriteq SpriteDeletionQueue #define spriteqloc g_spriteDeleteQueuePos diff --git a/source/games/duke/src/zz_demo.cpp b/source/games/duke/src/zz_demo.cpp deleted file mode 100644 index 1a376b665..000000000 --- a/source/games/duke/src/zz_demo.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#include "ns.h" // Must come before everything else! - -#include "duke3d.h" - -#include "savegame.h" -#include "screens.h" - -BEGIN_DUKE_NS - -//////////////////// - -int32_t G_PlaybackDemo(void) -{ - int32_t foundemo = 0, outofsync=0; - static int32_t in_menu = 0; - - totalclock = 0; - ototalclock = 0; - lockclock = 0; - - if (ready2send) - return 0; - -RECHECK: - in_menu = g_player[myconnectindex].ps->gm&MODE_MENU; - - if (foundemo == 0) - { - ud.recstat = 0; - - //fadepal(0,0,0, 0,252,28); - drawbackground(); - //M_DisplayMenus(); - videoNextPage(); - //fadepal(0,0,0, 252,0,-28); - ud.reccnt = 0; - } - - if (foundemo == 0 || in_menu || inputState.CheckAllInput() || numplayers > 1) - { - FX_StopAllSounds(); - M_StartControlPanel(false); - } - - ready2send = 0; - - inputState.ClearAllInput(); - - while (true) - { - // Main loop here. It also runs when there's no demo to show, - // so maybe a better name for this function would be - // G_MainLoopWhenNotInGame()? - - if (G_FPSLimit()) - { - if (foundemo == 0) - { - drawbackground(); - } - - if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL)) - { - videoNextPage(); - goto RECHECK; - } - - else if (g_player[myconnectindex].ps->gm&MODE_TYPE) - { - if ((g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE) - { - g_player[myconnectindex].ps->gm = 0; - M_StartControlPanel(false); - } - } - else - { - //if (ud.recstat != 2) - //M_DisplayMenus(); - - if (ud.multimode > 1)// && !Menu_IsTextInput(m_currentMenu)) - { - ControlInfo noshareinfo; - CONTROL_GetInput(&noshareinfo); - } - } - - if (ud.last_camsprite != ud.camerasprite) - ud.last_camsprite = ud.camerasprite; - - if (VOLUMEONE) - { - if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0) - rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, TILE_BETAVERSION, 0, 0, 2+8+16+128); - } - - videoNextPage(); - } - - G_HandleAsync(); - - if (g_player[myconnectindex].ps->gm == MODE_GAME) - { - // user wants to play a game, quit showing demo! - return 0; - } - } - - ud.multimode = numplayers; // fixes 2 infinite loops after watching demo - - // if we're in the menu, try next demo immediately - if (g_player[myconnectindex].ps->gm&MODE_MENU) - goto RECHECK; - - - // finished playing a demo and not in menu: - // return so that e.g. the title can be shown - return 1; -} - -END_DUKE_NS diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index f0e298da2..9aabb2052 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -57,8 +57,10 @@ void InitCheats(); void checkcommandline(); int registerosdcommands(void); int32_t G_MoveLoop(void); +int menuloop(void); int16_t max_ammo_amount[MAX_WEAPONS]; +int32_t spriteqamount = 64; uint8_t shadedsector[MAXSECTORS]; @@ -735,8 +737,6 @@ int GameInterface::app_main() return 0; } -int32_t G_PlaybackDemo(void); - void app_loop() { auto &myplayer = g_player[myconnectindex].ps; @@ -782,7 +782,7 @@ MAIN_LOOP_RESTART: M_StartControlPanel(false); M_SetMenu(NAME_Mainmenu); - if (G_PlaybackDemo()) + if (menuloop()) { FX_StopAllSounds(); g_noLogoAnim = 1; diff --git a/source/games/duke/src/zz_global.cpp b/source/games/duke/src/zz_global.cpp index da7549519..8e27f7bec 100644 --- a/source/games/duke/src/zz_global.cpp +++ b/source/games/duke/src/zz_global.cpp @@ -38,8 +38,7 @@ char g_gametypeNames[MAXGAMETYPES][33] float g_gameUpdateAvgTime = -1.f; int32_t respawnactortime = 768; -int32_t g_bouncemineRadius = 2500; -int32_t g_deleteQueueSize = 64; +int32_t bouncemineblastradius = 2500; int32_t respawnitemtime = 768; int32_t g_morterRadius = 2500; diff --git a/source/games/duke/src/zz_savegame.cpp b/source/games/duke/src/zz_savegame.cpp index b4cfccae9..d11b39d2a 100644 --- a/source/games/duke/src/zz_savegame.cpp +++ b/source/games/duke/src/zz_savegame.cpp @@ -847,8 +847,8 @@ static const dataspec_t svgm_anmisc[] = { 0, &camsprite, sizeof(camsprite), 1 }, { 0, &g_origins[0], sizeof(g_origins[0]), ARRAY_SIZE(g_origins) }, { 0, &g_spriteDeleteQueuePos, sizeof(g_spriteDeleteQueuePos), 1 }, - { DS_NOCHK, &g_deleteQueueSize, sizeof(g_deleteQueueSize), 1 }, - { DS_CNT(g_deleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_deleteQueueSize }, + { DS_NOCHK, &spriteqamount, sizeof(spriteqamount), 1 }, + { DS_CNT(spriteqamount), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&spriteqamount }, { DS_NOCHK, &numclouds, sizeof(numclouds), 1 }, { 0, &clouds[0], sizeof(clouds), 1 }, { 0, &cloudx, sizeof(cloudx), 1 },