ArmedObjects having NULL weapons in their weapon list [message #490197] |
Wed, 31 December 2014 07:34 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
Neijwiert
Messages: 124 Registered: October 2009
Karma: 0
|
Recruit |
|
|
Is there a reason for this to happen? Same story as my other post regarding duplicate stock scripts. In the map C&C_Hourglass.mix I have found that on LoadLevel the preset Nod_Turret_MP has a NULL WeaponClass pointer in their weapon list.
EDIT:
It appears that it concerns 2 different turrets with IDs:
1500244 and 1500245 they both have one NULL weapon in their weapon list.
EDIT #2:
The same turrets do appear to have their correct weapon aswell:
Weapon_Turret_Cannon
[Updated on: Wed, 31 December 2014 07:42] Report message to a moderator
|
|
|
Re: ArmedObjects having NULL weapons in their weapon list [message #490199 is a reply to message #490197] |
Wed, 31 December 2014 07:39 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](/images/custom_avatars/21300.png) |
Jerad2142
Messages: 3806 Registered: July 2006 Location: USA
Karma: 6
|
General (3 Stars) |
|
|
Neijwiert wrote on Wed, 31 December 2014 07:34 | Is there a reason for this to happen? Same story as my other post regarding duplicate stock scripts. In the map C&C_Hourglass.mix I have found that on LoadLevel the preset Nod_Turret_MP has a NULL WeaponClass pointer in their weapon list.
EDIT:
It appears that it concerns 2 different turrets with IDs:
1500244 and 1500245 they both have one NULL weapon in their weapon list.
|
I assume its for like in single player when you don't have any guns. They probably just leave the option to switch to the null weapon there so they don't have to add some hacky way to add a null weapon for empty hands/no weapon if no weapon gets selected. Or maybe your just seeing the end pointer of the list?
Visit Jerad's deer sweat shop
[Updated on: Wed, 31 December 2014 07:39] Report message to a moderator
|
|
|
|
Re: ArmedObjects having NULL weapons in their weapon list [message #490202 is a reply to message #490201] |
Wed, 31 December 2014 07:49 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](/images/custom_avatars/21300.png) |
Jerad2142
Messages: 3806 Registered: July 2006 Location: USA
Karma: 6
|
General (3 Stars) |
|
|
Neijwiert wrote on Wed, 31 December 2014 07:46 | Then why is it called Nod_Turret_MP?
MP = Multiplayer.
Also you could just do Commands->Select_Weapon(obj, NULL); whichs deselects your weapon even if you have one. So there must be some logic for that.
EDIT:
Also there's a function called Deselect in WeaponBagClass.
|
And those functions might just switch to the NULL weapon is all I'm saying.
Either that or your just seeing the end of the list IE:
Weapon1->next = Weapon2
Weapon2->next = NULL
Visit Jerad's deer sweat shop
[Updated on: Wed, 31 December 2014 07:50] Report message to a moderator
|
|
|
Re: ArmedObjects having NULL weapons in their weapon list [message #490203 is a reply to message #490202] |
Wed, 31 December 2014 07:54 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
Neijwiert
Messages: 124 Registered: October 2009
Karma: 0
|
Recruit |
|
|
Jerad Gray wrote on Wed, 31 December 2014 07:49 |
Neijwiert wrote on Wed, 31 December 2014 07:46 | Then why is it called Nod_Turret_MP?
MP = Multiplayer.
Also you could just do Commands->Select_Weapon(obj, NULL); whichs deselects your weapon even if you have one. So there must be some logic for that.
EDIT:
Also there's a function called Deselect in WeaponBagClass.
|
And those functions might just switch to the NULL weapon is all I'm saying.
Either that or your just seeing the end of the list IE:
Weapon1->next = Weapon2
Weapon2->next = NULL
|
Yeah it could be indeed for deselecting but It's not the end of the list. I'm using a for loop starting with index 0 and going until WeaponBagClass::Get_Count(). Then every iteration I use WeaponBagClass::Peek_Weapon(int index) which is simply return WeaponList[ index ];
|
|
|
|
|
|
|
Re: ArmedObjects having NULL weapons in their weapon list [message #490220 is a reply to message #490216] |
Thu, 01 January 2015 14:09 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
dblaney1
Messages: 358 Registered: March 2014 Location: United States
Karma: 0
|
Commander |
|
|
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](images/smiley_icons/icon_biggrin.gif)
|
However, if they stored them in an array instead of a linked list -1 could cause some pretty serious issues ![Razz](images/smiley_icons/icon_razz.gif)
|
Arrays in c++ allows you to do some really bad things lol.
[Updated on: Thu, 01 January 2015 14:09] Report message to a moderator
|
|
|
|
|
Re: ArmedObjects having NULL weapons in their weapon list [message #490235 is a reply to message #490230] |
Fri, 02 January 2015 14:28 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
dblaney1
Messages: 358 Registered: March 2014 Location: United States
Karma: 0
|
Commander |
|
|
Jerad Gray wrote on Fri, 02 January 2015 06:01 | Well if your using an array to be fast why throw some of those gains with an index check each time ;p
|
Not to mention you can walk right off the end of an array in c++ as well and even start changing adjacent memory.
|
|
|
|