Savegame, WorldThingDestroyed: Class checking doesn't work

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
XxMiltenXx
Posts: 219
Joined: Wed Jan 08, 2014 8:40 am
Graphics Processor: nVidia with Vulkan support
Location: Germany

Savegame, WorldThingDestroyed: Class checking doesn't work

Post by XxMiltenXx »

While using the Event WorldThingDestroyed I noticed a bug after loading a savegame with the following code:

Code: Select all

version "3.3"

Class Event : EventHandler
{
	override void WorldThingDestroyed(WorldEvent e)
	{
		let Item = Inventory(e.Thing);
		If (Item)
			Console.Printf("Yes, I am an item!");
	}
}
If you just enter the game and pick up any item, it will correctly display the message "Yes, I am an Item", however, if you now save and load the game and pick up any other items that existed while saving the game, it will not print that message anymore. However, if you spawn a new object (e.g. summon armorbonus) and pick it up, it will print the message correctly.
I replaced "Inventory" with "Actor", but the same thing happened.
I also checked "WorldThingDied", however, there it seems to work normally.

Attached is a PK3 with the Event and the GameInfo to load it for easy testing.

Tested with GZDoom g3.4pre-360-gd639e07 x64
Attachments
WorldThingDestroyed.pk3
(415 Bytes) Downloaded 28 times
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by _mental_ »

Check these lines, especially a comment. This seems to be done intentionally.
XxMiltenXx
Posts: 219
Joined: Wed Jan 08, 2014 8:40 am
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by XxMiltenXx »

Yeah, but from what I understand from the comment it was to eliminate objects that weren't actually spawned within the world.

But those items actually were, even if not after loading the game, so shouldn't they preserve the flag of being spawned?
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by _mental_ »

Apparently they are not because event processing code stops on that condition.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by Graf Zahl »

The logic here is wrong.

The flag gets set in CallPostBeginPlay - and only there.
Now, for an actor being reloaded from a savegame that call is never reached so the flag gets never set. In other words: As implemented this flag is not safe for checking within the playsim.
So either the code needs to be rewritten or the flag be serialized.
XxMiltenXx
Posts: 219
Joined: Wed Jan 08, 2014 8:40 am
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by XxMiltenXx »

I guess serializing would make sense, the flag gets set when it was spawned successful, so why shouldn't it be saved in savegames as well.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by _mental_ »

Fixed in 437b44b.
XxMiltenXx
Posts: 219
Joined: Wed Jan 08, 2014 8:40 am
Graphics Processor: nVidia with Vulkan support
Location: Germany

Re: Savegame, WorldThingDestroyed: Class checking doesn't wo

Post by XxMiltenXx »

Thank you :)
Post Reply

Return to “Closed Bugs [GZDoom]”