Author: sveinung
Date: Wed Aug 12 12:30:26 2015
New Revision: 29472

URL: http://svn.gna.org/viewcvs/freeciv?rev=29472&view=rev
Log:
orders system: replace ORDER_BUILD_CITY with ORDER_PERFORM_ACTION

Offer "Go and..." menu items for both join and found to give the player full
control. A smart menu item may choose another action than the one the player
intended. This will upset the player. A smart alternative can come later.

See patch #6220

Modified:
    trunk/client/control.c
    trunk/client/gui-gtk-2.0/menu.c
    trunk/client/gui-gtk-3.0/menu.c
    trunk/client/gui-qt/menu.cpp
    trunk/client/gui-qt/menu.h
    trunk/common/unit.h
    trunk/data/gtk_menus.xml
    trunk/fc_version
    trunk/server/savecompat.c
    trunk/server/savegame.c
    trunk/server/savegame2.c
    trunk/server/savegame3.c
    trunk/server/unithand.c
    trunk/server/unittools.c

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Wed Aug 12 12:30:26 2015
@@ -271,7 +271,7 @@
   Enter the given hover state.
 
     activity => The connect activity (ACTIVITY_IRRIGATE, etc.)
-    order => The last order (ORDER_BUILD_CITY, ORDER_LAST, etc.)
+    order => The last order (ORDER_PERFORM_ACTION, ORDER_LAST, etc.)
 **************************************************************************/
 void set_hover_state(struct unit_list *punits, enum cursor_hover_state state,
                     enum unit_activity activity,

Modified: trunk/client/gui-gtk-2.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/menu.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/menu.c     (original)
+++ trunk/client/gui-gtk-2.0/menu.c     Wed Aug 12 12:30:26 2015
@@ -1064,7 +1064,15 @@
 *****************************************************************/
 static void go_build_city_callback(GtkAction *action, gpointer data)
 {
-  request_unit_goto(ORDER_BUILD_CITY, ACTION_COUNT);
+  request_unit_goto(ORDER_PERFORM_ACTION, ACTION_FOUND_CITY);
+}
+
+/****************************************************************
+  Action "GO_JOIN_CITY" callback.
+*****************************************************************/
+static void go_join_city_callback(GtkAction *action, gpointer data)
+{
+  request_unit_goto(ORDER_PERFORM_ACTION, ACTION_JOIN_CITY);
 }
 
 /****************************************************************
@@ -1682,6 +1690,8 @@
        "b", NULL, G_CALLBACK(build_city_callback)},
       {"GO_BUILD_CITY", NULL, _("Go _to and Build city"),
        "<Shift>b", NULL, G_CALLBACK(go_build_city_callback)},
+      {"GO_JOIN_CITY", NULL, _("Go to and Join city"),
+       "<Shift>j", NULL, G_CALLBACK(go_join_city_callback)},
       {"AUTO_SETTLER", NULL, _("_Auto Settler"),
        "a", NULL, G_CALLBACK(auto_settle_callback)},
 
@@ -2184,6 +2194,8 @@
              || can_units_do(punits, unit_can_help_build_wonder_here)));
   menus_set_sensitive(unit_group, "GO_BUILD_CITY",
                       units_contain_cityfounder(punits));
+  menus_set_sensitive(unit_group, "GO_JOIN_CITY",
+                      units_can_do_action(punits, ACTION_JOIN_CITY, TRUE));
   menus_set_sensitive(unit_group, "BUILD_ROAD",
                       (can_units_do_any_road(punits)
                        || can_units_do(punits,

Modified: trunk/client/gui-gtk-3.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/menu.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/menu.c     (original)
+++ trunk/client/gui-gtk-3.0/menu.c     Wed Aug 12 12:30:26 2015
@@ -1064,7 +1064,15 @@
 *****************************************************************/
 static void go_build_city_callback(GtkAction *action, gpointer data)
 {
-  request_unit_goto(ORDER_BUILD_CITY, ACTION_COUNT);
+  request_unit_goto(ORDER_PERFORM_ACTION, ACTION_FOUND_CITY);
+}
+
+/****************************************************************
+  Action "GO_JOIN_CITY" callback.
+*****************************************************************/
+static void go_join_city_callback(GtkAction *action, gpointer data)
+{
+  request_unit_goto(ORDER_PERFORM_ACTION, ACTION_JOIN_CITY);
 }
 
 /****************************************************************
@@ -1683,6 +1691,8 @@
        "b", NULL, G_CALLBACK(build_city_callback)},
       {"GO_BUILD_CITY", NULL, _("Go _to and Build city"),
        "<Shift>b", NULL, G_CALLBACK(go_build_city_callback)},
+      {"GO_JOIN_CITY", NULL, _("Go to and Join city"),
+       "<Shift>j", NULL, G_CALLBACK(go_join_city_callback)},
       {"AUTO_SETTLER", NULL, _("_Auto Settler"),
        "a", NULL, G_CALLBACK(auto_settle_callback)},
 
@@ -2185,6 +2195,8 @@
              || can_units_do(punits, unit_can_help_build_wonder_here)));
   menus_set_sensitive(unit_group, "GO_BUILD_CITY",
                       units_contain_cityfounder(punits));
+  menus_set_sensitive(unit_group, "GO_JOIN_CITY",
+                      units_can_do_action(punits, ACTION_JOIN_CITY, TRUE));
   menus_set_sensitive(unit_group, "BUILD_ROAD",
                       (can_units_do_any_road(punits)
                        || can_units_do(punits,

Modified: trunk/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.cpp?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/client/gui-qt/menu.cpp        (original)
+++ trunk/client/gui-qt/menu.cpp        Wed Aug 12 12:30:26 2015
@@ -704,6 +704,10 @@
   menu_list.insertMulti(SETTLER, act);
   act->setShortcut(QKeySequence(tr("shift+b")));
   connect(act, SIGNAL(triggered()), this, SLOT(slot_go_build_city()));
+  act = menu->addAction(_("Go And Join City"));
+  menu_list.insertMulti(MIGRANT, act);
+  act->setShortcut(QKeySequence(tr("shift+j")));
+  connect(act, SIGNAL(triggered()), this, SLOT(slot_go_join_city()));
   act = menu->addAction(_("Auto Settler"));
   act->setShortcut(QKeySequence(tr("a")));
   menu_list.insertMulti(AUTOSETTLER, act);
@@ -1145,7 +1149,13 @@
         break;
 
       case SETTLER:
-        if (can_units_do(punits, unit_can_add_or_build_city)) {
+        if (units_contain_cityfounder(punits)) {
+          i.value()->setEnabled(true);
+        }
+        break;
+
+      case MIGRANT:
+        if (units_can_do_action(punits, ACTION_JOIN_CITY, true)) {
           i.value()->setEnabled(true);
         }
         break;
@@ -1491,7 +1501,15 @@
 ***************************************************************************/
 void mr_menu::slot_go_build_city()
 {
-  request_unit_goto(ORDER_BUILD_CITY, ACTION_COUNT);
+  request_unit_goto(ORDER_PERFORM_ACTION, ACTION_FOUND_CITY);
+}
+
+/***************************************************************************
+  Action "GO TO AND JOIN CITY"
+***************************************************************************/
+void mr_menu::slot_go_join_city()
+{
+  request_unit_goto(ORDER_PERFORM_ACTION, ACTION_JOIN_CITY);
 }
 
 /***************************************************************************

Modified: trunk/client/gui-qt/menu.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/menu.h?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/client/gui-qt/menu.h  (original)
+++ trunk/client/gui-qt/menu.h  Wed Aug 12 12:30:26 2015
@@ -70,6 +70,7 @@
   NUKE,
   UPGRADE,
   SETTLER,
+  MIGRANT,
   SAVE
 };
 
@@ -168,6 +169,7 @@
   /*used by work menu*/
   void slot_build_city();
   void slot_go_build_city();
+  void slot_go_join_city();
   void slot_auto_settler();
   void slot_build_road();
   void slot_build_irrigation();

Modified: trunk/common/unit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.h?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/common/unit.h (original)
+++ trunk/common/unit.h Wed Aug 12 12:30:26 2015
@@ -35,7 +35,7 @@
   ORDER_MOVE = 0,
   ORDER_ACTIVITY = 1,
   ORDER_FULL_MP = 2,
-  ORDER_BUILD_CITY = 3,
+  ORDER_OLD_BUILD_CITY = 3,
   ORDER_DISBAND = 4,
   ORDER_OLD_BUILD_WONDER = 5,
   ORDER_OLD_TRADE_ROUTE = 6,

Modified: trunk/data/gtk_menus.xml
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/gtk_menus.xml?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/data/gtk_menus.xml    (original)
+++ trunk/data/gtk_menus.xml    Wed Aug 12 12:30:26 2015
@@ -108,6 +108,7 @@
     <menu action="MENU_WORK">
       <menuitem action="BUILD_CITY" />
       <menuitem action="GO_BUILD_CITY" />
+      <menuitem action="GO_JOIN_CITY" />
       <menuitem action="AUTO_SETTLER" />
       <separator />
       <menuitem action="BUILD_ROAD" />

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Wed Aug 12 12:30:26 2015
@@ -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-3.0-2015.Aug.12b"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Aug.12c"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/savecompat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savecompat.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/server/savecompat.c   (original)
+++ trunk/server/savecompat.c   Wed Aug 12 12:30:26 2015
@@ -1052,7 +1052,7 @@
                        struct tile *tgt_tile)
 {
   switch (order) {
-  case ORDER_BUILD_CITY:
+  case ORDER_OLD_BUILD_CITY:
     if (tile_city(tgt_tile)
         && city_owner(tile_city(tgt_tile)) == unit_owner(act_unit)) {
       /* The player's cities are loaded right before his units. It wasn't

Modified: trunk/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/server/savegame.c     (original)
+++ trunk/server/savegame.c     Wed Aug 12 12:30:26 2015
@@ -289,7 +289,7 @@
     return ORDER_FULL_MP;
   case 'b':
   case 'B':
-    return ORDER_BUILD_CITY;
+    return ORDER_OLD_BUILD_CITY;
   case 'a':
   case 'A':
     return ORDER_ACTIVITY;

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Wed Aug 12 12:30:26 2015
@@ -570,7 +570,7 @@
     return ORDER_FULL_MP;
   case 'b':
   case 'B':
-    return ORDER_BUILD_CITY;
+    return ORDER_OLD_BUILD_CITY;
   case 'a':
   case 'A':
     return ORDER_ACTIVITY;

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Wed Aug 12 12:30:26 2015
@@ -704,7 +704,15 @@
     return ORDER_FULL_MP;
   case 'b':
   case 'B':
-    return ORDER_BUILD_CITY;
+#ifdef FREECIV_DEV_SAVE_COMPAT
+    /* Will be upgraded with sg_order_to_action(). */
+    return ORDER_OLD_BUILD_CITY;
+#else /* FREECIV_DEV_SAVE_COMPAT */
+    /* This order isn't supposed to show up in version 3 save games. */
+    log_error("Corrupt save game: build city ordered the old way.");
+
+    return ORDER_LAST;
+#endif /* FREECIV_DEV_SAVE_COMPAT */
   case 'a':
   case 'A':
     return ORDER_ACTIVITY;
@@ -760,8 +768,6 @@
     return 'w';
   case ORDER_ACTIVITY:
     return 'a';
-  case ORDER_BUILD_CITY:
-    return 'b';
   case ORDER_DISBAND:
     return 'd';
   case ORDER_HOMECITY:
@@ -770,6 +776,7 @@
     return 'x';
   case ORDER_PERFORM_ACTION:
     return 'p';
+  case ORDER_OLD_BUILD_CITY:
   case ORDER_OLD_BUILD_WONDER:
   case ORDER_OLD_TRADE_ROUTE:
   case ORDER_LAST:
@@ -5374,10 +5381,10 @@
           }
           break;
         case ORDER_FULL_MP:
-        case ORDER_BUILD_CITY:
         case ORDER_DISBAND:
         case ORDER_HOMECITY:
         case ORDER_ACTION_MOVE:
+        case ORDER_OLD_BUILD_CITY:
         case ORDER_OLD_BUILD_WONDER:
         case ORDER_OLD_TRADE_ROUTE:
         case ORDER_LAST:

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Aug 12 12:30:26 2015
@@ -3685,10 +3685,10 @@
 
       break;
     case ORDER_FULL_MP:
-    case ORDER_BUILD_CITY:
     case ORDER_DISBAND:
     case ORDER_HOMECITY:
       break;
+    case ORDER_OLD_BUILD_CITY:
     case ORDER_OLD_BUILD_WONDER:
     case ORDER_OLD_TRADE_ROUTE:
       /* This order has been replaced with ORDER_PERFORM_ACTION and the

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=29472&r1=29471&r2=29472&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Wed Aug 12 12:30:26 2015
@@ -3724,36 +3724,6 @@
 }
 
 /**************************************************************************
-  Returns the action id corresponding to the specified order id.
-**************************************************************************/
-static int order_to_action(struct unit *punit, enum unit_orders order)
-{
-  switch (order) {
-  case ORDER_BUILD_CITY:
-    if (tile_city(unit_tile(punit))) {
-      return ACTION_JOIN_CITY;
-    } else {
-      return ACTION_FOUND_CITY;
-    }
-  case ORDER_MOVE:
-  case ORDER_ACTION_MOVE:
-  case ORDER_FULL_MP:
-  case ORDER_ACTIVITY:
-  case ORDER_DISBAND:
-  case ORDER_HOMECITY:
-  case ORDER_PERFORM_ACTION:
-  case ORDER_OLD_BUILD_WONDER:
-  case ORDER_OLD_TRADE_ROUTE:
-  case ORDER_LAST:
-    /* Not action enabler controlled. */
-    break;
-  }
-
-  fc_assert_msg(FALSE, "No action to map order to.");
-  return ACTION_COUNT;
-}
-
-/**************************************************************************
   Returns TRUE iff it is reasonable to assume that the player is wathing
   the unit.
 
@@ -3851,14 +3821,6 @@
         return TRUE;
       }
       break;
-    case ORDER_BUILD_CITY:
-    case ORDER_OLD_BUILD_WONDER:
-    case ORDER_OLD_TRADE_ROUTE:
-      if (should_wait_for_mp(punit, order_to_action(punit, order.order))) {
-        log_debug("  stopping. Not enough move points this turn");
-        return TRUE;
-      }
-      break;
     case ORDER_PERFORM_ACTION:
       if (should_wait_for_mp(punit, order.action)) {
         log_debug("  stopping. Not enough move points this turn");
@@ -3868,6 +3830,9 @@
     case ORDER_ACTIVITY:
     case ORDER_DISBAND:
     case ORDER_HOMECITY:
+    case ORDER_OLD_BUILD_CITY:
+    case ORDER_OLD_BUILD_WONDER:
+    case ORDER_OLD_TRADE_ROUTE:
     case ORDER_LAST:
       /* Those actions don't require moves left. */
       break;
@@ -3901,33 +3866,6 @@
        send_unit_info(NULL, punit);
       }
       break;
-    case ORDER_BUILD_CITY:
-      if (tile_city(unit_tile(punit))) {
-        handle_unit_do_action(pplayer, unitid,
-                              tile_city(unit_tile(punit))->id,
-                              0, "",
-                              ACTION_JOIN_CITY);
-        log_debug("  joining city");
-      } else {
-        handle_unit_do_action(pplayer, unitid, unit_tile(punit)->index,
-                              0, city_name_suggestion(pplayer,
-                                                      unit_tile(punit)),
-                              ACTION_FOUND_CITY);
-        log_debug("  building city");
-      }
-
-      if (player_unit_by_number(pplayer, unitid)) {
-       /* Build failed. */
-       cancel_orders(punit, " orders canceled; failed to build city");
-        notify_player(pplayer, unit_tile(punit), E_UNIT_ORDERS, ftc_server,
-                      _("Orders for %s aborted because building "
-                        "of city failed."),
-                      unit_link(punit));
-       return TRUE;
-      } else {
-       /* Build succeeded => unit "died" */
-       return FALSE;
-      }
     case ORDER_ACTIVITY:
       activity = order.activity;
       {
@@ -4200,6 +4138,7 @@
       }
 
       break;
+    case ORDER_OLD_BUILD_CITY:
     case ORDER_OLD_BUILD_WONDER:
     case ORDER_OLD_TRADE_ROUTE:
     case ORDER_LAST:


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

Reply via email to