From c595a2c2935b5bfcb2c08cc9ec4a22db55bd1ff7 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 22 May 2025 17:09:26 -0300 Subject: implement TReadStream, TReadBuffer, and TReadBinaryFile --- src/script.hh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/script.hh') diff --git a/src/script.hh b/src/script.hh index 0a83196..42ddd2e 100644 --- a/src/script.hh +++ b/src/script.hh @@ -101,4 +101,35 @@ struct TWriteScriptFile { int Line; }; +struct TReadBinaryFile: TReadStream { + // REGULAR FUNCTIONS + // ========================================================================= + TReadBinaryFile(void); + void open(char *FileName); + int close(void); + void error(char *Text); + int getPosition(void); + int getSize(void); + void seek(int Offset); + + // VIRTUAL FUNCTIONS + // ========================================================================= + // TODO(fusion): `TReadStream` itself doesn't have a destructor on its VTABLE + // which makes me think there is something else going on here or the compiler + // optimized it away because it was never used but it seems problematic. + virtual ~TReadBinaryFile(void) override; // VTABLE[8] + // Duplicate destructor that also calls operator delete. // VTABLE[9] + + uint8 readByte(void) override; + void readBytes(uint8 *Buffer, int Count) override; + bool eof(TReadBinaryFile *this) override; + void skip(int Count) override; + + // DATA + // ========================================================================= + FILE *File; + char Filename[4096]; + int FileSize; +}; + #endif //TIBIA_SCRIPT_HH_ -- cgit v1.2.3