foxygit / doom Log in
commit 12b7676e7deb1e290be5128137014523227750a8
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Thu Mar 5 20:43:06 2015 +0100
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Thu Mar 5 20:49:22 2015 +0100

    Initialize floor->type and floor->crush fields in EV_BuildStairs()

    The floor->type and floor->crush fields of the floor thinkers added in
    EV_BuildStairs() were originally left uninitialized and thus contained
    random memory content.

    Initialize them to make sure the floor->type field does not trigger
    propagation of random content into the special and texture fields of
    the adjacent sector in T_MoveFloor(). That is, make sure its value
    is neither donutRaise, i.e. 11, nor lowerAndChange, i.e. 6.

    Also, the chances of 32 bit of random memory being "true", i.e. 0, are
    negligible.

    This is functionally equivalent to what PrBoom+ is doing.

    Fixes desync of mm09-512.lmp.

    Fixes #368.
---
 src/doom/p_floor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/doom/p_floor.c b/src/doom/p_floor.c
index 1384ee6b..c120d616 100644
--- a/src/doom/p_floor.c
+++ b/src/doom/p_floor.c
@@ -493,6 +493,9 @@ EV_BuildStairs
 	floor->speed = speed;
 	height = sec->floorheight + stairsize;
 	floor->floordestheight = height;
+	// Initialize
+	floor->type = lowerFloor;
+	floor->crush = true;

 	texture = sec->floorpic;

@@ -536,6 +539,9 @@ EV_BuildStairs
 		floor->sector = sec;
 		floor->speed = speed;
 		floor->floordestheight = height;
+		// Initialize
+		floor->type = lowerFloor;
+		floor->crush = true;
 		ok = 1;
 		break;
 	    }