[Fix inside]Camera + Morph = Crash

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 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: [Fix inside]Camera + Morph = Crash

Re: [Fix inside]Camera + Morph = Crash

by Major Cooke » Fri Sep 02, 2016 10:35 am

Thanks for applying this. This can be closed.

Re: [Fix inside]Camera + Morph = Crash

by Major Cooke » Thu Sep 01, 2016 1:52 pm

I'm gonna stick with Graf's route and not fix what isn't broken. As for the name... :shrug:

Re: [Fix inside]Camera + Morph = Crash

by Edward-san » Thu Sep 01, 2016 1:50 pm

I'm not convinced about the variable name, but dunno about any other 'alternative' ones. I wonder if it would be better to condense all the morph data into a struct or class...

Re: Camera + Morph = Crash

by Major Cooke » Thu Sep 01, 2016 1:01 pm

Bugfix PR. Things turned out to be a tad bit different -- but for good reason.

Tracer is not a safe pointer at all anymore, for storing players and their morphed counterparts. Why? A_RearrangePointers just to name one. The easiest thing to do for players is to introduce the 'alternative' pointer into the mix. I've thus removed all form of storing (un)morphed tracers in the players and morphs involving the morph swappage, and is now done through the alternative pointer.

Monsters remain unchanged: they have an (Un)MorphedMe pointer and aren't of concern.

This fixes several things, and does me a bonus favor:
  • Fixes the crash experienced here.
  • Fixes a long outstanding bug that only I was able to reproduce a long time ago involving morphs failing to unmorph due to the player tracer pointer being manipulated (Do an A_RadiusGive to all playerpawns which causes them to forget their tracers... That unmorph is never coming!)
  • The original target and tracer are now transferred forth for maintained consistency and better tracking of pointers. When the morph expires, it transfers the target and tracer back which may or may not have changed over time, again for consistency.

Re: Camera + Morph = Crash

by Edward-san » Thu Sep 01, 2016 11:00 am

Yeah, you can go ahead.

Re: Camera + Morph = Crash

by Major Cooke » Thu Sep 01, 2016 10:32 am

I believe target and master should also do the same thing because I could have been using SXF_ISTARGET as well.

Alright. I'll work on it, if edward isn't.

Re: Camera + Morph = Crash

by Graf Zahl » Thu Sep 01, 2016 10:27 am

No. There's only a flag on the unmorphed version, but you need tracer to get there. My solution here would be simple:

Add a new variable and set the unmorphed monster both as that and as tracer. I think that will solve all potential issues.

Re: Camera + Morph = Crash

by Major Cooke » Thu Sep 01, 2016 10:15 am

Graf Zahl wrote:Correct. Since it's no longer safe to use tracer for this, a different variable is needed.
Is there a particular property or flag that's set on a morphed actor to safely check, to transition them into a MorphedTarget/Master/Tracer?

Re: Camera + Morph = Crash

by Edward-san » Wed Aug 31, 2016 2:53 pm

I hope there's nothing which (ab)used the morphed tracer data...

Re: Camera + Morph = Crash

by Graf Zahl » Wed Aug 31, 2016 2:49 pm

Edward-san wrote: In order to fix this, I suspect the old actor pointer should be stored in a different place than the 'tracer'. Graf?
Correct. Since it's no longer safe to use tracer for this, a different variable is needed.

Re: Camera + Morph = Crash

by Major Cooke » Wed Aug 31, 2016 2:44 pm

I tested it again just to make sure:

Code: Select all

	Spawn:
		PLAY A 95 NoDelay
		{
			SetPlayerProperty(0,1,PROP_TOTALLYFROZEN);
			A_PrintBold("Camera On");
			A_SpawnItemEx("ChaseCam",-10,0,32,0,0,0,0,SXF_NOCHECKPOSITION|SXF_SETMASTER|SXF_ISTRACER,0,32700);
			ChangeCamera(32700,0,0);
		}
		PLAY A 0
		{
			A_RemoveChildren(true,RMVF_EVERYTHING,"ChaseCam");
		}
This doesn't crash, backing up Edward's words possibly.

Re: Camera + Morph = Crash

by Edward-san » Wed Aug 31, 2016 2:35 pm

It seems that this line in decorate.txt:

Code: Select all

			A_SpawnItemEx("ChaseCam",-10,0,32,0,0,0,0,SXF_NOCHECKPOSITION|SXF_SETMASTER|SXF_ISTRACER,0,32700);
makes sure that the morphed actor's tracer, which points to the actor before morphing, is overridden with the camera:

Code: Select all

	if (flags & SIXF_ISTRACER)
	{
		self->tracer = mo;
	}
from InitSpawnedItem, called by A_SpawnItemEx.

The old actor's information is lost, making the program crash when attempting to unmorph, because it's trying to get the player's info from invalid actor.

In order to fix this, I suspect the old actor pointer should be stored in a different place than the 'tracer'. Graf?

Re: Camera + Morph = Crash

by Major Cooke » Thu Aug 25, 2016 12:34 pm

Okay, first post updated. User variables removed.

Re: Camera + Morph = Crash

by Edward-san » Sun Aug 21, 2016 1:28 pm

Can you add a test wad which does just morph and unmorph? In a post above, I mentioned a problem with those steps and would like to check it again.

Re: Camera + Morph = Crash

by Major Cooke » Sun Aug 21, 2016 7:21 am

Meh.

Anyway, anything else I can try to do for this? Or is this something randi has to look into?

Top