lfnetwork.com mark read register faq members calendar

Thread: Increase MAX_WEAPONS
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 02-15-2009, 06:38 AM   #1
XycaleTh
Rookie
 
XycaleTh's Avatar
 
Join Date: Apr 2006
Location: UK
Posts: 67
Increase MAX_WEAPONS

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?

Last edited by XycaleTh; 02-15-2009 at 07:54 AM.
XycaleTh is offline   you may: quote & reply,
Old 02-15-2009, 08:12 AM   #2
BobaFettUU
Lurker
 
Join Date: Feb 2006
Posts: 6
Well, if the ps.ammo[] fields are actually networked in a full 32 bit (which you can check by setting them to -1 and see what the client receives, then yes this is possible to do.

That is, of course, assuming that your mod has both a server and a client side.
BobaFettUU is offline   you may: quote & reply,
Old 02-17-2009, 03:40 AM   #3
XycaleTh
Rookie
 
XycaleTh's Avatar
 
Join Date: Apr 2006
Location: UK
Posts: 67
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
Code:
int ammo[MAX_WEAPONS];
to
Code:
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!

Last edited by XycaleTh; 02-20-2009 at 05:30 AM. Reason: Corrected the psf_overrides.txt file name
XycaleTh is offline   you may: quote & reply,
Old 02-19-2009, 09:55 AM   #4
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Thank-you muchly for this information. =]


Last edited by -=*Raz0r*=-; 03-07-2009 at 06:42 AM.
-=*Raz0r*=- is offline   you may: quote & reply,
Old 04-25-2009, 05:14 AM   #5
BobaFettUU
Lurker
 
Join Date: Feb 2006
Posts: 6
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.
BobaFettUU is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > Increase MAX_WEAPONS

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:19 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.