A_WeaponReady: WRF_USER1 (etc.)

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

Yeah I figured not but still... Hell if I know where to find it, honestly.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Xaser »

What's the issue at present? Should be able to get away with copying+pasting+renaming how the Reload and Zoom states do things, since it's the same thing.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by edward850 »

Except it most certainly does.
Image

Edit: Gah what. Stop deleting posts! D:
For the record, Major Cooke said that BT_USER1-4 did nothing in the playsim. I'm assume he then found something he might have been missing.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

Sorry! Found out what it was.

WeaponState is BYTE, and the flags for WF_USER#OKAY are 256 and above. Changing it to WORD fixed it. I hope this won't have any unforeseen consequences.

Pull Request and putting this on my first post on page 1.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by edward850 »

WeaponState is serialized. You'll need to explicitly load a byte for older versions.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

(byte)WeaponState right?
Last edited by Major Cooke on Tue Dec 15, 2015 12:39 am, edited 2 times in total.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by edward850 »

You'll want to test that, but yes that should do it.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

Actually that doesn't work. Found something else that I think might though... Accuracy and stamina do this.

Code: Select all

if (SaveVersion < 4526)
	{
		BYTE oldWeaponState;
		arc << oldWeaponState;
		if (WeaponState != NULL)
		{
			WeaponState = oldWeaponState; //Shouldnt this be opposite? Looks like it should be but this is how accuracy and stamina did it...
		}
	}
	else
	{
		arc << WeaponState;
	}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Graf Zahl »

'That piece of code just looks wrong. If you deserialize an old savegame you should always set WeaponState. Like this:

Code: Select all

if (SaveVersion < 4526)
   {
      BYTE oldWeaponState;
      arc << oldWeaponState;
      WeaponState = oldWeaponState;
   }
   else
   {
      arc << WeaponState;
   }
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

And done.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Edward-san »

imho, you should keep the consistency with the | operator here.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

No other flags are being passed into it. It's fine.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Graf Zahl »

That may be, but it's bad style. Never use '+' with flag values, always use '|'. It's not the first time you did this and it was problematic in other cases. Better stop doing this altogether.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

Alright, done. Anything else?
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: A_WeaponReady: WRF_USER1 (etc.)

Post by Major Cooke »

Randi has added this. This can be closed.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”