Author: cazfi Date: Sun Aug 23 17:18:48 2015 New Revision: 29660 URL: http://svn.gna.org/viewcvs/freeciv?rev=29660&view=rev Log: Support unit class helptexts.
Requested by Jacob Nevins <jtn> See patch #5834 Modified: branches/S2_6/client/helpdata.c branches/S2_6/client/packhand.c branches/S2_6/common/packets.def branches/S2_6/common/unittype.c branches/S2_6/common/unittype.h branches/S2_6/data/alien/units.ruleset branches/S2_6/data/civ1/units.ruleset branches/S2_6/data/civ2/units.ruleset branches/S2_6/data/civ2civ3/units.ruleset branches/S2_6/data/classic/units.ruleset branches/S2_6/data/experimental/units.ruleset branches/S2_6/data/multiplayer/units.ruleset branches/S2_6/data/stub/units.ruleset branches/S2_6/fc_version branches/S2_6/server/ruleset.c branches/S2_6/tools/ruledit/rulesave.c Modified: branches/S2_6/client/helpdata.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/helpdata.c?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/client/helpdata.c (original) +++ branches/S2_6/client/helpdata.c Sun Aug 23 17:18:48 2015 @@ -3429,6 +3429,7 @@ { bool has_vet_levels; int flagid; + struct unit_class *pclass; fc_assert_ret_val(NULL != buf && 0 < bufsz && NULL != user_text, NULL); @@ -3442,31 +3443,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, @@ -3481,15 +3490,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")); @@ -3500,11 +3509,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: branches/S2_6/client/packhand.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/packhand.c?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/client/packhand.c (original) +++ branches/S2_6/client/packhand.c Sun Aug 23 17:18:48 2015 @@ -2992,6 +2992,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: branches/S2_6/common/packets.def URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/packets.def?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/common/packets.def (original) +++ branches/S2_6/common/packets.def Sun Aug 23 17:18:48 2015 @@ -1550,6 +1550,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: branches/S2_6/common/unittype.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.c?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/common/unittype.c (original) +++ branches/S2_6/common/unittype.c Sun Aug 23 17:18:48 2015 @@ -1560,6 +1560,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; } } @@ -1581,6 +1582,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: branches/S2_6/common/unittype.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.h?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/common/unittype.h (original) +++ branches/S2_6/common/unittype.h Sun Aug 23 17:18:48 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: branches/S2_6/data/alien/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/alien/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/alien/units.ruleset (original) +++ branches/S2_6/data/alien/units.ruleset Sun Aug 23 17:18:48 2015 @@ -63,6 +63,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: branches/S2_6/data/civ1/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ1/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/civ1/units.ruleset (original) +++ branches/S2_6/data/civ1/units.ruleset Sun Aug 23 17:18:48 2015 @@ -72,6 +72,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: branches/S2_6/data/civ2/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/civ2/units.ruleset (original) +++ branches/S2_6/data/civ2/units.ruleset Sun Aug 23 17:18:48 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: branches/S2_6/data/civ2civ3/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2civ3/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/civ2civ3/units.ruleset (original) +++ branches/S2_6/data/civ2civ3/units.ruleset Sun Aug 23 17:18:48 2015 @@ -81,6 +81,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: branches/S2_6/data/classic/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/classic/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/classic/units.ruleset (original) +++ branches/S2_6/data/classic/units.ruleset Sun Aug 23 17:18:48 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: branches/S2_6/data/experimental/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/experimental/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/experimental/units.ruleset (original) +++ branches/S2_6/data/experimental/units.ruleset Sun Aug 23 17:18:48 2015 @@ -85,6 +85,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: branches/S2_6/data/multiplayer/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/multiplayer/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/multiplayer/units.ruleset (original) +++ branches/S2_6/data/multiplayer/units.ruleset Sun Aug 23 17:18:48 2015 @@ -81,6 +81,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: branches/S2_6/data/stub/units.ruleset URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/stub/units.ruleset?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/data/stub/units.ruleset (original) +++ branches/S2_6/data/stub/units.ruleset Sun Aug 23 17:18:48 2015 @@ -56,6 +56,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: branches/S2_6/fc_version URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/fc_version (original) +++ branches/S2_6/fc_version Sun Aug 23 17:18:48 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-2.6-2015.Aug.19b" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Aug.23" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: branches/S2_6/server/ruleset.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/ruleset.c?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/server/ruleset.c (original) +++ branches/S2_6/server/ruleset.c Sun Aug 23 17:18:48 2015 @@ -1588,6 +1588,8 @@ } free(slist); + uc->helptext = lookup_strvec(file, sec_name, "helptext"); + if (!ok) { break; } @@ -5748,6 +5750,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: branches/S2_6/tools/ruledit/rulesave.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/tools/ruledit/rulesave.c?rev=29660&r1=29659&r2=29660&view=diff ============================================================================== --- branches/S2_6/tools/ruledit/rulesave.c (original) +++ branches/S2_6/tools/ruledit/rulesave.c Sun Aug 23 17:18:48 2015 @@ -2119,6 +2119,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