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
ArmedObjects having NULL weapons in their weapon list [message #490197] Wed, 31 December 2014 07:34 Go to next message
Neijwiert is currently offline  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 messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
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?


[Updated on: Wed, 31 December 2014 07:39]

Report message to a moderator

Re: ArmedObjects having NULL weapons in their weapon list [message #490201 is a reply to message #490199] Wed, 31 December 2014 07:46 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
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.

[Updated on: Wed, 31 December 2014 07:47]

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 messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
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


[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 messageGo to next message
Neijwiert is currently offline  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 #490204 is a reply to message #490197] Wed, 31 December 2014 08:06 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
As I recall index zero of the weapon bag is always a null "no weapon" weapon... jonwil could confirm that though.

http://steamsignature.com/card/1/76561197975867233.png
Re: ArmedObjects having NULL weapons in their weapon list [message #490207 is a reply to message #490204] Wed, 31 December 2014 08:28 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
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.


Re: ArmedObjects having NULL weapons in their weapon list [message #490211 is a reply to message #490207] Wed, 31 December 2014 09:46 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
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
Re: ArmedObjects having NULL weapons in their weapon list [message #490216 is a reply to message #490211] Thu, 01 January 2015 08:29 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
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


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 messageGo to next message
dblaney1 is currently offline  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

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


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 #490225 is a reply to message #490216] Thu, 01 January 2015 19:36 Go to previous messageGo to next message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
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
Re: ArmedObjects having NULL weapons in their weapon list [message #490230 is a reply to message #490225] Fri, 02 January 2015 06:01 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Well if your using an array to be fast why throw some of those gains with an index check each time ;p



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 messageGo to next message
dblaney1 is currently offline  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.
Re: ArmedObjects having NULL weapons in their weapon list [message #490237 is a reply to message #490197] Fri, 02 January 2015 17:55 Go to previous message
Neijwiert is currently offline  Neijwiert
Messages: 124
Registered: October 2009
Karma: 0
Recruit
Fine fine let's stop with: who finds the best solution. Lol it's 2015 and I feel like marty mcfly on my hoverboard with my shiny new nikes.
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: Fri Apr 19 00:58:25 MST 2024

Total time taken to generate the page: 0.01333 seconds