made shroud load properly

This commit is contained in:
uid68803 2003-12-31 18:23:32 +00:00
parent 132d42aad3
commit 3460a2cfb1
8 changed files with 107 additions and 29 deletions

View file

@ -124,6 +124,7 @@
[/race]
[trait]
id=loyal
name=loyal
[effect]
apply_to=loyal
@ -131,6 +132,7 @@
[/trait]
[trait]
id=strong
name=strong
[effect]
apply_to=attack
@ -145,6 +147,7 @@
[/trait]
[trait]
id=quick
name=quick
[effect]
apply_to=movement
@ -158,6 +161,7 @@
[/trait]
[trait]
id=intelligent
name=intelligent
[effect]
apply_to=max_experience
@ -166,6 +170,7 @@
[/trait]
[trait]
id=resilient
name=resilient
[effect]
apply_to=hitpoints

View file

@ -2,7 +2,7 @@
name=Walking Corpse
race=undead
image=undead-zombie.png
image_defensive==undead-zombie-attack.png
image_defensive=undead-zombie-attack.png
hitpoints=16
movement_type=undeadfoot
movement=4

View file

@ -251,7 +251,7 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
}
for(;;) {
data_res = network::receive_data(sides,0,5000);
data_res = network::receive_data(sides,0,10000);
check_response(data_res,data);
//if we have got valid side data

View file

@ -1358,6 +1358,7 @@ void turn_info::unit_list()
std::vector<std::string> items;
items.push_back(heading);
std::vector<gamemap::location> locations_list;
std::vector<unit> units_list;
for(unit_map::const_iterator i = units_.begin(); i != units_.end(); ++i) {
if(i->second.side() != team_num_)
@ -1383,14 +1384,21 @@ void turn_info::unit_list()
items.push_back(row.str());
//extra unit for the first row to make up the heading
if(units_list.empty())
if(units_list.empty()) {
locations_list.push_back(i->first);
units_list.push_back(i->second);
}
locations_list.push_back(i->first);
units_list.push_back(i->second);
}
gui::show_dialog(gui_,NULL,string_table["unit_list"],"",
gui::OK_ONLY,&items,&units_list);
const int selected = gui::show_dialog(gui_,NULL,string_table["unit_list"],"",
gui::OK_ONLY,&items,&units_list);
if(selected > 0 && selected < int(locations_list.size())) {
const gamemap::location& loc = locations_list[selected];
gui_.scroll_to_tile(loc.x,loc.y,display::WARP);
}
}
unit_map::iterator turn_info::current_unit()

View file

@ -31,7 +31,8 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
{
unit_map::const_iterator u = units.end();
if(int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END)) {
if(int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END)
|| type == POSITION) {
u = units.find(mouseover);
if(u == units.end()) {
u = units.find(loc);
@ -54,8 +55,11 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
case UNIT_LEVEL:
str << u->second.type().level();
break;
case UNIT_TRAITS:
return report(u->second.traits_description());
case UNIT_TRAITS: {
report res(u->second.traits_description());
res.tooltip = u->second.modification_description("trait");
return res;
}
case UNIT_STATUS: {
std::string status = "healthy", prefix = "";
if(map.on_board(loc) && u->second.invisible(map.underlying_terrain(map[loc.x][loc.y]))) {
@ -214,7 +218,6 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
str << (mouseover.x+1) << ", " << (mouseover.y+1);
u = units.find(mouseover);
if(u == units.end() || current_team.shrouded(mouseover.x,mouseover.y))
break;

View file

@ -192,6 +192,17 @@ team::team(const config& cfg, int gold) : gold_(gold), info_(cfg)
for(config::child_list::const_iterator v = villages.begin(); v != villages.end(); ++v) {
towers_.insert(gamemap::location(**v));
}
const std::string& shroud_data = cfg["shroud_data"];
for(std::string::const_iterator sh = shroud_data.begin(); sh != shroud_data.end(); ++sh) {
if(shroud_.empty() || *sh == '\n')
shroud_.resize(shroud_.size()+1);
if(*sh == '1')
shroud_.back().push_back(true);
else if(*sh == '0')
shroud_.back().push_back(false);
}
}
void team::write(config& cfg) const

View file

@ -685,9 +685,13 @@ void unit::add_modification(const std::string& type,
if(no_add == false && (span.empty() || span == "forever"))
modifications_.add_child(type,mod);
std::vector<std::string> effects_description;
for(config::const_child_itors i = mod.child_range("effect");
i.first != i.second; ++i.first) {
std::stringstream description;
const std::string& apply_to = (**i.first)["apply_to"];
if(apply_to == "new_attack") {
@ -701,19 +705,20 @@ void unit::add_modification(const std::string& type,
const std::string& increase_hp = (**i.first)["increase"];
const std::string& heal_full = (**i.first)["heal_full"];
const std::string& increase_total = (**i.first)["increase_total"];
const std::string& mult_total = (**i.first)["multiply_total"];
//if the hitpoints are allowed to end up greater than max hitpoints
const std::string& violate_max = (**i.first)["violate_maximum"];
if(increase_total.empty() == false) {
const int increase = atoi(increase_total.c_str());
maxHitpoints_ += increase;
}
description << (increase_total[0] != '-' ? "+" : "") << increase_total << translate_string("hp");
if(mult_total.empty() == false) {
const double factor = atoi(mult_total.c_str());
maxHitpoints_ = int(double(maxHitpoints_)*factor);
//a percentage on the end means increase by that many percent
if(increase_total[increase_total.size()-1] == '%') {
const std::string inc(increase_total.begin(),increase_total.end()-1);
maxHitpoints_ += (maxHitpoints_*atoi(inc.c_str()))/100;
} else {
maxHitpoints_ += atoi(increase_total.c_str());
}
}
if(maxHitpoints_ < 1)
@ -735,19 +740,22 @@ void unit::add_modification(const std::string& type,
hitpoints_ = 1;
} else if(apply_to == "movement") {
const std::string& increase = (**i.first)["increase"];
const std::string& mult = (**i.first)["multiply"];
const std::string& set_to = (**i.first)["set"];
if(increase.empty() == false) {
maxMovement_ += atoi(increase.c_str());
description << (increase[0] != '-' ? "+" : "") << increase << translate_string("moves");
if(increase[increase.size()-1] == '%') {
const std::string inc(increase.begin(),increase.end()-1);
maxMovement_ += (maxMovement_*atoi(inc.c_str()))/100;
} else {
maxMovement_ += atoi(increase.c_str());
}
if(maxMovement_ < 1)
maxMovement_ = 1;
}
if(mult.empty() == false) {
maxMovement_ = int(double(maxMovement_)*atof(mult.c_str()));
}
if(set_to.empty() == false) {
maxMovement_ = atoi(set_to.c_str());
}
@ -756,29 +764,57 @@ void unit::add_modification(const std::string& type,
moves_ = maxMovement_;
} else if(apply_to == "max_experience") {
const std::string& increase = (**i.first)["increase"];
const std::string& multiply = (**i.first)["multiply"];
if(increase.empty() == false) {
maxExperience_ += atoi(increase.c_str());
}
if(multiply.empty() == false) {
maxExperience_ = int(double(maxExperience_)*
atof(multiply.c_str()));
if(increase.empty() == false) {
description << (increase[0] != '-' ? "+" : "") << increase << translate_string("xp");
if(increase[increase.size()-1] == '%') {
const std::string inc(increase.begin(),increase.end()-1);
maxExperience_ += (maxExperience_*atoi(inc.c_str()))/100;
} else {
maxExperience_ += atoi(increase.c_str());
}
}
if(maxExperience_ < 1) {
maxExperience_ = 1;
}
} else if(apply_to == "loyal") {
description << string_table["loyal_description"];
if(upkeep_ > UPKEEP_LOYAL)
upkeep_ = UPKEEP_LOYAL;
}
const std::string desc = description.str();
if(!desc.empty())
effects_description.push_back(desc);
}
std::stringstream description;
description << translate_string_default(mod["id"],mod["name"]) << ": ";
if(mod["id"].empty() == false) {
description << translate_string_default(mod["id"] + "_description",mod["description"]) << " ";
}
if(effects_description.empty() == false) {
description << "(";
for(std::vector<std::string>::const_iterator i = effects_description.begin(); i != effects_description.end(); ++i) {
description << *i;
if(i+1 != effects_description.end())
description << "; ";
}
description << ")";
}
description << "\n";
modificationDescriptions_[type] += description.str();
}
void unit::apply_modifications()
{
log_scope("apply mods");
modificationDescriptions_.clear();
for(int i = 0; i != NumModificationTypes; ++i) {
const std::string& mod = ModificationTypes[i];
const config::child_list& mods = modifications_.get_children(mod);
@ -789,6 +825,17 @@ void unit::apply_modifications()
}
}
const std::string& unit::modification_description(const std::string& type) const
{
const string_map::const_iterator i = modificationDescriptions_.find(type);
if(i == modificationDescriptions_.end()) {
static const std::string empty_string;
return empty_string;
} else {
return i->second;
}
}
int unit::upkeep() const
{
switch(upkeep_) {

View file

@ -111,6 +111,8 @@ public:
void add_modification(const std::string& type, const config& modification,
bool no_add=false);
const std::string& modification_description(const std::string& type) const;
private:
const unit_type* type_;
@ -147,6 +149,8 @@ private:
std::string traitsDescription_;
string_map modificationDescriptions_;
bool guardian_;
gamemap::location goto_;