[Freeciv-Dev] (PR#10630) Governments requirement for units
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#10630) Governments requirement for units |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Tue, 19 Oct 2004 14:36:20 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10630 >
This patch adds an option for modpacks to make units require a specific
government before they can be built. Also removes unnecessary Fanatic unit
from default and civ1 rulesets. Adds an optional capability.
Eventually we should have a generalized requirements of some sort, but I
needed this now.
- Per
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.410
diff -u -r1.410 packhand.c
--- client/packhand.c 19 Oct 2004 18:11:21 -0000 1.410
+++ client/packhand.c 19 Oct 2004 21:29:33 -0000
@@ -2161,6 +2161,7 @@
u->move_rate = p->move_rate;
u->tech_requirement = p->tech_requirement;
u->impr_requirement = p->impr_requirement;
+ u->gov_requirement = p->gov_requirement;
u->vision_range = p->vision_range;
u->transport_capacity = p->transport_capacity;
u->hp = p->hp;
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.191
diff -u -r1.191 capstr.c
--- common/capstr.c 4 Oct 2004 19:35:14 -0000 1.191
+++ common/capstr.c 19 Oct 2004 21:29:33 -0000
@@ -82,7 +82,7 @@
* as long as possible. We want to maintain network compatibility with
* the stable branch for as long as possible.
*/
-#define CAPABILITY "+2.0"
+#define CAPABILITY "+2.0 gov_req"
void init_our_capability(void)
{
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.55
diff -u -r1.55 packets.def
--- common/packets.def 25 Sep 2004 22:18:41 -0000 1.55
+++ common/packets.def 19 Oct 2004 21:29:33 -0000
@@ -933,6 +933,7 @@
UINT8 move_rate;
TECH tech_requirement;
UINT8 impr_requirement;
+ GOVERNMENT gov_requirement; add-cap(gov_req)
UINT8 vision_range;
UINT8 transport_capacity;
UINT8 hp;
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.40
diff -u -r1.40 unittype.c
--- common/unittype.c 13 Sep 2004 15:54:53 -0000 1.40
+++ common/unittype.c 19 Oct 2004 21:29:38 -0000
@@ -482,9 +482,14 @@
if (unit_type_flag(id, F_NOBUILD)) {
return FALSE;
}
+ if (unit_types[id].gov_requirement != G_MAGIC
+ && unit_types[id].gov_requirement != p->government) {
+ return FALSE;
+ }
if (unit_type_flag(id, F_FANATIC)
- && !government_has_flag(get_gov_pplayer(p), G_FANATIC_TROOPS))
+ && !government_has_flag(get_gov_pplayer(p), G_FANATIC_TROOPS)) {
return FALSE;
+ }
if (get_invention(p,unit_types[id].tech_requirement)!=TECH_KNOWN)
return FALSE;
if (unit_type_flag(id, F_UNIQUE)) {
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.31
diff -u -r1.31 unittype.h
--- common/unittype.h 3 Sep 2004 04:22:37 -0000 1.31
+++ common/unittype.h 19 Oct 2004 21:29:38 -0000
@@ -191,6 +191,7 @@
int move_rate;
int tech_requirement;
int impr_requirement; /* should be Impr_Type_id */
+ int gov_requirement;
int vision_range;
int transport_capacity;
int hp;
Index: data/civ1/units.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/units.ruleset,v
retrieving revision 1.33
diff -u -r1.33 units.ruleset
--- data/civ1/units.ruleset 9 Sep 2004 21:25:46 -0000 1.33
+++ data/civ1/units.ruleset 19 Oct 2004 21:29:38 -0000
@@ -60,6 +60,8 @@
; for no alternate graphic.
; tech_req = required advance, names from techs.ruleset, or special:
; "None" => available from start; "Never" => never available
+; impr_req = required city improvement, names from buildings.ruleset
+; gov_req = required government, names from governments.ruleset
; obsolete_by = can be upgraded to and made obsolete by another unit by name
; move_type = "Land" or "Sea" or "Air" or "Heli"
; transport_cap = Number of units (ground, or air/missiles, depending on flags)
@@ -339,34 +341,6 @@
roles = "DefendGood", "FirstBuild", "HutTech",
"BarbarianTech", "BarbarianBuildTech", "BarbarianSeaTech"
-[unit_fanatics]
-name = _("Fanatics")
-move_type = "Land"
-tech_req = "Never"
-obsolete_by = "None"
-graphic = "u.fanatics"
-graphic_alt = "-"
-sound_move = "m_fanatics"
-sound_move_alt = "m_generic"
-sound_fight = "f_fanatics"
-sound_fight_alt = "f_generic"
-build_cost = 20
-pop_cost = 0
-attack = 4
-defense = 4
-hitpoints = 1
-firepower = 1
-move_rate = 1
-vision_range = 1
-transport_cap = 0
-fuel = 0
-uk_happy = 1
-uk_shield = 1
-uk_food = 0
-uk_gold = 0
-flags = ""
-roles = "DefendGood"
-
[unit_partisan]
name = _("Partisan")
move_type = "Land"
Index: data/civ2/units.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/units.ruleset,v
retrieving revision 1.40
diff -u -r1.40 units.ruleset
--- data/civ2/units.ruleset 9 Sep 2004 21:25:47 -0000 1.40
+++ data/civ2/units.ruleset 19 Oct 2004 21:29:38 -0000
@@ -60,6 +60,8 @@
; for no alternate graphic.
; tech_req = required advance, names from techs.ruleset, or special:
; "None" => available from start; "Never" => never available
+; impr_req = required city improvement, names from buildings.ruleset
+; gov_req = required government, names from governments.ruleset
; obsolete_by = can be upgraded to and made obsolete by another unit by name
; move_type = "Land" or "Sea" or "Air" or "Heli"
; transport_cap = Number of units (ground, or air/missiles, depending on flags)
@@ -348,6 +350,7 @@
name = _("Fanatics")
move_type = "Land"
tech_req = "Fundamentalism"
+gov_req = "Fundamentalism"
obsolete_by = "None"
graphic = "u.fanatics"
graphic_alt = "-"
Index: data/default/units.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/units.ruleset,v
retrieving revision 1.62
diff -u -r1.62 units.ruleset
--- data/default/units.ruleset 9 Sep 2004 21:25:47 -0000 1.62
+++ data/default/units.ruleset 19 Oct 2004 21:29:38 -0000
@@ -75,6 +75,7 @@
; tech_req = required advance, names from techs.ruleset, or special:
; "None" => available from start; "Never" => never available
; impr_req = required city improvement, names from buildings.ruleset
+; gov_req = required government, names from governments.ruleset
; obsolete_by = can be upgraded to and made obsolete by another unit by name
; move_type = "Land" or "Sea" or "Air" or "Heli"
; transport_cap = Number of units (ground, or air/missiles, depending on flags)
Index: data/trident/units.png
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident/units.png,v
retrieving revision 1.3
diff -u -r1.3 units.png
Binary files /tmp/cvsl37z2k and units.png differ
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.196
diff -u -r1.196 ruleset.c
--- server/ruleset.c 25 Sep 2004 22:18:42 -0000 1.196
+++ server/ruleset.c 19 Oct 2004 21:29:39 -0000
@@ -873,6 +873,14 @@
u = &unit_types[i];
u->tech_requirement = lookup_tech(file, sec[i], "tech_req",
FALSE, filename, u->name);
+ if (section_file_lookup(file, "%s.gov_req", sec[i])) {
+ char tmp[200] = "\0";
+ mystrlcat(tmp, sec[i], 200);
+ mystrlcat(tmp, ".gov_req", 200);
+ u->gov_requirement = lookup_government(file, tmp, filename);
+ } else {
+ u->gov_requirement = G_MAGIC; /* no requirement */
+ }
} unit_type_iterate_end;
unit_type_iterate(i) {
@@ -2802,6 +2810,7 @@
packet.move_rate = u->move_rate;
packet.tech_requirement = u->tech_requirement;
packet.impr_requirement = u->impr_requirement;
+ packet.gov_requirement = u->gov_requirement;
packet.vision_range = u->vision_range;
packet.transport_capacity = u->transport_capacity;
packet.hp = u->hp;
- [Freeciv-Dev] (PR#10630) Governments requirement for units,
Per I. Mathisen <=
|
|