- 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);
bool movementBlocked(int snum);
void GetInput();
void startmainmenu();
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 "gamestate.h"
#include "duke3d.h"
#include "sbar.h"
#include "baselayer.h"
@ -376,63 +377,73 @@ bool GameTicker()
//
//---------------------------------------------------------------------------
void startmainmenu()
{
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
FX_StopAllSounds();
gamestate = GS_DEMOSCREEN;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void app_loop()
{
gamestate = GS_STARTUP;
while (true)
{
totalclock = 0;
ototalclock = 0;
lockclock = 0;
ps[myconnectindex].ftq = 0;
//if (ud.warp_on == 0)
handleevents();
switch (gamestate)
{
#if 0 // fixme once the game loop has been done.
if ((ud.multimode > 1) && startupMap.IsNotEmpty())
default:
case GS_STARTUP:
totalclock = 0;
ototalclock = 0;
lockclock = 0;
ps[myconnectindex].ftq = 0;
if (userConfig.CommandMap.IsNotEmpty())
{
auto maprecord = FindMap(startupMap);
ud.m_respawn_monsters = ud.m_player_skill == 4;
for (int i = 0; i != -1; i = connectpoint2[i])
auto maprecord = FindMapByName(userConfig.CommandMap);
userConfig.CommandMap = "";
if (maprecord)
{
resetweapons(i);
resetinventory(i);
}
ud.m_respawn_monsters = ud.m_player_skill == 4;
StartGame(maprecord);
for (int i = 0; i != -1; i = connectpoint2[i])
{
resetweapons(i);
resetinventory(i);
}
startnewgame(maprecord, /*userConfig.skill*/2);
}
}
else
#endif
{
fi.ShowLogo([](bool) {});
fi.ShowLogo([](bool) { startmainmenu(); });
}
break;
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
FX_StopAllSounds();
case GS_DEMOSCREEN:
drawbackground();
break;
case GS_LEVEL:
if (GameTicker()) gamestate = GS_STARTUP;
break;
case GS_INTERMISSION:
// todo: run screen jobs here
break;
while (menuactive != MENU_Off)
{
handleevents();
drawbackground();
videoNextPage();
}
}
ud.showweapons = cl_showweapon;
setlocalplayerinput(&ps[myconnectindex]);
PlayerColorChanged();
inputState.ClearAllInput();
bool res;
do
{
handleevents();
res = GameTicker();
videoNextPage();
} while (!res);
videoNextPage();
}
}

View file

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