goes thru every entity that could possible have a weapon index (ie objects, weapons, etc) and changes the old index to the new index
| 773 | // goes thru every entity that could possible have a weapon index (ie objects, weapons, etc) |
| 774 | // and changes the old index to the new index |
| 775 | void RemapAllWeaponObjects(int old_index, int new_index) { |
| 776 | int i, j, k; |
| 777 | |
| 778 | // Remaps flying weapons |
| 779 | for (i = 0; i < MAX_OBJECTS; i++) { |
| 780 | |
| 781 | if (Objects[i].type == OBJ_WEAPON) { |
| 782 | if (Objects[i].id == old_index) { |
| 783 | Objects[i].id = new_index; |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | // Remaps weapons contained by generic objects |
| 789 | for (i = 0; i < MAX_OBJECT_IDS; i++) { |
| 790 | if (Object_info[i].static_wb) { |
| 791 | for (j = 0; j < MAX_WBS_PER_OBJ; j++) { |
| 792 | for (k = 0; k < MAX_WB_GUNPOINTS; k++) { |
| 793 | if (Object_info[i].static_wb[j].gp_weapon_index[k] == old_index) { |
| 794 | Object_info[i].static_wb[j].gp_weapon_index[k] = new_index; |
| 795 | } |
| 796 | } |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | // Remaps weapons contained by Ships |
| 802 | for (i = 0; i < MAX_SHIPS; i++) { |
| 803 | for (j = 0; j < MAX_WBS_PER_OBJ; j++) { |
| 804 | for (k = 0; k < MAX_WB_FIRING_MASKS; k++) { |
| 805 | if (Ships[i].static_wb[j].gp_weapon_index[k] == old_index) { |
| 806 | Ships[i].static_wb[j].gp_weapon_index[k] = new_index; |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | // Do spawns |
| 813 | for (i = 0; i < MAX_WEAPONS; i++) { |
| 814 | if (!Weapons[i].used) |
| 815 | continue; |
| 816 | |
| 817 | if (Weapons[i].spawn_handle == old_index) |
| 818 | Weapons[i].spawn_handle = new_index; |
| 819 | if (Weapons[i].alternate_spawn_handle == old_index) |
| 820 | Weapons[i].alternate_spawn_handle = new_index; |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | bool IsWeaponSecondary(int index) { |
| 825 | if (index < SECONDARY_INDEX) |