From ab3d0bd39f7a64ef877ad32eee7ee76a267e08be Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 27 Oct 2012 02:27:28 +0000 Subject: [PATCH] Mark weapon related globals as const --- main/multi.c | 1 - main/weapon.c | 16 ++++++++-------- main/weapon.h | 16 ++++++---------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/main/multi.c b/main/multi.c index 223b56fb4..e77199c2e 100644 --- a/main/multi.c +++ b/main/multi.c @@ -2439,7 +2439,6 @@ multi_send_player_explode(char type) multi_strip_robots(Player_num); } -extern ubyte Secondary_weapon_to_powerup[], Primary_weapon_to_powerup[]; extern int Proximity_dropped; /* diff --git a/main/weapon.c b/main/weapon.c index c01de9c2c..2194c6c7a 100644 --- a/main/weapon.c +++ b/main/weapon.c @@ -31,21 +31,21 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "playsave.h" // Convert primary weapons to indices in Weapon_info array. -ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS] = {0, 11, 12, 13, 14}; -ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS] = {8, 15, 16, 17, 18}; +const ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS] = {0, 11, 12, 13, 14}; +const ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS] = {8, 15, 16, 17, 18}; //for each primary weapon, what kind of powerup gives weapon -ubyte Primary_weapon_to_powerup[MAX_PRIMARY_WEAPONS] = {POW_LASER,POW_VULCAN_WEAPON,POW_SPREADFIRE_WEAPON,POW_PLASMA_WEAPON,POW_FUSION_WEAPON}; +const ubyte Primary_weapon_to_powerup[MAX_PRIMARY_WEAPONS] = {POW_LASER,POW_VULCAN_WEAPON,POW_SPREADFIRE_WEAPON,POW_PLASMA_WEAPON,POW_FUSION_WEAPON}; //for each Secondary weapon, what kind of powerup gives weapon -ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS] = {POW_MISSILE_1,POW_HOMING_AMMO_1,POW_PROXIMITY_WEAPON,POW_SMARTBOMB_WEAPON,POW_MEGA_WEAPON}; -int Primary_ammo_max[MAX_PRIMARY_WEAPONS] = {0, VULCAN_AMMO_MAX, 0, 0, 0}; -ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS] = {20, 10, 10, 5, 5}; +const ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS] = {POW_MISSILE_1,POW_HOMING_AMMO_1,POW_PROXIMITY_WEAPON,POW_SMARTBOMB_WEAPON,POW_MEGA_WEAPON}; +const int Primary_ammo_max[MAX_PRIMARY_WEAPONS] = {0, VULCAN_AMMO_MAX, 0, 0, 0}; +const ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS] = {20, 10, 10, 5, 5}; weapon_info Weapon_info[MAX_WEAPON_TYPES]; int N_weapon_types=0; sbyte Primary_weapon, Secondary_weapon; int POrderList (int num); int SOrderList (int num); -ubyte DefaultPrimaryOrder[] = { 4, 3, 2, 1, 0, 255 }; -ubyte DefaultSecondaryOrder[] = { 4, 3, 1, 0, 255, 2 }; +static const ubyte DefaultPrimaryOrder[] = { 4, 3, 2, 1, 0, 255 }; +static const ubyte DefaultSecondaryOrder[] = { 4, 3, 1, 0, 255, 2 }; extern ubyte MenuReordering; // ------------------------------------------------------------------------------------ diff --git a/main/weapon.h b/main/weapon.h index 4bdfc9117..984f0d84e 100644 --- a/main/weapon.h +++ b/main/weapon.h @@ -131,21 +131,17 @@ extern void do_weapon_select(int weapon_num, int secondary_flag); extern sbyte Primary_weapon, Secondary_weapon; -extern ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS]; -extern ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS]; +extern const ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS]; +extern const ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS]; //for each primary weapon, what kind of powerup gives weapon -extern ubyte Primary_weapon_to_powerup[MAX_SECONDARY_WEAPONS]; +extern const ubyte Primary_weapon_to_powerup[MAX_SECONDARY_WEAPONS]; //for each Secondary weapon, what kind of powerup gives weapon -extern ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS]; +extern const ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS]; extern void auto_select_weapon(int weapon_type); //parm is primary or secondary extern void select_weapon(int weapon_num, int secondary_flag, int print_message,int wait_for_rearm); -extern char *Primary_weapon_names_short[]; -extern char *Secondary_weapon_names_short[]; -extern char *Primary_weapon_names[]; -extern char *Secondary_weapon_names[]; -extern int Primary_ammo_max[MAX_PRIMARY_WEAPONS]; -extern ubyte Secondary_ammo_max[MAX_PRIMARY_WEAPONS]; +extern const int Primary_ammo_max[MAX_PRIMARY_WEAPONS]; +extern const ubyte Secondary_ammo_max[MAX_PRIMARY_WEAPONS]; #define HAS_WEAPON_FLAG 1 #define HAS_ENERGY_FLAG 2