Author: cazfi
Date: Sat Aug 20 18:55:23 2016
New Revision: 33654

URL: http://svn.gna.org/viewcvs/freeciv?rev=33654&view=rev
Log:
Do not start menu music when the client leaves game with purpose to quit 
completely.

Reported by Jacob Nevins <jtn>

See bug #24844

Modified:
    branches/S2_6/client/client_main.c
    branches/S2_6/client/client_main.h
    branches/S2_6/client/gui-gtk-2.0/gui_main.c
    branches/S2_6/client/gui-gtk-3.0/gui_main.c
    branches/S2_6/client/gui-qt/gui_main.cpp
    branches/S2_6/client/gui-sdl/gui_main.c
    branches/S2_6/client/gui-sdl2/gui_main.c
    branches/S2_6/client/gui-stub/gui_main.c
    branches/S2_6/client/gui-xaw/gui_main.c

Modified: branches/S2_6/client/client_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/client_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/client_main.c  (original)
+++ branches/S2_6/client/client_main.c  Sat Aug 20 18:55:23 2016
@@ -160,6 +160,8 @@
 #ifdef DEBUG
 bool hackless = FALSE;
 #endif
+
+static bool client_quitting = FALSE;
 
 /**************************************************************************
   Convert a text string from the internal to the data encoding, when it
@@ -846,8 +848,10 @@
   if (oldstate == C_S_RUNNING && newstate != C_S_PREPARING) {
     stop_style_music();
 
-    /* Back to menu */
-    start_menu_music("music_menu", NULL);
+    if (!is_client_quitting()) {
+      /* Back to menu */
+      start_menu_music("music_menu", NULL);
+    }
   }
 
   civclient_state = newstate;
@@ -1447,3 +1451,19 @@
 
   return NULL;
 }
+
+/****************************************************************************
+  Is the client marked as one going down?
+****************************************************************************/
+bool is_client_quitting(void)
+{
+  return client_quitting;
+}
+
+/****************************************************************************
+  Mark client as one going to quit as soon as possible,
+****************************************************************************/
+void start_quitting(void)
+{
+  client_quitting = TRUE;
+}

Modified: branches/S2_6/client/client_main.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/client_main.h?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/client_main.h  (original)
+++ branches/S2_6/client/client_main.h  Sat Aug 20 18:55:23 2016
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -117,6 +117,9 @@
 
 void client_exit(void);
 
+bool is_client_quitting(void);
+void start_quitting(void);
+
 /* Set in GUI code. */
 extern const char * const gui_character_encoding;
 extern const bool gui_use_transliteration;

Modified: branches/S2_6/client/gui-gtk-2.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/gui_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/gui_main.c (original)
+++ branches/S2_6/client/gui-gtk-2.0/gui_main.c Sat Aug 20 18:55:23 2016
@@ -1703,6 +1703,7 @@
   gui_up = TRUE;
   gtk_main();
   gui_up = FALSE;
+  start_quitting();
 
   destroy_server_scans();
   free_mapcanvas_and_overview();

Modified: branches/S2_6/client/gui-gtk-3.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/gui_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/gui_main.c (original)
+++ branches/S2_6/client/gui-gtk-3.0/gui_main.c Sat Aug 20 18:55:23 2016
@@ -1833,6 +1833,7 @@
   gui_up = TRUE;
   gtk_main();
   gui_up = FALSE;
+  start_quitting();
 
   destroy_server_scans();
   free_mapcanvas_and_overview();

Modified: branches/S2_6/client/gui-qt/gui_main.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/gui_main.cpp?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/gui_main.cpp    (original)
+++ branches/S2_6/client/gui-qt/gui_main.cpp    Sat Aug 20 18:55:23 2016
@@ -182,6 +182,7 @@
 
     freeciv_qt = new fc_client();
     freeciv_qt->main(qapp);
+    start_quitting();
   }
 }
 

Modified: branches/S2_6/client/gui-sdl/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/gui_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/gui_main.c     (original)
+++ branches/S2_6/client/gui-sdl/gui_main.c     Sat Aug 20 18:55:23 2016
@@ -1056,9 +1056,9 @@
 
   /* Main game loop */
   gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler,
-                main_mouse_button_down_handler, main_mouse_button_up_handler,
-                main_mouse_motion_handler);
-                 
+                 main_mouse_button_down_handler, main_mouse_button_up_handler,
+                 main_mouse_motion_handler);
+  start_quitting();
 }
 
 /**************************************************************************

Modified: branches/S2_6/client/gui-sdl2/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/gui_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/gui_main.c    (original)
+++ branches/S2_6/client/gui-sdl2/gui_main.c    Sat Aug 20 18:55:23 2016
@@ -992,6 +992,7 @@
   gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler, NULL,
                  main_mouse_button_down_handler, main_mouse_button_up_handler,
                  main_mouse_motion_handler);
+  start_quitting();
 }
 
 /**************************************************************************

Modified: branches/S2_6/client/gui-stub/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-stub/gui_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-stub/gui_main.c    (original)
+++ branches/S2_6/client/gui-stub/gui_main.c    Sat Aug 20 18:55:23 2016
@@ -111,6 +111,10 @@
 
   /* PORTME */
   fc_fprintf(stderr, "Freeciv rules!\n");
+
+  /* Main loop here */
+
+  start_quitting();
 }
 
 /****************************************************************************

Modified: branches/S2_6/client/gui-xaw/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-xaw/gui_main.c?rev=33654&r1=33653&r2=33654&view=diff
==============================================================================
--- branches/S2_6/client/gui-xaw/gui_main.c     (original)
+++ branches/S2_6/client/gui-xaw/gui_main.c     Sat Aug 20 18:55:23 2016
@@ -337,7 +337,7 @@
 
   /* include later - pain to see the warning at every run */
   XtSetLanguageProc(NULL, NULL, NULL);
-  
+
   toplevel = XtVaAppInitialize(
               &app_context,               /* Application context */
               "Freeciv",                  /* application class name */
@@ -358,7 +358,7 @@
 /*  XSynchronize(display, 1); 
   XSetErrorHandler(myerr);*/
 
-  if(appResources.version==NULL)  {
+  if (appResources.version == NULL)  {
     log_fatal(_("No version number in resources."));
     log_fatal(_("You probably have an old (circa V1.0)"
                 " Freeciv resource file somewhere."));
@@ -367,7 +367,7 @@
 
   /* TODO: Use capabilities here instead of version numbers */
   if (0 != strncmp(appResources.version, VERSION_STRING,
-                  strlen(appResources.version))) {
+                   strlen(appResources.version))) {
     log_fatal(_("Game version does not match Resource version."));
     log_fatal(_("Game version: %s - Resource version: %s"),
               VERSION_STRING, appResources.version);
@@ -375,19 +375,19 @@
                 " in /usr/lib/X11/app-defaults"));
     exit(EXIT_FAILURE);
   }
-  
-  if(!appResources.gotAppDefFile) {
+
+  if (!appResources.gotAppDefFile) {
     log_normal(_("Using fallback resources - which is OK"));
   }
 
   display = XtDisplay(toplevel);
-  screen_number=XScreenNumberOfScreen(XtScreen(toplevel));
-  display_depth=DefaultDepth(display, screen_number);
-  root_window=DefaultRootWindow(display);
-
-  display_color_type=get_visual(); 
-  
-  if(display_color_type!=COLOR_DISPLAY) {
+  screen_number = XScreenNumberOfScreen(XtScreen(toplevel));
+  display_depth = DefaultDepth(display, screen_number);
+  root_window = DefaultRootWindow(display);
+
+  display_color_type = get_visual();
+
+  if (display_color_type != COLOR_DISPLAY) {
     log_fatal(_("Only color displays are supported for now..."));
     /*    exit(EXIT_FAILURE); */
   }
@@ -422,8 +422,8 @@
     values.foreground = get_color(tileset, 
COLOR_MAPVIEW_CITYTEXT)->color.pixel;
     values.background = get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color.pixel;
     font_gc= XCreateGC(display, root_window, 
-                      GCForeground|GCBackground|GCGraphicsExposures, 
-                      &values);
+                       GCForeground|GCBackground|GCGraphicsExposures, 
+                       &values);
 
     prod_font_set = XCreateFontSet(display, city_productions_font_name,
        &missing_charset_list_return,
@@ -441,8 +441,8 @@
     values.foreground = get_color(tileset, 
COLOR_MAPVIEW_CITYTEXT)->color.pixel;
     values.background = get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color.pixel;
     prod_font_gc= XCreateGC(display, root_window,
-                           GCForeground|GCBackground|GCGraphicsExposures,
-                           &values);
+                            GCForeground|GCBackground|GCGraphicsExposures,
+                            &values);
 
     values.line_width = BORDER_WIDTH;
     values.line_style = LineOnOffDash;
@@ -450,33 +450,33 @@
     values.join_style = JoinMiter;
     values.fill_style = FillSolid;
     border_line_gc = XCreateGC(display, root_window,
-                              GCGraphicsExposures|GCLineWidth|GCLineStyle
-                              |GCCapStyle|GCJoinStyle|GCFillStyle, &values);
+                               GCGraphicsExposures|GCLineWidth|GCLineStyle
+                               |GCCapStyle|GCJoinStyle|GCFillStyle, &values);
 
     values.foreground = 0;
     values.background = 0;
     fill_bg_gc= XCreateGC(display, root_window, 
-                         GCForeground|GCBackground|GCGraphicsExposures,
-                         &values);
-
-    values.fill_style=FillStippled;
-    fill_tile_gc= XCreateGC(display, root_window, 
-                           
GCForeground|GCBackground|GCFillStyle|GCGraphicsExposures,
-                           &values);
+                          GCForeground|GCBackground|GCGraphicsExposures,
+                          &values);
+
+    values.fill_style = FillStippled;
+    fill_tile_gc = XCreateGC(display, root_window, 
+                             
GCForeground|GCBackground|GCFillStyle|GCGraphicsExposures,
+                             &values);
   }
 
   {
-    char d1[]={0x03,0x0c,0x03,0x0c};
-    char d2[]={0x08,0x02,0x08,0x02};
+    char d1[] = {0x03,0x0c,0x03,0x0c};
+    char d2[] = {0x08,0x02,0x08,0x02};
     gray50 = XCreateBitmapFromData(display, root_window, d1, 4, 4);
     gray25 = XCreateBitmapFromData(display, root_window, d2, 4, 4);
   }
-  
+
   /* 135 below is rough value (could be more intelligent) --dwp */
   num_units_below = 135 / tileset_full_tile_width(tileset);
-  num_units_below = MIN(num_units_below,MAX_NUM_UNITS_BELOW);
-  num_units_below = MAX(num_units_below,1);
-  
+  num_units_below = MIN(num_units_below, MAX_NUM_UNITS_BELOW);
+  num_units_below = MAX(num_units_below, 1);
+
   /* do setup_widgets before loading the rest of graphics to ensure that
      setup_widgets() has enough colors available:  (on 256-colour systems)
   */
@@ -497,15 +497,15 @@
 
   /* Do this outside setup_widgets() so after tiles are loaded */
   fill_econ_label_pixmaps();
-               
-  XtAddCallback(map_horizontal_scrollbar, XtNjumpProc, 
-               scrollbar_jump_callback, NULL);
-  XtAddCallback(map_vertical_scrollbar, XtNjumpProc, 
-               scrollbar_jump_callback, NULL);
-  XtAddCallback(map_horizontal_scrollbar, XtNscrollProc, 
-               scrollbar_scroll_callback, NULL);
-  XtAddCallback(map_vertical_scrollbar, XtNscrollProc, 
-               scrollbar_scroll_callback, NULL);
+
+  XtAddCallback(map_horizontal_scrollbar, XtNjumpProc,
+                scrollbar_jump_callback, NULL);
+  XtAddCallback(map_vertical_scrollbar, XtNjumpProc,
+                scrollbar_jump_callback, NULL);
+  XtAddCallback(map_horizontal_scrollbar, XtNscrollProc,
+                scrollbar_scroll_callback, NULL);
+  XtAddCallback(map_vertical_scrollbar, XtNscrollProc,
+                scrollbar_scroll_callback, NULL);
   XtAddCallback(turn_done_button, XtNcallback, end_turn_callback, NULL);
 
   XtAppAddWorkProc(app_context, toplevel_work_proc, NULL);
@@ -513,16 +513,16 @@
   XtRealizeWidget(toplevel);
 
   x_interval_id = XtAppAddTimeOut(app_context, TIMER_INTERVAL,
-                                 timer_callback, NULL);
+                                  timer_callback, NULL);
 
   init_mapcanvas_and_overview();
 
   fill_unit_below_pixmaps();
 
   set_indicator_icons(client_research_sprite(),
-                     client_warming_sprite(),
-                     client_cooling_sprite(),
-                     client_government_sprite());
+                      client_warming_sprite(),
+                      client_cooling_sprite(),
+                      client_government_sprite());
 
   wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", 0);
   XSetWMProtocols(display, XtWindow(toplevel), &wm_delete_window, 1);
@@ -540,6 +540,8 @@
   }
 
   XtAppMainLoop(app_context);
+
+  start_quitting();
 }
 
 /**************************************************************************
@@ -547,7 +549,6 @@
 **************************************************************************/
 void ui_exit()
 {
-
 }
 
 /**************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to