blob: 42ddd2e37e868731bff25dbaf2b1253810c2fe3a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#ifndef TIBIA_SCRIPT_HH_
#define TIBIA_SCRIPT_HH_ 1
#include "common.hh"
#include "enums.hh"
struct TReadScriptFile {
// REGULAR FUNCTIONS
// =========================================================================
TReadScriptFile(void);
~TReadScriptFile(void);
void open(const char *FileName);
void close(void);
void error(const char *Text);
void nextToken(void);
char *getIdentifier(void);
int getNumber(void);
char *getString(void);
uint8 *getBytesequence(void);
void getCoordinate(int *x, int *y, int *z);
char getSpecial(void);
char *readIdentifier(void){
this->nextToken();
return this->getIdentifier();
}
int readNumber(void){
this->nextToken();
int Sign = 1;
if(this->Token == SPECIAL && this->Special == '-'){
Sign = -1;
this->nextToken();
}
return Sign * this->getNumber();
}
char *readString(void){
this->nextToken();
return this->getString();
}
uint8 *readBytesequence(void){
this->nextToken();
return this->getBytesequence();
}
void readCoordinate(int *x, int *y, int *z){
this->nextToken();
this->getCoordinate(x, y, z);
}
char readSpecial(void){
this->nextToken();
return this->getSpecial();
}
void TReadScriptFile::readSymbol(char Symbol){
if(this->readSpecial() != Symbol){
this->error("symbol mismatch");
}
}
// DATA
// =========================================================================
TOKEN Token;
FILE *File[3];
char Filename[3][4096];
int Line[3];
char String[4000];
int RecursionDepth;
uint8 *Bytes;
int Number;
int CoordX;
int CoordY;
int CoordZ;
char Special;
};
struct TWriteScriptFile {
// REGULAR FUNCTIONS
// =========================================================================
TWriteScriptFile(void);
~TWriteScriptFile(void);
void open(char *FileName);
void close(void);
void error(char *Text);
void writeLn(void);
void writeText(char *Text);
void writeNumber(int Number);
void writeString(char *Text);
void writeCoordinate(int x ,int y ,int z);
void writeBytesequence(uint8 *Sequence, int Length);
// DATA
// =========================================================================
FILE *File;
char Filename[4096];
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_
|