diff options
author | truelight <truelight@openttd.org> | 2005-03-01 17:32:47 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-03-01 17:32:47 +0000 |
commit | 71de43f4db47ca67c72d21684a5affde19e6685f (patch) | |
tree | e5bdc261156314c783932f078c6d85c92fe51768 | |
parent | 7f78acebef9ba7e17fe18b7bd23a2c8928afb650 (diff) | |
download | openttd-71de43f4db47ca67c72d21684a5affde19e6685f.tar.xz |
(svn r1918) -Fix: [ 1101874 ] Dedicated server now accepts '-g' (load game) as param
-rw-r--r-- | dedicated.c | 24 |
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) { |