This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathack431.c
340 lines (290 loc) · 10.7 KB
/
ack431.c
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
330
331
332
333
334
335
336
337
338
339
340
/*
* Copyright Matt Goff (Kline) 2009
* If you use my code, please give credit where it is due.
* Support provided at www.ackmud.net
*/
#include "h/areaconvert.h"
#include "h/extern.h"
void read_ack431( ifstream &file )
{
string tmp;
while ( !file.eof() )
{
getline(file, tmp);
if ( tmp[0] == '#' )
{
if ( tmp[1] == '$' )
break;
if ( tmp == "#AREA" )
read_ack431_area(file);
else if ( tmp == "#ROOMS" )
read_ack431_room(file);
else if ( tmp == "#MOBILES" )
read_ack431_npc(file);
else if ( tmp == "#OBJECTS" )
read_ack431_obj(file);
else if ( tmp == "#SHOPS" )
read_ack431_shop(file);
else if ( tmp == "#RESETS" )
read_ack431_reset(file);
}
}
return;
}
void read_ack431_area( ifstream &file )
{
string tmp;
char delim = '~';
char c;
getline(file, area.name, delim);
while ( !file.eof() )
{
c = file.get();
if ( c == '#' )
break;
switch ( c )
{
case 'B': getline(file, tmp); S_BIT(area.int_flags_in, ACK431_AFLAG_BUILDING); area.flags_found += "building "; break;
case 'F': getline(file, tmp); area.reset_rate = str2int(tmp); break;
case 'I': file.ignore(1); getline(file, tmp, ' '); area.min_level = str2int(tmp); getline(file, tmp); area.max_level = str2int(tmp); break;
case 'K': getline(file, area.keyword, delim); break;
case 'L': getline(file, area.level_label, delim); break;
case 'M': getline(file, tmp); S_BIT(area.int_flags_in, ACK431_AFLAG_NO_ROOM_AFF); area.flags_found += "no_room_affs "; break;
case 'N': getline(file, tmp); break;
case 'O': getline(file, area.owner, delim); break;
case 'P': getline(file, tmp); S_BIT(area.int_flags_in, ACK431_AFLAG_PAYAREA); area.flags_found += "pay_area "; break;
case 'Q': getline(file, tmp); area.revision = str2int(tmp); break;
case 'R': getline(file, area.can_read, delim); break;
case 'S': getline(file, tmp); S_BIT(area.int_flags_in, ACK431_AFLAG_NOSHOW); area.flags_found += "no_show "; break;
case 'T': getline(file, tmp); S_BIT(area.int_flags_in, ACK431_AFLAG_TELEPORT); area.flags_found += "teleport "; break;
case 'U': getline(file, area.reset_msg, delim); break;
case 'V': file.ignore(1); getline(file, tmp, ' '); area.min_vnum = str2int(tmp); getline(file, tmp); area.max_vnum = str2int(tmp); break;
case 'W': getline(file, area.can_write, delim); break;
case 'X': getline(file, tmp); break;
}
}
file.unget();
return;
}
void read_ack431_room( ifstream &file )
{
string tmp;
room_data *room;
int vnum = 0;
char delim = '~';
char c;
while ( !file.eof() )
{
tmp.clear();
while ( (c = file.get()) != '#' );
if ( c == '#' )
getline(file, tmp); vnum = str2int(tmp);
if ( vnum == 0 ) /* reached the end */
break;
room = new room_data;
room->vnum = vnum;
getline(file, room->name, delim);
getline(file, room->description, delim);
getline(file, tmp, ' '); room->int_flags_in = str2int(tmp);
getline(file, tmp); room->sector = str2int(tmp);
while ( !file.eof() )
{
c = file.get();
if ( c == 'S' ) /* stop */
break;
if ( c == 'D' ) /* door */
{
exit_data *exit = new exit_data;
getline(file, tmp);
room->exit[str2int(tmp)] = exit;
getline(file, exit->description, delim);
getline(file, exit->keyword, delim);
getline(file, tmp, ' '); exit->int_flags_in = str2int(tmp);
getline(file, tmp, ' '); exit->key = str2int(tmp);
getline(file, tmp); exit->vnum = str2int(tmp);
}
if ( c == 'E' ) /* extra descrip */
{
extra_data *extra = new extra_data;
getline(file, extra->keyword, delim);
getline(file, extra->description, delim);
room->extra_list.push_back(extra);
}
}
room_list.push_back(room);
}
return;
}
void read_ack431_npc( ifstream &file )
{
string tmp;
npc_data *npc;
int vnum = 0;
char delim = '~';
char c;
while ( !file.eof() )
{
tmp.clear();
while ( (c = file.get()) != '#' );
if ( c == '#' )
getline(file, tmp); vnum = str2int(tmp);
if ( vnum == 0 ) /* reached the end */
break;
npc = new npc_data;
npc->vnum = vnum;
getline(file, npc->player_name, delim);
getline(file, npc->short_descr, delim);
getline(file, npc->long_descr, delim);
getline(file, npc->description, delim);
getline(file, tmp, ' '); npc->int_act_flags_in = str2int(tmp);
getline(file, tmp, ' '); npc->affected_by = str2int(tmp);
getline(file, tmp, ' '); npc->alignment = str2int(tmp);
file.ignore(1); /* S */
getline(file, tmp, ' '); npc->level = str2int(tmp);
getline(file, tmp); npc->sex = str2int(tmp);
getline(file, tmp, ' '); npc->ac_mod = str2int(tmp);
getline(file, tmp, ' '); npc->hr_mod = str2int(tmp);
getline(file, tmp); npc->dr_mod = str2int(tmp);
c = file.get(); /* ! */
if ( c == '!' )
{
getline(file, tmp, ' '); npc->pclass = str2int(tmp);
getline(file, tmp, ' '); npc->clan = str2int(tmp);
getline(file, tmp, ' '); npc->race = str2int(tmp);
getline(file, tmp, ' '); npc->position = str2int(tmp);
getline(file, tmp, ' '); npc->skills = str2int(tmp);
getline(file, tmp, ' '); npc->cast = str2int(tmp);
getline(file, tmp); npc->def = str2int(tmp);
}
else
file.unget();
c = file.get(); /* | */
if ( c == '|' )
{
getline(file, tmp, ' '); npc->strong_magic = str2int(tmp);
getline(file, tmp, ' '); npc->weak_magic = str2int(tmp);
getline(file, tmp, ' '); npc->race_mod = str2int(tmp);
getline(file, tmp, ' '); npc->power_skill = str2int(tmp);
getline(file, tmp, ' '); npc->power_cast = str2int(tmp);
getline(file, tmp, ' '); npc->resist = str2int(tmp);
getline(file, tmp); npc->suscept = str2int(tmp);
}
else
file.unget();
npc_list.push_back(npc);
}
return;
}
void read_ack431_obj( ifstream &file )
{
string tmp;
obj_data *obj;
int vnum = 0;
int i = 0;
char delim = '~';
char c;
while ( !file.eof() )
{
tmp.clear();
while ( (c = file.get()) != '#' );
if ( c == '#' )
getline(file, tmp); vnum = str2int(tmp);
if ( vnum == 0 ) /* reached the end */
break;
obj = new obj_data;
obj->vnum = vnum;
obj->level = 1; /* Level may or may not be provided in some ACK431 area files */
getline(file, obj->name, delim);
getline(file, obj->short_descr, delim);
getline(file, obj->long_descr, delim);
getline(file, tmp, ' '); obj->type = str2int(tmp);
getline(file, tmp, ' '); obj->int_extra_flags_in = str2int(tmp);
getline(file, tmp, ' '); obj->int_wear_flags_in = str2int(tmp);
getline(file, tmp); obj->int_item_apply_in = str2int(tmp);
for ( i = 0; i < MAX_OBJ_VALUE - 1; i++ )
getline(file, tmp, ' '); obj->value[i] = str2int(tmp);
getline(file, tmp); obj->value[MAX_OBJ_VALUE-1] = str2int(tmp);
getline(file, tmp); obj->weight = str2int(tmp);
while ( !file.eof() )
{
c = file.get();
if ( c == 'A' ) /* affect */
{
affect_data *aff = new affect_data;
getline(file, tmp, ' '); aff->int_location_in = str2int(tmp);
getline(file, tmp); aff->modifier = str2int(tmp);
obj->apply_list.push_back(aff);
}
else if ( c == 'E' ) /* extra descr */
{
extra_data *extra = new extra_data;
getline(file, extra->keyword, delim);
getline(file, extra->description, delim);
obj->extra_list.push_back(extra);
}
else if ( c == 'L' ) /* item level */
{
getline(file, tmp); obj->level = str2int(tmp);
}
else /* nothing interesting found */
{
file.unget();
break;
}
}
obj_list.push_back(obj);
}
return;
}
void read_ack431_shop( ifstream &file )
{
string tmp;
shop_data *shop;
int vnum = 0;
int i = 0;
char c;
while ( !file.eof() )
{
tmp.clear();
c = file.peek();
if ( c == '0' )
{ break; cout << "hit the end" << endl;} /* reached the end, written this way due to how shops save */
else
{ getline(file, tmp, ' '); vnum = str2int(tmp); }
shop = new shop_data;
shop->keeper = vnum;
for ( i = 0; i < MAX_TRADE - 1; i++ )
getline(file, tmp, ' '); shop->buy_type[i] = str2int(tmp);
getline(file, tmp, ' '); shop->prof_buy = str2int(tmp);
getline(file, tmp, ' '); shop->prof_sell = str2int(tmp);
getline(file, tmp, ' '); shop->hour_open = str2int(tmp);
getline(file, tmp); shop->hour_close = str2int(tmp);
shop_list.push_back(shop);
}
return;
}
void read_ack431_reset( ifstream &file )
{
string tmp;
reset_data *reset;
char c;
while ( !file.eof() )
{
tmp.clear();
c = file.get();
while ( c == ' ' )
c = file.get();
if ( c == 'S' ) /* reached the end */
break;
reset = new reset_data;
reset->command = c;
file.ignore(3); /* old 'ifflag', unused */
getline(file, tmp, ' '); reset->arg1 = str2int(tmp);
getline(file, tmp, ' '); reset->arg2 = str2int(tmp);
getline(file, tmp, ' '); reset->arg3 = ( c == 'G' || c == 'R' ) ? 0 : str2int(tmp);
getline(file, reset->notes);
getline(file, tmp); /* read the blank line */
reset_list.push_back(reset);
}
return;
}