[Fixed] DECORATE: SpawnFloat

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.
Cornflake
Posts: 24
Joined: Sat Jan 24, 2004 8:04 pm

DECORATE: SpawnFloat

Post by Cornflake »

I pretty sure this is a bug:

In the DECORATE lump, there is a flag called SpawnFloat, which is supposed to make a decoration "spawn at a random height between the floor and ceiling".

I put the decorations in my level in a room that had a floor height of 0 and ceiling height of 384, but the decorations only seemed to spawn at most 128 units above the floor. I tried giving them an initial height but that seemed to do nothing.

The only flags I had set were NoGravity and SpawnFloatin the DECORATE lump.

Here comes the strange part:

I made the ceiling 512 instead of the 256 and the maximum height of the decorations semed to jump to about 144 units above the floor. I raised it to 4096 and it seemed to jump to 192 or so. A ceiling with a 64 unit height made the decorations sit flat on the floor.

Is there something messed up with calculating the heights of decorations using SpawnFloat? It seems as if the differences are exponential.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49188
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

That's the calculations that are done:

Code: Select all

	else if (iz == FLOATRANDZ)
	{
		fixed_t space = actor->ceilingz - actor->height - actor->floorz;
		if (space > 48*FRACUNIT)
		{
			space -= 40*FRACUNIT;
			actor->z = ((space * rng())>>8) + actor->floorz + 40*FRACUNIT;
		}
		else
		{
			actor->z = actor->floorz;
		}
	}
They perfectly match your results and they are exactly the same in Hexen and Heretic where this flag comes from.
Cornflake
Posts: 24
Joined: Sat Jan 24, 2004 8:04 pm

Post by Cornflake »

Well, then this page should be changed to reflect what it truely does:

http://www.zdoom.org/wiki/wiki.phtml?title=DECORATE

The part where is states: "spawn at a random height between the floor and ceiling" is misleading.
NiGHTMARE
Posts: 3463
Joined: Sat Jul 19, 2003 8:39 am

Post by NiGHTMARE »

Why not change it yourself? That is the whole point of a Wiki afterall :)
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm

Post by randi »

Except you got the wiki entry wrong. The correct behavior is:
  • Is the space at least 48 units tall?
    • No, then spawn it on the floor.
    • Yes, then spawn it at least 40 units above the floor.
It behaves strangely because this bit overflows when the space is more than 257 units (after subtracting 40):

Code: Select all

(space * rng())>>8
Simple to fix:

Code: Select all

MulScale8 (space, rng())
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49188
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

So this was a bug that has been in Heretic and Hexen, right?
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm

Post by randi »

Yes.

Return to “Closed Bugs [GZDoom]”