- defer FinishLevel handling to the main loop instead of doing it deep inside the game logic code.

This commit is contained in:
Christoph Oelckers 2020-08-22 10:03:21 +02:00
parent 9f682083c8
commit c74a1f03e3
5 changed files with 18 additions and 92 deletions

View file

@ -60,6 +60,7 @@ int32_t registerosdcommands(void);
void InitFonts();
int htimer = 0;
bool EndLevel = false;
/* these are XORed in the original game executable then XORed back to normal when the game first starts. Here they are normally */
const char *gString[] =
@ -925,7 +926,7 @@ void CheckKeys()
}
else if (!strcmp(pToken, "EXIT"))
{
FinishLevel();
EndLevel = true;
}
else if (!strcmp(pToken, "CREATURE"))
{
@ -1920,6 +1921,12 @@ GAMELOOP:
{
tclocks += 4;
GameMove();
if (EndLevel)
{
EndLevel = false;
FinishLevel();
break;
}
}
}
}
@ -2730,4 +2737,9 @@ void LoadTextureState()
}
CCMD(ex_endlevel)
{
EndLevel = true;
}
END_PS_NS

View file

@ -107,58 +107,6 @@ enum basepal_t {
BASEPALCOUNT
};
#pragma pack(push, 1)
struct demo_header
{
uint8_t nMap;
int16_t nWeapons;
int16_t nCurrentWeapon;
int16_t clip;
int16_t items;
int16_t nHealth;
int16_t field_2;
int16_t nAction;
int16_t nSprite;
int16_t bIsMummified;
int16_t someNetVal;
int16_t invincibility;
int16_t nAir;
int16_t nSeq;
int16_t nMaskAmount;
uint16_t keys;
int16_t nMagic;
uint8_t item[8];
int16_t nAmmo[7]; // TODO - kMaxWeapons?
int16_t pad[2];
int16_t nCurrentWeapon2;
int16_t field_3FOUR;
int16_t bIsFiring;
int16_t field_38;
int16_t field_3A;
int16_t field_3C;
int16_t nRun;
int16_t nLives;
};
struct demo_input
{
int32_t moveframes;
int32_t xVel;
int32_t yVel;
int16_t nAngle;
uint16_t buttons;
int16_t nTarget;
uint8_t horizon;
int8_t nItem;
int32_t h;
uint8_t i;
uint8_t pad[11];
};
#pragma pack(pop)
void ExitGame();
void ShutDown(void);
void DebugOut(const char *fmt, ...);
@ -215,6 +163,7 @@ void UpdateScreenSize();
void HandleAsync();
extern bool EndLevel;
extern int32_t g_commandSetup;
extern int32_t g_noSetup;

View file

@ -289,41 +289,6 @@ int menu_LoadGameMenu()
void menu_GameLoad2(FILE *fp, bool bIsDemo)
{
if (bIsDemo)
{
demo_header header;
fread(&header, 1, sizeof(demo_header), fp);
GameStats.nMap = header.nMap;
GameStats.nWeapons = header.nWeapons;
GameStats.nCurrentWeapon = header.nCurrentWeapon;
GameStats.clip = header.clip;
GameStats.items = header.items;
GameStats.player.nHealth = header.nHealth;
GameStats.player.field_2 = header.field_2;
GameStats.player.nAction = header.nAction;
GameStats.player.nSprite = header.nSprite;
GameStats.player.bIsMummified = header.bIsMummified;
GameStats.player.someNetVal = header.someNetVal;
GameStats.player.invincibility = header.invincibility;
GameStats.player.nAir = header.nAir;
GameStats.player.nSeq = header.nSeq;
GameStats.player.nMaskAmount = header.nMaskAmount;
GameStats.player.keys = header.keys;
GameStats.player.nMagic = header.nMagic;
Bmemcpy(GameStats.player.items, header.item, sizeof(header.item));
Bmemcpy(GameStats.player.nAmmo, header.nAmmo, sizeof(header.nAmmo));
Bmemcpy(GameStats.player.pad, header.pad, sizeof(header.pad));
GameStats.player.nCurrentWeapon = header.nCurrentWeapon2;
GameStats.player.field_3FOUR = header.field_3FOUR;
GameStats.player.bIsFiring = header.bIsFiring;
GameStats.player.field_38 = header.field_38;
GameStats.player.field_3A = header.field_3A;
GameStats.player.field_3C = header.field_3C;
GameStats.player.nRun = header.nRun;
GameStats.nLives = header.nLives;
}
else
fread(&GameStats, sizeof(GameStats), 1, fp);
nPlayerWeapons[nLocalPlayer] = GameStats.nWeapons;

View file

@ -1543,7 +1543,7 @@ void DoFinale()
}
else if (nFinaleStage == 3 && (int)totalclock >= dword_1542FC)
{
FinishLevel();
EndLevel = true;
}
}
else

View file

@ -1274,7 +1274,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
}
else
{
FinishLevel();
EndLevel = true;
}
return;
@ -2708,7 +2708,7 @@ do_default_b:
{
if (!bInDemo)
{
FinishLevel();
EndLevel = true;
}
else {
//inputState.keySetState(32, 1); // Huh, what?