stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src game/loadgame.c game/savegame.c s...


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src game/loadgame.c game/savegame.c s...
Date: 1 Feb 2004 09:04:06 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/02/01 09:04:05

Modified files:
        src/game       : loadgame.c savegame.c 
        src/stratagus  : script.c 

Log message:
        Save and Load SyncHash and SyncRandSeed, so they replay stays in sync

Patches:
Index: stratagus/src/game/loadgame.c
diff -u stratagus/src/game/loadgame.c:1.84 stratagus/src/game/loadgame.c:1.85
--- stratagus/src/game/loadgame.c:1.84  Tue Jan 27 22:03:26 2004
+++ stratagus/src/game/loadgame.c       Sun Feb  1 09:04:04 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: loadgame.c,v 1.84 2004/01/27 11:03:26 wizzard Exp $
+//      $Id: loadgame.c,v 1.85 2004/01/31 22:04:04 wizzard Exp $
 
 //@{
 
@@ -214,6 +214,8 @@
 global void LoadGame(char* filename)
 {
        unsigned long game_cycle;
+       unsigned syncrand;
+       unsigned synchash;
 
        CleanModules();
        // log will be enabled if found in the save game
@@ -231,6 +233,8 @@
        CclGarbageCollect(0);
 
        game_cycle = GameCycle;
+       syncrand = SyncRandSeed;
+       synchash = SyncHash;
 
        InitModules();
        LoadModules();
@@ -240,6 +244,8 @@
 #endif
 
        GameCycle = game_cycle;
+       SyncRandSeed = syncrand;
+       SyncHash = synchash;
        SelectionChanged();
        MustRedraw = RedrawEverything;
 }
Index: stratagus/src/game/savegame.c
diff -u stratagus/src/game/savegame.c:1.43 stratagus/src/game/savegame.c:1.44
--- stratagus/src/game/savegame.c:1.43  Tue Jan 27 21:15:22 2004
+++ stratagus/src/game/savegame.c       Sun Feb  1 09:04:04 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: savegame.c,v 1.43 2004/01/27 10:15:22 wizzard Exp $
+//      $Id: savegame.c,v 1.44 2004/01/31 22:04:04 wizzard Exp $
 
 //@{
 
@@ -59,6 +59,7 @@
 #include "spells.h"
 #include "commands.h"
 #include "script.h"
+#include "actions.h"
 
 /*----------------------------------------------------------------------------
 --  Variables
@@ -100,12 +101,14 @@
        CLprintf(file, "SaveGame({\n");
        CLprintf(file, "---  \"comment\", \"Generated by Stratagus Version " 
VERSION "\",\n");
        CLprintf(file, "---  \"comment\", \"Visit http://Stratagus.Org for more 
informations\",\n");
-       CLprintf(file, "---  \"comment\", \"$Id: savegame.c,v 1.43 2004/01/27 
10:15:22 wizzard Exp $\",\n");
+       CLprintf(file, "---  \"comment\", \"$Id: savegame.c,v 1.44 2004/01/31 
22:04:04 wizzard Exp $\",\n");
        CLprintf(file, "---  \"type\",    \"%s\",\n", "single-player");
        CLprintf(file, "---  \"date\",    \"%s\",\n", s);
        CLprintf(file, "---  \"map\",     \"%s\",\n", TheMap.Description);
        CLprintf(file, "---  \"engine\",  {%d, %d, %d},\n",
                StratagusMajorVersion, StratagusMinorVersion, 
StratagusPatchLevel);
+       CLprintf(file, "  SyncHash = %d, \n", SyncHash);
+       CLprintf(file, "  SyncRandSeed = %d, \n", SyncRandSeed);
        CLprintf(file, "  SaveFile = \"%s\"\n", TheMap.Info->Filename);
        // Save media type
        {
Index: stratagus/src/stratagus/script.c
diff -u stratagus/src/stratagus/script.c:1.173 
stratagus/src/stratagus/script.c:1.174
--- stratagus/src/stratagus/script.c:1.173      Sun Feb  1 07:06:57 2004
+++ stratagus/src/stratagus/script.c    Sun Feb  1 09:04:05 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script.c,v 1.173 2004/01/31 20:06:57 nobody_ Exp $
+//      $Id: script.c,v 1.174 2004/01/31 22:04:05 wizzard Exp $
 
 //@{
 
@@ -69,6 +69,7 @@
 #include "network.h"
 #include "cdaudio.h"
 #include "spells.h"
+#include "actions.h"
 
 
 /*----------------------------------------------------------------------------
@@ -252,21 +253,24 @@
                value = LuaToString(l, -2);
                
                if (!strcmp(value, "SaveFile")) {
-                       value = LuaToString(l, -1);
-                       strcpy(CurrentMapPath, value);
+                       strcpy(CurrentMapPath, LuaToString(l, -1));
                        // If .pud, we don't need to load anything from it
-                       if (!strcasestr(value, ".pud")) {
-                               LibraryFileName(value, buf);
+                       if (!strcasestr(LuaToString(l, -1), ".pud")) {
+                               LibraryFileName(LuaToString(l, -1), buf);
                                if (LuaLoadFile(buf) == -1) {
                                        DebugLevel0Fn("Load failed: %s" _C_ 
value);
                                }
                        }
-                       lua_pop(l, 1);
+               } else if (!strcmp(value, "SyncHash")) {
+                       SyncHash = LuaToNumber(l, -1);
+               } else if (!strcmp(value, "SyncRandSeed")) {
+                       SyncRandSeed = LuaToNumber(l, -1);
                } else {
                        lua_pushfstring(l, "Unsupported tag: %s", value);
                        lua_error(l);
                        DebugCheck(1);
                }
+               lua_pop(l, 1);
        }
 
        return 0;
@@ -1404,7 +1408,7 @@
        }
 
        fprintf(fd, "--- -----------------------------------------\n");
-       fprintf(fd, "--- $Id: script.c,v 1.173 2004/01/31 20:06:57 nobody_ Exp 
$\n");
+       fprintf(fd, "--- $Id: script.c,v 1.174 2004/01/31 22:04:05 wizzard Exp 
$\n");
 
        fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
 
@@ -1428,7 +1432,7 @@
        }
 
        fprintf(fd, "--- -----------------------------------------\n");
-       fprintf(fd, "--- $Id: script.c,v 1.173 2004/01/31 20:06:57 nobody_ Exp 
$\n");
+       fprintf(fd, "--- $Id: script.c,v 1.174 2004/01/31 22:04:05 wizzard Exp 
$\n");
 
        // Global options
        if (OriginalFogOfWar) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]