Add [leader] tag to [side].

Which does the exact same thing as if you'd just place its contents in
the [side] by themselves.
This commit is contained in:
Alexander van Gessel 2011-02-21 02:03:26 +01:00
parent 535c6fdfea
commit 1be29d4663
3 changed files with 30 additions and 21 deletions

View file

@ -36,6 +36,8 @@ Version 1.9.4+svn:
* New [allow_end_turn] and [disallow_end_turn] commands to enable/disable
the human players' ability to end their turn from the user interface
(feature request #13141).
* [side] tags may now contain [leader] tags to create their leader(s), as
opposed to mixing the leader's attributes with the side attributes.
* Miscellaneous and bugfixes:
* Fixed: g++ compiler warnings.
* Added: cmake target to build the gui design pdf.

View file

@ -46,16 +46,18 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
{campaigns/Under_the_Burning_Suns/utils/kaleh-abilities.cfg}
[side]
name= "Kaleh"
type=Kaleh
variation=Youth
random_gender=yes
id="test"
no_leader=yes
[leader]
name= "Kaleh"
type=Kaleh
variation=Youth
random_gender=yes
id="test"
max_hitpoints=90
experience=99
[/leader]
side=1
canrecruit=yes
controller=human
max_hitpoints=90
experience=99
recruit="Ghost,Troll Whelp,Assassin,Elvish Hero,Elvish Fighter,Elvish Archer,Horseman,Mage,Elvish Shaman,Red Mage,Spearman,Swordsman,Duelist,Fencer,Elvish Captain,Elvish Ranger,Elvish Shyde,Thief,Rogue,White Mage,Mage of Light,Elvish Sharpshooter,Silver Mage,Vampire Bat,Blood Bat,Dread Bat,Soulless,Walking Corpse"
gold=2000
team_name="1"

View file

@ -607,7 +607,7 @@ public:
bool snapshot, const config &starting_pos)
: gold_info_ngold_(0)
, gold_info_add_(false)
, leader_cfg_()
, leader_configs_()
, level_(level)
, map_(map)
, player_cfg_(NULL)
@ -667,7 +667,7 @@ protected:
int gold_info_ngold_;
bool gold_info_add_;
config leader_cfg_;
std::deque<config> leader_configs_;
const config &level_;
gamemap &map_;
const config *player_cfg_;
@ -743,7 +743,6 @@ protected:
unit_configs_.clear();
seen_ids_.clear();
leader_cfg_ = config();
}
@ -861,6 +860,18 @@ protected:
}
}
void handle_leader(const config &leader)
{
leader_configs_.push_back(leader);
config::attribute_value &a1 = leader_configs_.back()["canrecruit"];
if (a1.blank()) a1 = true;
config::attribute_value &a2 = leader_configs_.back()["placement"];
if (a2.blank()) a2 = "map,leader";
handle_unit(leader_configs_.back(), "leader_cfg");
}
void leader()
{
log_step("leader");
@ -871,16 +882,10 @@ protected:
// If this side tag describes the leader of the side
if (!side_cfg_["no_leader"].to_bool() && side_cfg_["controller"] != "null") {
leader_cfg_ = side_cfg_;
config::attribute_value &a1 = leader_cfg_["canrecruit"];
if (a1.blank()) a1 = true;
config::attribute_value &a2 = leader_cfg_["placement"];
if (a2.blank()) a2 = "map,leader";
handle_unit(leader_cfg_,"leader_cfg");
} else {
leader_cfg_ = config();
handle_leader(side_cfg_);
}
foreach (const config &l, side_cfg_.child_range("leader")) {
handle_leader(l);
}
}