Crash when assigning actors in ZScript

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.
User avatar
krokots
Posts: 269
Joined: Tue Jan 19, 2010 5:07 pm

Crash when assigning actors in ZScript

Post by krokots »

The crash occurs when I use AddInventory a lot of times in a row. For example, I add 100 items to an actor, and sometime it creates a crash.

Details:
I have an array of strings. Let's say 100 strings (Inventory classes).

Code: Select all

		foreach(cls : items)
		{
			Inventory item = Inventory(Actor.Spawn(cls));
			if(!item)
			{
				Console.printf("\cgInvalid item, not adding to inventory : "..cls);
				continue;
			}					
			if(!item.CallTryPickup(Owner))
			{
				Console.printf("\cgFailed to add item to inventory : "..item.GetClassName());
				item.Destroy();
			}
		}
4 out of 5 times it works, but every couple of times, this crashes inside gzdoom.pk3 on AddInventory. This doesn't seem to make any sense to me, because it crashes after

Code: Select all

Inv = item;
where item is not null, but Inv is somehow null.
You do not have the required permissions to view the files attached to this post.
Last edited by krokots on Thu Aug 10, 2023 4:06 am, edited 1 time in total.
User avatar
krokots
Posts: 269
Joined: Tue Jan 19, 2010 5:07 pm

Re: Crash when assigning actors in ZScript

Post by krokots »

I can avoid the crash when I change 'Spawn+CallTryPickup' combo to 'GiveInventoryType' :

Code: Select all

		foreach(cls : items)
		{
			Inventory item = Owner.GiveInventoryType(cls);
			if(!item)
			{
				Console.printf("\cgInvalid item, not adding to inventory : "..cls);
			}
		}
User avatar
krokots
Posts: 269
Joined: Tue Jan 19, 2010 5:07 pm

Re: Crash when assigning actors in ZScript

Post by krokots »

Fuck it. Somehow all this was connected to the spawned item (ND_Orb) sometimes rarely having set state label to "null" just after spawning.

Return to “Closed Bugs [GZDoom]”