MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DemoReadHeader

Function DemoReadHeader

Descent3/demofile.cpp:738–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736
737extern bool IsRestoredGame;
738int DemoReadHeader() {
739 char szsig[10];
740 int16_t ver;
741 char demo_mission[_MAX_PATH];
742 int level_num;
743 int frame_count;
744 float demo_gametime;
745 mprintf(0, "Reading demo header...\n");
746 ASSERT(Demo_flags == DF_PLAYBACK);
747 cf_ReadString((char *)szsig, 10, Demo_cfp);
748 ver = cf_ReadShort(Demo_cfp);
749
750 if (strcmp(szsig, D3_DEMO_SIG) != 0) {
751 if (strcmp(szsig, D3_DEMO_SIG_NEW) != 0) {
752 mprintf(0, "Bad demo header signature!\n");
753 return 0;
754 }
755 }
756
757 if (ver > GAMESAVE_VERSION) {
758 // This file version is too new!
759 // return 0;
760 }
761
762 cf_ReadString(demo_mission, _MAX_PATH, Demo_cfp);
763 level_num = cf_ReadInt(Demo_cfp);
764 demo_gametime = cf_ReadFloat(Demo_cfp);
765 frame_count = cf_ReadInt(Demo_cfp);
766
767 // Now load the mission
768 Osiris_DisableCreateEvents();
769 IsRestoredGame = true;
770 if (LoadMission((const char *)demo_mission)) {
771 mng_LoadAddonPages();
772
773 SetCurrentLevel(level_num);
774 if (!LoadAndStartCurrentLevel()) {
775 mprintf(0, "Couldn't start new level to play back the demo!\n");
776 Osiris_EnableCreateEvents();
777 return 0;
778 }
779 } else {
780 mprintf(0, "Couldn't load the level to play back the demo!\n");
781 Osiris_EnableCreateEvents();
782 return 0;
783 }
784 Osiris_EnableCreateEvents();
785
786 FrameCount = frame_count;
787 Demo_next_frame = demo_gametime;
788
789 if (gs_Xlates)
790 mem_free(gs_Xlates);
791 gs_Xlates = (struct gs_tables *)mem_malloc(sizeof(gs_tables));
792
793 try {
794 LGSXlateTables(Demo_cfp);
795

Callers 1

DemoPlaybackFileFunction · 0.85

Calls 15

cf_ReadStringFunction · 0.85
cf_ReadShortFunction · 0.85
cf_ReadIntFunction · 0.85
cf_ReadFloatFunction · 0.85
LoadMissionFunction · 0.85
mng_LoadAddonPagesFunction · 0.85
SetCurrentLevelFunction · 0.85
LoadAndStartCurrentLevelFunction · 0.85
LGSXlateTablesFunction · 0.85
LGSRoomsFunction · 0.85

Tested by

no test coverage detected