Commits

wifiman committed a7524aa

Made itemlist const.

Comments (0)

Files changed (10)

 {
 	gclient_t	*cl;
 	int			i, index;
-	gitem_t		*it;
+	const gitem_t *it;
 
 	cl = ent->client;
 
 {
 	gclient_t	*cl;
 	int			i, index;
-	gitem_t		*it;
+	const gitem_t *it;
 
 	cl = ent->client;
 
 static void Cmd_Give_f (edict_t *ent)
 {
 	char		*name;
-	gitem_t		*it;
+	const gitem_t *it;
 	int			index;
 	int			i;
 	qboolean	give_all;
 static void Cmd_Use_f (edict_t *ent)
 {
 	int			index;
-	gitem_t		*it;
+	const gitem_t *it;
 	char		*s;
 
 	if (ent->client->resp.spectator)
 static void Cmd_Drop_f (edict_t *ent)
 {
 	int			index;
-	gitem_t		*it;
+	const gitem_t *it;
 	char		*s;
 
 	if (ent->client->resp.spectator)
 */
 static void Cmd_InvUse_f (edict_t *ent)
 {
-	gitem_t		*it;
+	const gitem_t *it;
 
 	ValidateSelectedItem (ent);
 
 {
 	gclient_t	*cl;
 	int			i, index;
-	gitem_t		*it;
+	const gitem_t *it;
 	int			selected_weapon;
 
 	cl = ent->client;
 {
 	gclient_t	*cl;
 	int			i, index;
-	gitem_t		*it;
+	const gitem_t *it;
 	int			selected_weapon;
 
 	cl = ent->client;
 {
 	gclient_t	*cl;
 	int			index;
-	gitem_t		*it;
+	const gitem_t *it;
 
 	cl = ent->client;
 
 */
 static void Cmd_InvDrop_f (edict_t *ent)
 {
-	gitem_t		*it;
+	const gitem_t *it;
 
 	ValidateSelectedItem (ent);
 
 	gclient_t	*client;
 	int			save;
 	int			index;
-	gitem_t		*armor;
+	const gitem_t *armor;
 
 	if (!damage)
 		return 0;
 
 
 qboolean	Pickup_Weapon (edict_t *ent, edict_t *other);
-void		Use_Weapon (edict_t *ent, gitem_t *inv);
-void		Drop_Weapon (edict_t *ent, gitem_t *inv);
+void Use_Weapon (edict_t *ent, const gitem_t *inv);
+void Drop_Weapon (edict_t *ent, const gitem_t *inv);
 
 void Weapon_Blaster (edict_t *ent);
 void Weapon_Shotgun (edict_t *ent);
 #define HEALTH_IGNORE_MAX	1
 #define HEALTH_TIMED		2
 
-void Use_Quad (edict_t *ent, gitem_t *item);
+void Use_Quad (edict_t *ent, const gitem_t *item);
 static int	quad_drop_timeout_hack;
 
 //======================================================================
 GetItemByIndex
 ===============
 */
-gitem_t	*GetItemByIndex (int index)
+const gitem_t *GetItemByIndex (int index)
 {
 	if (index == 0 || index >= game.num_items)
 		return NULL;
 
 ===============
 */
-gitem_t	*FindItemByClassname (const char *classname)
+const gitem_t *FindItemByClassname (const char *classname)
 {
 	int		i;
-	gitem_t	*it;
+	const gitem_t *it;
 
 	it = itemlist;
 	for (i=0 ; i<game.num_items ; i++, it++)
 
 ===============
 */
-gitem_t	*FindItem (const char *pickup_name)
+const gitem_t *FindItem (const char *pickup_name)
 {
 	int		i;
-	gitem_t	*it;
+	const gitem_t *it;
 
 	it = itemlist;
 	for (i=0 ; i<game.num_items ; i++, it++)
 	return true;
 }
 
-void Drop_General (edict_t *ent, gitem_t *item)
+void Drop_General (edict_t *ent, const gitem_t *item)
 {
 	Drop_Item (ent, item);
 	ent->client->pers.inventory[ITEM_INDEX(item)]--;
 
 qboolean Pickup_Bandolier (edict_t *ent, edict_t *other)
 {
-	gitem_t	*item;
+	const gitem_t *item;
 	int		index;
 
 	if (other->client->pers.max_bullets < 250)
 
 qboolean Pickup_Pack (edict_t *ent, edict_t *other)
 {
-	gitem_t	*item;
+	const gitem_t *item;
 	int		index;
 
 	if (other->client->pers.max_bullets < 300)
 
 //======================================================================
 
-void Use_Quad (edict_t *ent, gitem_t *item)
+void Use_Quad (edict_t *ent, const gitem_t *item)
 {
 	int		timeout;
 
 
 //======================================================================
 
-void Use_Breather (edict_t *ent, gitem_t *item)
+void Use_Breather (edict_t *ent, const gitem_t *item)
 {
 	ent->client->pers.inventory[ITEM_INDEX(item)]--;
 	ValidateSelectedItem (ent);
 
 //======================================================================
 
-void Use_Envirosuit (edict_t *ent, gitem_t *item)
+void Use_Envirosuit (edict_t *ent, const gitem_t *item)
 {
 	ent->client->pers.inventory[ITEM_INDEX(item)]--;
 	ValidateSelectedItem (ent);
 
 //======================================================================
 
-void	Use_Invulnerability (edict_t *ent, gitem_t *item)
+void Use_Invulnerability (edict_t *ent, const gitem_t *item)
 {
 	ent->client->pers.inventory[ITEM_INDEX(item)]--;
 	ValidateSelectedItem (ent);
 
 //======================================================================
 
-void	Use_Silencer (edict_t *ent, gitem_t *item)
+void Use_Silencer (edict_t *ent, const gitem_t *item)
 {
 	ent->client->pers.inventory[ITEM_INDEX(item)]--;
 	ValidateSelectedItem (ent);
 
 //======================================================================
 
-qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count)
+qboolean Add_Ammo (edict_t *ent, const gitem_t *item, int count)
 {
 	int			index;
 	int			max;
 	return true;
 }
 
-void Drop_Ammo (edict_t *ent, gitem_t *item)
+void Drop_Ammo (edict_t *ent, const gitem_t *item)
 {
 	edict_t	*dropped;
 	int		index;
 	return POWER_ARMOR_NONE;
 }
 
-void Use_PowerArmor (edict_t *ent, gitem_t *item)
+void Use_PowerArmor (edict_t *ent, const gitem_t *item)
 {
 	int		index;
 
 	return true;
 }
 
-void Drop_PowerArmor (edict_t *ent, gitem_t *item)
+void Drop_PowerArmor (edict_t *ent, const gitem_t *item)
 {
 	if ((ent->flags & FL_POWER_ARMOR) && (ent->client->pers.inventory[ITEM_INDEX(item)] == 1))
 		Use_PowerArmor (ent, item);
 	}
 }
 
-edict_t *Drop_Item (edict_t *ent, gitem_t *item)
+edict_t *Drop_Item (edict_t *ent, const gitem_t *item)
 {
 	edict_t	*dropped;
 	vec3_t	forward, right;
 and for each item in each client's inventory.
 ===============
 */
-void PrecacheItem (gitem_t *it)
+void PrecacheItem (const gitem_t *it)
 {
 	char	*s, *start;
 	char	data[MAX_QPATH];
 	int		len;
-	gitem_t	*ammo;
+	const gitem_t *ammo;
 
 	if (!it)
 		return;
 be on an entity that hasn't spawned yet.
 ============
 */
-void SpawnItem (edict_t *ent, gitem_t *item)
+void SpawnItem (edict_t *ent, const gitem_t *item)
 {
 	PrecacheItem (item);
 
 
 //======================================================================
 
-gitem_t	itemlist[] = 
+const gitem_t itemlist[] =
 {
 	{
 		NULL
 void SetItemNames (void)
 {
 	int		i;
-	gitem_t	*it;
+	const gitem_t *it;
 
 	for (i=0 ; i<game.num_items ; i++)
 	{
 {
 	char		*classname;	// spawning name
 	qboolean	(*pickup)(struct edict_s *ent, struct edict_s *other);
-	void		(*use)(struct edict_s *ent, struct gitem_s *item);
-	void		(*drop)(struct edict_s *ent, struct gitem_s *item);
+	void		(*use)(struct edict_s *ent, const struct gitem_s *item);
+	void		(*drop)(struct edict_s *ent, const struct gitem_s *item);
 	void		(*weaponthink)(struct edict_s *ent);
 	char		*pickup_sound;
 	char		*world_model;
 
 
 extern const field_t fields[];
-extern	gitem_t	itemlist[];
+extern const gitem_t itemlist[];
 extern gitem_set_t itemlist_set[];
 
 
 //
 // g_items.c
 //
-void PrecacheItem (gitem_t *it);
+void PrecacheItem (const gitem_t *it);
 void InitItems (void);
 void SetItemNames (void);
-gitem_t	*FindItem (const char *pickup_name);
-gitem_t	*FindItemByClassname (const char *classname);
+const gitem_t *FindItem (const char *pickup_name);
+const gitem_t *FindItemByClassname (const char *classname);
 #define	ITEM_INDEX(x) ((int)((x)-itemlist))
-edict_t *Drop_Item (edict_t *ent, gitem_t *item);
+edict_t *Drop_Item (edict_t *ent, const gitem_t *item);
 void SetRespawn (edict_t *ent, float delay);
 void ChangeWeapon (edict_t *ent);
-void SpawnItem (edict_t *ent, gitem_t *item);
+void SpawnItem (edict_t *ent, const gitem_t *item);
 void Think_Weapon (edict_t *ent);
 int ArmorIndex (edict_t *ent);
 int PowerArmorType (edict_t *ent);
-gitem_t	*GetItemByIndex (int index);
-qboolean Add_Ammo (edict_t *ent, gitem_t *item, int count);
+const gitem_t *GetItemByIndex (int index);
+qboolean Add_Ammo (edict_t *ent, const gitem_t *item, int count);
 void Touch_Item (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf);
 
 //
 //
 // g_save.c
 //
-gitem_t *GetDefaultWeapon (void);
+const gitem_t *GetDefaultWeapon (void);
 const spawnitem_t *GetSpawnItems (void);
 void UpdateSetItems (void);
 
 	int			max_cells;
 	int			max_slugs;
 
-	gitem_t		*weapon;
-	gitem_t		*lastweapon;
+	const gitem_t		*weapon;
+	const gitem_t		*lastweapon;
 
 	int			power_cubes;	// used for tracking the cubes in coop games
 	int			score;			// for calculating total unit score in coop games
 
 	qboolean	weapon_thunk;
 
-	gitem_t		*newweapon;
+	const gitem_t		*newweapon;
 
 	// sum up damage over an entire frame, so
 	// shotgun blasts give a single big kick
 
 	int			style;			// also used as areaportal number
 
-	gitem_t		*item;			// for bonus items
+	const gitem_t		*item;			// for bonus items
 
 	// common data blocks
 	moveinfo_t		moveinfo;
 	{NULL, 0, F_INT}
 };
 
-gitem_t *GetDefaultWeapon (void)
+const gitem_t *GetDefaultWeapon (void)
 {
-	static gitem_t *weapon = NULL;
+	static const gitem_t *weapon = NULL;
 
 	if (!weapon || g_defaultweapon->modified) {
 		weapon = FindItem(g_defaultweapon->string);
 		const char *c = g_setitems->string;
 
 		{ // C89 doesn't allow declaring variables in a for statement, so I get to waste a block for readability.
-			int      n;
-			gitem_t *item;
+			int            n;
+			const gitem_t *item;
 
 			for (n = game.num_items, item = itemlist; n > 0; --n, ++item) {
 				ITEM_QUANTITY(item) = item->origQuantity;
 
 			if (nameLen == 0) {
 				// apply to all items
-				gitem_t *item;
-				int      n;
+				const gitem_t *item;
+				int            n;
 				for (n = game.num_items, item = itemlist; n > 0; --n, ++item) {
 					if (qty != INT_MIN)
 						ITEM_QUANTITY(item) = qty;
 					ITEM_EXFLAGS(item) = (ITEM_EXFLAGS(item) & mask) | flags;
 				}
 			} else {
-				gitem_t *item = FindItem(name);
+				const gitem_t *item = FindItem(name);
 				if (!item)
 					item = FindItemByClassname(name);
 				if (!item) {
 			if (nameLen == 0)
 				gi.cprintf(NULL, PRINT_HIGH, "g_spawnitems: item specified without a name.\n");
 			else {
-				gitem_t *item = FindItem(name);
+				const gitem_t *item = FindItem(name);
 				if (!item)
 					item = FindItemByClassname(name);
 				if (!item)
 		if ( *(edict_t **)p == NULL)
 			index = -1;
 		else
-			index = *(gitem_t **)p - itemlist;
+			index = *(const gitem_t **)p - itemlist;
 		*(int *)p = index;
 		break;
 
 	case F_ITEM:
 		index = *(int *)p;
 		if ( index == -1 )
-			*(gitem_t **)p = NULL;
+			*(const gitem_t **)p = NULL;
 		else
-			*(gitem_t **)p = &itemlist[index];
+			*(const gitem_t **)p = &itemlist[index];
 		break;
 
 	//relative to code segment
 void ED_CallSpawn (edict_t *ent)
 {
 	const spawn_t *s;
-	gitem_t	*item;
+	const gitem_t *item;
 	int		i;
 
 	if (!ent->classname)
 	int argc;
 	int n;
 	gclient_t *client;
-	gitem_t *item;
+	const gitem_t *item;
 	char *c;
 
 	argc = gi.argc();
 
 void TossClientWeapon (edict_t *self)
 {
-	gitem_t		*item;
+	const gitem_t *item;
 	edict_t		*drop;
 	qboolean	quad;
 	float		spread;
 void InitClientPersistant (gclient_t *client)
 {
 	int		index;
-	gitem_t *const defaultweapon = GetDefaultWeapon ();
+	const gitem_t *const defaultweapon = GetDefaultWeapon ();
 
 	memset (&client->pers, 0, sizeof(client->pers));
 
 */
 void G_SetStats (edict_t *ent)
 {
-	gitem_t		*item;
+	const gitem_t *item;
 	int			index, cells;
 	int			power_armor_type;
 
 qboolean Pickup_Weapon (edict_t *ent, edict_t *other)
 {
 	int			index;
-	gitem_t		*ammo;
+	const gitem_t *ammo;
 
 	index = ITEM_INDEX(ent->item);
 
 	}
 }
 
-static qboolean NoAmmoTryWeapon (edict_t *const ent, gitem_t *const weap)
+static qboolean NoAmmoTryWeapon (edict_t *const ent, const gitem_t *const weap)
 {
-	gitem_t *const ammo = weap->ammo ? FindItem(weap->ammo) : NULL;
+	const gitem_t *const ammo = weap->ammo ? FindItem(weap->ammo) : NULL;
 
 	if (!ent->client->pers.inventory[ITEM_INDEX(weap)])
 		return false;
 Make the weapon ready if there is ammo
 ================
 */
-void Use_Weapon (edict_t *ent, gitem_t *item)
+void Use_Weapon (edict_t *ent, const gitem_t *item)
 {
 	int			ammo_index;
-	gitem_t		*ammo_item;
+	const gitem_t *ammo_item;
 
 	// see if we're already using it
 	if (item == ent->client->pers.weapon)