Files
2026-05-09 22:10:40 -07:00

142 lines
4.5 KiB
C++

/*
===========================================================================
IceTech GPL Source Code
Copyright (C) 2026 Justin Marshall
This file is part of the IceTech GPL Source Code (?IceTech Source Code?).
IceTech Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
IceTech Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with IceTech Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the IceTech Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the IceTech Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing Justin Marshall, justinmarshall20@gmail.com
===========================================================================
*/
#ifndef __DEMOFILE_H__
#define __DEMOFILE_H__
/*
===============================================================================
Demo file
===============================================================================
*/
typedef enum {
DS_FINISHED,
DS_RENDER,
DS_SOUND,
DS_VERSION
} demoSystem_t;
class idDemoFile : public idFile {
public:
idDemoFile();
~idDemoFile();
const char* GetName(void) { return (f ? f->GetName() : ""); }
const char* GetFullPath(void) { return (f ? f->GetFullPath() : ""); }
void SetLog(bool b, const char* p);
void Log(const char* p);
bool OpenForReading(const char* fileName);
bool OpenForWriting(const char* fileName);
void Close();
const char* ReadHashString();
void WriteHashString(const char* str);
void ReadDict(idDict& dict);
void WriteDict(const idDict& dict);
int Read(void* buffer, int len);
int Write(const void* buffer, int len);
#ifdef QUAKE4
// Quake 4 idFile interface completeness.
// These fix C2259 abstract-class errors when idDemoFile derives from the newer idFile.
int Length(void);
unsigned int Timestamp(void);
int Tell(void);
void ForceFlush(void);
void Flush(void);
int Seek(long offset, fsOrigin_t origin);
void Rewind(void);
int Printf(const char* fmt, ...);
int VPrintf(const char* fmt, va_list arg);
int WriteFloatString(const char* fmt, ...);
int ReadInt(int& value);
int ReadUnsignedInt(unsigned int& value);
int ReadShort(short& value);
int ReadUnsignedShort(unsigned short& value);
int ReadChar(char& value);
int ReadUnsignedChar(unsigned char& value);
int ReadFloat(float& value);
int ReadBool(bool& value);
int ReadString(idStr& string);
int ReadVec2(idVec2& vec);
int ReadVec3(idVec3& vec);
int ReadVec4(idVec4& vec);
int ReadVec5(idVec5& vec);
int ReadVec6(idVec6& vec);
int ReadMat3(idMat3& mat);
int ReadBounds(idBounds& bounds);
int WriteInt(const int value);
int WriteUnsignedInt(const unsigned int value);
int WriteShort(const short value);
int WriteUnsignedShort(unsigned short value);
int WriteChar(const char value);
int WriteUnsignedChar(const unsigned char value);
int WriteFloat(const float value);
int WriteBool(const bool value);
int WriteString(const char* string);
int WriteVec2(const idVec2& vec);
int WriteVec3(const idVec3& vec);
int WriteVec4(const idVec4& vec);
int WriteVec5(const idVec5& vec);
int WriteVec6(const idVec6& vec);
int WriteMat3(const idMat3& mat);
int WriteBounds(const idBounds& bounds);
void WriteNumericStructArray(int numStructs, int structSize[], int numValues, byte* data, const char* format);
void WriteSyncId(void);
void ReadSyncId(const char* syncId, const char* debugLabel);
#endif
private:
static idCompressor* AllocCompressor(int type);
bool writing;
byte* fileImage;
idFile* f;
idCompressor* compressor;
idList<idStr*> demoStrings;
idFile* fLog;
bool log;
idStr logStr;
static idCVar com_logDemos;
static idCVar com_compressDemos;
static idCVar com_preloadDemos;
};
#endif /* !__DEMOFILE_H__ */