Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » ArmedObjects having NULL weapons in their weapon list
Re: ArmedObjects having NULL weapons in their weapon list [message #490225 is a reply to message #490216] Thu, 01 January 2015 19:36 Go to previous messageGo to previous message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma:
Recruit
Jerad Gray wrote on Thu, 01 January 2015 08:29

Neijwiert wrote on Wed, 31 December 2014 09:46

Jerad Gray wrote on Wed, 31 December 2014 08:28

danpaul88 wrote on Wed, 31 December 2014 08:06

As I recall index zero of the weapon bag is always a null "no weapon" weapon... jonwil could confirm that though.

Which would make sense, far easier to have a slot for no weapon then hacking in a special "no weapon" state into all the weapon functions.


Well how I would do it is to have the WeaponIndex variable be -1. That saves 4 bytes of memory so you don't have to store the NULL pointer in the weapon list Very Happy

However, if they stored them in an array instead of a linked list -1 could cause some pretty serious issues Razz


Or you could just do a quick check if it's -1 before accessing the array
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: scripts 4.2 RC1 is now available for testing
Next Topic: Scripts 4.2 to enter private beta testing soon, here are some changes in it
Goto Forum:
  


Current Time: Sun Dec 29 09:47:14 MST 2024

Total time taken to generate the page: 0.00929 seconds