shithub: choc

Download patch

ref: 99f836fcb772f4720066975d79909719b03398c8
parent: a64aec204b31884506af334bca9984c1183b442a
author: Simon Howard <[email protected]>
date: Fri Sep 1 16:45:45 EDT 2006

Sync the -loadgame parameter across all clients connected to a server.
Loading/saving multiplayer games should all work now.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 593

--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: d_main.c 591 2006-08-31 22:11:08Z fraggle $
+// $Id: d_main.c 593 2006-09-01 20:45:45Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -184,7 +184,7 @@
 //-----------------------------------------------------------------------------
 
 
-static const char rcsid[] = "$Id: d_main.c 591 2006-08-31 22:11:08Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 593 2006-09-01 20:45:45Z fraggle $";
 
 #define	BGCOLOR		7
 #define	FGCOLOR		8
@@ -294,6 +294,7 @@
 int             startepisode;
 int		startmap;
 boolean		autostart;
+int             startloadgame;
 
 FILE*		debugfile;
 
@@ -1809,6 +1810,22 @@
 	autostart = true;
     }
 
+    // Check for load game parameter
+    // We do this here and save the slot number, so that the network code
+    // can override it or send the load slot to other players.
+
+    p = M_CheckParm ("-loadgame");
+    
+    if (p && p < myargc-1)
+    {
+        startloadgame = atoi(myargv[p+1]);
+    }
+    else
+    {
+        // Not loading a game
+        startloadgame = -1;
+    }
+
     if (M_CheckParm("-novert"))
         novert = true;
     else if (M_CheckParm("-nonovert"))
@@ -1902,10 +1919,9 @@
 	D_DoomLoop ();  // never returns
     }
 	
-    p = M_CheckParm ("-loadgame");
-    if (p && p < myargc-1)
+    if (startloadgame >= 0)
     {
-        strcpy(file, P_SaveGameFile(atoi(myargv[p+1])));
+        strcpy(file, P_SaveGameFile(startloadgame));
 	G_LoadGame (file);
     }
 	
@@ -1919,3 +1935,4 @@
 
     D_DoomLoop ();  // never returns
 }
+
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: doomstat.h 531 2006-05-25 22:39:57Z fraggle $
+// $Id: doomstat.h 593 2006-09-01 20:45:45Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -78,6 +78,11 @@
 extern  skill_t		startskill;
 extern  int             startepisode;
 extern	int		startmap;
+
+// Savegame slot to load on startup.  This is the value provided to
+// the -loadgame option.  If this has not been provided, this is -1.
+
+extern  int             startloadgame;
 
 extern  boolean		autostart;
 
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_client.c 557 2006-06-03 18:23:09Z fraggle $
+// $Id: net_client.c 593 2006-09-01 20:45:45Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -469,6 +469,7 @@
     settings.episode = startepisode;
     settings.map = startmap;
     settings.skill = startskill;
+    settings.loadgame = startloadgame;
     settings.gameversion = gameversion;
     settings.nomonsters = nomonsters;
     settings.timelimit = timelimit;
@@ -681,6 +682,7 @@
     startepisode = settings.episode;
     startmap = settings.map;
     startskill = settings.skill;
+    startloadgame = settings.loadgame;
     lowres_turn = settings.lowres_turn;
     nomonsters = settings.nomonsters;
     net_cl_new_sync = settings.new_sync != 0;
--- a/src/net_defs.h
+++ b/src/net_defs.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_defs.h 475 2006-05-05 19:49:34Z fraggle $
+// $Id: net_defs.h 593 2006-09-01 20:45:45Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -180,6 +180,7 @@
     int lowres_turn;
     int new_sync;
     int timelimit;
+    int loadgame;
 } net_gamesettings_t;
 
 #define NET_TICDIFF_FORWARD      (1 << 0)
--- a/src/net_structrw.c
+++ b/src/net_structrw.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: net_structrw.c 475 2006-05-05 19:49:34Z fraggle $
+// $Id: net_structrw.c 593 2006-09-01 20:45:45Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -81,6 +81,7 @@
     NET_WriteInt8(packet, settings->lowres_turn);
     NET_WriteInt8(packet, settings->new_sync);
     NET_WriteInt32(packet, settings->timelimit);
+    NET_WriteInt8(packet, settings->loadgame);
 }
 
 boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings)
@@ -94,8 +95,9 @@
         && NET_ReadInt8(packet, (unsigned int *) &settings->skill)
         && NET_ReadInt8(packet, (unsigned int *) &settings->gameversion)
         && NET_ReadInt8(packet, (unsigned int *) &settings->lowres_turn)
-	&& NET_ReadInt8(packet, (unsigned int *) &settings->new_sync)
-	&& NET_ReadInt32(packet, (unsigned int *) &settings->timelimit);
+        && NET_ReadInt8(packet, (unsigned int *) &settings->new_sync)
+        && NET_ReadInt32(packet, (unsigned int *) &settings->timelimit)
+        && NET_ReadSInt8(packet, (signed int *) &settings->loadgame);
 }
 
 void NET_WriteTiccmdDiff(net_packet_t *packet, net_ticdiff_t *diff,