[Freeciv-commits] r34111 - in /trunk: common/actions.c common/actions.h server/rscompat.c

2016-10-12 Thread sveinung84
Author: sveinung
Date: Thu Oct 13 01:23:29 2016
New Revision: 34111

URL: http://svn.gna.org/viewcvs/freeciv?rev=34111=rev
Log:
Centralize action obligatory hard req handling.

Introduce action_enabler_obligatory_reqs_add(). Have it use the same data as
the sanity cheking. Use it when upgrading a ruleset.

See patch #7803

Modified:
trunk/common/actions.c
trunk/common/actions.h
trunk/server/rscompat.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=34111=34110=34111=diff
==
--- trunk/common/actions.c  (original)
+++ trunk/common/actions.c  Thu Oct 13 01:23:29 2016
@@ -1062,6 +1062,51 @@
 }
 
 /**
+  Inserts any missing obligatory hard requirements in the action enabler
+  based on its action.
+
+  See action_enabler_obligatory_reqs_missing()
+**/
+void action_enabler_obligatory_reqs_add(struct action_enabler *enabler)
+{
+  /* Sanity check: a non existing action enabler is missing but it doesn't
+   * miss any obligatory hard requirements. */
+  fc_assert_ret(enabler);
+
+  /* Sanity check: a non existing action doesn't have any obligatory hard
+   * requirements. */
+  fc_assert_ret(action_id_is_valid(enabler->action));
+
+  obligatory_req_vector_iterate(_hard_reqs[enabler->action],
+obreq) {
+struct requirement_vector *ae_vec;
+
+/* Select action enabler requirement vector. */
+ae_vec = (obreq->is_target ? >target_reqs :
+ >actor_reqs);
+
+if (!does_req_contradicts_reqs(>contradiction, ae_vec)) {
+  struct requirement missing;
+
+  /* Change the requirement from what should conflict to what is
+   * wanted. */
+  missing.present = !obreq->contradiction.present;
+  missing.source = obreq->contradiction.source;
+  missing.range = obreq->contradiction.range;
+  missing.survives = obreq->contradiction.survives;
+  missing.quiet = obreq->contradiction.quiet;
+
+  /* Insert the missing requirement. */
+  requirement_vector_append(ae_vec, missing);
+}
+  } obligatory_req_vector_iterate_end;
+
+  /* Sanity check: obligatory requirement insertion should have fixed the
+   * action enabler. */
+  fc_assert(action_enabler_obligatory_reqs_missing(enabler) == NULL);
+}
+
+/**
   Returns TRUE iff the specified player knows (has seen) the specified
   tile.
 **/

Modified: trunk/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=34111=34110=34111=diff
==
--- trunk/common/actions.h  (original)
+++ trunk/common/actions.h  Thu Oct 13 01:23:29 2016
@@ -365,6 +365,7 @@
 
 const char *
 action_enabler_obligatory_reqs_missing(struct action_enabler *enabler);
+void action_enabler_obligatory_reqs_add(struct action_enabler *enabler);
 
 struct action *action_is_blocked_by(const int action_id,
 const struct unit *actor_unit,

Modified: trunk/server/rscompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/rscompat.c?rev=34111=34110=34111=diff
==
--- trunk/server/rscompat.c (original)
+++ trunk/server/rscompat.c Thu Oct 13 01:23:29 2016
@@ -935,23 +935,9 @@
 
   }
 
-  if (ae->action == ACTION_ESTABLISH_EMBASSY
-  || ae->action == ACTION_SPY_INVESTIGATE_CITY
-  || ae->action == ACTION_SPY_STEAL_GOLD
-  || ae->action == ACTION_SPY_STEAL_TECH
-  || ae->action == ACTION_SPY_TARGETED_STEAL_TECH
-  || ae->action == ACTION_SPY_INCITE_CITY
-  || ae->action == ACTION_SPY_BRIBE_UNIT) {
-/* The rule that the target must be foreign used to be implicit. It
- * must now be explicitly stated in the ruleset. */
-
-struct requirement req
-= req_from_values(VUT_DIPLREL, REQ_RANGE_LOCAL,
-  FALSE, TRUE, TRUE, DRO_FOREIGN);
-
-if (!is_req_in_vec(, >actor_reqs)) {
-  requirement_vector_append(>actor_reqs, req);
-}
+  if (action_enabler_obligatory_reqs_missing(ae)) {
+/* Add previously implicit obligatory hard requirement(s). */
+action_enabler_obligatory_reqs_add(ae);
   }
 } action_enablers_iterate_end;
   }


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


[Freeciv-commits] r34109 - in /branches/S2_6/client/gui-gtk-3.22: diplodlg.c menu.c optiondlg.c wldlg.c

2016-10-12 Thread cazfi74
Author: cazfi
Date: Wed Oct 12 19:37:38 2016
New Revision: 34109

URL: http://svn.gna.org/viewcvs/freeciv?rev=34109=rev
Log:
Got rid of deprecated gtk_image_menu_item_...() calls in gtk3.22-client.

See patch #6706

Modified:
branches/S2_6/client/gui-gtk-3.22/diplodlg.c
branches/S2_6/client/gui-gtk-3.22/menu.c
branches/S2_6/client/gui-gtk-3.22/optiondlg.c
branches/S2_6/client/gui-gtk-3.22/wldlg.c

Modified: branches/S2_6/client/gui-gtk-3.22/diplodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/diplodlg.c?rev=34109=34108=34109=diff
==
--- branches/S2_6/client/gui-gtk-3.22/diplodlg.c(original)
+++ branches/S2_6/client/gui-gtk-3.22/diplodlg.cWed Oct 12 19:37:38 2016
@@ -735,10 +735,7 @@
   menu = gtk_menu_new();
   pdialog->menu0 = menu;
 
-  menuitem = gtk_image_menu_item_new_with_label(_("Add Clause..."));
-  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
-gtk_image_new_from_stock(GTK_STOCK_ADD,
- GTK_ICON_SIZE_MENU));
+  menuitem = gtk_menu_item_new_with_label(_("Add Clause..."));
   gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
   gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
   g_object_set_data(G_OBJECT(menu), "plr", plr0);
@@ -820,10 +817,7 @@
   menu = gtk_menu_new();
   pdialog->menu1 = menu;
 
-  menuitem = gtk_image_menu_item_new_with_label(_("Add Clause..."));
-  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
-gtk_image_new_from_stock(GTK_STOCK_ADD,
- GTK_ICON_SIZE_MENU));
+  menuitem = gtk_menu_item_new_with_label(_("Add Clause..."));
   gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
   gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
   g_object_set_data(G_OBJECT(menu), "plr", plr1);

Modified: branches/S2_6/client/gui-gtk-3.22/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/menu.c?rev=34109=34108=34109=diff
==
--- branches/S2_6/client/gui-gtk-3.22/menu.c(original)
+++ branches/S2_6/client/gui-gtk-3.22/menu.cWed Oct 12 19:37:38 2016
@@ -2530,25 +2530,11 @@
 
 governments_iterate(g) {
   if (g != game.government_during_revolution) {
-struct sprite *gsprite;
-
 /* TRANS: %s is a government name */
 fc_snprintf(buf, sizeof(buf), _("%s..."),
 government_name_translation(g));
-item = gtk_image_menu_item_new_with_label(buf);
+item = gtk_menu_item_new_with_label(buf);
 g_object_set_data(G_OBJECT(item), "government", g);
-
-if ((gsprite = get_government_sprite(tileset, g))) {
-  GtkWidget *image;
-  GdkPixbuf *pb = sprite_get_pixbuf(gsprite);
-
-  image = gtk_image_new_from_pixbuf(pb);
-  g_object_unref(pb);
-  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
-  gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), 
TRUE);
-  gtk_widget_show(image);
-}
-
 g_signal_connect(item, "activate",
  G_CALLBACK(government_callback), g);
 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

Modified: branches/S2_6/client/gui-gtk-3.22/optiondlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/optiondlg.c?rev=34109=34108=34109=diff
==
--- branches/S2_6/client/gui-gtk-3.22/optiondlg.c   (original)
+++ branches/S2_6/client/gui-gtk-3.22/optiondlg.c   Wed Oct 12 19:37:38 2016
@@ -193,24 +193,17 @@
 
   menu = gtk_menu_new();
 
-  item = gtk_image_menu_item_new_with_label(_("Refresh this option"));
-  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
-  gtk_image_new_from_stock(GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU));
+  item = gtk_menu_item_new_with_label(_("Refresh this option"));
   gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   g_signal_connect(item, "activate",
G_CALLBACK(option_refresh_callback), poption);
 
-  item = gtk_image_menu_item_new_with_label(_("Reset this option"));
-  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
-  gtk_image_new_from_stock(GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU));
+  item = gtk_menu_item_new_with_label(_("Reset this option"));
   gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   g_signal_connect(item, "activate",
G_CALLBACK(option_reset_callback), poption);
 
-  item = gtk_image_menu_item_new_with_label(
- _("Apply the changes for this option"));
-  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
-  gtk_image_new_from_stock(GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU));
+  

[Freeciv-commits] r34108 - /trunk/server/unittools.c

2016-10-12 Thread sveinung84
Author: sveinung
Date: Wed Oct 12 16:13:40 2016
New Revision: 34108

URL: http://svn.gna.org/viewcvs/freeciv?rev=34108=rev
Log:
Auto attack is performed by the rules.

When the autoattack setting is enabled a server side auto attack happens
automatically. This means that auto attack isn't player performed. The
player doesn't control if his units (or a particular unit) should auto
attack or not. This means that auto attack isn't controlled by a server side
agent. The autoattack setting is a rule. Declare that the actions performed
by it is done by the rules.

See patch #7811

Modified:
trunk/server/unittools.c

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=34108=34107=34108=diff
==
--- trunk/server/unittools.c(original)
+++ trunk/server/unittools.cWed Oct 12 16:13:40 2016
@@ -3122,21 +3122,21 @@
   if (is_action_enabled_unit_on_units(ACTION_CAPTURE_UNITS,
   penemy, unit_tile(punit))) {
 /* Choose capture. */
-handle_unit_do_action(unit_owner(penemy),
-  penemy->id, tile_index(unit_tile(punit)),
-  0, "", ACTION_CAPTURE_UNITS);
+unit_perform_action(unit_owner(penemy),
+penemy->id, tile_index(unit_tile(punit)),
+0, "", ACTION_CAPTURE_UNITS, ACT_REQ_RULES);
   } else if (is_action_enabled_unit_on_units(ACTION_BOMBARD,
  penemy, unit_tile(punit))) {
 /* Choose bombard. */
-handle_unit_do_action(unit_owner(penemy),
-  penemy->id, tile_index(unit_tile(punit)),
-  0, "", ACTION_BOMBARD);
+unit_perform_action(unit_owner(penemy),
+penemy->id, tile_index(unit_tile(punit)),
+0, "", ACTION_BOMBARD, ACT_REQ_RULES);
   } else if (is_action_enabled_unit_on_tile(ACTION_ATTACK,
 penemy, unit_tile(punit))) {
 /* Choose regular attack. */
-handle_unit_do_action(unit_owner(penemy),
-  penemy->id, tile_index(unit_tile(punit)),
-  0, "", ACTION_ATTACK);
+unit_perform_action(unit_owner(penemy),
+penemy->id, tile_index(unit_tile(punit)),
+0, "", ACTION_ATTACK, ACT_REQ_RULES);
   }
 } else {
 #ifdef REALLY_DEBUG_THIS


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


[Freeciv-commits] r34107 - /trunk/common/actions.c

2016-10-12 Thread sveinung84
Author: sveinung
Date: Wed Oct 12 16:13:26 2016
New Revision: 34107

URL: http://svn.gna.org/viewcvs/freeciv?rev=34107=rev
Log:
Data driven action obligatory hard requirements.

Making the obligatory hard requirements data driven makes it more readable.
It also enables other functions to use the data rather than adding the same
information more than once.

See patch #7802

Modified:
trunk/common/actions.c

[This mail would be too long, it was shortened to contain the URLs only.]

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=34107=34106=34107=diff


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


[Freeciv-commits] r34105 - /trunk/windows/installer_msys2/Makefile

2016-10-12 Thread cazfi74
Author: cazfi
Date: Wed Oct 12 09:58:08 2016
New Revision: 34105

URL: http://svn.gna.org/viewcvs/freeciv?rev=34105=rev
Log:
Set msys2 Windows Installer makefile target 'all' to depend on those installers 
that can
be built with official msys2 environment.

See patch #7813

Modified:
trunk/windows/installer_msys2/Makefile

Modified: trunk/windows/installer_msys2/Makefile
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/windows/installer_msys2/Makefile?rev=34105=34104=34105=diff
==
--- trunk/windows/installer_msys2/Makefile  (original)
+++ trunk/windows/installer_msys2/Makefile  Wed Oct 12 09:58:08 2016
@@ -33,8 +33,9 @@
 # Make rules
 #
 
-# by default build all installers
-all: gtk3-installer gtk2-installer sdl2-installer qt-installer 
ruledit-installer
+# by default build all installers that are buildable with current msys2 
environment
+# gtk2-installer and qt-installers are not built.
+all: gtk3-installer gtk3x-installer sdl2-installer ruledit-installer
 
 gtk3x-installer:
make GUI=gtk3x FCMP=gtk3x EXTRA_CONFIG="--disable-ruledit 
$(EXTRA_CONFIG)" wrap-gtk3x


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


[Freeciv-commits] r34106 - /branches/S2_6/win32/installer_msys2/Makefile

2016-10-12 Thread cazfi74
Author: cazfi
Date: Wed Oct 12 09:58:14 2016
New Revision: 34106

URL: http://svn.gna.org/viewcvs/freeciv?rev=34106=rev
Log:
Set msys2 Windows Installer makefile target 'all' to depend on those installers 
that can
be built with official msys2 environment.

See patch #7813

Modified:
branches/S2_6/win32/installer_msys2/Makefile

Modified: branches/S2_6/win32/installer_msys2/Makefile
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/win32/installer_msys2/Makefile?rev=34106=34105=34106=diff
==
--- branches/S2_6/win32/installer_msys2/Makefile(original)
+++ branches/S2_6/win32/installer_msys2/MakefileWed Oct 12 09:58:14 2016
@@ -33,8 +33,9 @@
 # Make rules
 #
 
-# by default build all installers
-all: gtk3-installer gtk2-installer sdl2-installer qt-installer 
ruledit-installer
+# by default build all installers that are buildable with current msys2 
environment
+# gtk2-installer and qt-installers are not built.
+all: gtk3-installer sdl2-installer ruledit-installer
 
 # These are what can be built in current official environment version
 buildable-win32: gtk3-installer sdl2-installer ruledit-installer


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


[Freeciv-commits] r34103 - in /branches/S2_6: client/gui-qt/ data/themes/gui-qt/Classic/ data/themes/gui-qt/Necrophos/ data/themes/gui-qt/Nigh...

2016-10-12 Thread mlewczuk80
Author: mir3x
Date: Wed Oct 12 08:26:30 2016
New Revision: 34103

URL: http://svn.gna.org/viewcvs/freeciv?rev=34103=rev
Log:
Qt client - replaced QInputDialog with custom dialog

See patch #7812 


Modified:
branches/S2_6/client/gui-qt/citydlg.cpp
branches/S2_6/client/gui-qt/hudwidget.cpp
branches/S2_6/client/gui-qt/hudwidget.h
branches/S2_6/client/gui-qt/mapctrl.cpp
branches/S2_6/data/themes/gui-qt/Classic/resource.qss
branches/S2_6/data/themes/gui-qt/Necrophos/resource.qss
branches/S2_6/data/themes/gui-qt/NightStalker/resource.qss

Modified: branches/S2_6/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/citydlg.cpp?rev=34103=34102=34103=diff
==
--- branches/S2_6/client/gui-qt/citydlg.cpp (original)
+++ branches/S2_6/client/gui-qt/citydlg.cpp Wed Oct 12 08:26:30 2016
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -1872,15 +1871,12 @@
 /
 void city_dialog::city_rename()
 {
-  bool ok;
-  QString text = QInputDialog::getText(this,
-   _("Rename City"),
-   _("What should we rename the city to?"),
-   QLineEdit::Normal,
-   city_name_get(pcity), );
-
-  if (ok && !text.isEmpty()) {
-::city_rename(pcity, text.toLocal8Bit().data());
+  hud_input_box ask(gui()->central_wdg);
+
+  ask.set_text_title_definput(_("What should we rename the city to?"),
+  _("Rename City"), city_name_get(pcity));
+  if (ask.exec() == QDialog::Accepted) {
+::city_rename(pcity, ask.input_edit.text().toLocal8Bit().data());
   }
 }
 
@@ -1890,26 +1886,28 @@
 void city_dialog::save_cma()
 {
   struct cm_parameter param;
-  bool ok;
-  QString text = QInputDialog::getText(this,
-   _("Name new preset"),
-   _("What should we name the preset?"),
-   QLineEdit::Normal,
-   _("new preset"), );
-
-  if (ok && !text.isEmpty()) {
-param.allow_disorder = false;
-param.allow_specialists = true;
-param.require_happy = cma_celeb_checkbox->isChecked();
-param.happy_factor = slider_tab[2 * O_LAST + 1]->value();
-
-for (int i = O_FOOD; i < O_LAST; i++) {
-  param.minimal_surplus[i] = slider_tab[2 * i]->value();
-  param.factor[i] = slider_tab[2 * i + 1]->value();
-}
-
-cmafec_preset_add(text.toLocal8Bit().data(), );
-update_cma_tab();
+  QString text;
+  hud_input_box ask(gui()->central_wdg);
+
+  ask.set_text_title_definput(_("What should we name the preset?"),
+  _("Name new preset"),
+  _("new preset"));
+  if (ask.exec() == QDialog::Accepted) {
+text = ask.input_edit.text().toLocal8Bit().data();
+if (!text.isEmpty()) {
+  param.allow_disorder = false;
+  param.allow_specialists = true;
+  param.require_happy = cma_celeb_checkbox->isChecked();
+  param.happy_factor = slider_tab[2 * O_LAST + 1]->value();
+
+  for (int i = O_FOOD; i < O_LAST; i++) {
+param.minimal_surplus[i] = slider_tab[2 * i]->value();
+param.factor[i] = slider_tab[2 * i + 1]->value();
+  }
+
+  cmafec_preset_add(text.toLocal8Bit().data(), );
+  update_cma_tab();
+}
   }
 }
 
@@ -3142,17 +3140,19 @@
 {
   struct worklist queue;
   struct global_worklist *gw;
-  bool ok;
-  QString text = QInputDialog::getText(this,
-   _("Save current worklist"),
-   _("What should we name new worklist?"),
-   QLineEdit::Normal,
-   _("New worklist"), );
-
-  if (ok && !text.isEmpty()) {
-gw = global_worklist_new(text.toLocal8Bit().data());
-city_get_queue(pcity, );
-global_worklist_set(gw, );
+  QString text;
+  hud_input_box ask(gui()->central_wdg);
+
+  ask.set_text_title_definput(_("What should we name new worklist?"),
+  _("Save current worklist"),
+  _("New worklist"));
+  if (ask.exec() == QDialog::Accepted) {
+text = ask.input_edit.text().toLocal8Bit().data();
+if (!text.isEmpty()) {
+  gw = global_worklist_new(text.toLocal8Bit().data());
+  city_get_queue(pcity, );
+  global_worklist_set(gw, );
+}
   }
 }
 

Modified: branches/S2_6/client/gui-qt/hudwidget.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/hudwidget.cpp?rev=34103=34102=34103=diff
==
--- branches/S2_6/client/gui-qt/hudwidget.cpp   (original)
+++