foxygit / doom Log in
commit 2e6406e08349f3bfb6f5d38ac5042aca7a02073d
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Dec 28 20:57:20 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Dec 28 20:57:20 2009 +0000

    When recording low resolution (non-longtics) Vanilla demos, carry
    forward the error from angleturn caused by the reduced resolution, so
    that consecutive errors can accumulate, possibly making turning slightly
    smoother.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1770
---
 src/g_game.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/g_game.c b/src/g_game.c
index 8255fdd0..542c1a7d 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -650,10 +650,20 @@ void G_BuildTiccmd (ticcmd_t* cmd)

     if (lowres_turn)
     {
-        // round angleturn to the nearest 256 boundary
+        static signed short carry = 0;
+        signed short desired_angleturn;
+
+        desired_angleturn = cmd->angleturn + carry;
+
+        // round angleturn to the nearest 256 unit boundary
         // for recording demos with single byte values for turn

-        cmd->angleturn = (cmd->angleturn + 128) & 0xff00;
+        cmd->angleturn = (desired_angleturn + 128) & 0xff00;
+
+        // Carry forward the error from the reduced resolution to the
+        // next tic, so that successive small movements can accumulate.
+
+        carry = desired_angleturn - cmd->angleturn;
     }
 }