stratagus-cvs
[Top][All Lists]
Advanced

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

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


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src game/game.c game/loadgame.c game/...
Date: 27 Jan 2004 21:15:25 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/27 21:15:25

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

Log message:
        Support to Load map, before save game, loads triggers, and other map 
information not saved

Patches:
Index: stratagus/src/game/game.c
diff -u stratagus/src/game/game.c:1.129 stratagus/src/game/game.c:1.130
--- stratagus/src/game/game.c:1.129     Thu Jan 22 17:18:19 2004
+++ stratagus/src/game/game.c   Tue Jan 27 21:15:22 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: game.c,v 1.129 2004/01/22 06:18:19 wizzard Exp $
+//      $Id: game.c,v 1.130 2004/01/27 10:15:22 wizzard Exp $
 
 //@{
 
@@ -113,6 +113,7 @@
                fprintf(stderr, "%s: invalid Stratagus map\n", filename);
                ExitFatal(-1);
        }
+       TheMap.Info->Filename = strdup(filename);
 }
 
 /**
@@ -154,6 +155,7 @@
        // ARI: This bombs out, if no pud, so will be safe.
        if (strcasestr(filename, ".pud")) {
                LoadPud(filename, map);
+               map->Info->Filename = strdup(filename);
        }
 }
 
Index: stratagus/src/game/loadgame.c
diff -u stratagus/src/game/loadgame.c:1.82 stratagus/src/game/loadgame.c:1.83
--- stratagus/src/game/loadgame.c:1.82  Wed Jan 21 15:57:14 2004
+++ stratagus/src/game/loadgame.c       Tue Jan 27 21:15:22 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: loadgame.c,v 1.82 2004/01/21 04:57:14 jsalmon3 Exp $
+//      $Id: loadgame.c,v 1.83 2004/01/27 10:15:22 wizzard Exp $
 
 //@{
 
@@ -218,6 +218,7 @@
        CleanModules();
        // log will be enabled if found in the save game
        CommandLogDisabled = 1;
+       SaveGameLoading = 1;
 
        LoadCcl();
 
@@ -241,6 +242,7 @@
        GameCycle = game_cycle;
        SelectionChanged();
        MustRedraw = RedrawEverything;
+       SaveGameLoading = 0;
 }
 
 /**
Index: stratagus/src/game/savegame.c
diff -u stratagus/src/game/savegame.c:1.42 stratagus/src/game/savegame.c:1.43
--- stratagus/src/game/savegame.c:1.42  Sat Jan 17 02:17:23 2004
+++ stratagus/src/game/savegame.c       Tue Jan 27 21:15:22 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: savegame.c,v 1.42 2004/01/16 15:17:23 wizzard Exp $
+//      $Id: savegame.c,v 1.43 2004/01/27 10:15:22 wizzard Exp $
 
 //@{
 
@@ -97,17 +97,16 @@
        //
        //              Parseable header
        //
-       CLprintf(file, "---SaveGame(\n");
+       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.42 2004/01/16 
15:17:23 wizzard Exp $\",\n");
+       CLprintf(file, "---  \"comment\", \"$Id: savegame.c,v 1.43 2004/01/27 
10:15:22 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, "---  \"savefile\" {%d, %d, %d},\n",
-               StratagusMajorVersion, StratagusMinorVersion, 
StratagusPatchLevel);
+       CLprintf(file, "  SaveFile = \"%s\"\n", TheMap.Info->Filename);
        // Save media type
        {
 #if defined(USE_GUILE) || defined(USE_SIOD)
@@ -128,7 +127,7 @@
 #endif
        }
        CLprintf(file, "\n---  \"preview\", \"%s.pam\",\n", filename);
-       CLprintf(file, "---  )\n\n");
+       CLprintf(file, "} )\n\n");
 
        // FIXME: probably not the right place for this
        CLprintf(file, "SetGameCycle(%lu)\n", GameCycle);
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.46 
stratagus/src/include/stratagus.h:1.47
--- stratagus/src/include/stratagus.h:1.46      Sat Jan 24 13:42:26 2004
+++ stratagus/src/include/stratagus.h   Tue Jan 27 21:15:23 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: stratagus.h,v 1.46 2004/01/24 02:42:26 jsalmon3 Exp $
+//      $Id: stratagus.h,v 1.47 2004/01/27 10:15:23 wizzard Exp $
 
 #ifndef __STRATAGUS_H__
 #define __STRATAGUS_H__
@@ -415,6 +415,7 @@
 
 extern void LoadGame(char*);                /// Load saved game back
 extern void SaveGame(const char*);          /// Save game for later load
+extern int SaveGameLoading;                 /// Save game is in progress of 
loading
 
 extern void LoadAll(void);                  /// Load all data back
 
Index: stratagus/src/map/map.c
diff -u stratagus/src/map/map.c:1.76 stratagus/src/map/map.c:1.77
--- stratagus/src/map/map.c:1.76        Wed Jan 21 05:41:59 2004
+++ stratagus/src/map/map.c     Tue Jan 27 21:15:23 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: map.c,v 1.76 2004/01/20 18:41:59 nobody_ Exp $
+//     $Id: map.c,v 1.77 2004/01/27 10:15:23 wizzard Exp $
 
 //@{
 
@@ -621,6 +621,9 @@
                }
                if (info->MapTerrainName) {
                        free(info->MapTerrainName);
+               }
+               if (info->Filename) {
+                       free(info->Filename);
                }
                free(info);
        }
Index: stratagus/src/stratagus/script.c
diff -u stratagus/src/stratagus/script.c:1.169 
stratagus/src/stratagus/script.c:1.170
--- stratagus/src/stratagus/script.c:1.169      Sat Jan 24 02:18:32 2004
+++ stratagus/src/stratagus/script.c    Tue Jan 27 21:15:24 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script.c,v 1.169 2004/01/23 15:18:32 nobody_ Exp $
+//      $Id: script.c,v 1.170 2004/01/27 10:15:24 wizzard Exp $
 
 //@{
 
@@ -83,6 +83,7 @@
 global char* CclStartFile;              /// CCL start file
 global char* GameName;                  /// Game Preferences
 global int CclInConfigFile;             /// True while config file parsing
+global int SaveGameLoading;                                    /// If a Saved 
Game is Loading
 
 global char* Tips[MAX_TIPS + 1];        /// Array of tips
 global int  ShowTips;                   /// Show tips at start of level
@@ -235,6 +236,47 @@
 }
 
 /**
+**  Load the SaveGame Header
+**
+**  @param l  Lua variable stack
+*/
+local int CclSaveGame(lua_State* l)
+{
+       const char* value;
+       char buf[1024];
+
+    if (lua_gettop(l) != 1 || !lua_istable(l, 1)) {
+               lua_pushstring(l, "incorrect argument");
+               lua_error(l);
+    }
+
+       lua_pushnil(l);
+       while (lua_next(l, 1)) {
+               value = LuaToString(l, -2);
+               
+               if (!strcmp(value, "SaveFile")) {
+                       value = LuaToString(l, -1);
+                       strcpy(CurrentMapPath, value);
+                       if (strcasestr(value, ".pud")) {
+                               //LoadPud(LibraryFileName(value, buf), &TheMap);
+                       } else {
+                               LibraryFileName(value, buf);
+                               if (LuaLoadFile(buf) == -1) {
+                                       DebugLevel0Fn("Load failed: %s" _C_ 
value);
+                               }
+                       }
+                       lua_pop(l, 1);
+               } else {
+                       lua_pushfstring(l, "Unsupported tag: %s", value);
+                       lua_error(l);
+                       DebugCheck(1);
+               }
+       }
+
+       return 0;
+}
+
+/**
 **  FIXME: docu
 */
 global const char* LuaToString(lua_State* l, int narg)
@@ -895,6 +937,10 @@
        const char* name;
        char buffer[1024];
 
+       if (SaveGameLoading) {
+               return 0;
+       }
+
        if (lua_gettop(l) != 1) {
                lua_pushstring(l, "incorrect argument");
                lua_error(l);
@@ -1292,6 +1338,7 @@
        lua_register(Lua, "DefineDefaultResourceAmounts", 
CclDefineDefaultResourceAmounts);
 
        lua_register(Lua, "Load", CclLoad);
+       lua_register(Lua, "SaveGame", CclSaveGame);
 
        NetworkCclRegister();
        IconCclRegister();
@@ -1363,7 +1410,7 @@
        }
 
        fprintf(fd, "--- -----------------------------------------\n");
-       fprintf(fd, "--- $Id: script.c,v 1.169 2004/01/23 15:18:32 nobody_ Exp 
$\n");
+       fprintf(fd, "--- $Id: script.c,v 1.170 2004/01/27 10:15:24 wizzard Exp 
$\n");
 
        fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
 
@@ -1387,7 +1434,7 @@
        }
 
        fprintf(fd, "--- -----------------------------------------\n");
-       fprintf(fd, "--- $Id: script.c,v 1.169 2004/01/23 15:18:32 nobody_ Exp 
$\n");
+       fprintf(fd, "--- $Id: script.c,v 1.170 2004/01/27 10:15:24 wizzard Exp 
$\n");
 
        // Global options
        if (OriginalFogOfWar) {




reply via email to

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