1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5 
6 This file is part of NBlood.
7 
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #pragma once
24 
25 #include "controls.h"
26 #include "levels.h"
27 
28 #define kInputBufferSize 1024
29 
30 #pragma pack(push, 1)
31 
32 struct GAMEOPTIONSLEGACY {
33     char nGameType;
34     char nDifficulty;
35     int nEpisode;
36     int nLevel;
37     char zLevelName[144];
38     char zLevelSong[144];
39     int nTrackNumber; //at12a;
40     char szSaveGameName[16];
41     char szUserGameName[16];
42     short nSaveGameSlot;
43     int picEntry;
44     unsigned int uMapCRC;
45     char nMonsterSettings;
46     int uGameFlags;
47     int uNetGameFlags;
48     char nWeaponSettings;
49     char nItemSettings;
50     char nRespawnSettings;
51     char nTeamSettings;
52     int nMonsterRespawnTime;
53     int nWeaponRespawnTime;
54     int nItemRespawnTime;
55     int nSpecialRespawnTime;
56 };
57 
58 struct DEMOHEADER
59 {
60     int signature;
61     short nVersion;
62     int nBuild;
63     int nInputCount;
64     int nNetPlayers;
65     short nMyConnectIndex;
66     short nConnectHead;
67     short connectPoints[8];
68 };
69 
70 #pragma pack(pop)
71 
72 struct DEMOCHAIN
73 {
74     DEMOCHAIN *pNext;
75     char zName[BMAX_PATH];
76 };
77 
78 class CDemo {
79 public:
80     CDemo();
81     ~CDemo();
82     bool Create(const char *);
83     void Write(GINPUT *);
84     void Close(void);
85     bool SetupPlayback(const char *);
86     void ProcessKeys(void);
87     void Playback(void);
88     void StopPlayback(void);
89     void LoadDemoInfo(void);
90     void NextDemo(void);
91     void FlushInput(int nCount);
92     void ReadInput(int nCount);
93     bool at0; // record
94     bool at1; // playback
95     bool m_bLegacy;
96     char at2;
97     int at3;
98     int hPFile;
99     FILE *hRFile;
100     int atb;
101     DEMOHEADER atf;
102     GAMEOPTIONS m_gameOptions;
103     GINPUT at1aa[kInputBufferSize];
104     const char **pzDemoFile;
105     DEMOCHAIN *pFirstDemo;
106     DEMOCHAIN *pCurrentDemo;
107     int at59ef;
108 };
109 
110 extern CDemo gDemo;
111