From 1b4f98be712c3ec2f7a87ce8866c1c66e430f533 Mon Sep 17 00:00:00 2001 From: brian Date: Wed, 19 Nov 2025 00:29:04 -0800 Subject: [PATCH] Fix for CCW rotating doors reaching a negative Build angle, resulting in open and snap back behavior. --- source/games/duke/src/actors.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 5031b0b3a5..6fdd98a711 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -2519,7 +2519,11 @@ void handle_se11(DDukeActor *actor) if (actor->temp_data[4] <= -511 || actor->temp_data[4] >= 512) { actor->temp_data[4] = 0; - actor->temp_angle = mapangle(actor->temp_angle.Buildang() & 0xffffff00); // Gross hack! What is this supposed to do? + // Normalize to avoid getting negative Build angle on CCW rotations + int snapped = actor->temp_angle.Normalized360().Buildang(); + // Quantize to 256-bit increments to prevent vector drift (legacy Build behavior) + snapped &= 0xffffff00; + actor->temp_angle = mapangle(snapped); movesector(actor, actor->temp_data[1], actor->temp_angle); //SetActor(actor, actor->spr.pos); }