X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=6db427ff5333ec44191426f5346ee4c32258df1e;hp=8fb9f80df81798f971ea07192ded0064caba7f09;hb=796c49130a11576aeb603104bdd25a6020598761;hpb=014f8db5b98964dddaf817ce5cd8cf7930bc7ae4 diff --git a/src/init.c b/src/init.c index 8fb9f80d..6db427ff 100644 --- a/src/init.c +++ b/src/init.c @@ -5051,6 +5051,9 @@ void Execute_Command(char *command) { Error(ERR_EXIT_HELP, "unrecognized command '%s'", command); } + + /* disable networking if any valid command was recognized */ + options.network = setup.network_mode = FALSE; } static void InitSetup() @@ -5087,7 +5090,6 @@ static void InitPlayerInfo() } local_player->connected_locally = TRUE; - local_player->connected_network = TRUE; } static void InitArtworkInfo() @@ -5487,6 +5489,8 @@ static void InitLevelInfo() if (leveldir_current == NULL) leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); } + + SetLevelSetInfo(leveldir_current->identifier, level_nr); } static void InitLevelArtworkInfo() @@ -5605,30 +5609,39 @@ static void InitArtworkDone() InitGlobalAnimations(); } -void InitNetworkServer() +void InitNetworkSettings() { -#if defined(NETWORK_AVALIABLE) - int nr_wanted; -#endif - - if (setup.network_mode) - options.network = TRUE; + InitNetworkInfo(options.network || setup.network_mode, + FALSE, + options.serveronly, + options.server_host, + options.server_port); +} - if (!options.network) +void InitNetworkServer() +{ + if (!network.enabled || network.connected) return; -#if defined(NETWORK_AVALIABLE) - nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED); + LimitScreenUpdates(FALSE); - if (!ConnectToServer(options.server_host, options.server_port)) - Error(ERR_EXIT, "cannot connect to network game server"); + if (!ConnectToServer(network.server_host, network.server_port)) + { + network.enabled = FALSE; - SendToServer_PlayerName(setup.player_name); - SendToServer_ProtocolVersion(); + setup.network_mode = FALSE; + } + else + { + SendToServer_ProtocolVersion(); + SendToServer_PlayerName(setup.player_name); + SendToServer_NrWanted(setup.network_player_nr + 1); - if (nr_wanted) - SendToServer_NrWanted(nr_wanted); -#endif + network.connected = TRUE; + } + + /* short time to recognize result of network initialization */ + Delay_WithScreenUpdates(1000); } static boolean CheckArtworkConfigForCustomElements(char *filename) @@ -6001,10 +6014,12 @@ void OpenAll() if (options.execute_command) Execute_Command(options.execute_command); - if (options.serveronly) + InitNetworkSettings(); + + if (network.serveronly) { #if defined(PLATFORM_UNIX) - NetworkServer(options.server_port, options.serveronly); + NetworkServer(network.server_port, TRUE); #else Error(ERR_WARN, "networking only supported in Unix version"); #endif @@ -6089,6 +6104,8 @@ void OpenAll() return; } + InitNetworkServer(); + SetGameStatus(GAME_MODE_MAIN); FadeSetEnterScreen(); @@ -6101,8 +6118,6 @@ void OpenAll() DrawMainMenu(); - InitNetworkServer(); - #if 0 Error(ERR_DEBUG, "::: SDL_GetBasePath() == '%s'", SDL_GetBasePath());