[chocolate-doom] 68/79: Vanilla savegame load/save

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 30 15:07:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to annotated tag chocolate-doom-0.1.3
in repository chocolate-doom.

commit 764d7ecb7a88b2ad0381574a05b90ccedce6655c
Author: Simon Howard <fraggle at gmail.com>
Date:   Mon Jan 16 21:40:38 2006 +0000

    Vanilla savegame load/save
    
    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 296
---
 NEWS          |  2 ++
 src/p_saveg.c | 42 ++++++++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 28a3998..3c63096 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@
          the ENDOOM screen to be disabled.
 
     Fixes for big endian machines (thanks locust)
+    Savegame fixes: we now load and save to the Vanilla Doom savegame
+        format.
     Fixed the behavior of the dehacked maximum health setting.
     Fix the "-skill 0" hack to play without any items (thanks to Janizdreg
         for pointing out that this was nonfunctional)
diff --git a/src/p_saveg.c b/src/p_saveg.c
index 0073e6e..455dc61 100644
--- a/src/p_saveg.c
+++ b/src/p_saveg.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: p_saveg.c 202 2005-10-16 01:18:10Z fraggle $
+// $Id: p_saveg.c 296 2006-01-16 21:40:38Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.4  2006/01/16 21:40:38  fraggle
+// Vanilla savegame load/save
+//
 // Revision 1.3  2005/10/16 01:18:10  fraggle
 // Global "configdir" variable with directory to store config files in.
 // Create a function to find the filename for a savegame slot.  Store
@@ -40,7 +43,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: p_saveg.c 202 2005-10-16 01:18:10Z fraggle $";
+rcsid[] = "$Id: p_saveg.c 296 2006-01-16 21:40:38Z fraggle $";
 
 #include "dstrings.h"
 #include "deh_main.h"
@@ -257,6 +260,19 @@ typedef enum
 } thinkerclass_t;
 
 
+// There is a small issue with the packing of mobjs.  The 'mapthing'
+// field in mobj_t is 10 bytes long.  Watcom packed this without any
+// alignment issues; gcc aligns the fields to 4-byte boundaries.  This
+// means that the size of the mobj_t structure is 2 bytes extra than
+// in Vanilla Doom.  
+//
+// These functions have a temporary fix for this.  We copy the tracer
+// field back two bytes to manually pack the data.  This is obviously
+// horrible, non compiler-portable, not endian safe, etc. etc.
+//
+// This will be properly fixed once I rework the savegame code.
+// The correct size of the mobj_t structure is 154 bytes.
+
 
 //
 // P_ArchiveThinkers
@@ -265,7 +281,7 @@ void P_ArchiveThinkers (void)
 {
     thinker_t*		th;
     mobj_t*		mobj;
-	
+
     // save off the current thinkers
     for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
     {
@@ -276,6 +292,15 @@ void P_ArchiveThinkers (void)
 	    mobj = (mobj_t *)save_p;
 	    memcpy (mobj, th, sizeof(*mobj));
 	    save_p += sizeof(*mobj);
+
+            // Hack fix for structure packing bug, see above.
+
+            if (sizeof(mobj_t) == 156)
+            {
+                memmove(save_p - 6, save_p - 4, 4);
+                save_p -= 2;
+            }
+
 	    mobj->state = (state_t *)(mobj->state - states);
 	    
 	    if (mobj->player)
@@ -316,7 +341,7 @@ void P_UnArchiveThinkers (void)
 	currentthinker = next;
     }
     P_InitThinkers ();
-	
+    
     // read in saved thinkers
     while (1)
     {
@@ -331,6 +356,15 @@ void P_UnArchiveThinkers (void)
 	    mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL);
 	    memcpy (mobj, save_p, sizeof(*mobj));
 	    save_p += sizeof(*mobj);
+
+            // Hack fix for structure packing bug, see above.
+
+            if (sizeof(mobj_t) == 156)
+            {
+                save_p -= 2;
+                memmove(&mobj->tracer, save_p - 4, 4);
+            }
+
 	    mobj->state = &states[(int)mobj->state];
 	    mobj->target = NULL;
 	    if (mobj->player)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list