create paramameter table for script
| 434 | |
| 435 | // create paramameter table for script |
| 436 | int GenerateScriptParamInfo(int id, const char *script_text) { |
| 437 | char word[256]; |
| 438 | char saved_word[256]; |
| 439 | bool inword = false; |
| 440 | int index = 0; |
| 441 | int state = 0; |
| 442 | int i, strsize = strlen(script_text); |
| 443 | |
| 444 | for (i = 0; i < strsize; i++) { |
| 445 | char ch; |
| 446 | |
| 447 | ch = script_text[i]; |
| 448 | |
| 449 | if (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n' && ch != '(' && ch != ')' && ch != ',') { |
| 450 | // no whitespace |
| 451 | if (!inword) |
| 452 | inword = true; |
| 453 | if (inword) |
| 454 | word[index++] = ch; |
| 455 | } else { |
| 456 | // word is complete, check if a keyword |
| 457 | word[index] = 0; |
| 458 | // if we are in state 1, then we have PROBABLY FOUND a script name, make sure name matches |
| 459 | if (state == 0) { |
| 460 | // in parameter definition if we've reached a ')', reset state to start |
| 461 | if (Script_names[id].nparms == MAX_SCRPARAMS) { |
| 462 | OutrageMessageBox("Parameter parsing list size maxed."); |
| 463 | return i; |
| 464 | } else if (ch == ')') |
| 465 | break; |
| 466 | else if (inword) { |
| 467 | strcpy(saved_word, word); |
| 468 | state = 1; |
| 469 | } |
| 470 | } else if (state == 1) { |
| 471 | // in parameter name |
| 472 | if (inword) { |
| 473 | Script_names[id].add_parameter(saved_word, word); |
| 474 | state = 0; // read next parameter |
| 475 | } |
| 476 | if (ch == ')') |
| 477 | break; |
| 478 | } |
| 479 | index = 0; |
| 480 | inword = false; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | return i; |
| 485 | } |
| 486 | |
| 487 | char *GotoScriptInText(char *text, const char *script) { |
| 488 | char word[256]; |
no test coverage detected