[modify_side] can change shroud_data

this still doesn't work properly, see provided scenario-test.cfg event
This commit is contained in:
Ignacio R. Morelle 2008-04-22 17:25:14 +00:00
parent 5585c36028
commit 48e687d844
4 changed files with 69 additions and 3 deletions

View File

@ -177,6 +177,55 @@ Xu ,Xu , Qxu , Qxu , Ql , Ql
{ACT_TELEPORT 10 3 27 15}
[event]
name=moveto
[filter]
side=1
[/filter]
[modify_side]
side=1
shroud_data="|111111111111
|1111111111111
|1111111111111
|11111111111111
|11111111111111
|001111111111111
|111111111111111
|1111111111111111
|111111111111111
|1111111111111111
|1111111111111111
|11111111111111111
|11111111111111111
|11111111111111111
|1111111111111111
|1111111111111111
|111111111111111
|111111111111111
|11111111111111
|11111111111111
|1111111111111
|
|
|
|
|
|
|
|
|
|
|
|00000000000001111111
|000000000000011111111
|00000000000001111111
|000000000000000111111
|00000000000000011111
"
[/modify_side]
[/event]
[side]
random_gender=yes
type="Silver Mage"
@ -184,7 +233,7 @@ Xu ,Xu , Qxu , Qxu , Ql , Ql
canrecruit=yes
controller=human
hitpoints=80
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"
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,Soulless,Walking Corpse"
gold=2000
enemy=2
shroud=yes

View File

@ -716,10 +716,11 @@ void event_handler::handle_event_command(const queued_event& event_info,
std::string recruit_str = cfg["recruit"];
std::string fog = cfg["fog"];
std::string shroud = cfg["shroud"];
std::string shroud_data = cfg["shroud_data"];
std::string village_gold = cfg["village_gold"];
const config::child_list& ai = cfg.get_parsed_config().get_children("ai");
// TODO: also allow client to modify a side's colour if it
// is possible to change it on the fly without causing visual glitches
//!@todo also allow client to modify a side's colour if it
//!is possible to change it on the fly without causing visual glitches
assert(state_of_game != NULL);
const int side_num = lexical_cast_default<int>(side,1);
@ -762,6 +763,10 @@ void event_handler::handle_event_command(const queued_event& event_info,
if (!shroud.empty()) {
(*teams)[team_index].set_shroud( utils::string_bool(shroud, true) );
}
// Set shroud data
if (!shroud_data.empty()) {
(*teams)[team_index].replace_shroud_map_data(shroud_data);
}
// Set fog
if (!fog.empty()) {
(*teams)[team_index].set_fog( utils::string_bool(fog, true) );

View File

@ -349,6 +349,14 @@ void team::team_info::write(config& cfg) const
cfg["colour"] = lexical_cast_default<std::string>(colour);
}
void team::replace_shroud_map_data(const std::string& shroud_data)
{
//!@todo TODO: in the future I'd like to make external shroud data to be
//! combined with the current one instead of always replacing it.
shroud_.reset();
shroud_.read(shroud_data);
}
team::team(const config& cfg, int gold) :
gold_(gold),
villages_(),

View File

@ -252,6 +252,10 @@ public:
void set_shroud(bool shroud) { shroud_.set_enabled(shroud); }
void set_fog(bool fog) { fog_.set_enabled(fog); }
//! Converts a WML shroud map into shroud data and applies it to
//! this player.
void replace_shroud_map_data(const std::string& shroud_data);
bool knows_about_team(size_t index) const;
bool copy_ally_shroud();