Jump to content

Home

Increase MAX_WEAPONS


XycaleTh

Recommended Posts

Before you say "you can't do that!", let me tell you my idea.

 

Now, as far as I can tell, MAX_WEAPONS is only used once in q_shared.h (and so only used this once between mod and engine), and that's for defining the size of the ammo array in playerState_s. If I instead set this to 19 (value of MAX_WEAPONS), I'm free to change MAX_WEAPONS.

 

To overcome the problem of the game referencing ammo[] with an index of greater than 18, I thought of using the low and high 16-bits of each index to store the amount of ammo, i.e. for a given array element, the lower 16 bits will hold the amount of ammo for one weapon, and the higher 16 bits for a second weapon.

 

I can replace all references to ammo[] with a function to correctly set/get the required ammo index. And then there's the problem of ps.stats[sTAT_WEAPON] only being a 16-bit field (at least that's what it says in the code...). I can simply replace this with one of the userInts provided. There will still be a limited number of weapons I can have (32), but that should be more than enough.

 

Do these changes sound okay?

Link to comment
Share on other sites

Well I've gone through with my idea and it seems to work fine! :) Here's how to do it:

 

In q_shared.h, change

int ammo[MAX_WEAPONS];

to

short ammo[38];

38 is MAX_WEAPONS * 2. Using a short means that only 16 bits are used per ammo slot, rather than 32, allowing for double the number of weapons.

 

You must also remember that ps.stats[sTAT_WEAPONS] holds a bit field of the weapons a player carries. However, this is sent as a 19-bit field (contrary to what the declaration in the header says of 16 bits). I've simply replaced all instances of ps.stats[sTAT_WEAPONS] with ps.userInt1, and resized this field to 32 bits in the ext_data/MP/psf_overrides.txt file.

 

And then now you're increase the maximum weapon limit up to 32! :D

Link to comment
Share on other sites

  • 2 months later...

I have a not-so-good comment on this i'm afraid.

 

I've recently checked the JA networking system, and it appears that ammo is sent over as 16 bit, and not 32.

 

As such, if you change the ammo fields to shorts, only half of em will be networked.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...