unit::underlying_description_ -> unit::underlying_id_
This commit is contained in:
parent
c90216ddc9
commit
f6e4419d2f
7 changed files with 41 additions and 41 deletions
|
@ -866,8 +866,8 @@ attack::attack(game_display& gui, const gamemap& map,
|
|||
return;
|
||||
}
|
||||
|
||||
a_id_ = a_->second.underlying_description();
|
||||
d_id_ = d_->second.underlying_description();
|
||||
a_id_ = a_->second.underlying_id();
|
||||
d_id_ = d_->second.underlying_id();
|
||||
|
||||
// no attack weapon => stop here and don't attack
|
||||
if (attack_with < 0) {
|
||||
|
|
|
@ -462,7 +462,7 @@ gamemap::location ai_interface::move_unit_partial(location from, location to,
|
|||
|
||||
while(steps.empty() == false && (!(info_.units.find(to) == info_.units.end() || from == to))){
|
||||
LOG_AI << "AI attempting illegal move. Attempting to move onto existing unit\n";
|
||||
LOG_AI << "\t" << info_.units.find(to)->second.underlying_description() <<" already on " << to << "\n";
|
||||
LOG_AI << "\t" << info_.units.find(to)->second.underlying_id() <<" already on " << to << "\n";
|
||||
LOG_AI <<"\tremoving "<<*(steps.end()-1)<<"\n";
|
||||
to = *(steps.end()-1);
|
||||
steps.pop_back();
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace dfool {
|
|||
|
||||
// for(unit_map::iterator ua = get_info().units.begin(); ua != get_info().units.end(); ++ua) {
|
||||
// std::string t = ua->second.get_ai_special();
|
||||
// LOG_STREAM(info, ai)<<"ua:"<<ua->second.underlying_description()<<"\t"<<t<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"ua:"<<ua->second.underlying_id()<<"\t"<<t<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t\t"<<ua->first.x<<","<<ua->first.y<<std::endl;
|
||||
// }
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace dfool {
|
|||
// unit_map::iterator u = unit(*ui,get_info().units);
|
||||
// if(u!=get_info().units.end()){
|
||||
// LOG_STREAM(info, ai)<<"\t"<<u->second.name()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_description()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_id()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t\t"<<u->second.get_ai_special()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t\t"<<u->first.x<<","<<u->first.y<<std::endl;
|
||||
// }
|
||||
|
@ -68,7 +68,7 @@ namespace dfool {
|
|||
unit_map::iterator u = unit(*ui,get_info().units);
|
||||
if(u!=get_info().units.end()){
|
||||
// LOG_STREAM(info, ai)<<"\t"<<u->second.name()<<std::endl;
|
||||
LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_description()<<std::endl;
|
||||
LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_id()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t\t"<<u->second.get_ai_special()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\t\t"<<u->first.x<<","<<u->first.y<<std::endl;
|
||||
|
||||
|
@ -105,16 +105,16 @@ namespace dfool {
|
|||
if(ui!=get_info().units.end()){
|
||||
std::string ais=ui->second.get_ai_special();
|
||||
|
||||
// LOG_STREAM(info, ai)<<"\t match: "<<ui->second.underlying_description()<<"\t"<<ais<<":::"<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t match: "<<ui->second.underlying_id()<<"\t"<<ais<<":::"<<std::endl;
|
||||
|
||||
bool used=(ais.size() > 0);
|
||||
if(used){
|
||||
// LOG_STREAM(info, ai)<<"\t\talready assigned: "<<ui->second.underlying_description()<<"\t"<<ais<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\talready assigned: "<<ui->second.underlying_id()<<"\t"<<ais<<std::endl;
|
||||
}else{
|
||||
ui->second.assign_ai_special(order_id);
|
||||
order_units.push_back(*i);
|
||||
|
||||
// LOG_STREAM(info, ai)<<"\t\tmatching: "<<ui->second.underlying_description()<<" to order: "<<order_id<<"\t"<<ui->second.get_ai_special()<<std::endl;
|
||||
// LOG_STREAM(info, ai)<<"\t\tmatching: "<<ui->second.underlying_id()<<" to order: "<<order_id<<"\t"<<ui->second.get_ai_special()<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ namespace dfool {
|
|||
if(type=="set_order"){
|
||||
std::string set_id=(**com)["id"];
|
||||
std::string a=(u->second.get_ai_special());
|
||||
LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_description()<<"\t"<<a<<"->"<<set_id<<std::endl;
|
||||
LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_id()<<"\t"<<a<<"->"<<set_id<<std::endl;
|
||||
(u->second.assign_ai_special(set_id));
|
||||
a=(u->second.get_ai_special());
|
||||
LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_description()<<"\t"<<a<<" =?= "<<set_id<<std::endl;
|
||||
LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_id()<<"\t"<<a<<" =?= "<<set_id<<std::endl;
|
||||
}
|
||||
if(type=="break"){
|
||||
com_break=true;
|
||||
|
@ -189,8 +189,8 @@ namespace dfool {
|
|||
for(unit_list::const_iterator i = ul.begin(); i != ul.end(); ++i) {
|
||||
// LOG_STREAM(info, ai)<<"filter2:"<<std::endl;
|
||||
unit_map::iterator j = unit(*i,um);
|
||||
// LOG_STREAM(info, ai)<<"j:"<<j->second.underlying_description()<<":"<<j->first.x<<","<<j->first.y<<std::endl;
|
||||
if(j->second.underlying_description().size()>0){
|
||||
// LOG_STREAM(info, ai)<<"j:"<<j->second.underlying_id()<<":"<<j->first.x<<","<<j->first.y<<std::endl;
|
||||
if(j->second.underlying_id().size()>0){
|
||||
// LOG_STREAM(info, ai)<<"filter3:"<<std::endl;
|
||||
if(j->second.matches_filter(&filter,j->first)) {
|
||||
// LOG_STREAM(info, ai)<<"filter4:"<<std::endl;
|
||||
|
@ -212,7 +212,7 @@ namespace dfool {
|
|||
bool hidden_by_fog = current_team().fogged(i->first);
|
||||
bool hidden = i->second.invisible(i->first, um, get_info().teams);
|
||||
if((no_fog || !hidden_by_fog) && !hidden) {
|
||||
visible_units.push_back(i->second.underlying_description());
|
||||
visible_units.push_back(i->second.underlying_id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ namespace dfool {
|
|||
unit_list all;
|
||||
const unit_map& um=get_info().units;
|
||||
for(unit_map::const_iterator i = um.begin(); i != um.end(); ++i) {
|
||||
// LOG_STREAM(info, ai)<<"all:"<<i->second.underlying_description()<<std::endl;
|
||||
all.push_back(i->second.underlying_description());
|
||||
// LOG_STREAM(info, ai)<<"all:"<<i->second.underlying_id()<<std::endl;
|
||||
all.push_back(i->second.underlying_id());
|
||||
}
|
||||
return(all);
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ namespace dfool {
|
|||
|
||||
std::cout<<"known units:\n";
|
||||
for(unit_map::const_iterator uu = known_units.begin();uu!=known_units.end();uu++){
|
||||
std::cout<<"\t"<<uu->second.underlying_description()<<" "<<uu->first<<"\n";
|
||||
std::cout<<"\t"<<uu->second.underlying_id()<<" "<<uu->first<<"\n";
|
||||
}
|
||||
|
||||
calculate_moves(known_units,possible_moves,srcdst,dstsrc,false,false,NULL,true);
|
||||
|
@ -273,7 +273,7 @@ namespace dfool {
|
|||
}
|
||||
}
|
||||
|
||||
LOG_STREAM(info, ai)<<"\tmoving : "<< m->second.underlying_description() <<" "<<" from ("<<closest_move.first.x<<","<<closest_move.first.y<<")"<<" to ("<<target.x<<","<<target.y<<")"<<std::endl;
|
||||
LOG_STREAM(info, ai)<<"\tmoving : "<< m->second.underlying_id() <<" "<<" from ("<<closest_move.first.x<<","<<closest_move.first.y<<")"<<" to ("<<target.x<<","<<target.y<<")"<<std::endl;
|
||||
LOG_STREAM(info, ai)<<"\tdistance: "<<closest_distance<<"\n";
|
||||
|
||||
if(closest_distance != -1) {
|
||||
|
@ -288,8 +288,8 @@ namespace dfool {
|
|||
unit_map::iterator dfool_ai::unit(std::string unit_id, unit_map& um){
|
||||
// LOG_STREAM(info, ai)<<"unit start:"<<unit_id<<std::endl;
|
||||
for(unit_map::iterator u = um.begin(); u != um.end(); u++){
|
||||
if(unit_id == u->second.underlying_description()){
|
||||
// LOG_STREAM(info, ai)<<"unit:"<<unit_id<<" , "<< u->second.underlying_description()<<std::endl;
|
||||
if(unit_id == u->second.underlying_id()){
|
||||
// LOG_STREAM(info, ai)<<"unit:"<<unit_id<<" , "<< u->second.underlying_id()<<std::endl;
|
||||
return u;
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ namespace dfool {
|
|||
}
|
||||
|
||||
void unit_memory::add_unit_sighting(unit u, gamemap::location l, size_t t){
|
||||
std::string unit_id= u.underlying_description();
|
||||
std::string unit_id= u.underlying_id();
|
||||
// Check if this unit has already been seen
|
||||
size_t i,j;
|
||||
for(i=0; i < ids_.size();i++){
|
||||
|
|
|
@ -437,7 +437,7 @@ bool python_ai::is_unit_valid(const unit* unit)
|
|||
static PyObject* unit_get_name(wesnoth_unit* unit, void* /*closure*/)
|
||||
{
|
||||
u_check;
|
||||
return Py_BuildValue(STRINGVALUE, unit->unit_->underlying_description().c_str());
|
||||
return Py_BuildValue(STRINGVALUE, unit->unit_->underlying_id().c_str());
|
||||
}
|
||||
|
||||
static PyObject* unit_is_enemy(wesnoth_unit* unit, void* /*closure*/)
|
||||
|
|
|
@ -2218,7 +2218,7 @@ void event_handler::handle_event_command(const queued_event& event_info,
|
|||
citor != player->available_units.end(); ++citor) {
|
||||
|
||||
const std::string desciption =
|
||||
citor->underlying_description();
|
||||
citor->underlying_id();
|
||||
if(std::find(desciptions.begin(), desciptions.end(),
|
||||
desciption) != desciptions.end()) {
|
||||
|
||||
|
@ -2233,16 +2233,16 @@ void event_handler::handle_event_command(const queued_event& event_info,
|
|||
|
||||
// Avoid duplicates in the list.
|
||||
//! @todo it would be better to change available_units from
|
||||
//! a vector to a map and use the underlying_description
|
||||
//! a vector to a map and use the underlying_id
|
||||
//! as key.
|
||||
const std::string key = u.underlying_description();
|
||||
const std::string key = u.underlying_id();
|
||||
for(std::vector<unit>::iterator itor =
|
||||
player->available_units.begin();
|
||||
itor != player->available_units.end(); ++itor) {
|
||||
|
||||
LOG_NG << "Replaced unit '"
|
||||
<< key << "' on the recall list\n";
|
||||
if(itor->underlying_description() == key) {
|
||||
if(itor->underlying_id() == key) {
|
||||
player->available_units.erase(itor);
|
||||
break;
|
||||
}
|
||||
|
@ -2930,12 +2930,12 @@ entity_location::entity_location(gamemap::location loc, const std::string& id)
|
|||
{}
|
||||
|
||||
entity_location::entity_location(unit_map::iterator itor)
|
||||
: location(itor->first), id_(itor->second.underlying_description())
|
||||
: location(itor->first), id_(itor->second.underlying_id())
|
||||
{}
|
||||
|
||||
bool entity_location::matches_unit(const unit& u) const
|
||||
{
|
||||
return id_ == u.underlying_description();
|
||||
return id_ == u.underlying_id();
|
||||
}
|
||||
|
||||
bool entity_location::requires_unit() const
|
||||
|
|
22
src/unit.cpp
22
src/unit.cpp
|
@ -94,7 +94,7 @@ unit::unit(const unit& o):
|
|||
name_(o.name_),
|
||||
description_(o.description_),
|
||||
custom_unit_description_(o.custom_unit_description_),
|
||||
underlying_description_(o.underlying_description_),
|
||||
underlying_id_(o.underlying_id_),
|
||||
language_name_(o.language_name_),
|
||||
undead_variation_(o.undead_variation_),
|
||||
variation_(o.variation_),
|
||||
|
@ -272,14 +272,14 @@ unit::unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map,
|
|||
}
|
||||
generate_traits(!use_traits);
|
||||
apply_modifications();
|
||||
if(underlying_description_.empty()){
|
||||
if(underlying_id_.empty()){
|
||||
char buf[80];
|
||||
if(!custom_unit_description_.empty()){
|
||||
snprintf(buf, sizeof(buf), "%s-%d-%s",type()->id().c_str(), get_random(), custom_unit_description_.c_str());
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%s-%d",type()->id().c_str(), get_random());
|
||||
}
|
||||
underlying_description_ = buf;
|
||||
underlying_id_ = buf;
|
||||
}
|
||||
|
||||
unrenamable_ = false;
|
||||
|
@ -313,14 +313,14 @@ unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit, unit_
|
|||
}
|
||||
generate_traits(!use_traits);
|
||||
apply_modifications();
|
||||
if(underlying_description_.empty()){
|
||||
if(underlying_id_.empty()){
|
||||
char buf[80];
|
||||
if(!custom_unit_description_.empty()){
|
||||
snprintf(buf, sizeof(buf), "%s-%d-%s",type()->id().c_str(), get_random(), custom_unit_description_.c_str());
|
||||
}else{
|
||||
snprintf(buf, sizeof(buf), "%s-%d",type()->id().c_str(), get_random());
|
||||
}
|
||||
underlying_description_ = buf;
|
||||
underlying_id_ = buf;
|
||||
}
|
||||
|
||||
unrenamable_ = false;
|
||||
|
@ -883,12 +883,12 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location&
|
|||
const std::string& defense = t_defense;
|
||||
const std::string& mvt_cost = t_movement_cost;
|
||||
|
||||
if(description.empty() == false && description != this->underlying_description()) {
|
||||
if(description.empty() == false && description != this->underlying_id()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow 'speaker' as an alternative to description, since people use it so often
|
||||
if(speaker.empty() == false && speaker != this->underlying_description()) {
|
||||
if(speaker.empty() == false && speaker != this->underlying_id()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1191,12 +1191,12 @@ void unit::read(const config& cfg, bool use_traits, game_state* state)
|
|||
custom_unit_description_ = cfg["user_description"];
|
||||
std::string custom_unit_desc = cfg["unit_description"];
|
||||
|
||||
underlying_description_ = cfg["description"];
|
||||
if(underlying_description_.empty()){
|
||||
underlying_id_ = cfg["description"];
|
||||
if(underlying_id_.empty()){
|
||||
char buf[80];
|
||||
snprintf(buf, sizeof(buf), "%s-%d",cfg["type"].c_str(), state ?
|
||||
state->get_random() : get_random());
|
||||
underlying_description_ = buf;
|
||||
underlying_id_ = buf;
|
||||
}
|
||||
if(description_.empty()) {
|
||||
description_ = cfg["type"].c_str();
|
||||
|
@ -1484,7 +1484,7 @@ void unit::write(config& cfg) const
|
|||
cfg["overlays"] = utils::join(overlays_);
|
||||
|
||||
cfg["user_description"] = custom_unit_description_;
|
||||
cfg["description"] = underlying_description_;
|
||||
cfg["description"] = underlying_id_;
|
||||
|
||||
if(can_recruit())
|
||||
cfg["canrecruit"] = "yes";
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
void rename(const std::string& name) { if (!unrenamable_) custom_unit_description_ = name; }
|
||||
//! The unit type name
|
||||
const std::string& description() const { return (custom_unit_description_); }
|
||||
const std::string& underlying_description() const { return underlying_description_; }
|
||||
const std::string& underlying_id() const { return underlying_id_; }
|
||||
const t_string& language_name() const { return language_name_; }
|
||||
const std::string& undead_variation() const { return undead_variation_; }
|
||||
//! The unit's profile
|
||||
|
@ -303,7 +303,7 @@ private:
|
|||
std::string name_;
|
||||
std::string description_;
|
||||
std::string custom_unit_description_;
|
||||
std::string underlying_description_;
|
||||
std::string underlying_id_;
|
||||
t_string language_name_;
|
||||
std::string undead_variation_;
|
||||
std::string variation_;
|
||||
|
|
Loading…
Add table
Reference in a new issue