-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfile.h
More file actions
329 lines (232 loc) · 7.58 KB
/
file.h
File metadata and controls
329 lines (232 loc) · 7.58 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#ifndef twf_file_h
#define twf_file_h
/*
* FILE LOCATIONS
*/
#define ACTION_SWAP_DIR "../var/swap/action/"
#define AREA_DIR "../area/"
#define AREA_PREV_DIR "../prev/area/"
#define BACKUP_DIR "../reimb/"
#define CLAN_DIR "../clans/"
#define CLAN_NOTE_DIR "../notes/clans/"
#define DUMP_DIR "../dumps/"
#define DUMP_PREV_DIR "../prev/dumps/"
#define FILES_DIR "../files/"
#define FILES_PREV_DIR "../prev/files/"
#define IMMORTAL_LOG_DIR "../logs/immortal/"
#define LOST_FOUND_DIR "../lost+found/"
#define MOB_LOG_DIR "../logs/mob/"
#define MAIL_DIR "../mail/"
#define NOTE_DIR "../notes/"
#define OBJ_LOG_DIR "../logs/object/"
#define PLAYER_DIR "../player/"
#define PLAYER_LOG_DIR "../logs/player/"
#define PLAYER_PREV_DIR "../prev/player/"
#define HTML_CLAN_DIR "../public_html/clans/"
#define HTML_DIR "../public_html/"
#define HTML_HELP_DIR "../public_html/help/"
#define ROOM_DIR "../rooms/"
#define ROOM_PREV_DIR "../prev/rooms/"
#define ROOM_LOG_DIR "../logs/room/"
#define ROOM_SWAP_DIR "../var/swap/room/"
#define SQL_EXPORT_DIR "../sql/"
#define SQL_PREV_DIR "../prev/sql/"
#define TABLE_DIR "../tables/"
#define TABLE_PREV_DIR "../prev/tables/"
#define TEMP_DIR "../var/tmp"
#define ACCOUNT_FILE "accounts"
#define AREA_LIST "area.lst"
#define BADNAME_FILE "badname.txt"
#define BANNED_FILE "banned.txt"
#define BUG_FILE "../files/bugs.txt"
#define CUSTOM_FILE "custom.txt"
#define DICTIONARY_FILE "dictionary.txt"
#define GODLOCK_FILE "../var/control/godlock"
#define HELP_FILE "help.are"
#define HELP_SQL "help.sql"
#define HTML_INDEX_FILE "index.html"
#define HTML_PLAYER_FILE "players.html"
#define LIST_FILE "Lists"
#define MOB_FILE "mob.mob"
#define OBJECT_FILE "obj.obj"
#define PANIC_FILE "../var/control/panic"
#define QUEST_FILE "quest"
#define REBOOT_FILE "../var/control/reboot"
#define REMORT_FILE "remort.txt"
#define RTABLE_FILE "rtables"
#define SHOP_FILE "shop.dat"
#define SHUTDOWN_FILE "../var/control/shutdown"
#define TRAINER_FILE "trainer.dat"
#define WIZLOCK_FILE "../var/control/wizlock"
#define WORLD_FILE "world"
/*
* BUG FUNCTIONS
*/
void panic ( const char* );
void bug ( int, const char* );
#define BUG_APHID 3
#define BUG_BEETLE 2
#define BUG_ROACH 1
inline void aphid ( const char* text ) { bug( BUG_APHID, text ); }
inline void beetle ( const char* text ) { bug( BUG_BEETLE, text ); }
inline void roach ( const char* text ) { bug( BUG_ROACH, text ); }
inline void bug ( const char* text ) { bug( BUG_BEETLE, text ); }
template < class T >
void aphid( const char* text, T item )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, tostring( item, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( BUG_APHID, tmp );
}
template < class T >
void roach( const char* text, T item )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, tostring( item, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( BUG_ROACH, tmp );
}
template < class S, class T >
void roach( const char* text, S item1, T item2 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, tostring( item1, 0 ), tostring( item2, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( BUG_ROACH, tmp );
}
template < class S, class T, class U >
void roach( const char* text, S item1, T item2, U item3 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text,
tostring( item1, 0 ),
tostring( item2, 0 ),
tostring( item3, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( BUG_ROACH, tmp );
}
template < class S, class T, class U, class V >
void roach( const char* text, S item1, T item2, U item3, V item4 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text,
tostring( item1, 0 ),
tostring( item2, 0 ),
tostring( item3, 0 ),
tostring( item4, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( BUG_ROACH, tmp );
}
template < class T >
void bug( const char* text, T item )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, tostring( item, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( tmp );
}
template < class S, class T >
void bug( const char* text, S item1, T item2 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, tostring( item1, 0 ), tostring( item2, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( tmp );
}
template < class S, class T, class U >
void bug( const char* text, S item1, T item2, U item3 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text,
tostring( item1, 0 ), tostring( item2, 0 ), tostring( item3, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( tmp );
}
template < class S, class T, class U, class V >
void bug( const char* text, S item1, T item2, U item3, V item4 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text,
tostring( item1, 0 ), tostring( item2, 0 ),
tostring( item3, 0 ), tostring( item4, 0 ) );
if( *text == '%' )
*tmp = toupper( *tmp );
bug( tmp );
}
template < class T >
void panic( const char* text, T item )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, item );
if( *text == '%' )
*tmp = toupper( *tmp );
panic( tmp );
}
template < class S, class T >
void panic( const char* text, S item1, T item2 )
{
char tmp [ TWO_LINES ];
snprintf( tmp, TWO_LINES, text, item1, item2 );
if( *text == '%' )
*tmp = toupper( *tmp );
panic( tmp );
}
/*
* BOOT CONTROL
*/
void quit ( int status );
void shutdown( const char *, const char * = 0 );
void reboot( const char *, const char * = 0 );
bool create_control_file( const char *, const char *, const char * = 0 );
bool exist_control_file( const char * );
void delete_control_file( const char * );
void check_panic( );
/*
* FILE ROUTINES
*/
FILE* open_file ( const char*, const char*, const char*,
bool = false );
FILE* open_file ( const char*, const char*,
bool = false );
bool delete_file ( const char*, const char*, bool = true );
bool rename_file ( const char*, const char*,
const char*, const char* );
char fread_letter ( FILE *fp );
int fread_number ( FILE *fp );
unsigned fread_unsigned ( FILE *fp );
void fread_to_eol ( FILE *fp );
//char* fread_block ( FILE* );
char* fread_string ( FILE*, int );
char* fread_word ( FILE* );
void fwrite_string ( FILE*, const char* );
void fwrite_xmlstring ( FILE*, const char* );
void fwrite_sqlstring ( FILE*, const char* );
void write_all ( bool = false );
/*
* HELP ROUTINES
*/
bool save_help ( );
/*
* WORLD ROUTINES
*/
bool save_world ( );
void load_world ( );
/*
* QUITTING ROUTINES
*/
void forced_quit ( player_data*, bool = false );
/*
* WEBPAGE ROUTINES
*/
//void w3_help ( void );
//void w3_who ( void );
#endif // twf_file_h