Author: cazfi
Date: Sun Aug 23 17:18:22 2015
New Revision: 29659

URL: http://svn.gna.org/viewcvs/freeciv?rev=29659&view=rev
Log:
Support unit class helptexts.

Requested by Jacob Nevins <jtn>

See patch #5834

Modified:
    trunk/client/helpdata.c
    trunk/client/packhand.c
    trunk/common/packets.def
    trunk/common/unittype.c
    trunk/common/unittype.h
    trunk/data/alien/units.ruleset
    trunk/data/civ1/units.ruleset
    trunk/data/civ2/units.ruleset
    trunk/data/civ2civ3/units.ruleset
    trunk/data/classic/units.ruleset
    trunk/data/experimental/units.ruleset
    trunk/data/multiplayer/units.ruleset
    trunk/data/stub/units.ruleset
    trunk/fc_version
    trunk/server/ruleset.c
    trunk/tools/ruledit/rulesave.c

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Sun Aug 23 17:18:22 2015
@@ -3447,6 +3447,7 @@
 {
   bool has_vet_levels;
   int flagid;
+  struct unit_class *pclass;
 
   fc_assert_ret_val(NULL != buf && 0 < bufsz && NULL != user_text, NULL);
 
@@ -3460,31 +3461,39 @@
 
   buf[0] = '\0';
 
+  pclass = utype_class(utype);
   cat_snprintf(buf, bufsz,
-               _("* Belongs to %s unit class.\n"),
-               uclass_name_translation(utype_class(utype)));
-  if (uclass_has_flag(utype_class(utype), UCF_CAN_OCCUPY_CITY)
+               _("* Belongs to %s unit class."),
+               uclass_name_translation(pclass));
+  if (NULL != pclass->helptext) {
+    strvec_iterate(pclass->helptext, text) {
+      cat_snprintf(buf, bufsz, "\n%s\n", _(text));
+    } strvec_iterate_end;
+  } else {
+    CATLSTR(buf, bufsz, "\n");
+  }
+  if (uclass_has_flag(pclass, UCF_CAN_OCCUPY_CITY)
       && !utype_has_flag(utype, UTYF_CIVILIAN)) {
     CATLSTR(buf, bufsz, _("  * Can occupy empty enemy cities.\n"));
   }
-  if (!uclass_has_flag(utype_class(utype), UCF_TERRAIN_SPEED)) {
+  if (!uclass_has_flag(pclass, UCF_TERRAIN_SPEED)) {
     CATLSTR(buf, bufsz, _("  * Speed is not affected by terrain.\n"));
   }
-  if (!uclass_has_flag(utype_class(utype), UCF_TERRAIN_DEFENSE)) {
+  if (!uclass_has_flag(pclass, UCF_TERRAIN_DEFENSE)) {
     CATLSTR(buf, bufsz, _("  * Does not get defense bonuses from terrain.\n"));
   }
-  if (!uclass_has_flag(utype_class(utype), UCF_ZOC)) {
+  if (!uclass_has_flag(pclass, UCF_ZOC)) {
     CATLSTR(buf, bufsz, _("  * Not subject to zones of control.\n"));
   } else if (!utype_has_flag(utype, UTYF_IGZOC)) {
     CATLSTR(buf, bufsz, _("  * Subject to zones of control.\n"));
   }
-  if (uclass_has_flag(utype_class(utype), UCF_DAMAGE_SLOWS)) {
+  if (uclass_has_flag(pclass, UCF_DAMAGE_SLOWS)) {
     CATLSTR(buf, bufsz, _("  * Slowed down while damaged.\n"));
   }
-  if (uclass_has_flag(utype_class(utype), UCF_MISSILE)) {
+  if (uclass_has_flag(pclass, UCF_MISSILE)) {
     CATLSTR(buf, bufsz, _("  * Gets used up in making an attack.\n"));
   }
-  if (uclass_has_flag(utype_class(utype), UCF_CAN_FORTIFY)
+  if (uclass_has_flag(pclass, UCF_CAN_FORTIFY)
       && !utype_has_flag(utype, UTYF_CANT_FORTIFY)) {
     if (utype->defense_strength > 0) {
       CATLSTR(buf, bufsz,
@@ -3499,15 +3508,15 @@
               _("  * May fortify to stay put.\n"));
     }
   }
-  if (uclass_has_flag(utype_class(utype), UCF_UNREACHABLE)) {
+  if (uclass_has_flag(pclass, UCF_UNREACHABLE)) {
     CATLSTR(buf, bufsz,
            _("  * Is unreachable. Most units cannot attack this one.\n"));
   }
-  if (uclass_has_flag(utype_class(utype), UCF_CAN_PILLAGE)) {
+  if (uclass_has_flag(pclass, UCF_CAN_PILLAGE)) {
     CATLSTR(buf, bufsz,
            _("  * Can pillage tile improvements.\n"));
   }
-  if (uclass_has_flag(utype_class(utype), UCF_DOESNT_OCCUPY_TILE)
+  if (uclass_has_flag(pclass, UCF_DOESNT_OCCUPY_TILE)
       && !utype_has_flag(utype, UTYF_CIVILIAN)) {
     CATLSTR(buf, bufsz,
            _("  * Doesn't prevent enemy cities from working the tile it's 
on.\n"));
@@ -3518,11 +3527,11 @@
   }
   /* Must use flag to distinguish from UTYF_MARINES text. */
   if (utype->attack_strength > 0
-      && uclass_has_flag(utype_class(utype), UCF_ATT_FROM_NON_NATIVE)) {
+      && uclass_has_flag(pclass, UCF_ATT_FROM_NON_NATIVE)) {
     CATLSTR(buf, bufsz,
             _("  * Can launch attack from non-native tiles.\n"));
   }
-  if (uclass_has_flag(utype_class(utype), UCF_AIRLIFTABLE)) {
+  if (uclass_has_flag(pclass, UCF_AIRLIFTABLE)) {
     CATLSTR(buf, bufsz,
             _("  * Can be airlifted from a suitable city.\n"));
   }

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Sun Aug 23 17:18:22 2015
@@ -3028,6 +3028,8 @@
   c->hp_loss_pct = p->hp_loss_pct;
   c->hut_behavior = p->hut_behavior;
   c->flags       = p->flags;
+
+  PACKET_STRVEC_EXTRACT(c->helptext, p->helptext);
 }
 
 /****************************************************************************

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Sun Aug 23 17:18:22 2015
@@ -1557,6 +1557,8 @@
   UINT8 hp_loss_pct;
   UINT8 hut_behavior;
   BV_UCLASS_FLAGS flags;
+
+  STRING helptext[MAX_LEN_PACKET];
 end
 
 PACKET_RULESET_EXTRA = 232; sc, lsend

Modified: trunk/common/unittype.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.c?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/common/unittype.c     (original)
+++ trunk/common/unittype.c     Sun Aug 23 17:18:22 2015
@@ -1639,6 +1639,7 @@
     unit_classes[i].cache.refuel_bases = NULL;
     unit_classes[i].cache.native_tile_extras = NULL;
     unit_classes[i].cache.subset_movers = NULL;
+    unit_classes[i].helptext = NULL;
   }
 }
 
@@ -1660,6 +1661,10 @@
     }
     if (unit_classes[i].cache.subset_movers != NULL) {
       unit_class_list_destroy(unit_classes[i].cache.subset_movers);
+    }
+    if (unit_classes[i].helptext != NULL) {
+      strvec_destroy(unit_classes[i].helptext);
+      unit_classes[i].helptext = NULL;
     }
   }
 }

Modified: trunk/common/unittype.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.h?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/common/unittype.h     (original)
+++ trunk/common/unittype.h     Sun Aug 23 17:18:22 2015
@@ -114,6 +114,8 @@
   int non_native_def_pct;
   enum hut_behavior hut_behavior;
   bv_unit_class_flags flags;
+
+  struct strvec *helptext;
 
   struct {
     enum move_level land_move;

Modified: trunk/data/alien/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/alien/units.ruleset      (original)
+++ trunk/data/alien/units.ruleset      Sun Aug 23 17:18:22 2015
@@ -70,6 +70,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/civ1/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/civ1/units.ruleset       (original)
+++ trunk/data/civ1/units.ruleset       Sun Aug 23 17:18:22 2015
@@ -77,6 +77,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/civ2/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/civ2/units.ruleset       (original)
+++ trunk/data/civ2/units.ruleset       Sun Aug 23 17:18:22 2015
@@ -82,6 +82,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/civ2civ3/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/civ2civ3/units.ruleset   (original)
+++ trunk/data/civ2civ3/units.ruleset   Sun Aug 23 17:18:22 2015
@@ -90,6 +90,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/classic/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/classic/units.ruleset    (original)
+++ trunk/data/classic/units.ruleset    Sun Aug 23 17:18:22 2015
@@ -88,6 +88,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/experimental/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/experimental/units.ruleset       (original)
+++ trunk/data/experimental/units.ruleset       Sun Aug 23 17:18:22 2015
@@ -91,6 +91,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/multiplayer/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/multiplayer/units.ruleset        (original)
+++ trunk/data/multiplayer/units.ruleset        Sun Aug 23 17:18:22 2015
@@ -87,6 +87,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/data/stub/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/units.ruleset?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/data/stub/units.ruleset       (original)
+++ trunk/data/stub/units.ruleset       Sun Aug 23 17:18:22 2015
@@ -57,6 +57,8 @@
 ;                 "Normal", "Nothing" or "Frighten"
 ; flags         = List of unit class flags (from the following list; you
 ;                 cannot add custom unit class flags)
+; helptext     = optional help text string; should escape all raw newlines 
+;                so that xgettext parsing works
 ;
 ; ** Unit class Flags **
 ;

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Aug 23 17:18:22 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.19b"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Aug.23"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Sun Aug 23 17:18:22 2015
@@ -1595,6 +1595,8 @@
       }
       free(slist);
 
+      uc->helptext = lookup_strvec(file, sec_name, "helptext");
+
       if (!ok) {
         break;
       }
@@ -5903,6 +5905,8 @@
     packet.hp_loss_pct = c->hp_loss_pct;
     packet.hut_behavior = c->hut_behavior;
     packet.flags = c->flags;
+
+    PACKET_STRVEC_COMPUTE(packet.helptext, c->helptext);
 
     lsend_packet_ruleset_unit_class(dest, &packet);
   } unit_class_iterate_end;

Modified: trunk/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=29659&r1=29658&r2=29659&view=diff
==============================================================================
--- trunk/tools/ruledit/rulesave.c      (original)
+++ trunk/tools/ruledit/rulesave.c      Sun Aug 23 17:18:22 2015
@@ -2174,6 +2174,8 @@
                              "%s.flags", path);
     }
 
+    save_strvec(sfile, puc->helptext, path, "helptext");
+
   } unit_class_iterate_end;
 
   sect_idx = 0;


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

Reply via email to