summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-09-01 20:45:45 +0000
committerSimon Howard2006-09-01 20:45:45 +0000
commit99f836fcb772f4720066975d79909719b03398c8 (patch)
treeb1b247c31700d20cc0b936b07c9815f2c83bfa47
parenta64aec204b31884506af334bca9984c1183b442a (diff)
downloadchocolate-doom-99f836fcb772f4720066975d79909719b03398c8.tar.gz
chocolate-doom-99f836fcb772f4720066975d79909719b03398c8.tar.bz2
chocolate-doom-99f836fcb772f4720066975d79909719b03398c8.zip
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
-rw-r--r--src/d_main.c27
-rw-r--r--src/doomstat.h7
-rw-r--r--src/net_client.c4
-rw-r--r--src/net_defs.h3
-rw-r--r--src/net_structrw.c8
5 files changed, 38 insertions, 11 deletions
diff --git a/src/d_main.c b/src/d_main.c
index 7d26fa3f..d0c21db3 100644
--- 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 @@ skill_t startskill;
int startepisode;
int startmap;
boolean autostart;
+int startloadgame;
FILE* debugfile;
@@ -1809,6 +1810,22 @@ void D_DoomMain (void)
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 @@ void D_DoomMain (void)
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 @@ void D_DoomMain (void)
D_DoomLoop (); // never returns
}
+
diff --git a/src/doomstat.h b/src/doomstat.h
index 0632d416..2b41b36e 100644
--- 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
@@ -79,6 +79,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;
// Selected by user.
diff --git a/src/net_client.c b/src/net_client.c
index 7956f73f..b104341a 100644
--- 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 @@ void NET_CL_StartGame(void)
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 @@ static void NET_CL_ParseGameStart(net_packet_t *packet)
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;
diff --git a/src/net_defs.h b/src/net_defs.h
index 05bfb93c..928212fe 100644
--- 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 @@ typedef struct
int lowres_turn;
int new_sync;
int timelimit;
+ int loadgame;
} net_gamesettings_t;
#define NET_TICDIFF_FORWARD (1 << 0)
diff --git a/src/net_structrw.c b/src/net_structrw.c
index 0e527ebc..4f5890e9 100644
--- 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 @@ void NET_WriteSettings(net_packet_t *packet, net_gamesettings_t *settings)
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 @@ boolean NET_ReadSettings(net_packet_t *packet, net_gamesettings_t *settings)
&& 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,