- more cleanup of game.cpp.

The game init code is done.
This commit is contained in:
Christoph Oelckers 2020-08-16 19:11:04 +02:00
parent baf1166319
commit 01d9bde7f4
3 changed files with 129 additions and 133 deletions

View file

@ -1974,10 +1974,6 @@ drawscreen(PLAYERp pp)
// Boss Health Meter, if Boss present // Boss Health Meter, if Boss present
BossHealthMeter(); BossHealthMeter();
//if (!M_Active())
videoNextPage();
#if SYNC_TEST #if SYNC_TEST
SyncStatMessage(); SyncStatMessage();
#endif #endif

View file

@ -155,7 +155,6 @@ SWBOOL CameraTestMode = FALSE;
char ds[645]; // debug string char ds[645]; // debug string
extern short NormalVisibility; extern short NormalVisibility;
SWBOOL QuitFlag = FALSE;
SWBOOL CommandSetup = FALSE; SWBOOL CommandSetup = FALSE;
char buffer[80], ch; char buffer[80], ch;
@ -173,36 +172,74 @@ void InitRunLevel(void);
void RunLevel(void); void RunLevel(void);
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
// Transitioning helper.
void Logo(const CompletionFunc& completion);
int SyncScreenJob()
{
while (gamestate == GS_INTERMISSION || gamestate == GS_INTRO)
{
DoUpdateSounds();
handleevents();
updatePauseStatus();
D_ProcessEvents();
ControlInfo info;
CONTROL_GetInput(&info);
C_RunDelayedCommands();
RunScreenJobFrame(); // This handles continuation through its completion callback.
videoNextPage();
}
return 0;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Toggle_Crouch", // This is the last one used by EDuke32"",
};
bool InitGame() bool InitGame()
{ {
InitCheats();
buttonMap.SetButtons(actions, NUM_ACTIONS);
automapping = 1;
gs = gs_defaults;
for (int i = 0; i < MAX_SW_PLAYERS; i++)
INITLIST(&Player[i].PanelSpriteList);
DebugOperate = TRUE;
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;
if (SW_SHAREWARE)
Printf("SHADOW WARRIOR(tm) Version 1.2 (Shareware Version)\n");
else
Printf("SHADOW WARRIOR(tm) Version 1.2\n");
if (sw_snd_scratch == 0) // This is always 0 at this point - this check is only here to prevent whole program optimization from eliminating the variable.
Printf("Copyright (c) 1997 3D Realms Entertainment\n");
registerosdcommands();
registerinputcommands();
engineInit(); engineInit();
auto pal = fileSystem.LoadFile("3drealms.pal", 0); auto pal = fileSystem.LoadFile("3drealms.pal", 0);
if (pal.Size() >= 768) if (pal.Size() >= 768)
@ -509,6 +546,7 @@ void InitLevel(void)
auto maprec = NextLevel; auto maprec = NextLevel;
NextLevel = nullptr; NextLevel = nullptr;
if (!maprec) maprec = currentLevel;
if (!maprec) if (!maprec)
{ {
NewGame = false; NewGame = false;
@ -684,12 +722,9 @@ void NewLevel(void)
while (LoadGameOutsideMoveLoop); while (LoadGameOutsideMoveLoop);
STAT_Update(false); STAT_Update(false);
if (!QuitFlag) // for good measure do this
{ ready2send = 0;
// for good measure do this waitforeverybody();
ready2send = 0;
waitforeverybody();
}
StatScreen(&Player[myconnectindex]); StatScreen(&Player[myconnectindex]);
@ -797,12 +832,6 @@ void MenuLevel(void)
break; break;
} }
if (QuitFlag)
{
// Quiting Game
break;
}
// must lock the clock for drawing so animations will happen // must lock the clock for drawing so animations will happen
totalclocklock = totalclock; totalclocklock = totalclock;
@ -833,13 +862,11 @@ void EndGameSequence(void)
//BonusScreen(); //BonusScreen();
ExitLevel = FALSE; ExitLevel = FALSE;
QuitFlag = FALSE;
//if (FinishAnim == ANIM_ZILLA) //if (FinishAnim == ANIM_ZILLA)
// CreditsLevel(); // CreditsLevel();
ExitLevel = FALSE; ExitLevel = FALSE;
QuitFlag = FALSE;
if (currentLevel->levelNumber != 4 && currentLevel->levelNumber != 20) if (currentLevel->levelNumber != 4 && currentLevel->levelNumber != 20)
{ {
@ -879,6 +906,30 @@ void StatScreen(PLAYERp mpp)
//MPBonusScreen(); //MPBonusScreen();
} }
// Transitioning helper.
void Logo(const CompletionFunc& completion);
int SyncScreenJob()
{
while (gamestate == GS_INTERMISSION || gamestate == GS_INTRO)
{
DoUpdateSounds();
handleevents();
updatePauseStatus();
D_ProcessEvents();
ControlInfo info;
CONTROL_GetInput(&info);
C_RunDelayedCommands();
RunScreenJobFrame(); // This handles continuation through its completion callback.
videoNextPage();
}
return 0;
}
void GameIntro(void) void GameIntro(void)
{ {
Logo([](bool) { gamestate = GS_LEVEL; }); Logo([](bool) { gamestate = GS_LEVEL; });
@ -886,25 +937,6 @@ void GameIntro(void)
MenuLevel(); MenuLevel();
} }
void Control()
{
InitGame();
GameIntro();
while (!QuitFlag)
{
handleevents();
C_RunDelayedCommands();
NewLevel();
}
//SybexScreen();
throw CExitEvent(0);
}
void getinput(SW_PACKET *, SWBOOL); void getinput(SW_PACKET *, SWBOOL);
@ -922,12 +954,13 @@ void RunLevel(void)
handleevents(); handleevents();
C_RunDelayedCommands(); C_RunDelayedCommands();
D_ProcessEvents(); D_ProcessEvents();
updatePauseStatus();
if (LoadGameOutsideMoveLoop) if (LoadGameOutsideMoveLoop)
{ {
return; // Stop the game loop if a savegame was loaded from the menu. return; // Stop the game loop if a savegame was loaded from the menu.
} }
updatePauseStatus();
if (paused) if (paused)
{ {
@ -948,9 +981,7 @@ void RunLevel(void)
} }
drawscreen(Player + screenpeek); drawscreen(Player + screenpeek);
videoNextPage();
if (QuitFlag)
break;
if (ExitLevel) if (ExitLevel)
{ {
@ -962,81 +993,31 @@ void RunLevel(void)
ready2send = 0; ready2send = 0;
} }
static const char* actions[] = {
"Move_Forward",
"Move_Backward",
"Turn_Left",
"Turn_Right",
"Strafe",
"Fire",
"Open",
"Run",
"Alt_Fire", // Duke3D", Blood
"Jump",
"Crouch",
"Look_Up",
"Look_Down",
"Look_Left",
"Look_Right",
"Strafe_Left",
"Strafe_Right",
"Aim_Up",
"Aim_Down",
"SendMessage",
"Map",
"Shrink_Screen",
"Enlarge_Screen",
"Show_Opponents_Weapon",
"Map_Follow_Mode",
"See_Coop_View",
"Mouse_Aiming",
"Dpad_Select",
"Dpad_Aiming",
"Last_Weapon",
"Alt_Weapon",
"Third_Person_View",
"Toggle_Crouch", // This is the last one used by EDuke32"",
};
int32_t GameInterface::app_main() int32_t GameInterface::app_main()
{ {
int i; InitGame();
extern int MovesPerPacket;
void DoSector(void);
void gameinput(void);
int cnt = 0;
InitCheats(); GameIntro();
buttonMap.SetButtons(actions, NUM_ACTIONS);
automapping = 1;
gs = gs_defaults;
for (i = 0; i < MAX_SW_PLAYERS; i++) while (true)
INITLIST(&Player[i].PanelSpriteList); {
handleevents();
C_RunDelayedCommands();
DebugOperate = TRUE; NewLevel();
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112; }
if (SW_SHAREWARE) //SybexScreen();
Printf("SHADOW WARRIOR(tm) Version 1.2 (Shareware Version)\n"); throw CExitEvent(0);
else
Printf("SHADOW WARRIOR(tm) Version 1.2\n");
if (sw_snd_scratch == 0) // This is always 0 at this point - this check is only here to prevent whole program optimization from eliminating the variable.
Printf("Copyright (c) 1997 3D Realms Entertainment\n");
registerosdcommands();
registerinputcommands();
Control();
return 0; return 0;
} }
char WangBangMacro[10][64]; //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int RandomRange(int range) int RandomRange(int range)
{ {
@ -1060,6 +1041,12 @@ int RandomRange(int range)
return value; return value;
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int StdRandomRange(int range) int StdRandomRange(int range)
{ {
uint32_t rand_num; uint32_t rand_num;
@ -1086,6 +1073,12 @@ int StdRandomRange(int range)
return value; return value;
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
#include "saveable.h" #include "saveable.h"
saveable_module saveable_build{}; saveable_module saveable_build{};
@ -1103,18 +1096,22 @@ void Saveable_Init_Dynamic()
saveable_build.numdata = NUM_SAVEABLE_ITEMS(saveable_build_data); saveable_build.numdata = NUM_SAVEABLE_ITEMS(saveable_build_data);
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
{ {
return { 0, 48 }; return { 0, 48 };
} }
::GameInterface* CreateInterface() ::GameInterface* CreateInterface()
{ {
return new GameInterface; return new GameInterface;
} }
GameStats GameInterface::getStats() GameStats GameInterface::getStats()
{ {
PLAYERp pp = Player + myconnectindex; PLAYERp pp = Player + myconnectindex;

View file

@ -123,8 +123,11 @@ InitNetPlayerOptions(void)
// myconnectindex palette // myconnectindex palette
pp->TeamColor = gs.NetColor; pp->TeamColor = gs.NetColor;
pp->SpriteP->pal = PALETTE_PLAYER0 + pp->TeamColor; if (pp->SpriteP)
User[pp->SpriteP - sprite]->spal = pp->SpriteP->pal; {
pp->SpriteP->pal = PALETTE_PLAYER0 + pp->TeamColor;
User[pp->SpriteP - sprite]->spal = pp->SpriteP->pal;
}
} }
void void