summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-03-01 17:32:47 +0000
committertruelight <truelight@openttd.org>2005-03-01 17:32:47 +0000
commit6519d3bc97ec4eded4ff415c158856b77f139ee1 (patch)
treee5bdc261156314c783932f078c6d85c92fe51768
parentccbb6263ead4f1bf331ee613fdf7734e079dcd43 (diff)
downloadopenttd-6519d3bc97ec4eded4ff415c158856b77f139ee1.tar.xz
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
-rw-r--r--dedicated.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/dedicated.c b/dedicated.c
index 4ddd7c7a2..0c2de4a0b 100644
--- a/dedicated.c
+++ b/dedicated.c
@@ -44,6 +44,9 @@ int dup2(int oldd, int newd) { return -1; }
static void *_dedicated_video_mem;
+extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
+extern void SwitchMode(int new_mode);
+
#ifdef UNIX
/* We want to fork our dedicated server */
void DedicatedFork(void)
@@ -255,10 +258,27 @@ static int DedicatedVideoMainLoop(void)
// Load the dedicated server stuff
_is_network_server = true;
_network_dedicated = true;
- _switch_mode = SM_NONE;
_network_playas = OWNER_SPECTATOR;
_local_player = OWNER_SPECTATOR;
- DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME);
+
+ /* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */
+ if (_switch_mode != SM_LOAD) {
+ _switch_mode = SM_NONE;
+ DoCommandP(0, Random(), InteractiveRandom(), NULL, CMD_GEN_RANDOM_NEW_GAME);
+ } else {
+ _switch_mode = SM_NONE;
+ /* First we need to test if the savegame can be loaded, else we will end up playing the
+ * intro game... */
+ if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) {
+ /* Loading failed, pop out.. */
+ DEBUG(net, 0)("Loading request map failed. Aborting..");
+ _networking = false;
+ } else {
+ /* We can load this game, so go ahead */
+ SwitchMode(SM_LOAD);
+ }
+ }
+
// Done loading, start game!
if (!_networking) {