Author: cazfi
Date: Sat Dec 27 07:56:57 2014
New Revision: 27417

URL: http://svn.gna.org/viewcvs/freeciv?rev=27417&view=rev
Log:
Added support for scenario field 'handmade'. Going to edit mode with handmade
scenario gives warnings about risk of losing some data that editor is unable
to handle.

See patch #5608

Modified:
    trunk/client/gui-gtk-2.0/dialogs.c
    trunk/client/gui-gtk-3.0/dialogs.c
    trunk/client/gui-qt/dialogs.cpp
    trunk/client/gui-qt/qtg_cxxside.cpp
    trunk/client/gui-qt/qtg_cxxside.h
    trunk/client/gui-sdl/dialogs.c
    trunk/client/gui-sdl2/dialogs.c
    trunk/client/gui-stub/dialogs.c
    trunk/client/gui-xaw/dialogs.c
    trunk/client/gui_cbsetter.c
    trunk/client/gui_interface.c
    trunk/client/gui_interface.h
    trunk/client/include/dialogs_g.h
    trunk/client/packhand.c
    trunk/common/packets.def
    trunk/fc_version
    trunk/server/edithand.c
    trunk/server/savegame.c
    trunk/server/savegame2.c

Modified: trunk/client/gui-gtk-2.0/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/dialogs.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/dialogs.c  (original)
+++ trunk/client/gui-gtk-2.0/dialogs.c  Sat Dec 27 07:56:57 2014
@@ -1522,3 +1522,13 @@
 
   gtk_widget_destroy(dialog);
 }
+
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool handmade_scenario_warning(void)
+{
+  /* Just tell the client common code to handle this. */
+  return FALSE;
+}

Modified: trunk/client/gui-gtk-3.0/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/dialogs.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/dialogs.c  (original)
+++ trunk/client/gui-gtk-3.0/dialogs.c  Sat Dec 27 07:56:57 2014
@@ -1532,3 +1532,13 @@
 
   gtk_widget_destroy(dialog);
 }
+
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool handmade_scenario_warning(void)
+{
+  /* Just tell the client common code to handle this. */
+  return FALSE;
+}

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Sat Dec 27 07:56:57 2014
@@ -2603,3 +2603,12 @@
   return opened_dialog;
 }
 
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool qtg_handmade_scenario_warning()
+{
+  /* Just tell the client common code to handle this. */
+  return false;
+}

Modified: trunk/client/gui-qt/qtg_cxxside.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/qtg_cxxside.cpp?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-qt/qtg_cxxside.cpp (original)
+++ trunk/client/gui-qt/qtg_cxxside.cpp Sat Dec 27 07:56:57 2014
@@ -95,6 +95,7 @@
   funcs->real_city_dialog_refresh = qtg_real_city_dialog_refresh;
   funcs->popdown_city_dialog = qtg_popdown_city_dialog;
   funcs->popdown_all_city_dialogs = qtg_popdown_all_city_dialogs;
+  funcs->handmade_scenario_warning = qtg_handmade_scenario_warning;
   funcs->refresh_unit_city_dialogs = qtg_refresh_unit_city_dialogs;
   funcs->city_dialog_is_open = qtg_city_dialog_is_open;
 

Modified: trunk/client/gui-qt/qtg_cxxside.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/qtg_cxxside.h?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-qt/qtg_cxxside.h   (original)
+++ trunk/client/gui-qt/qtg_cxxside.h   Sat Dec 27 07:56:57 2014
@@ -118,6 +118,7 @@
 void qtg_real_city_dialog_refresh(struct city *pcity);
 void qtg_popdown_city_dialog(struct city *pcity);
 void qtg_popdown_all_city_dialogs();
+bool qtg_handmade_scenario_warning();
 void qtg_refresh_unit_city_dialogs(struct unit *punit);
 bool qtg_city_dialog_is_open(struct city *pcity);
 

Modified: trunk/client/gui-sdl/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl/dialogs.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-sdl/dialogs.c      (original)
+++ trunk/client/gui-sdl/dialogs.c      Sat Dec 27 07:56:57 2014
@@ -3736,3 +3736,13 @@
 {
   /* PORTME */
 }
+
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool handmade_scenario_warning(void)
+{
+  /* Just tell the client common code to handle this. */
+  return FALSE;
+}

Modified: trunk/client/gui-sdl2/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/dialogs.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-sdl2/dialogs.c     (original)
+++ trunk/client/gui-sdl2/dialogs.c     Sat Dec 27 07:56:57 2014
@@ -3725,3 +3725,13 @@
 {
   /* PORTME */
 }
+
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool handmade_scenario_warning(void)
+{
+  /* Just tell the client common code to handle this. */
+  return FALSE;
+}

Modified: trunk/client/gui-stub/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-stub/dialogs.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-stub/dialogs.c     (original)
+++ trunk/client/gui-stub/dialogs.c     Sat Dec 27 07:56:57 2014
@@ -284,3 +284,13 @@
 {
   /* PORTME */
 }
+
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool gui_handmade_scenario_warning(void)
+{
+  /* Just tell the client common code to handle this. */
+  return FALSE;
+}

Modified: trunk/client/gui-xaw/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-xaw/dialogs.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui-xaw/dialogs.c      (original)
+++ trunk/client/gui-xaw/dialogs.c      Sat Dec 27 07:56:57 2014
@@ -1619,3 +1619,13 @@
 {
   /* PORTME */
 }
+
+/****************************************************************
+  Give a warning when user is about to edit scenario with manually
+  set properties.
+*****************************************************************/
+bool handmade_scenario_warning(void)
+{
+  /* Just tell the client common code to handle this. */
+  return FALSE;
+}

Modified: trunk/client/gui_cbsetter.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui_cbsetter.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui_cbsetter.c (original)
+++ trunk/client/gui_cbsetter.c Sat Dec 27 07:56:57 2014
@@ -25,6 +25,7 @@
 #include "chatline_g.h"
 #include "citydlg_g.h"
 #include "connectdlg_g.h"
+#include "dialogs_g.h"
 #include "editgui_g.h"
 #include "graphics_g.h"
 #include "gui_main_g.h"
@@ -108,6 +109,7 @@
   funcs->real_city_dialog_refresh = gui_real_city_dialog_refresh;
   funcs->popdown_city_dialog = gui_popdown_city_dialog;
   funcs->popdown_all_city_dialogs = gui_popdown_all_city_dialogs;
+  funcs->handmade_scenario_warning = gui_handmade_scenario_warning;
   funcs->refresh_unit_city_dialogs = gui_refresh_unit_city_dialogs;
   funcs->city_dialog_is_open = gui_city_dialog_is_open;
 

Modified: trunk/client/gui_interface.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui_interface.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui_interface.c        (original)
+++ trunk/client/gui_interface.c        Sat Dec 27 07:56:57 2014
@@ -23,6 +23,7 @@
 #include "chatline_g.h"
 #include "citydlg_g.h"
 #include "connectdlg_g.h"
+#include "dialogs_g.h"
 #include "editgui_g.h"
 #include "graphics_g.h"
 #include "gui_main_g.h"
@@ -532,6 +533,14 @@
 }
 
 /**************************************************************************
+  Call handmade_scenario_warning callback
+**************************************************************************/
+bool handmade_scenario_warning()
+{
+  return funcs.handmade_scenario_warning();
+}
+
+/**************************************************************************
   Call refresh_unit_city_dialogs callback
 **************************************************************************/
 void refresh_unit_city_dialogs(struct unit *punit)

Modified: trunk/client/gui_interface.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui_interface.h?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/gui_interface.h        (original)
+++ trunk/client/gui_interface.h        Sat Dec 27 07:56:57 2014
@@ -126,6 +126,7 @@
   void (*real_city_dialog_refresh)(struct city *pcity);
   void (*popdown_city_dialog)(struct city *pcity);
   void (*popdown_all_city_dialogs)(void);
+  bool (*handmade_scenario_warning)(void);
   void (*refresh_unit_city_dialogs)(struct unit *punit);
   bool (*city_dialog_is_open)(struct city *pcity);
 

Modified: trunk/client/include/dialogs_g.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/include/dialogs_g.h?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/include/dialogs_g.h    (original)
+++ trunk/client/include/dialogs_g.h    Sat Dec 27 07:56:57 2014
@@ -74,6 +74,7 @@
 GUI_FUNC_PROTO(bool, popup_theme_suggestion_dialog, const char *theme_name)
 GUI_FUNC_PROTO(void, show_tech_gained_dialog, Tech_type_id tech)
 GUI_FUNC_PROTO(void, show_tileset_error, const char *msg)
+GUI_FUNC_PROTO(bool, handmade_scenario_warning, void)
 
 GUI_FUNC_PROTO(void, popdown_all_game_dialogs, void)
 

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Sat Dec 27 07:56:57 2014
@@ -1850,6 +1850,17 @@
     popdown_all_city_dialogs();
     /* Clears the current goto command. */
     set_hover_state(NULL, HOVER_NONE, ACTIVITY_LAST, NULL, ORDER_LAST);
+
+    if (pinfo->is_edit_mode && game.scenario.handmade) {
+      if (!handmade_scenario_warning()) {
+        /* Gui didn't handle this */
+        output_window_append(ftc_client,
+                             _("This scenario may have manually set properties 
the editor "
+                               "cannot handle."));
+        output_window_append(ftc_client,
+                             _("They won't be saved when scenario is saved 
from the editor."));
+      }
+    }
   }
 
   game.info = *pinfo;
@@ -2799,6 +2810,7 @@
   sz_strlcpy(game.scenario.description, packet->description);
   game.scenario.players = packet->players;
   game.scenario.startpos_nations = packet->startpos_nations;
+  game.scenario.handmade = packet->handmade;
 
   editgui_notify_object_changed(OBJTYPE_GAME, 1, FALSE);
 }

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Sat Dec 27 07:56:57 2014
@@ -1814,6 +1814,7 @@
   STRING description[MAX_LEN_PACKET];
   BOOL   players;
   BOOL   startpos_nations;
+  BOOL   handmade;
 end
 
 PACKET_SAVE_SCENARIO = 181; cs, handle-per-conn, dsend

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sat Dec 27 07:56:57 2014
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Dec.26"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Dec.27"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/edithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/edithand.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/server/edithand.c     (original)
+++ trunk/server/edithand.c     Sat Dec 27 07:56:57 2014
@@ -1595,5 +1595,8 @@
     return;
   }
 
+  /* Client initiated scenario saving is not handmade */
+  game.scenario.handmade = FALSE;
+
   save_game(name, "Scenario", TRUE);
 }

Modified: trunk/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/server/savegame.c     (original)
+++ trunk/server/savegame.c     Sat Dec 27 07:56:57 2014
@@ -3039,6 +3039,9 @@
     }
     game.scenario.players
       = secfile_lookup_bool_default(file, TRUE, "scenario.save_players");
+
+    /* Assume any scenario from pre-editor time handmade with special 
settings. */
+    game.scenario.handmade = TRUE;
   } else {
     game.scenario.is_scenario = FALSE;
   }

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=27417&r1=27416&r2=27417&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Sat Dec 27 07:56:57 2014
@@ -2341,6 +2341,9 @@
     game.scenario.startpos_nations
       = secfile_lookup_bool_default(loading->file, FALSE,
                                     "scenario.startpos_nations");
+    game.scenario.handmade
+      = secfile_lookup_bool_default(loading->file, FALSE,
+                                    "scenario.handmade");
 
     sg_failure_ret(loading->server_state == S_S_INITIAL
                    || (loading->server_state == S_S_RUNNING
@@ -2380,6 +2383,10 @@
   secfile_insert_bool(saving->file, game.scenario.players, "scenario.players");
   secfile_insert_bool(saving->file, game.scenario.startpos_nations,
                       "scenario.startpos_nations");
+  if (game.scenario.handmade) {
+    secfile_insert_bool(saving->file, game.scenario.handmade,
+                        "scenario.handmade");
+  }
 }
 
 /* =======================================================================


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

Reply via email to