fixed bug with handling networking packets if request dialog is active
[rocksndiamonds.git] / src / init.c
index c1faec094d8c91545a5b03913eb601984acc2fa8..2167984b663649481289e4d4c0c5f14be1670312 100644 (file)
@@ -88,7 +88,7 @@ static int copy_properties[][5] =
 static int get_graphic_parameter_value(char *, char *, int);
 
 
-void DrawInitAnim(void)
+static void DrawInitAnim(void)
 {
   struct GraphicInfo *graphic_info_last = graphic_info;
   int graphic = 0;
@@ -136,7 +136,21 @@ void DrawInitAnim(void)
   FrameCounter++;
 }
 
-void FreeGadgets(void)
+static void DrawProgramInfo(void)
+{
+  int font1_nr = FC_YELLOW;
+  int font2_nr = FC_RED;
+  int font2_height = getFontHeight(font2_nr);
+  int ypos1 = 20;
+  int ypos2 = 50;
+  int ypos3 = WIN_YSIZE - 20 - font2_height;
+
+  DrawInitText(getProgramInitString(),           ypos1, font1_nr);
+  DrawInitText(setup.internal.program_copyright, ypos2, font2_nr);
+  DrawInitText(setup.internal.program_website,   ypos3, font2_nr);
+}
+
+static void FreeGadgets(void)
 {
   FreeLevelEditorGadgets();
   FreeGameButtons();
@@ -171,7 +185,7 @@ inline static void InitElementSmallImagesScaledUp(int graphic)
   CreateImageWithSmallImages(graphic, g->scale_up_factor, g->tile_size);
 }
 
-void InitElementSmallImages(void)
+static void InitElementSmallImages(void)
 {
   print_timestamp_init("InitElementSmallImages");
 
@@ -233,7 +247,7 @@ inline static void InitScaledImagesScaledUp(int graphic)
   ScaleImage(graphic, g->scale_up_factor);
 }
 
-void InitScaledImages(void)
+static void InitScaledImages(void)
 {
   struct PropertyMapping *property_mapping = getImageListPropertyMapping();
   int num_property_mappings = getImageListPropertyMappingSize();
@@ -248,7 +262,7 @@ void InitScaledImages(void)
     InitScaledImagesScaledUp(property_mapping[i].artwork_index);
 }
 
-void InitBitmapPointers(void)
+static void InitBitmapPointers(void)
 {
   int num_images = getImageListSize();
   int i;
@@ -333,7 +347,7 @@ static int getFontFromToken(char *token)
   return FONT_INITIAL_1;
 }
 
-void InitFontGraphicInfo(void)
+static void InitFontGraphicInfo(void)
 {
   static struct FontBitmapInfo *font_bitmap_info = NULL;
   struct PropertyMapping *property_mapping = getImageListPropertyMapping();
@@ -572,7 +586,7 @@ void InitFontGraphicInfo(void)
               getFontBitmapID, getFontFromToken);
 }
 
-void InitGlobalAnimGraphicInfo(void)
+static void InitGlobalAnimGraphicInfo(void)
 {
   struct PropertyMapping *property_mapping = getImageListPropertyMapping();
   int num_property_mappings = getImageListPropertyMappingSize();
@@ -644,7 +658,7 @@ void InitGlobalAnimGraphicInfo(void)
 #endif
 }
 
-void InitGlobalAnimSoundInfo(void)
+static void InitGlobalAnimSoundInfo(void)
 {
   struct PropertyMapping *property_mapping = getSoundListPropertyMapping();
   int num_property_mappings = getSoundListPropertyMappingSize();
@@ -693,7 +707,7 @@ void InitGlobalAnimSoundInfo(void)
 #endif
 }
 
-void InitGlobalAnimMusicInfo(void)
+static void InitGlobalAnimMusicInfo(void)
 {
   struct PropertyMapping *property_mapping = getMusicListPropertyMapping();
   int num_property_mappings = getMusicListPropertyMappingSize();
@@ -742,7 +756,7 @@ void InitGlobalAnimMusicInfo(void)
 #endif
 }
 
-void InitElementGraphicInfo(void)
+static void InitElementGraphicInfo(void)
 {
   struct PropertyMapping *property_mapping = getImageListPropertyMapping();
   int num_property_mappings = getImageListPropertyMappingSize();
@@ -1123,7 +1137,7 @@ void InitElementGraphicInfo(void)
   UPDATE_BUSY_STATE();
 }
 
-void InitElementSpecialGraphicInfo(void)
+static void InitElementSpecialGraphicInfo(void)
 {
   struct PropertyMapping *property_mapping = getImageListPropertyMapping();
   int num_property_mappings = getImageListPropertyMappingSize();
@@ -4874,7 +4888,7 @@ static void InitGlobal(void)
   global.use_envelope_request = FALSE;
 }
 
-void Execute_Command(char *command)
+static void Execute_Command(char *command)
 {
   int i;
 
@@ -5099,6 +5113,7 @@ static void InitGameInfo(void)
 {
   game.restart_level = FALSE;
   game.restart_game_message = NULL;
+  game.request_active = FALSE;
 }
 
 static void InitPlayerInfo(void)
@@ -5321,13 +5336,12 @@ void InitGfxBuffers(void)
   InitGfxBuffers_SP();
 }
 
-void InitGfx(void)
+static void InitGfx(void)
 {
   struct GraphicInfo *graphic_info_last = graphic_info;
   char *filename_font_initial = NULL;
   char *filename_anim_initial = NULL;
   Bitmap *bitmap_font_initial = NULL;
-  int font_height;
   int i, j;
 
   /* determine settings for initial font (for displaying startup messages) */
@@ -5378,12 +5392,7 @@ void InitGfx(void)
 
   InitFontGraphicInfo();
 
-  font_height = getFontHeight(FC_RED);
-
-  DrawInitText(getProgramInitString(), 20, FC_YELLOW);
-  DrawInitText(setup.internal.program_copyright, 50, FC_RED);
-  DrawInitText(setup.internal.program_website, WIN_YSIZE - 20 - font_height,
-              FC_RED);
+  DrawProgramInfo();
 
   DrawInitText("Loading graphics", 120, FC_GREEN);
 
@@ -5490,7 +5499,7 @@ void InitGfx(void)
   init_last = init;
 }
 
-void InitGfxBackground(void)
+static void InitGfxBackground(void)
 {
   fieldbuffer = bitmap_db_field;
   SetDrawtoField(DRAW_TO_BACKBUFFER);
@@ -5634,12 +5643,19 @@ static void InitArtworkDone(void)
   InitGlobalAnimations();
 }
 
-void InitNetworkSettings(void)
+static void InitNetworkSettings(void)
 {
-  InitNetworkInfo(options.network || setup.network_mode,
+  boolean network_enabled = (options.network || setup.network_mode);
+  char *network_server = (options.server_host != NULL ? options.server_host :
+                         setup.network_server_hostname);
+
+  if (strEqual(network_server, STR_NETWORK_AUTO_DETECT))
+    network_server = NULL;
+
+  InitNetworkInfo(network_enabled,
                  FALSE,
                  options.serveronly,
-                 options.server_host,
+                 network_server,
                  options.server_port);
 }
 
@@ -5650,6 +5666,9 @@ void InitNetworkServer(void)
 
   LimitScreenUpdates(FALSE);
 
+  if (game_status == GAME_MODE_LOADING)
+    DrawProgramInfo();
+
   if (!ConnectToServer(network.server_host, network.server_port))
   {
     network.enabled = FALSE;
@@ -5666,7 +5685,8 @@ void InitNetworkServer(void)
   }
 
   /* short time to recognize result of network initialization */
-  Delay_WithScreenUpdates(1000);
+  if (game_status == GAME_MODE_LOADING)
+    Delay_WithScreenUpdates(1000);
 }
 
 static boolean CheckArtworkConfigForCustomElements(char *filename)