Build a translation table for various items
| 2632 | |
| 2633 | // Build a translation table for various items |
| 2634 | void BuildXlateTable(CFILE *ifile, int (*lookup_func)(const char *), int16_t *xlate_table, int max_items, int type) { |
| 2635 | char name[PAGENAME_LEN]; |
| 2636 | int n; |
| 2637 | int i; |
| 2638 | |
| 2639 | n = cf_ReadInt(ifile); // get num items |
| 2640 | for (i = 0; i < n; i++) { |
| 2641 | |
| 2642 | cf_ReadString(name, sizeof(name), ifile); // get old name |
| 2643 | |
| 2644 | if (!name[0]) // if null name, don't look up |
| 2645 | xlate_table[i] = -1; |
| 2646 | else { // look up, and warn if not found |
| 2647 | xlate_table[i] = lookup_func(name); // returns -1 if not found |
| 2648 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2649 | if ((xlate_table[i] == -1) && (type != -1)) |
| 2650 | AddFailedXLateItem(type, i, name); |
| 2651 | #endif |
| 2652 | } |
| 2653 | } |
| 2654 | for (; i < max_items; i++) // clear out rest of array |
| 2655 | xlate_table[i] = -1; |
| 2656 | } |
| 2657 | |
| 2658 | #define ISCHUNK(name) (!strncmp(chunk_name, name, 4)) |
| 2659 |
no test coverage detected