This is a very confusing function. It takes all the weapons that we have loaded and remaps then into their proper places (if they are static).
| 714 | // This is a very confusing function. It takes all the weapons that we have loaded |
| 715 | // and remaps then into their proper places (if they are static). |
| 716 | void RemapWeapons() { |
| 717 | int limit = sizeof(Static_weapon_names) / sizeof(void *); |
| 718 | int i; |
| 719 | |
| 720 | for (i = 0; i < MAX_STATIC_WEAPONS; i++) { |
| 721 | if (Weapons[i].used) { |
| 722 | int match = -1; |
| 723 | for (int t = 0; t < limit; t++) |
| 724 | if (!stricmp(Weapons[i].name, Static_weapon_names[t])) { |
| 725 | match = t; |
| 726 | break; |
| 727 | } |
| 728 | |
| 729 | if (match == -1) // this weapon is not supposed to be in the static area |
| 730 | { |
| 731 | int new_index; |
| 732 | |
| 733 | new_index = MoveWeaponFromIndex(i); |
| 734 | RemapAllWeaponObjects(i, new_index); |
| 735 | } else // this weapon is a static weapon, make sure its in its place |
| 736 | { |
| 737 | if (i != match) // its not where it belongs, move it |
| 738 | { |
| 739 | int new_index; |
| 740 | |
| 741 | new_index = MatchWeaponToIndex(Weapons[i].name, match); |
| 742 | |
| 743 | if (new_index != 0) |
| 744 | RemapAllWeaponObjects(match, new_index); |
| 745 | RemapAllWeaponObjects(i, match); |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | for (i = MAX_STATIC_WEAPONS; i < MAX_WEAPONS; i++) { |
| 752 | if (Weapons[i].used) { |
| 753 | int match = -1; |
| 754 | for (int t = 0; t < limit; t++) |
| 755 | if (!stricmp(Weapons[i].name, Static_weapon_names[t])) { |
| 756 | match = t; |
| 757 | break; |
| 758 | } |
| 759 | |
| 760 | if (match != -1) // this is a static weapon that isn't supposed to be in the free area |
| 761 | { |
| 762 | |
| 763 | int new_index; |
| 764 | new_index = MatchWeaponToIndex(Weapons[i].name, match); |
| 765 | if (new_index != 0) |
| 766 | RemapAllWeaponObjects(match, new_index); |
| 767 | RemapAllWeaponObjects(i, match); |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | // goes thru every entity that could possible have a weapon index (ie objects, weapons, etc) |
no test coverage detected