-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbug.cc
More file actions
381 lines (341 loc) · 10.8 KB
/
bug.cc
File metadata and controls
381 lines (341 loc) · 10.8 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#include <ctype.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#include "define.h"
#include "struct.h"
/*
* BUG ROUTINES
*/
static void mob_bugs( char_data* ch, species_data* species, bool& found,
bool make )
{
bool compile = make && !species->attack->binary;
if( compile ) {
species->attack->compile( );
}
if( species->attack->corrupt ) {
found = true;
page( ch, " Mob #%d (%s) attack program is not compiling.\n\r",
species->vnum, species );
} else if( compile && !species->attack->binary ) {
found = true;
page( ch, " Mob #%d (%s) has no attack program.\n\r",
species->vnum, species );
}
if( compile ) {
species->attack->decompile( );
}
int i = 1;
bool desc = false;
for( mprog_data *mprog = species->mprog; mprog; i++, mprog = mprog->next ) {
bool compile = make && !mprog->binary;
if( compile ) {
mprog->compile( );
}
if( mprog->corrupt ) {
found = true;
page( ch, " Mprog #%d on mob #%d (%s) is not compiling.\n\r",
i, species->vnum, species );
}
if( compile ) {
mprog->decompile( );
}
if( mprog->trigger == MPROG_TRIGGER_DESCRIBE )
desc = true;
}
if( !desc && !*species->descr->complete ) {
page( ch, " Mob #%d (%s) has no description.\n\r", species->vnum, species );
}
if( !is_set( species->act_flags, ACT_HUMANOID ) ) {
// Check marmor table.
int max = 0;
int i;
for( i = 0; i < MAX_ARMOR; ++i ) {
if( species->chance[i] <= max ) {
page( ch, " Mob #%d (%s) marmor entry #%d has non-increasing chance entry.\n\r",
species->vnum, species, i+1 );
} else {
max = species->chance[i];
}
if( species->chance[i] < 1 || species->chance[i] > 1000 ) {
page( ch, " Mob #%d (%s) marmor entry #%d has out-of-range chance entry.\n\r",
species->vnum, species, i+1 );
}
if( species->chance[i] == 1000 ) {
break;
}
}
if( i == MAX_ARMOR ) {
page( ch, " Mob #%d (%s) marmor table has no 1000 chance entry.\n\r",
species->vnum, species );
}
}
}
void obj_bugs( char_data* ch, obj_clss_data* obj, bool& found,
bool make )
{
int i = 1;
bool desc = false;
for( oprog_data *oprog = obj->oprog; oprog; i++, oprog = oprog->next ) {
bool compile = make && !oprog->binary;
if( compile ) {
oprog->compile( );
}
if( oprog->corrupt ) {
found = true;
page( ch, " Oprog #%d on obj #%d (%s) is not compiling.\n\r",
i, obj->vnum, obj );
}
if( compile ) {
oprog->decompile( );
}
if( oprog->trigger == OPROG_TRIGGER_DESCRIBE )
desc = true;
}
if( !desc ) {
bool either = false;
bool after = false;
bool before = false;
const char* keyword;
for( int i = 0; i < obj->extra_descr; i++ ) {
keyword = obj->extra_descr[i]->keyword;
either |= !strcasecmp( keyword, "either" );
after |= !strcasecmp( keyword, "after" );
before |= !strcasecmp( keyword, "before" );
}
if( !either &&
( !after ||
( !before && ( obj->fakes == 0
|| obj->fakes == obj->vnum ) ) ) ) {
page( ch, " Object #%-4d (%s) missing description oextra.\n\r",
obj->vnum, obj->Name( ) );
found = true;
}
}
if( is_set( obj->extra_flags, OFLAG_NOSHOW )
&& is_set( obj->wear_flags, ITEM_TAKE ) ) {
page( ch, " Object #%-4d (%s) takeable and 'no.show'.\n\r",
obj->vnum, obj->Name( ) );
found = true;
}
if( obj->fakes && obj->fakes != obj->vnum ) {
obj_clss_data *fake = get_obj_index( obj->fakes );
if( !fake ) {
page( ch, " Object #%-4d (%s) fake object %d nonexistent.\n\r",
obj->vnum, obj->Name( ), obj->fakes );
found = true;
} else if( is_set( obj->extra_flags, OFLAG_THE_BEFORE )
!= is_set( fake->extra_flags, OFLAG_THE_BEFORE ) ) {
page( ch, " Object #%-4d (%s) fake object %d has non-matching oflag %s.\n\r",
obj->vnum, obj->Name( ), obj->fakes, oflag_name[OFLAG_THE_BEFORE] );
found = true;
} else if( is_set( obj->extra_flags, OFLAG_THE_AFTER )
!= is_set( fake->extra_flags, OFLAG_THE_AFTER ) ) {
page( ch, " Object #%-4d (%s) fake object %d has non-matching oflag %s.\n\r",
obj->vnum, obj->Name( ), obj->fakes, oflag_name[OFLAG_THE_AFTER] );
found = true;
} else if( strcmp( obj->prefix_singular, fake->prefix_singular ) ) {
page( ch, " Object #%-4d (%s) fake object %d has non-matching prefix_s.\n\r",
obj->vnum, obj->Name( ), obj->fakes );
found = true;
} else if( strcmp( obj->prefix_plural, fake->prefix_plural ) ) {
page( ch, " Object #%-4d (%s) fake object %d has non-matching prefix_p.\n\r",
obj->vnum, obj->Name( ), obj->fakes );
found = true;
} else if( strcmp( separate( obj->singular, false ), separate( fake->singular, false ) ) ) {
page( ch, " Object #%-4d (%s) fake object %d has non-matching un-identified singular.\n\r",
obj->vnum, obj->Name( ), obj->fakes );
found = true;
} else if( strcmp( separate( obj->plural, false ), separate( fake->plural, false ) ) ) {
page( ch, " Object #%-4d (%s) fake object %d has non-matching un-identified plural.\n\r",
obj->vnum, obj->Name( ), obj->fakes );
found = true;
}
}
}
void room_bugs( char_data* ch, room_data* room, bool& found,
bool make )
{
if( midair( 0, room ) ) {
exit_data *exit = exit_direction( room, DIR_DOWN );
if( !exit ) {
page( ch, " Air room %d has no downward exit.\n\r",
room->vnum );
found = true;
} else {
if( is_set( exit->exit_info, EX_ISDOOR ) ) {
page( ch, " Air room %d downward exit has %s dflag set.\n\r",
room->vnum, dflag_name[EX_ISDOOR] );
found = true;
}
if( is_set( exit->exit_info, EX_CLOSED ) ) {
page( ch, " Air room %d downward exit has %s dflag set.\n\r",
room->vnum, dflag_name[EX_CLOSED] );
found = true;
}
if( is_set( exit->exit_info, EX_NO_MOB ) ) {
page( ch, " Air room %d downward exit has %s dflag set.\n\r",
room->vnum, dflag_name[EX_NO_MOB] );
found = true;
}
if( exit->size < room->size ) {
page( ch, " Air room %d downward exit size is smaller than room size.\n\r",
room->vnum );
found = true;
}
room_data *to = exit->to_room;
if( is_set( to->room_flags, RFLAG_NO_MOB ) ) {
page( ch, " Air room %d downward room %d has %s rflag set.\n\r",
room->vnum, to->vnum, rflag_name[RFLAG_NO_MOB] );
found = true;
}
if( is_set( to->room_flags, RFLAG_NO_MOUNT ) ) {
page( ch, " Air room %d downward room %d has %s rflag set.\n\r",
room->vnum, to->vnum, rflag_name[RFLAG_NO_MOUNT] );
found = true;
}
if( to->size < room->size ) {
page( ch, " Air room %d downward room %d size is smaller than room size.\n\r",
room->vnum, to->vnum );
found = true;
}
if( is_submerged( 0, to ) ) {
page( ch, " Air room %d downward room %d is underwater terrain.\n\r",
room->vnum, to->vnum );
found = true;
}
if( room->area != to->area
&& to->area->status != AREA_OPEN ) {
page( ch, " Air room %d downward room %d is not open to players.\n\r",
room->vnum, to->vnum );
found = true;
}
}
}
for( int i = 0; i < room->exits; ++i ) {
exit_data *exit = room->exits[i];
if( exit_data *exit2 = reverse( exit ) ) {
if( exit->size != exit2->size
&& room->vnum < exit->to_room->vnum ) {
page( ch, " Room %d exit %s size is inconsistent.\n\r",
room->vnum, dir_table[exit->direction].name );
found = true;
}
}
}
action_data* action;
int i, j;
for( i = 1, action = room->action; action; i++, action = action->next ) {
bool compile = make && !action->binary;
if( compile ) {
action->compile( );
}
if( action->corrupt ) {
found = true;
page( ch, " Acode #%d in room %d is not compiling.\n\r",
i, room->vnum );
}
if( compile ) {
action->decompile( );
}
if( action->trigger == TRIGGER_ENTERING
|| action->trigger == TRIGGER_LEAVING ) {
for( j = 0; j < MAX_DIR; ++j )
if( is_set( action->flags, j ) )
break;
if( j == MAX_DOOR ) {
found = true;
page( ch,
" Acode #%d in room %d has no direction flag checked.\n\r",
i, room->vnum );
}
}
}
}
void do_bugs( char_data* ch, const char *argument )
{
area_data* area;
reset_data* reset;
room_data* room;
species_data* species;
obj_clss_data* obj;
bool found = false;
int i;
int flags;
if( !get_flags( ch, argument, &flags, "omtrac", "Bugs" ) )
return;
if( ( flags & 0x1f ) == 0 )
flags = 0xf;
bool compile = is_set( flags, 5 );
page( ch, "Bugs Found:\n\r" );
/*-- OBJECTS --*/
if( is_set( flags, 0 ) ) {
for( i = 1; i <= obj_clss_max; ++i ) {
if( ( obj = obj_index_list[i] ) ) {
obj_bugs( ch, obj, found, compile );
}
}
}
/*-- TRAINERS --*/
if( is_set( flags, 2 ) ) {
for( const trainer_data *trainer = trainer_list; trainer; trainer = trainer->next ) {
if( !trainer->room ) {
page( ch, " Trainer nowhere??\n\r" );
found = true;
continue;
}
if( !( species = get_species( trainer->trainer ) ) ) {
page( ch, " Trainer in room #%d with non-existent species.\n\r",
trainer->room->vnum );
found = true;
continue;
}
for( reset = trainer->room->reset; reset; reset = reset->next )
if( reset->vnum == trainer->trainer
&& is_set( reset->flags, RSFLAG_MOB ) )
break;
if( !reset ) {
page( ch,
" Trainer entry in room %d for mob %d with no reset.\n\r",
trainer->room->vnum, trainer->trainer );
found = true;
}
}
}
/*-- MOBILE BUGS --*/
if( is_set( flags, 1 ) ) {
for( i = 1; i <= species_max; ++i ) {
if( ( species = species_list[i] ) ) {
mob_bugs( ch, species, found, compile );
}
}
}
/*-- AREAS --*/
if( is_set( flags, 4 ) ) {
for( area = area_list; area; area = area->next ) {
if( area->status == AREA_OPEN ) {
bool loaded = area->act_loaded;
for( room = area->room_first; room; room = room->next ) {
room_bugs( ch, room, found, compile );
}
if( !loaded && area->act_loaded ) {
area->clear_actions( );
}
}
}
}
if( is_set( flags, 3 ) ) {
bool loaded = ch->in_room->area->act_loaded;
for( room = ch->in_room->area->room_first; room; room = room->next ) {
room_bugs( ch, room, found, compile );
}
if( !loaded && ch->in_room->area->act_loaded ) {
ch->in_room->area->clear_actions( );
}
}
if( !found )
page( ch, " none\n\r" );
}