| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include "jacl.h" |
| 8 |
#include "language.h" |
| 9 |
#include "types.h" |
| 10 |
#include "prototypes.h" |
| 11 |
#include "interpreter.h" |
| 12 |
#include "encapsulate.h" |
| 13 |
#include <string.h> |
| 14 |
|
| 15 |
#ifdef __NDS__ |
| 16 |
extern int screen_width; |
| 17 |
extern int screen_depth; |
| 18 |
#endif |
| 19 |
|
| 20 |
#ifndef GLK |
| 21 |
#ifndef __NDS__ |
| 22 |
extern char game_url[]; |
| 23 |
extern char user_id[]; |
| 24 |
#endif |
| 25 |
#endif |
| 26 |
|
| 27 |
extern int value_resolved; |
| 28 |
|
| 29 |
char macro_function[84]; |
| 30 |
int value_has_been_resolved; |
| 31 |
|
| 32 |
static int count_resolve(const char *testString); |
| 33 |
static const char* expand_function(const char *name); |
| 34 |
static int array_length_resolve(const char *testString); |
| 35 |
static char* macro_resolve(const char *testString); |
| 36 |
|
| 37 |
int * |
| 38 |
container_resolve(const char *container_name) |
| 39 |
{ |
| 40 |
container_name = arg_text_of(container_name); |
| 41 |
|
| 42 |
|
| 43 |
struct integer_type *resolved_integer; |
| 44 |
|
| 45 |
if ((resolved_integer = integer_resolve(container_name)) != NULL) |
| 46 |
return (&resolved_integer->value); |
| 47 |
else if (object_element_resolve(container_name)) |
| 48 |
return (object_element_address); |
| 49 |
else if (!strcmp(container_name, "noun1")) |
| 50 |
return (&noun[0]); |
| 51 |
else if (!strcmp(container_name, "noun2")) |
| 52 |
return (&noun[1]); |
| 53 |
else if (!strcmp(container_name, "noun3")) |
| 54 |
return (&noun[2]); |
| 55 |
else if (!strcmp(container_name, "noun4")) |
| 56 |
return (&noun[3]); |
| 57 |
else if (!strcmp(container_name, "player")) |
| 58 |
return (&player); |
| 59 |
else if (!strcmp(container_name, "here")) |
| 60 |
return (&object[player]->PARENT); |
| 61 |
else |
| 62 |
return ((int *) NULL); |
| 63 |
} |
| 64 |
|
| 65 |
const char * |
| 66 |
var_text_of_word(int wordnumber) |
| 67 |
{ |
| 68 |
const char *value; |
| 69 |
|
| 70 |
if (percented[wordnumber] == FALSE) { |
| 71 |
return (word[wordnumber]); |
| 72 |
} else { |
| 73 |
value_has_been_resolved = TRUE; |
| 74 |
value = arg_text_of(word[wordnumber]); |
| 75 |
while (value_has_been_resolved && percented[wordnumber]) { |
| 76 |
value = arg_text_of(value); |
| 77 |
percented[wordnumber]--; |
| 78 |
} |
| 79 |
|
| 80 |
return (value); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
const char * |
| 85 |
arg_text_of_word(int wordnumber) |
| 86 |
{ |
| 87 |
const char *value; |
| 88 |
|
| 89 |
if (quoted[wordnumber] == 1) { |
| 90 |
return (word[wordnumber]); |
| 91 |
} else { |
| 92 |
value_has_been_resolved = TRUE; |
| 93 |
value = arg_text_of(word[wordnumber]); |
| 94 |
while (value_has_been_resolved && percented[wordnumber]) { |
| 95 |
value = arg_text_of(value); |
| 96 |
percented[wordnumber]--; |
| 97 |
} |
| 98 |
|
| 99 |
return (value); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
const char * |
| 104 |
text_of_word(int wordnumber) |
| 105 |
{ |
| 106 |
const char *value; |
| 107 |
|
| 108 |
if (quoted[wordnumber] == 1) { |
| 109 |
return (word[wordnumber]); |
| 110 |
} else { |
| 111 |
value_has_been_resolved = TRUE; |
| 112 |
value = text_of(word[wordnumber]); |
| 113 |
while (value_has_been_resolved && percented[wordnumber]) { |
| 114 |
value = text_of(value); |
| 115 |
percented[wordnumber]--; |
| 116 |
} |
| 117 |
|
| 118 |
return (value); |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
const char * |
| 123 |
text_of(const char *string) |
| 124 |
{ |
| 125 |
struct integer_type *resolved_integer; |
| 126 |
struct cinteger_type *resolved_cinteger; |
| 127 |
struct string_type *resolved_string; |
| 128 |
struct string_type *resolved_cstring; |
| 129 |
char *return_string; |
| 130 |
|
| 131 |
int index; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
if ((return_string = macro_resolve(string)) != NULL) { |
| 136 |
value_has_been_resolved = FALSE; |
| 137 |
return(return_string); |
| 138 |
} else if ((resolved_integer = integer_resolve(string)) != NULL) { |
| 139 |
value_has_been_resolved = FALSE; |
| 140 |
integer_buffer[0] = 0; |
| 141 |
sprintf(integer_buffer, "%d", resolved_integer->value); |
| 142 |
return(integer_buffer); |
| 143 |
} else if ((resolved_cinteger = cinteger_resolve(string)) != NULL) { |
| 144 |
value_has_been_resolved = FALSE; |
| 145 |
integer_buffer[0] = 0; |
| 146 |
sprintf(integer_buffer, "%d", resolved_cinteger->value); |
| 147 |
return(integer_buffer); |
| 148 |
} else if (object_element_resolve(string)) { |
| 149 |
value_has_been_resolved = FALSE; |
| 150 |
integer_buffer[0] = 0; |
| 151 |
sprintf(integer_buffer, "%d", oec); |
| 152 |
return(integer_buffer); |
| 153 |
} else if ((index = object_resolve(string)) != -1) { |
| 154 |
value_has_been_resolved = FALSE; |
| 155 |
if (index < 1 || index > objects) { |
| 156 |
badptrrun(string, index); |
| 157 |
return (""); |
| 158 |
} else { |
| 159 |
return(object[index]->label); |
| 160 |
} |
| 161 |
} else if ((resolved_string = string_resolve(string)) != NULL) { |
| 162 |
return (resolved_string->value); |
| 163 |
} else if ((resolved_cstring = cstring_resolve(string)) != NULL) { |
| 164 |
return (resolved_cstring->value); |
| 165 |
} else if (function_resolve(string) != NULL) { |
| 166 |
value_has_been_resolved = FALSE; |
| 167 |
sprintf(integer_buffer, "%d", execute(string)); |
| 168 |
return(integer_buffer); |
| 169 |
#ifndef GLK |
| 170 |
#ifndef __NDS__ |
| 171 |
} else if (!strcmp(string, "$url")) { |
| 172 |
value_has_been_resolved = FALSE; |
| 173 |
return (game_url); |
| 174 |
} else if (!strcmp(string, "$user_id")) { |
| 175 |
value_has_been_resolved = FALSE; |
| 176 |
return (user_id); |
| 177 |
#endif |
| 178 |
#endif |
| 179 |
} else { |
| 180 |
value_has_been_resolved = FALSE; |
| 181 |
return (string); |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
const char * |
| 186 |
arg_text_of(const char *string) |
| 187 |
{ |
| 188 |
struct string_type *resolved_string; |
| 189 |
struct string_type *resolved_cstring; |
| 190 |
char *macro_text; |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
if ((macro_text = macro_resolve(string)) != NULL) { |
| 195 |
value_has_been_resolved = FALSE; |
| 196 |
return(macro_text); |
| 197 |
} else if ((resolved_string = string_resolve(string)) != NULL) { |
| 198 |
return (resolved_string->value); |
| 199 |
} else if ((resolved_cstring = cstring_resolve(string)) != NULL) { |
| 200 |
value_has_been_resolved = FALSE; |
| 201 |
return (resolved_cstring->value); |
| 202 |
} else { |
| 203 |
value_has_been_resolved = FALSE; |
| 204 |
return (string); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
int |
| 209 |
validate(const char *string) |
| 210 |
{ |
| 211 |
int index, |
| 212 |
count; |
| 213 |
|
| 214 |
if (string == NULL) { |
| 215 |
return (FALSE); |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
count = strlen(string); |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
for (index = 0; index < count; index++) { |
| 224 |
if (!isdigit((int) *(string + index)) && string[index] != '-') { |
| 225 |
|
| 226 |
return (FALSE); |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
return (TRUE); |
| 231 |
} |
| 232 |
|
| 233 |
long |
| 234 |
value_of(const char *value, int run_time) |
| 235 |
{ |
| 236 |
long compare; |
| 237 |
|
| 238 |
value_resolved = TRUE; |
| 239 |
|
| 240 |
value = arg_text_of(value); |
| 241 |
|
| 242 |
|
| 243 |
struct integer_type *resolved_integer; |
| 244 |
struct cinteger_type *resolved_cinteger; |
| 245 |
struct string_type *resolved_string; |
| 246 |
|
| 247 |
if (!strcmp(value, "**held")) { |
| 248 |
return (FALSE); |
| 249 |
} else if (!strcmp(value, "**here")) { |
| 250 |
return (FALSE); |
| 251 |
} else if (!strcmp(value, "**anywhere")) { |
| 252 |
return (FALSE); |
| 253 |
} else if (!strcmp(value, "**present")) { |
| 254 |
return (FALSE); |
| 255 |
} else if (!strcmp(value, "*held")) { |
| 256 |
return (FALSE); |
| 257 |
} else if (!strcmp(value, "*here")) { |
| 258 |
return (FALSE); |
| 259 |
} else if (!strcmp(value, "*anywhere")) { |
| 260 |
return (FALSE); |
| 261 |
} else if (!strcmp(value, "*present")) { |
| 262 |
return (FALSE); |
| 263 |
} else if (!strcmp(value, "random")) { |
| 264 |
return random_number(); |
| 265 |
#ifdef GLK |
| 266 |
} else if (!strcmp(value, "status_height")) { |
| 267 |
glk_window_get_size(statuswin, &status_width, &status_height); |
| 268 |
return status_height; |
| 269 |
} else if (!strcmp(value, "status_width")) { |
| 270 |
glk_window_get_size(statuswin, &status_width, &status_height); |
| 271 |
return status_width; |
| 272 |
#else |
| 273 |
#ifdef __NDS__ |
| 274 |
} else if (!strcmp(value, "status_height")) { |
| 275 |
return screen_depth; |
| 276 |
} else if (!strcmp(value, "status_width")) { |
| 277 |
return screen_width; |
| 278 |
#else |
| 279 |
} else if (!strcmp(value, "status_height")) { |
| 280 |
value_resolved = FALSE; |
| 281 |
return -1; |
| 282 |
} else if (!strcmp(value, "status_width")) { |
| 283 |
value_resolved = FALSE; |
| 284 |
return -1; |
| 285 |
#endif |
| 286 |
#endif |
| 287 |
} else if (!strcmp(value, "unixtime")) { |
| 288 |
return (time(NULL)); |
| 289 |
} else if (validate(value)) { |
| 290 |
return (atoi(value)); |
| 291 |
} else if (((resolved_string = string_resolve(value)) != NULL) && validate(resolved_string->value)) { |
| 292 |
return (atoi(resolved_string->value)); |
| 293 |
} else if ((resolved_cinteger = cinteger_resolve(value)) != NULL) { |
| 294 |
return (resolved_cinteger->value); |
| 295 |
} else if ((resolved_integer = integer_resolve(value)) != NULL) { |
| 296 |
return (resolved_integer->value); |
| 297 |
} else if (function_resolve(value) != NULL) { |
| 298 |
return (execute(value)); |
| 299 |
} else if (object_element_resolve(value)) { |
| 300 |
return (oec); |
| 301 |
} else if ((compare = attribute_resolve(value))) { |
| 302 |
resolved_attribute = SYSTEM_ATTRIBUTE; |
| 303 |
return (compare); |
| 304 |
} else if ((compare = user_attribute_resolve(value))) { |
| 305 |
resolved_attribute = USER_ATTRIBUTE; |
| 306 |
return (compare); |
| 307 |
} else if ((compare = object_resolve(value)) != -1) { |
| 308 |
return (compare); |
| 309 |
} else if (*value == '@') { |
| 310 |
return (count_resolve(value)); |
| 311 |
} else { |
| 312 |
if (run_time) { |
| 313 |
unkvarrun(value); |
| 314 |
} |
| 315 |
value_resolved = FALSE; |
| 316 |
return (-1); |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
struct integer_type * |
| 321 |
integer_resolve(const char *name) |
| 322 |
{ |
| 323 |
int index, |
| 324 |
iterator, |
| 325 |
counter; |
| 326 |
int delimiter = 0; |
| 327 |
char expression[84]; |
| 328 |
|
| 329 |
strncpy(expression, name, 80); |
| 330 |
|
| 331 |
counter = strlen(expression); |
| 332 |
|
| 333 |
for (index = 0; index < counter; index++) { |
| 334 |
if (expression[index] == '[') { |
| 335 |
|
| 336 |
|
| 337 |
expression[index] = 0; |
| 338 |
delimiter = index + 1; |
| 339 |
|
| 340 |
|
| 341 |
for (iterator = counter; iterator > 0; iterator--) { |
| 342 |
if (expression[iterator] == ']') { |
| 343 |
expression[iterator] = 0; |
| 344 |
break; |
| 345 |
} else if (expression[iterator] == '(') { |
| 346 |
|
| 347 |
return (FALSE); |
| 348 |
} |
| 349 |
} |
| 350 |
break; |
| 351 |
} else if (expression[index] == '<') { |
| 352 |
|
| 353 |
|
| 354 |
return (NULL); |
| 355 |
} else if (expression[index] == '(') { |
| 356 |
|
| 357 |
|
| 358 |
return (NULL); |
| 359 |
} else if (expression[index] == ' ') |
| 360 |
return (NULL); |
| 361 |
} |
| 362 |
|
| 363 |
|
| 364 |
if (delimiter == 0) { |
| 365 |
return (integer_resolve_indexed (name, 0)); |
| 366 |
} |
| 367 |
|
| 368 |
|
| 369 |
if (delimiter == 1) { |
| 370 |
return (NULL); |
| 371 |
} |
| 372 |
|
| 373 |
counter = value_of(&expression[delimiter], TRUE); |
| 374 |
|
| 375 |
if (counter > -1) { |
| 376 |
return (integer_resolve_indexed (expression, counter)); |
| 377 |
} else { |
| 378 |
|
| 379 |
return (NULL); |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
struct integer_type * |
| 384 |
integer_resolve_indexed(const char *name, int index) |
| 385 |
{ |
| 386 |
struct integer_type *pointer = integer_table; |
| 387 |
|
| 388 |
if (pointer == NULL) |
| 389 |
return (NULL); |
| 390 |
|
| 391 |
do { |
| 392 |
if (!strcmp(name, pointer->name)) { |
| 393 |
if (index == 0) { |
| 394 |
return (pointer); |
| 395 |
} else { |
| 396 |
|
| 397 |
|
| 398 |
pointer = pointer->next_integer; |
| 399 |
index--; |
| 400 |
} |
| 401 |
} else |
| 402 |
pointer = pointer->next_integer; |
| 403 |
} |
| 404 |
while (pointer != NULL); |
| 405 |
|
| 406 |
|
| 407 |
return (NULL); |
| 408 |
} |
| 409 |
|
| 410 |
struct cinteger_type * |
| 411 |
cinteger_resolve(const char *name) |
| 412 |
{ |
| 413 |
int index, |
| 414 |
iterator, |
| 415 |
counter; |
| 416 |
int delimiter = 0; |
| 417 |
char expression[84]; |
| 418 |
|
| 419 |
strncpy(expression, name, 80); |
| 420 |
|
| 421 |
counter = strlen(expression); |
| 422 |
|
| 423 |
for (index = 0; index < counter; index++) { |
| 424 |
if (expression[index] == '[') { |
| 425 |
|
| 426 |
|
| 427 |
expression[index] = 0; |
| 428 |
delimiter = index + 1; |
| 429 |
|
| 430 |
|
| 431 |
for (iterator = counter; iterator > 0; iterator--) { |
| 432 |
if (expression[iterator] == ']') { |
| 433 |
expression[iterator] = 0; |
| 434 |
break; |
| 435 |
} else if (expression[iterator] == '(') { |
| 436 |
|
| 437 |
return (FALSE); |
| 438 |
} |
| 439 |
} |
| 440 |
break; |
| 441 |
} else if (expression[index] == '<') { |
| 442 |
|
| 443 |
|
| 444 |
return (NULL); |
| 445 |
} else if (expression[index] == '(') { |
| 446 |
|
| 447 |
|
| 448 |
return (NULL); |
| 449 |
} else if (expression[index] == ' ') |
| 450 |
return (NULL); |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
if (delimiter == 0) { |
| 455 |
return (cinteger_resolve_indexed (name, 0)); |
| 456 |
} |
| 457 |
|
| 458 |
|
| 459 |
if (delimiter == 1) { |
| 460 |
return (NULL); |
| 461 |
} |
| 462 |
|
| 463 |
counter = value_of(&expression[delimiter], TRUE); |
| 464 |
|
| 465 |
if (counter > -1) { |
| 466 |
return (cinteger_resolve_indexed (expression, counter)); |
| 467 |
} else { |
| 468 |
|
| 469 |
return (NULL); |
| 470 |
} |
| 471 |
} |
| 472 |
|
| 473 |
struct cinteger_type * |
| 474 |
cinteger_resolve_indexed(const char *name, int index) |
| 475 |
{ |
| 476 |
struct cinteger_type *pointer = cinteger_table; |
| 477 |
|
| 478 |
if (pointer == NULL) |
| 479 |
return (NULL); |
| 480 |
|
| 481 |
do { |
| 482 |
if (!strcmp(name, pointer->name)) { |
| 483 |
if (index == 0) { |
| 484 |
return (pointer); |
| 485 |
} else { |
| 486 |
|
| 487 |
|
| 488 |
pointer = pointer->next_cinteger; |
| 489 |
index--; |
| 490 |
} |
| 491 |
} else |
| 492 |
pointer = pointer->next_cinteger; |
| 493 |
} |
| 494 |
while (pointer != NULL); |
| 495 |
|
| 496 |
|
| 497 |
return (NULL); |
| 498 |
} |
| 499 |
|
| 500 |
struct string_type * |
| 501 |
string_resolve(const char *name) |
| 502 |
{ |
| 503 |
int index, |
| 504 |
iterator, |
| 505 |
counter; |
| 506 |
int delimiter = 0; |
| 507 |
char expression[84]; |
| 508 |
|
| 509 |
strncpy(expression, name, 80); |
| 510 |
|
| 511 |
counter = strlen(expression); |
| 512 |
|
| 513 |
for (index = 0; index < counter; index++) { |
| 514 |
if (expression[index] == '[') { |
| 515 |
expression[index] = 0; |
| 516 |
delimiter = index + 1; |
| 517 |
for (iterator = counter; iterator > 0; iterator--) { |
| 518 |
if (expression[iterator] == ']') { |
| 519 |
expression[iterator] = 0; |
| 520 |
break; |
| 521 |
} |
| 522 |
} |
| 523 |
break; |
| 524 |
} else if (expression[index] == '<') { |
| 525 |
|
| 526 |
|
| 527 |
return (NULL); |
| 528 |
} else if (expression[index] == '(') { |
| 529 |
|
| 530 |
|
| 531 |
return (NULL); |
| 532 |
} else if (expression[index] == ' ') |
| 533 |
return (NULL); |
| 534 |
} |
| 535 |
|
| 536 |
if (delimiter == 0) { |
| 537 |
|
| 538 |
return (string_resolve_indexed (name, 0)); |
| 539 |
} |
| 540 |
|
| 541 |
if (delimiter == 1) { |
| 542 |
|
| 543 |
return (NULL); |
| 544 |
} |
| 545 |
|
| 546 |
counter = value_of(&expression[delimiter], TRUE); |
| 547 |
|
| 548 |
if (counter > -1) { |
| 549 |
return (string_resolve_indexed (expression, counter)); |
| 550 |
} else |
| 551 |
return (NULL); |
| 552 |
} |
| 553 |
|
| 554 |
struct string_type * |
| 555 |
string_resolve_indexed(const char *name, int index) |
| 556 |
{ |
| 557 |
struct string_type *pointer = string_table; |
| 558 |
|
| 559 |
if (pointer == NULL) |
| 560 |
return (NULL); |
| 561 |
|
| 562 |
do { |
| 563 |
if (!strcmp(name, pointer->name)) { |
| 564 |
if (index == 0) { |
| 565 |
return (pointer); |
| 566 |
} else { |
| 567 |
|
| 568 |
|
| 569 |
pointer = pointer->next_string; |
| 570 |
index--; |
| 571 |
} |
| 572 |
} else { |
| 573 |
pointer = pointer->next_string; |
| 574 |
} |
| 575 |
} |
| 576 |
while (pointer != NULL); |
| 577 |
|
| 578 |
return (NULL); |
| 579 |
} |
| 580 |
|
| 581 |
struct string_type * |
| 582 |
cstring_resolve(const char *name) |
| 583 |
{ |
| 584 |
int index, |
| 585 |
iterator, |
| 586 |
counter; |
| 587 |
int delimiter = 0; |
| 588 |
char expression[84]; |
| 589 |
|
| 590 |
strncpy(expression, name, 80); |
| 591 |
|
| 592 |
counter = strlen(expression); |
| 593 |
|
| 594 |
for (index = 0; index < counter; index++) { |
| 595 |
if (expression[index] == '[') { |
| 596 |
expression[index] = 0; |
| 597 |
delimiter = index + 1; |
| 598 |
for (iterator = counter; iterator > 0; iterator--) { |
| 599 |
if (expression[iterator] == ']') { |
| 600 |
expression[iterator] = 0; |
| 601 |
break; |
| 602 |
} |
| 603 |
} |
| 604 |
break; |
| 605 |
} else if (expression[index] == '<') { |
| 606 |
|
| 607 |
|
| 608 |
return (NULL); |
| 609 |
} else if (expression[index] == '(') { |
| 610 |
|
| 611 |
|
| 612 |
return (NULL); |
| 613 |
} else if (expression[index] == ' ') |
| 614 |
return (NULL); |
| 615 |
} |
| 616 |
|
| 617 |
if (delimiter == 0) { |
| 618 |
|
| 619 |
return (cstring_resolve_indexed (name, 0)); |
| 620 |
} |
| 621 |
|
| 622 |
if (delimiter == 1) { |
| 623 |
|
| 624 |
return (NULL); |
| 625 |
} |
| 626 |
|
| 627 |
counter = value_of(&expression[delimiter], TRUE); |
| 628 |
|
| 629 |
if (counter > -1) { |
| 630 |
return (cstring_resolve_indexed (expression, counter)); |
| 631 |
} else |
| 632 |
return (NULL); |
| 633 |
} |
| 634 |
|
| 635 |
struct string_type * |
| 636 |
cstring_resolve_indexed(const char *name, int index) |
| 637 |
{ |
| 638 |
struct string_type *pointer = cstring_table; |
| 639 |
|
| 640 |
if (pointer == NULL) |
| 641 |
return (NULL); |
| 642 |
|
| 643 |
do { |
| 644 |
if (!strcmp(name, pointer->name)) { |
| 645 |
if (index == 0) { |
| 646 |
return (pointer); |
| 647 |
} else { |
| 648 |
|
| 649 |
|
| 650 |
pointer = pointer->next_string; |
| 651 |
index--; |
| 652 |
} |
| 653 |
} else { |
| 654 |
pointer = pointer->next_string; |
| 655 |
} |
| 656 |
} |
| 657 |
while (pointer != NULL); |
| 658 |
|
| 659 |
return (NULL); |
| 660 |
} |
| 661 |
|
| 662 |
struct function_type * |
| 663 |
function_resolve(const char *name) |
| 664 |
{ |
| 665 |
char *full_name; |
| 666 |
char core_name[84]; |
| 667 |
int index; |
| 668 |
|
| 669 |
struct function_type *pointer = function_table; |
| 670 |
|
| 671 |
if (function_table == NULL) |
| 672 |
return (NULL); |
| 673 |
|
| 674 |
|
| 675 |
index = 0; |
| 676 |
|
| 677 |
while (*name && index < 80) { |
| 678 |
if (*name == '<') { |
| 679 |
break; |
| 680 |
} else { |
| 681 |
core_name[index++] = *name++; |
| 682 |
} |
| 683 |
} |
| 684 |
core_name[index] = 0; |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
full_name = (char *) expand_function(core_name); |
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
do { |
| 693 |
if (!strcmp(full_name, pointer->name)) |
| 694 |
return (pointer); |
| 695 |
else |
| 696 |
pointer = pointer->next_function; |
| 697 |
} |
| 698 |
while (pointer != NULL); |
| 699 |
|
| 700 |
|
| 701 |
return (NULL); |
| 702 |
} |
| 703 |
|
| 704 |
const char * |
| 705 |
expand_function(const char *name) |
| 706 |
{ |
| 707 |
|
| 708 |
|
| 709 |
int index, |
| 710 |
counter; |
| 711 |
int delimiter = 0; |
| 712 |
char expression[84]; |
| 713 |
|
| 714 |
strncpy(expression, name, 80); |
| 715 |
|
| 716 |
counter = strlen(expression); |
| 717 |
|
| 718 |
for (index = 0; index < counter; index++) { |
| 719 |
if (expression[index] == '.') { |
| 720 |
expression[index] = 0; |
| 721 |
delimiter = index + 1; |
| 722 |
break; |
| 723 |
} |
| 724 |
} |
| 725 |
|
| 726 |
if (delimiter == FALSE) { |
| 727 |
|
| 728 |
return (arg_text_of(name)); |
| 729 |
} |
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
index = value_of(expression, TRUE); |
| 735 |
|
| 736 |
if (index < 1 || index > objects) { |
| 737 |
return ((char *) name); |
| 738 |
} |
| 739 |
|
| 740 |
if (cinteger_resolve(&expression[delimiter]) != NULL || |
| 741 |
integer_resolve(&expression[delimiter]) != NULL || |
| 742 |
object_element_resolve(&expression[delimiter])) { |
| 743 |
|
| 744 |
|
| 745 |
sprintf(function_name, "%ld", value_of(&expression[delimiter], TRUE)); |
| 746 |
} else { |
| 747 |
strcpy(function_name, &expression[delimiter]); |
| 748 |
} |
| 749 |
strcat(function_name, "_"); |
| 750 |
strcat(function_name, object[index]->label); |
| 751 |
|
| 752 |
return ((char *) function_name); |
| 753 |
} |
| 754 |
|
| 755 |
char * |
| 756 |
macro_resolve(const char *testString) |
| 757 |
{ |
| 758 |
int index, |
| 759 |
counter; |
| 760 |
int delimiter = 0; |
| 761 |
char expression[84]; |
| 762 |
|
| 763 |
strncpy(expression, testString, 80); |
| 764 |
|
| 765 |
counter = strlen(expression); |
| 766 |
|
| 767 |
for (index = 0; index < counter; index++) { |
| 768 |
if (expression[index] == '{' || expression[index] == '}') { |
| 769 |
expression[index] = 0; |
| 770 |
if (!delimiter) |
| 771 |
delimiter = index + 1; |
| 772 |
} |
| 773 |
} |
| 774 |
|
| 775 |
if (delimiter == FALSE) |
| 776 |
return (NULL); |
| 777 |
|
| 778 |
if (*expression != 0) { |
| 779 |
index = value_of(expression, TRUE); |
| 780 |
} else { |
| 781 |
index = 0; |
| 782 |
} |
| 783 |
|
| 784 |
if (!strcmp(&expression[delimiter], "list")) { |
| 785 |
if (index < 1 || index > objects) { |
| 786 |
badptrrun(expression, index); |
| 787 |
return (NULL); |
| 788 |
} else { |
| 789 |
return (list_output(index, FALSE)); |
| 790 |
} |
| 791 |
} else if (!strcmp(&expression[delimiter], "plain")) { |
| 792 |
if (index < 1 || index > objects) { |
| 793 |
badptrrun(expression, index); |
| 794 |
return (NULL); |
| 795 |
} else { |
| 796 |
return (plain_output(index, FALSE)); |
| 797 |
} |
| 798 |
} else if (!strcmp(&expression[delimiter], "long")) { |
| 799 |
if (index < 1 || index > objects) { |
| 800 |
badptrrun(expression, index); |
| 801 |
return (NULL); |
| 802 |
} else { |
| 803 |
return (long_output(index)); |
| 804 |
} |
| 805 |
} else if (!strcmp(&expression[delimiter], "sub")) { |
| 806 |
if (index < 1 || index > objects) { |
| 807 |
badptrrun(expression, index); |
| 808 |
return (NULL); |
| 809 |
} else { |
| 810 |
return (sub_output(index, FALSE)); |
| 811 |
} |
| 812 |
} else if (!strcmp(&expression[delimiter], "obj")) { |
| 813 |
if (index < 1 || index > objects) { |
| 814 |
badptrrun(expression, index); |
| 815 |
return (NULL); |
| 816 |
} else { |
| 817 |
return (obj_output(index, FALSE)); |
| 818 |
} |
| 819 |
} else if (!strcmp(&expression[delimiter], "that")) { |
| 820 |
if (index < 1 || index > objects) { |
| 821 |
badptrrun(expression, index); |
| 822 |
return (NULL); |
| 823 |
} else { |
| 824 |
return (that_output(index, FALSE)); |
| 825 |
} |
| 826 |
} else if (!strcmp(&expression[delimiter], "it")) { |
| 827 |
if (index < 1 || index > objects) { |
| 828 |
badptrrun(expression, index); |
| 829 |
return (NULL); |
| 830 |
} else { |
| 831 |
return (it_output(index)); |
| 832 |
} |
| 833 |
} else if (!strcmp(&expression[delimiter], "doesnt")) { |
| 834 |
if (index < 1 || index > objects) { |
| 835 |
badptrrun(expression, index); |
| 836 |
return (NULL); |
| 837 |
} else { |
| 838 |
return (doesnt_output(index)); |
| 839 |
} |
| 840 |
} else if (!strcmp(&expression[delimiter], "does")) { |
| 841 |
if (index < 1 || index > objects) { |
| 842 |
badptrrun(expression, index); |
| 843 |
return (NULL); |
| 844 |
} else { |
| 845 |
return (does_output(index)); |
| 846 |
} |
| 847 |
} else if (!strcmp(&expression[delimiter], "isnt")) { |
| 848 |
if (index < 1 || index > objects) { |
| 849 |
badptrrun(expression, index); |
| 850 |
return (NULL); |
| 851 |
} else { |
| 852 |
return (isnt_output(index)); |
| 853 |
} |
| 854 |
} else if (!strcmp(&expression[delimiter], "is")) { |
| 855 |
if (index < 1 || index > objects) { |
| 856 |
badptrrun(expression, index); |
| 857 |
return (NULL); |
| 858 |
} else { |
| 859 |
return (is_output(index)); |
| 860 |
} |
| 861 |
} else if (!strcmp(&expression[delimiter], "the")) { |
| 862 |
if (index < 1 || index > objects) { |
| 863 |
badptrrun(expression, index); |
| 864 |
return (NULL); |
| 865 |
} else { |
| 866 |
return (sentence_output(index, FALSE)); |
| 867 |
} |
| 868 |
} else if (!strcmp(&expression[delimiter], "s")) { |
| 869 |
if (index < 1 || index > objects) { |
| 870 |
badptrrun(expression, index); |
| 871 |
return (NULL); |
| 872 |
} else { |
| 873 |
if (object[index]->attributes & PLURAL) { |
| 874 |
strcpy(temp_buffer, ""); |
| 875 |
} else { |
| 876 |
strcpy(temp_buffer, "s"); |
| 877 |
} |
| 878 |
return (temp_buffer); |
| 879 |
} |
| 880 |
} else if (!strcmp(&expression[delimiter], "names")) { |
| 881 |
if (index < 1 || index > objects) { |
| 882 |
badptrrun(expression, index); |
| 883 |
return (NULL); |
| 884 |
} else { |
| 885 |
return (object_names(index, temp_buffer)); |
| 886 |
} |
| 887 |
} else if (!strcmp(&expression[delimiter], "label")) { |
| 888 |
if (index < 1 || index > objects) { |
| 889 |
badptrrun(expression, index); |
| 890 |
return (NULL); |
| 891 |
} else { |
| 892 |
return (object[index]->label); |
| 893 |
} |
| 894 |
} else if (!strcmp(&expression[delimiter], "List")) { |
| 895 |
if (index < 1 || index > objects) { |
| 896 |
badptrrun(expression, index); |
| 897 |
return (NULL); |
| 898 |
} else { |
| 899 |
return (list_output(index, TRUE)); |
| 900 |
} |
| 901 |
} else if (!strcmp(&expression[delimiter], "Plain")) { |
| 902 |
if (index < 1 || index > objects) { |
| 903 |
badptrrun(expression, index); |
| 904 |
return (NULL); |
| 905 |
} else { |
| 906 |
return (plain_output(index, TRUE)); |
| 907 |
} |
| 908 |
} else if (!strcmp(&expression[delimiter], "Sub")) { |
| 909 |
if (index < 1 || index > objects) { |
| 910 |
badptrrun(expression, index); |
| 911 |
return (NULL); |
| 912 |
} else { |
| 913 |
return (sub_output(index, TRUE)); |
| 914 |
} |
| 915 |
} else if (!strcmp(&expression[delimiter], "Obj")) { |
| 916 |
if (index < 1 || index > objects) { |
| 917 |
badptrrun(expression, index); |
| 918 |
return (NULL); |
| 919 |
} else { |
| 920 |
return (obj_output(index, TRUE)); |
| 921 |
} |
| 922 |
} else if (!strcmp(&expression[delimiter], "That")) { |
| 923 |
if (index < 1 || index > objects) { |
| 924 |
badptrrun(expression, index); |
| 925 |
return (NULL); |
| 926 |
} else { |
| 927 |
return (that_output(index, TRUE)); |
| 928 |
} |
| 929 |
} else if (!strcmp(&expression[delimiter], "It")) { |
| 930 |
if (index < 1 || index > objects) { |
| 931 |
badptrrun(expression, index); |
| 932 |
return (NULL); |
| 933 |
} else { |
| 934 |
return (it_output(index)); |
| 935 |
} |
| 936 |
} else if (!strcmp(&expression[delimiter], "Doesnt")) { |
| 937 |
if (index < 1 || index > objects) { |
| 938 |
badptrrun(expression, index); |
| 939 |
return (NULL); |
| 940 |
} else { |
| 941 |
return (doesnt_output(index)); |
| 942 |
} |
| 943 |
} else if (!strcmp(&expression[delimiter], "Does")) { |
| 944 |
if (index < 1 || index > objects) { |
| 945 |
badptrrun(expression, index); |
| 946 |
return (NULL); |
| 947 |
} else { |
| 948 |
return (does_output(index)); |
| 949 |
} |
| 950 |
} else if (!strcmp(&expression[delimiter], "Isnt")) { |
| 951 |
if (index < 1 || index > objects) { |
| 952 |
badptrrun(expression, index); |
| 953 |
return (NULL); |
| 954 |
} else { |
| 955 |
return (isnt_output(index)); |
| 956 |
} |
| 957 |
} else if (!strcmp(&expression[delimiter], "Is")) { |
| 958 |
if (index < 1 || index > objects) { |
| 959 |
badptrrun(expression, index); |
| 960 |
return (NULL); |
| 961 |
} else { |
| 962 |
return (is_output(index)); |
| 963 |
} |
| 964 |
} else if (!strcmp(&expression[delimiter], "The")) { |
| 965 |
if (index < 1 || index > objects) { |
| 966 |
badptrrun(expression, index); |
| 967 |
return (NULL); |
| 968 |
} else { |
| 969 |
return (sentence_output(index, TRUE)); |
| 970 |
} |
| 971 |
} else { |
| 972 |
strcpy (macro_function, "+macro_"); |
| 973 |
strcat (macro_function, &expression[delimiter]); |
| 974 |
strcat (macro_function, "<"); |
| 975 |
sprintf (temp_buffer, "%d", index); |
| 976 |
strcat (macro_function, temp_buffer); |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
if (execute(macro_function)) { |
| 981 |
return (string_resolve("return_value")->value); |
| 982 |
} |
| 983 |
} |
| 984 |
|
| 985 |
return (NULL); |
| 986 |
} |
| 987 |
|
| 988 |
int |
| 989 |
count_resolve(const char *testString) |
| 990 |
{ |
| 991 |
struct function_type *resolved_function = NULL; |
| 992 |
|
| 993 |
if (*(testString + 1) == 0) { |
| 994 |
|
| 995 |
|
| 996 |
return (executing_function->call_count); |
| 997 |
} else if ((resolved_function = function_resolve(testString + 1)) != NULL) { |
| 998 |
return (resolved_function->call_count); |
| 999 |
} else { |
| 1000 |
return array_length_resolve(testString); |
| 1001 |
} |
| 1002 |
} |
| 1003 |
|
| 1004 |
int |
| 1005 |
array_length_resolve(const char *testString) |
| 1006 |
{ |
| 1007 |
int counter = 0; |
| 1008 |
const char *array_name = &testString[1]; |
| 1009 |
|
| 1010 |
struct integer_type *integer_pointer = integer_table; |
| 1011 |
struct cinteger_type *cinteger_pointer = cinteger_table; |
| 1012 |
struct string_type *string_pointer = string_table; |
| 1013 |
struct string_type *cstring_pointer = cstring_table; |
| 1014 |
|
| 1015 |
if (integer_pointer != NULL) { |
| 1016 |
do { |
| 1017 |
if (!strcmp(array_name, integer_pointer->name)) { |
| 1018 |
counter++; |
| 1019 |
} |
| 1020 |
integer_pointer = integer_pointer->next_integer; |
| 1021 |
} |
| 1022 |
while (integer_pointer != NULL); |
| 1023 |
} |
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
if (counter) |
| 1028 |
return (counter); |
| 1029 |
|
| 1030 |
if (string_pointer != NULL) { |
| 1031 |
do { |
| 1032 |
if (!strcmp(array_name, string_pointer->name)) { |
| 1033 |
counter++; |
| 1034 |
} |
| 1035 |
string_pointer = string_pointer->next_string; |
| 1036 |
} |
| 1037 |
while (string_pointer != NULL); |
| 1038 |
} |
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
if (counter) |
| 1043 |
return (counter); |
| 1044 |
|
| 1045 |
if (cinteger_pointer != NULL) { |
| 1046 |
do { |
| 1047 |
if (!strcmp(array_name, cinteger_pointer->name)) { |
| 1048 |
counter++; |
| 1049 |
} |
| 1050 |
cinteger_pointer = cinteger_pointer->next_cinteger; |
| 1051 |
} |
| 1052 |
while (cinteger_pointer != NULL); |
| 1053 |
} |
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
if (counter) |
| 1058 |
return (counter); |
| 1059 |
|
| 1060 |
if (cstring_pointer != NULL) { |
| 1061 |
do { |
| 1062 |
if (!strcmp(array_name, cstring_pointer->name)) { |
| 1063 |
counter++; |
| 1064 |
} |
| 1065 |
cstring_pointer = cstring_pointer->next_string; |
| 1066 |
} |
| 1067 |
while (cstring_pointer != NULL); |
| 1068 |
} |
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
if (counter) |
| 1073 |
return (counter); |
| 1074 |
|
| 1075 |
|
| 1076 |
return (0); |
| 1077 |
} |
| 1078 |
|
| 1079 |
int |
| 1080 |
object_element_resolve(const char *testString) |
| 1081 |
{ |
| 1082 |
int index, |
| 1083 |
iterator, |
| 1084 |
counter; |
| 1085 |
int delimiter = 0; |
| 1086 |
char expression[84]; |
| 1087 |
|
| 1088 |
struct integer_type *resolved_integer; |
| 1089 |
struct cinteger_type *resolved_cinteger; |
| 1090 |
|
| 1091 |
strncpy(expression, testString, 80); |
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
counter = strlen(expression); |
| 1097 |
|
| 1098 |
for (index = 0; index < counter; index++) { |
| 1099 |
if (expression[index] == '(') { |
| 1100 |
expression[index] = 0; |
| 1101 |
delimiter = index + 1; |
| 1102 |
for (iterator = counter; iterator > 0; iterator--) { |
| 1103 |
if (expression[iterator] == ')') { |
| 1104 |
expression[iterator] = 0; |
| 1105 |
break; |
| 1106 |
} |
| 1107 |
} |
| 1108 |
break; |
| 1109 |
} else if (expression[index] == '<') { |
| 1110 |
|
| 1111 |
|
| 1112 |
return (FALSE); |
| 1113 |
} else if (expression[index] == '[') { |
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
for (; index < counter; index++) { |
| 1120 |
if (expression[index] == ']') { |
| 1121 |
|
| 1122 |
break; |
| 1123 |
} else if (expression[index] == '(') { |
| 1124 |
|
| 1125 |
|
| 1126 |
return (FALSE); |
| 1127 |
} |
| 1128 |
} |
| 1129 |
} else if (expression[index] == ' ') |
| 1130 |
return (FALSE); |
| 1131 |
} |
| 1132 |
|
| 1133 |
|
| 1134 |
if (delimiter == FALSE || delimiter == 1) |
| 1135 |
return (FALSE); |
| 1136 |
|
| 1137 |
index = object_resolve(expression); |
| 1138 |
|
| 1139 |
if (index == -1) { |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
if ((resolved_integer = integer_resolve(expression)) != NULL) { |
| 1145 |
index = resolved_integer->value; |
| 1146 |
} else if ((resolved_cinteger = cinteger_resolve(expression)) != NULL) { |
| 1147 |
index = resolved_cinteger->value; |
| 1148 |
} |
| 1149 |
} |
| 1150 |
|
| 1151 |
if (index < 1 || index > objects) { |
| 1152 |
badptrrun(expression, index); |
| 1153 |
return (FALSE); |
| 1154 |
} |
| 1155 |
|
| 1156 |
counter = value_of(&expression[delimiter], TRUE); |
| 1157 |
|
| 1158 |
if (counter < 0 || counter > 15) { |
| 1159 |
sprintf(error_buffer, |
| 1160 |
"ERROR: In function \"%s\", element \"%s\" out of range (%d).^", |
| 1161 |
executing_function->name, &expression[delimiter], counter); |
| 1162 |
write_text(error_buffer); |
| 1163 |
return (FALSE); |
| 1164 |
} else { |
| 1165 |
oec = object[index]->integer[counter]; |
| 1166 |
object_element_address = &object[index]->integer[counter]; |
| 1167 |
return (TRUE); |
| 1168 |
} |
| 1169 |
} |
| 1170 |
|
| 1171 |
int |
| 1172 |
object_resolve(const char *object_string) |
| 1173 |
{ |
| 1174 |
int index; |
| 1175 |
|
| 1176 |
if (!strcmp(object_string, "noun1")) |
| 1177 |
return (noun[0]); |
| 1178 |
else if (!strcmp(object_string, "noun2")) |
| 1179 |
return (noun[1]); |
| 1180 |
else if (!strcmp(object_string, "noun3")) |
| 1181 |
return (noun[2]); |
| 1182 |
else if (!strcmp(object_string, "noun4")) |
| 1183 |
return (noun[3]); |
| 1184 |
else if (!strcmp(object_string, "player")) |
| 1185 |
return (player); |
| 1186 |
else if (!strcmp(object_string, "here")) |
| 1187 |
return (HERE); |
| 1188 |
else if (!strcmp(object_string, "self") || |
| 1189 |
!strcmp(object_string, "this")) { |
| 1190 |
if (executing_function != NULL && executing_function->self == 0) { |
| 1191 |
sprintf(error_buffer, |
| 1192 |
"ERROR: Reference to 'self' from global function \"%s\".^", |
| 1193 |
executing_function->name); |
| 1194 |
write_text(error_buffer); |
| 1195 |
} else |
| 1196 |
return (executing_function->self); |
| 1197 |
} else { |
| 1198 |
for (index = 1; index <= objects; index++) { |
| 1199 |
if (!strcmp(object_string, object[index]->label)) |
| 1200 |
return (index); |
| 1201 |
} |
| 1202 |
} |
| 1203 |
|
| 1204 |
return (-1); |
| 1205 |
} |
| 1206 |
|
| 1207 |
long |
| 1208 |
attribute_resolve(const char *attribute) |
| 1209 |
{ |
| 1210 |
unsigned int bit_mask; |
| 1211 |
|
| 1212 |
if (!strcmp(attribute, "VISITED")) |
| 1213 |
return (VISITED); |
| 1214 |
else if (!strcmp(attribute, "DARK")) |
| 1215 |
return (DARK); |
| 1216 |
else if (!strcmp(attribute, "ON_WATER")) |
| 1217 |
return (ON_WATER); |
| 1218 |
else if (!strcmp(attribute, "UNDER_WATER")) |
| 1219 |
return (UNDER_WATER); |
| 1220 |
else if (!strcmp(attribute, "WITHOUT_AIR")) |
| 1221 |
return (WITHOUT_AIR); |
| 1222 |
else if (!strcmp(attribute, "OUTDOORS")) |
| 1223 |
return (OUTDOORS); |
| 1224 |
else if (!strcmp(attribute, "MID_AIR")) |
| 1225 |
return (MID_AIR); |
| 1226 |
else if (!strcmp(attribute, "TIGHT_ROPE")) |
| 1227 |
return (TIGHT_ROPE); |
| 1228 |
else if (!strcmp(attribute, "POLLUTED")) |
| 1229 |
return (POLLUTED); |
| 1230 |
else if (!strcmp(attribute, "SOLVED")) |
| 1231 |
return (SOLVED); |
| 1232 |
else if (!strcmp(attribute, "MID_WATER")) |
| 1233 |
return (MID_WATER); |
| 1234 |
else if (!strcmp(attribute, "DARKNESS")) { |
| 1235 |
bit_mask = DARKNESS; |
| 1236 |
if (check_light(HERE)) { |
| 1237 |
bit_mask = ~bit_mask; |
| 1238 |
object[HERE]->attributes = object[HERE]->attributes & bit_mask; |
| 1239 |
} else { |
| 1240 |
object[HERE]->attributes = object[HERE]->attributes | bit_mask; |
| 1241 |
} |
| 1242 |
return (DARKNESS); |
| 1243 |
} else if (!strcmp(attribute, "MAPPED")) |
| 1244 |
return (MAPPED); |
| 1245 |
else if (!strcmp(attribute, "KNOWN")) |
| 1246 |
return (KNOWN); |
| 1247 |
else if (!strcmp(attribute, "CLOSED")) |
| 1248 |
return (CLOSED); |
| 1249 |
else if (!strcmp(attribute, "LOCKED")) |
| 1250 |
return (LOCKED); |
| 1251 |
else if (!strcmp(attribute, "DEAD")) |
| 1252 |
return (DEAD); |
| 1253 |
else if (!strcmp(attribute, "IGNITABLE")) |
| 1254 |
return (IGNITABLE); |
| 1255 |
else if (!strcmp(attribute, "WORN")) |
| 1256 |
return (WORN); |
| 1257 |
else if (!strcmp(attribute, "CONCEALING")) |
| 1258 |
return (CONCEALING); |
| 1259 |
else if (!strcmp(attribute, "LUMINOUS")) |
| 1260 |
return (LUMINOUS); |
| 1261 |
else if (!strcmp(attribute, "WEARABLE")) |
| 1262 |
return (WEARABLE); |
| 1263 |
else if (!strcmp(attribute, "CLOSABLE")) |
| 1264 |
return (CLOSABLE); |
| 1265 |
else if (!strcmp(attribute, "LOCKABLE")) |
| 1266 |
return (LOCKABLE); |
| 1267 |
else if (!strcmp(attribute, "ANIMATE")) |
| 1268 |
return (ANIMATE); |
| 1269 |
else if (!strcmp(attribute, "LIQUID")) |
| 1270 |
return (LIQUID); |
| 1271 |
else if (!strcmp(attribute, "CONTAINER")) |
| 1272 |
return (CONTAINER); |
| 1273 |
else if (!strcmp(attribute, "SURFACE")) |
| 1274 |
return (SURFACE); |
| 1275 |
else if (!strcmp(attribute, "PLURAL")) |
| 1276 |
return (PLURAL); |
| 1277 |
else if (!strcmp(attribute, "FLAMMABLE")) |
| 1278 |
return (FLAMMABLE); |
| 1279 |
else if (!strcmp(attribute, "BURNING")) |
| 1280 |
return (BURNING); |
| 1281 |
else if (!strcmp(attribute, "LOCATION")) |
| 1282 |
return (LOCATION); |
| 1283 |
else if (!strcmp(attribute, "ON")) |
| 1284 |
return (ON); |
| 1285 |
else if (!strcmp(attribute, "DAMAGED")) |
| 1286 |
return (DAMAGED); |
| 1287 |
else if (!strcmp(attribute, "FEMALE")) |
| 1288 |
return (FEMALE); |
| 1289 |
else if (!strcmp(attribute, "POSSESSIVE")) |
| 1290 |
return (POSSESSIVE); |
| 1291 |
else if (!strcmp(attribute, "OUT_OF_REACH")) |
| 1292 |
return (OUT_OF_REACH); |
| 1293 |
else if (!strcmp(attribute, "TOUCHED")) |
| 1294 |
return (TOUCHED); |
| 1295 |
else if (!strcmp(attribute, "SCORED")) |
| 1296 |
return (SCORED); |
| 1297 |
else if (!strcmp(attribute, "SITTING")) |
| 1298 |
return (SITTING); |
| 1299 |
else if (!strcmp(attribute, "NPC")) |
| 1300 |
return (NPC); |
| 1301 |
else if (!strcmp(attribute, "DONE")) |
| 1302 |
return (DONE); |
| 1303 |
else if (!strcmp(attribute, "GAS")) |
| 1304 |
return (MAPPED); |
| 1305 |
else if (!strcmp(attribute, "NO_TAB")) |
| 1306 |
return (NO_TAB); |
| 1307 |
else if (!strcmp(attribute, "NOT_IMPORTANT")) |
| 1308 |
return (NOT_IMPORTANT); |
| 1309 |
else |
| 1310 |
return (0); |
| 1311 |
} |
| 1312 |
|
| 1313 |
long |
| 1314 |
user_attribute_resolve(const char *name) |
| 1315 |
{ |
| 1316 |
struct attribute_type *pointer = attribute_table; |
| 1317 |
|
| 1318 |
if (pointer == NULL) |
| 1319 |
return (0); |
| 1320 |
|
| 1321 |
do { |
| 1322 |
if (!strcmp(name, pointer->name)) { |
| 1323 |
return (pointer->value); |
| 1324 |
} else |
| 1325 |
pointer = pointer->next_attribute; |
| 1326 |
} |
| 1327 |
while (pointer != NULL); |
| 1328 |
|
| 1329 |
|
| 1330 |
return (0); |
| 1331 |
} |