Author: sveinung
Date: Thu Aug  6 15:02:04 2015
New Revision: 29353

URL: http://svn.gna.org/viewcvs/freeciv?rev=29353&view=rev
Log:
Tolerate a missing action when preparing UI name

The Qt client will try to name menu items before the ruleset has sent the
names of the actions. Tolerate this behavior to make it easier to use action
UI names in the Qt client's menus.

When the ruleset definition is missing a UI name is constructed based on the
action's rule name. It includes a warning that the UI name may be wrong. The
warning lets the player know that this may be the action the ruleset
documentation mentioned using a different name. It also makes the fact that
the UI name wasn't used easier to detect.

See patch #6180

Modified:
    branches/S2_6/common/actions.c

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=29353&r1=29352&r2=29353&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Thu Aug  6 15:02:04 2015
@@ -221,6 +221,28 @@
   /* Text representation of the probability. */
   const char* probtxt;
 
+  if (actions[action_id] == NULL) {
+    /* Could be a client who haven't gotten the ruleset yet */
+
+    /* so there shouldn't be any action probability to show */
+    fc_assert(prob == ACTPROB_NA);
+
+    /* but the action should be valid */
+    fc_assert_ret_val_msg(gen_action_is_valid(action_id),
+                          "Invalid action",
+                          "Invalid action %d", action_id);
+
+    /* and no custom text will be insterted */
+    fc_assert(custom == NULL || custom[0] == '\0');
+
+    /* Make the best of what is known */
+    astr_set(&str, _("%s%s (name may be wrong)"),
+             mnemonic, gen_action_name(action_id));
+
+    /* Return the guess. */
+    return astr_str(&str);
+  }
+
   /* How to interpret action probabilities like prob is documented in
    * actions.h */
   switch (prob) {


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

Reply via email to