Author: sveinung
Date: Thu Sep 10 12:30:59 2015
New Revision: 29847

URL: http://svn.gna.org/viewcvs/freeciv?rev=29847&view=rev
Log:
Mark actions requiring player specified details

Some actions supports details beyond target. Details can be anything from
the name of the city that should be founded to the id of the tech to steal.
Freeciv can't always fill in a detail if it is missing.

Mark actions where the player has to specify additional details. Make the
information easy to access by defining the new function
action_requires_details()

See patch #6338

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

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=29847&r1=29846&r2=29847&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Thu Sep 10 12:30:59 2015
@@ -35,7 +35,7 @@
 
 static struct action *action_new(enum gen_action id,
                                  enum action_target_kind target_kind,
-                                 bool hostile);
+                                 bool hostile, bool requires_details);
 
 static bool is_enabler_active(const struct action_enabler *enabler,
                              const struct player *actor_player,
@@ -62,77 +62,77 @@
 {
   /* Hard code the actions */
   actions[ACTION_SPY_POISON] = action_new(ACTION_SPY_POISON, ATK_CITY,
-      TRUE);
+      TRUE, FALSE);
   actions[ACTION_SPY_SABOTAGE_UNIT] =
       action_new(ACTION_SPY_SABOTAGE_UNIT, ATK_UNIT,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_SPY_BRIBE_UNIT] =
       action_new(ACTION_SPY_BRIBE_UNIT, ATK_UNIT,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_SPY_SABOTAGE_CITY] =
       action_new(ACTION_SPY_SABOTAGE_CITY, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_SPY_TARGETED_SABOTAGE_CITY] =
       action_new(ACTION_SPY_TARGETED_SABOTAGE_CITY, ATK_CITY,
-                 TRUE);
+                 TRUE, TRUE);
   actions[ACTION_SPY_INCITE_CITY] =
       action_new(ACTION_SPY_INCITE_CITY, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_ESTABLISH_EMBASSY] =
       action_new(ACTION_ESTABLISH_EMBASSY, ATK_CITY,
-                 FALSE);
+                 FALSE, FALSE);
   actions[ACTION_SPY_STEAL_TECH] =
       action_new(ACTION_SPY_STEAL_TECH, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_SPY_TARGETED_STEAL_TECH] =
       action_new(ACTION_SPY_TARGETED_STEAL_TECH, ATK_CITY,
-                 TRUE);
+                 TRUE, TRUE);
   actions[ACTION_SPY_INVESTIGATE_CITY] =
       action_new(ACTION_SPY_INVESTIGATE_CITY, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_SPY_STEAL_GOLD] =
       action_new(ACTION_SPY_STEAL_GOLD, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_TRADE_ROUTE] =
       action_new(ACTION_TRADE_ROUTE, ATK_CITY,
-                 FALSE);
+                 FALSE, FALSE);
   actions[ACTION_MARKETPLACE] =
       action_new(ACTION_MARKETPLACE, ATK_CITY,
-                 FALSE);
+                 FALSE, FALSE);
   actions[ACTION_HELP_WONDER] =
       action_new(ACTION_HELP_WONDER, ATK_CITY,
-                 FALSE);
+                 FALSE, FALSE);
   actions[ACTION_CAPTURE_UNITS] =
       action_new(ACTION_CAPTURE_UNITS, ATK_UNITS,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_FOUND_CITY] =
       action_new(ACTION_FOUND_CITY, ATK_TILE,
-                 FALSE);
+                 FALSE, FALSE);
   actions[ACTION_JOIN_CITY] =
       action_new(ACTION_JOIN_CITY, ATK_CITY,
-                 FALSE);
+                 FALSE, FALSE);
   actions[ACTION_STEAL_MAPS] =
       action_new(ACTION_STEAL_MAPS, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_BOMBARD] =
       action_new(ACTION_BOMBARD,
                  /* FIXME: Target is actually Units + City */
                  ATK_UNITS,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_SPY_NUKE] =
       action_new(ACTION_SPY_NUKE, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_NUKE] =
       action_new(ACTION_NUKE,
                  /* FIXME: Target is actually Tile + Units + City */
                  ATK_TILE,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_DESTROY_CITY] =
       action_new(ACTION_DESTROY_CITY, ATK_CITY,
-                 TRUE);
+                 TRUE, FALSE);
   actions[ACTION_EXPEL_UNIT] =
       action_new(ACTION_EXPEL_UNIT, ATK_UNIT,
-                 TRUE);
+                 TRUE, FALSE);
 
   /* Initialize the action enabler list */
   action_iterate(act) {
@@ -195,7 +195,7 @@
 **************************************************************************/
 static struct action *action_new(enum gen_action id,
                                  enum action_target_kind target_kind,
-                                 bool hostile)
+                                 bool hostile, bool requires_details)
 {
   struct action *action;
 
@@ -205,6 +205,7 @@
   action->actor_kind = AAK_UNIT;
   action->target_kind = target_kind;
   action->hostile = hostile;
+  action->requires_details = requires_details;
 
   /* The ui_name is loaded from the ruleset. Until generalized actions
    * are ready it has to be defined seperatly from other action data. */
@@ -290,6 +291,19 @@
   fc_assert_msg(actions[action_id], "Action %d don't exist.", action_id);
 
   return actions[action_id]->hostile;
+}
+
+/**************************************************************************
+  Returns TRUE iff the specified action REQUIRES the player to provide
+  details in addition to actor and target. Returns FALSE if the action
+  doesn't support any additional details or if they can be set by Freeciv
+  it self.
+**************************************************************************/
+bool action_requires_details(int action_id)
+{
+  fc_assert_msg(actions[action_id], "Action %d don't exist.", action_id);
+
+  return actions[action_id]->requires_details;
 }
 
 /**************************************************************************

Modified: trunk/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=29847&r1=29846&r2=29847&view=diff
==============================================================================
--- trunk/common/actions.h      (original)
+++ trunk/common/actions.h      Thu Sep 10 12:30:59 2015
@@ -149,7 +149,13 @@
   enum gen_action id;
   enum action_actor_kind actor_kind;
   enum action_target_kind target_kind;
+
   bool hostile; /* TODO: Should this be a scale in stead? */
+
+  /* Is the player required to specify details about this action? Only true
+   * IFF the action needs details AND the server won't fill them in when
+   * unspecified. */
+  bool requires_details;
 
   /* The name of the action shown in the UI */
   char ui_name[MAX_LEN_NAME];
@@ -209,6 +215,8 @@
 const char *action_name_translation(const struct action *action);
 
 bool action_is_hostile(int action_id);
+
+bool action_requires_details(int action_id);
 
 int action_get_role(int action_id);
 


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

Reply via email to