- merged the two main loops into one.

Yet to do: Run the screen jobs from the main loop as well.
This commit is contained in:
Christoph Oelckers 2020-07-18 23:50:46 +02:00
parent e97e663b49
commit a3e9ea97a8
3 changed files with 65 additions and 43 deletions

View file

@ -235,5 +235,6 @@ void calcviewpitch(player_struct* p, double factor);
void sethorizon(int snum, int sb_snum, double factor, bool frominput = false); void sethorizon(int snum, int sb_snum, double factor, bool frominput = false);
bool movementBlocked(int snum); bool movementBlocked(int snum);
void GetInput(); void GetInput();
void startmainmenu();
END_DUKE_NS END_DUKE_NS

View file

@ -28,6 +28,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "ns.h" // Must come before everything else! #include "ns.h" // Must come before everything else!
#include "gamestate.h"
#include "duke3d.h" #include "duke3d.h"
#include "sbar.h" #include "sbar.h"
#include "baselayer.h" #include "baselayer.h"
@ -376,23 +377,43 @@ bool GameTicker()
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void startmainmenu()
{
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
FX_StopAllSounds();
gamestate = GS_DEMOSCREEN;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void app_loop() void app_loop()
{ {
gamestate = GS_STARTUP;
while (true) while (true)
{ {
handleevents();
switch (gamestate)
{
default:
case GS_STARTUP:
totalclock = 0; totalclock = 0;
ototalclock = 0; ototalclock = 0;
lockclock = 0; lockclock = 0;
ps[myconnectindex].ftq = 0; ps[myconnectindex].ftq = 0;
//if (ud.warp_on == 0) if (userConfig.CommandMap.IsNotEmpty())
{ {
#if 0 // fixme once the game loop has been done. auto maprecord = FindMapByName(userConfig.CommandMap);
if ((ud.multimode > 1) && startupMap.IsNotEmpty()) userConfig.CommandMap = "";
if (maprecord)
{ {
auto maprecord = FindMap(startupMap);
ud.m_respawn_monsters = ud.m_player_skill == 4; ud.m_respawn_monsters = ud.m_player_skill == 4;
for (int i = 0; i != -1; i = connectpoint2[i]) for (int i = 0; i != -1; i = connectpoint2[i])
@ -400,39 +421,29 @@ void app_loop()
resetweapons(i); resetweapons(i);
resetinventory(i); resetinventory(i);
} }
startnewgame(maprecord, /*userConfig.skill*/2);
StartGame(maprecord); }
} }
else else
#endif
{ {
fi.ShowLogo([](bool) {}); fi.ShowLogo([](bool) { startmainmenu(); });
} }
break;
M_StartControlPanel(false); case GS_DEMOSCREEN:
M_SetMenu(NAME_Mainmenu);
FX_StopAllSounds();
while (menuactive != MENU_Off)
{
handleevents();
drawbackground(); drawbackground();
videoNextPage(); break;
}
}
ud.showweapons = cl_showweapon; case GS_LEVEL:
setlocalplayerinput(&ps[myconnectindex]); if (GameTicker()) gamestate = GS_STARTUP;
PlayerColorChanged(); break;
inputState.ClearAllInput();
bool res; case GS_INTERMISSION:
do // todo: run screen jobs here
{ break;
handleevents();
res = GameTicker(); }
videoNextPage(); videoNextPage();
} while (!res);
} }
} }

View file

@ -32,6 +32,8 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "mapinfo.h" #include "mapinfo.h"
#include "secrets.h" #include "secrets.h"
#include "statistics.h" #include "statistics.h"
#include "gamestate.h"
#include "sbar.h"
BEGIN_DUKE_NS BEGIN_DUKE_NS
@ -755,6 +757,7 @@ void resettimevars(void)
{ {
totalclock = 0; totalclock = 0;
cloudtotalclock = 0; cloudtotalclock = 0;
levelTextTime = 85;
ototalclock = 0; ototalclock = 0;
lockclock = 0; lockclock = 0;
ready2send = 1; ready2send = 1;
@ -1031,8 +1034,15 @@ void startnewgame(MapRecord* map, int skill)
if (enterlevel(map, MODE_GAME)) if (enterlevel(map, MODE_GAME))
{ {
ps[myconnectindex].gm = 0; ps[myconnectindex].gm = 0;
M_StartControlPanel(false); startmainmenu();
M_SetMenu(NAME_Mainmenu); }
else
{
ud.showweapons = cl_showweapon;
setlocalplayerinput(&ps[myconnectindex]);
PlayerColorChanged();
inputState.ClearAllInput();
gamestate = GS_LEVEL;
} }
} }