mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Fix reading demo file
# Conflicts: # source/exhumed/src/exhumed.cpp
This commit is contained in:
parent
7a7a0e16e8
commit
75789eee50
4 changed files with 108 additions and 40 deletions
|
@ -1441,6 +1441,10 @@ void FinishLevel()
|
|||
}
|
||||
}
|
||||
|
||||
EDUKE32_STATIC_ASSERT(sizeof(demo_header) == 75);
|
||||
EDUKE32_STATIC_ASSERT(sizeof(demo_input) == 36);
|
||||
|
||||
|
||||
void WritePlaybackInputs()
|
||||
{
|
||||
fwrite(&moveframes, sizeof(moveframes), 1, vcrfp);
|
||||
|
@ -1449,43 +1453,20 @@ void WritePlaybackInputs()
|
|||
|
||||
uint8_t ReadPlaybackInputs()
|
||||
{
|
||||
assert(sizeof(PlayerInput) == 32);
|
||||
|
||||
if (fread(&moveframes, 1, sizeof(moveframes), vcrfp))
|
||||
demo_input input;
|
||||
if (fread(&input, 1, sizeof(input), vcrfp))
|
||||
{
|
||||
#if 0
|
||||
fread(&sPlayerInput[nLocalPlayer], 1, sizeof(PlayerInput), vcrfp);
|
||||
#else
|
||||
/*
|
||||
struct PlayerInput
|
||||
{
|
||||
int xVel;
|
||||
int yVel;
|
||||
short nAngle;
|
||||
short buttons;
|
||||
short nTarget;
|
||||
char horizon;
|
||||
int8_t nItem;
|
||||
int h;
|
||||
char i;
|
||||
char field_15[11];
|
||||
};
|
||||
*/
|
||||
fread(&sPlayerInput[nLocalPlayer].xVel, 1, sizeof(sPlayerInput[nLocalPlayer].xVel), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].yVel, 1, sizeof(sPlayerInput[nLocalPlayer].yVel), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].nAngle, 1, sizeof(sPlayerInput[nLocalPlayer].nAngle), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].buttons, 1, sizeof(sPlayerInput[nLocalPlayer].buttons), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].nTarget, 1, sizeof(sPlayerInput[nLocalPlayer].nTarget), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].horizon, 1, sizeof(sPlayerInput[nLocalPlayer].horizon), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].nItem, 1, sizeof(sPlayerInput[nLocalPlayer].nItem), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].h, 1, sizeof(sPlayerInput[nLocalPlayer].h), vcrfp);
|
||||
fread(&sPlayerInput[nLocalPlayer].i, 1, sizeof(sPlayerInput[nLocalPlayer].i), vcrfp);
|
||||
moveframes = input.moveframes;
|
||||
sPlayerInput[nLocalPlayer].xVel = input.xVel;
|
||||
sPlayerInput[nLocalPlayer].yVel = input.yVel;
|
||||
sPlayerInput[nLocalPlayer].nAngle = fix16_from_int(input.nAngle<<2);
|
||||
sPlayerInput[nLocalPlayer].buttons = input.buttons;
|
||||
sPlayerInput[nLocalPlayer].nTarget = input.nTarget;
|
||||
sPlayerInput[nLocalPlayer].horizon = fix16_from_int(input.horizon);
|
||||
sPlayerInput[nLocalPlayer].nItem = input.nItem;
|
||||
sPlayerInput[nLocalPlayer].h = input.h;
|
||||
sPlayerInput[nLocalPlayer].i = input.i;
|
||||
|
||||
// skip pad
|
||||
fseek(vcrfp, 11, SEEK_CUR);
|
||||
|
||||
|
||||
#endif
|
||||
besttarget = sPlayerInput[nLocalPlayer].nTarget;
|
||||
Ra[nLocalPlayer].nTarget = besttarget;
|
||||
return kTrue;
|
||||
|
@ -2149,7 +2130,7 @@ STARTGAME2:
|
|||
|
||||
if (bPlayback)
|
||||
{
|
||||
menu_GameLoad2(vcrfp);
|
||||
menu_GameLoad2(vcrfp, true);
|
||||
levelnew = GameStats.nMap;
|
||||
levelnum = GameStats.nMap;
|
||||
forcelevel = GameStats.nMap;
|
||||
|
@ -2327,7 +2308,7 @@ LOOP3:
|
|||
if (bPlayback)
|
||||
{
|
||||
// YELLOW
|
||||
if ((bInDemo && inputState.keyBufferWaiting() || !ReadPlaybackInputs()) && inputState.keyGetChar())
|
||||
if (((bInDemo && inputState.keyBufferWaiting()) || !ReadPlaybackInputs()) && inputState.keyGetChar())
|
||||
{
|
||||
inputState.keyFlushChars();
|
||||
inputState.ClearAllKeyStatus();
|
||||
|
|
|
@ -43,6 +43,58 @@ 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 ShutDown(void);
|
||||
void DebugOut(const char *fmt, ...);
|
||||
int ExhumedMain(int argc, char *argv[]);
|
||||
|
|
|
@ -1374,9 +1374,44 @@ void menu_ResetKeyTimer()
|
|||
keytimer = (int)totalclock + 2400;
|
||||
}
|
||||
|
||||
void menu_GameLoad2(FILE *fp)
|
||||
void menu_GameLoad2(FILE *fp, bool bIsDemo)
|
||||
{
|
||||
fread(&GameStats, sizeof(GameStats), 1, fp);
|
||||
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;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void menu_DoPlasma();
|
|||
int menu_Menu(int val);
|
||||
void menu_AdjustVolume();
|
||||
short menu_GameLoad(int nSlot);
|
||||
void menu_GameLoad2(FILE *fp);
|
||||
void menu_GameLoad2(FILE *fp, bool bIsDemo = false);
|
||||
void menu_GameSave2(FILE *fp);
|
||||
void menu_GameSave(int nSaveSlot);
|
||||
|
||||
|
|
Loading…
Reference in a new issue