[ACS+DECO]Game crash when unmorphing (now with a sample)

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ACS+DECO]Game crash when unmorphing (now with a sample)

Re: [ACS+DECO]Game crash when unmorphing (now with a sample)

by TDRR » Wed Sep 18, 2019 8:11 am

Boondorl wrote:I found the culprit. It's this line right here in the UndoPlayerMorph function in player_morph.zs (around line 257):

Code: Select all

self.player = null;
which causes the game to crash. I'm not sure why this is being done, but moving the line around doesn't help, and given the stack trace above which mentions CheckWeaponSwitch, I'm guessing at some point a safety check isn't being done properly and it's trying to read from the now null self.player.
That line doesn't make sense IMO. Maybe that's an oversight or something? Still stupid i have been chasing nothing but a smoke trail and i had to fix it with a crappy workaround, shame having compatibility with Zandro and modern GZDoom is quite hard.

Re: [ACS+DECO]Game crash when unmorphing (now with a sample)

by Boondorl » Wed Sep 18, 2019 6:54 am

I found the culprit. It's this line right here in the UndoPlayerMorph function in player_morph.zs (around line 257):

Code: Select all

self.player = null;
which causes the game to crash. I'm not sure why this is being done, but moving the line around doesn't help, and given the stack trace above which mentions CheckWeaponSwitch, I'm guessing at some point a safety check isn't being done properly and it's trying to read from the now null self.player.

Re: [ACS+DECO]Game crash when unmorphing (now with a sample)

by TDRR » Tue Sep 17, 2019 9:51 pm

Void Weaver wrote:Glad to help you, bro. But the reason of crash is still unclear, hope that a somebody ZScript-pro give a some explanations.

And a some hint: GetPlayerInput work for deco too - GetPlayerInput_(DECORATE). ;)
Yes it indeed seems to be that the caller of the action (The weapon) is taken away by the Unmorph item, and then ZDoom gets confused and dies.

It works for DECORATE, but that's not the case in Zandronum. Remember Zandronum is based on GZD 1.8.6, a version from 2014.

Re: [ACS+DECO]Game crash when unmorphing (now with a sample)

by Void Weaver » Tue Sep 17, 2019 9:24 pm

Glad to help you, bro. But the reason of crash is still unclear, hope that a somebody ZScript-pro give a some explanations.

And a some hint: GetPlayerInput work for deco too - GetPlayerInput_(DECORATE). ;)

Re: [ACS+DECO]Game crash when unmorphing (now with a sample)

by TDRR » Tue Sep 17, 2019 9:09 pm

Void Weaver wrote:I absolutely have no idea which logic causes game crash (but can assume that game consider initiator of A_GiveInventory as Null, since giver will instntly removes by "Unmorpher" itself), but it can be fixed by calling your "Unmorpher" from external source, smth. like as:

Code: Select all

ACTOR DoomPlayerExceptItIsAMorph : DoomPlayer
{
	Player.DisplayName "Doom Player except it's a morph"
	Player.MorphWeapon "ChainsawForTesting"
	Translation Ice
	States
	{
	Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("UnmorpherOperator",0,0,0,0,0,0,0,SXF_SETMASTER) //Call external actor which will monitoring for unmorphing condition
	Idle:
	PLAY A 1
	Loop
	}
}

ACTOR UnmorpherOperator
{
+NOINTERACTION
States
{
Spawn:
POSS A 1 NoDelay
{
A_Warp(AAPTR_MASTER,0,0,0,0,0,"",0.5); //Just for visualization
If(GetPlayerInput(MODINPUT_BUTTONS,AAPTR_MASTER)&BT_ALTATTACK){A_GiveInventory("Unmorpher",1,AAPTR_MASTER);Return state("Null");} //Any condition; current one: "If my MASTER did press Alt-fire, then give to him "Unmorpher" and self-remove, otherwise return to cycle"
Else{Return state("");}
}
Loop
}
}
I can't use that, because GetPlayerInput can't be used in Zandronum, not from DECORATE. Also adding an external actor to the mix is probably going to stir up the clientside predictor.

So i'm thinking maybe an ACS script could be done instead and that gives the player the unmorpher item.
Tested it and... YES IT WORKED! Awesome! Thanks for the help Weaver.

Re: [ACS+DECO]Game crash when unmorphing (now with a sample)

by Void Weaver » Tue Sep 17, 2019 8:50 pm

I absolutely have no idea which logic causes game crash (but can assume that game consider initiator of A_GiveInventory as Null, since giver will instntly removes by "Unmorpher" itself), but it can be fixed by calling your "Unmorpher" from external source, smth. like as:

Code: Select all

ACTOR DoomPlayerExceptItIsAMorph : DoomPlayer
{
	Player.DisplayName "Doom Player except it's a morph"
	Player.MorphWeapon "ChainsawForTesting"
	Translation Ice
	States
	{
	Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("UnmorpherOperator",0,0,0,0,0,0,0,SXF_SETMASTER) //Call external actor which will monitoring for unmorphing condition
	Idle:
	PLAY A 1
	Loop
	}
}

ACTOR UnmorpherOperator
{
+NOINTERACTION
States
{
Spawn:
POSS A 1 NoDelay
{
A_Warp(AAPTR_MASTER,0,0,0,0,0,"",0.5); //Just for visualization
If(GetPlayerInput(MODINPUT_BUTTONS,AAPTR_MASTER)&BT_ALTATTACK){A_GiveInventory("Unmorpher",1,AAPTR_MASTER);Return state("Null");} //Any condition; current one: "If my MASTER did press Alt-fire, then give to him "Unmorpher" and self-remove, otherwise return to cycle"
Else{Return state("");}
}
Loop
}
}
Also unmorphing will work correct if the item will be picked up from ground.

Re: [ACS+DECO]Game crash when unmorphing

by TDRR » Tue Sep 17, 2019 5:30 pm

Here's a runnable sample since Graf once asked me about it:
MorphCrashSample.pk3
(718 Bytes) Downloaded 54 times
Just go to Doom 2 MAP01, grab the chainsaw and press altfire. And BAM! It crashes.

Re: [ACS+DECO]Game crash when unmorphing

by TDRR » Fri Jan 04, 2019 10:48 pm

Wivicer wrote:No, that's your code. Basically, at some point your code attempts to read a value from something that doesn't have one.
Which doesn't make much sense, i'm doing the exact same thing Heretic does except i force it. There isn't anything really wrong with the code as it is.

I think i can't do anything to fix this, short of doing something that just breaks compatibility with older GZDoom versions/Zandronum, which would be even worse. Using that unmorphing ACS special doesn't do anything at all either.

Re: [ACS+DECO]Game crash when unmorphing

by Wivicer » Fri Jan 04, 2019 6:04 pm

No, that's your code. Basically, at some point your code attempts to read a value from something that doesn't have one.

Re: [ACS+DECO]Game crash when unmorphing

by TDRR » Fri Jan 04, 2019 4:43 pm

Graf Zahl wrote:I was asking because the line number did not match.
If it aborts with a null pointer access there is a bug in the code that needs addressing.
I suppose that's in your end? Or do i need to fix something in DUBG?

Re: [ACS+DECO]Game crash when unmorphing

by Graf Zahl » Fri Jan 04, 2019 4:41 pm

I was asking because the line number did not match.
If it aborts with a null pointer access there is a bug in the code that needs addressing.

Re: [ACS+DECO]Game crash when unmorphing

by TDRR » Fri Jan 04, 2019 4:30 pm

Eh Performance is even worse than before: 50fps at 640x480 compared to GZDoom 1.8.6 where i get 160fps with max resolution

That aside, here's the current trace:

Code: Select all

VM Execution aborted: tried to read from address zero
Called from PlayerPawn.CheckWeaponChange at gzdoom.pk3: zscript/shared/player.txt, line 390
Called from PlayerPawn.TickPSprites at gzdoom.pk3: zscript/shared/player.txt, line 444
Called from PlayerPawn.PlayerThink at gzdoom.pk3: zscript/shared/player.txt, line 1449

Re: [ACS+DECO]Game crash when unmorphing

by TDRR » Fri Jan 04, 2019 4:15 pm

Graf Zahl wrote:What version did you test with? The stack trace doesn't match 3.7.1.
I haven't tested it with 3.7.1 because i thought it would be the same as with 3.6.0, but i'm going to try again and put the results here.

Re: [ACS+DECO]Game crash when unmorphing

by Graf Zahl » Fri Jan 04, 2019 4:04 pm

What version did you test with? The stack trace doesn't match 3.7.1.

[ACS+DECO]Game crash when unmorphing (now with a sample)

by TDRR » Fri Jan 04, 2019 2:01 pm

Scroll down to the last post to get the runnable sample
Now, like some of you know, in later GZDoom versions DUBG crashes when leaving a vehicle. This also happens with Death Foretold but it uses a different way of unmorphing IIRC.
I'm using a Unmorpher item inheriting from the tome of power:

Code: Select all

ACTOR Unmorpher : ArtiTomeOfPower
{
Game Doom
+INVENTORY.AUTOACTIVATE
+INVENTORY.QUIET
-INVENTORY.INVBAR
-INVENTORY.PICKUPFLASH
-COUNTITEM
-FLOATBOB
Inventory.PickupMessage ""
Powerup.Duration 1
}
While this works fine in GZDoom 1.8.6 and Zandronum, it doesn't work at all in ZScript-powered versions, instead giving me this VM abort:

Code: Select all

VM Execution aborted: tried to read from address zero
Called from PlayerPawn.CheckWeaponChange at gzdoom.pk3: zscript/shared/player.txt, line 374
Called from PlayerPawn.TickPSprites at gzdoom.pk3: zscript/shared/player.txt, line 428
Called from PlayerPawn.PlayerThink at gzdoom.pk3: zscript/shared/player.txt, line 1248
For an example use DUBG, it's only 5MB so the download is fast and doesn't take up much space. Choose the Dguy's unknown battlegrounds episode and go into any vehicle you find by pressing the +use key, press it again to get out of the car and trigger the VM abort. All DECORATE code related to these vehicles is found in the VEHICLES lump in the root of the PK3, and in the scripts folder there's ACS code relating to it, but i doubt it has anything to do with the crash.

How can i fix it? Also yes the game crashes when unmorphing anything with this item.

Top