Removed fallback from unit::id
According to @gfgtdf, this was likely a legacy feature.
This commit is contained in:
parent
8354469ca4
commit
7106c1215a
2 changed files with 6 additions and 12 deletions
|
@ -28,7 +28,7 @@
|
|||
unit_ptr recall_list_manager::find_if_matches_id(const std::string &unit_id)
|
||||
{
|
||||
std::vector<unit_ptr >::iterator it = std::find_if(recall_list_.begin(), recall_list_.end(),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id(false) == unit_id; });
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; });
|
||||
if (it != recall_list_.end()) {
|
||||
return *it;
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ unit_ptr recall_list_manager::find_if_matches_id(const std::string &unit_id)
|
|||
unit_const_ptr recall_list_manager::find_if_matches_id(const std::string &unit_id) const
|
||||
{
|
||||
std::vector<unit_ptr >::const_iterator it = std::find_if(recall_list_.begin(), recall_list_.end(),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id(false) == unit_id; });
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; });
|
||||
if (it != recall_list_.end()) {
|
||||
return *it;
|
||||
} else {
|
||||
|
@ -56,7 +56,7 @@ unit_const_ptr recall_list_manager::find_if_matches_id(const std::string &unit_i
|
|||
void recall_list_manager::erase_if_matches_id(const std::string &unit_id)
|
||||
{
|
||||
recall_list_.erase(std::remove_if(recall_list_.begin(), recall_list_.end(),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id(false) == unit_id; }),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; }),
|
||||
recall_list_.end());
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ void recall_list_manager::add (const unit_ptr & ptr)
|
|||
size_t recall_list_manager::find_index(const std::string & unit_id) const
|
||||
{
|
||||
std::vector<unit_ptr >::const_iterator it = std::find_if(recall_list_.begin(), recall_list_.end(),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id(false) == unit_id; });
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; });
|
||||
|
||||
return it - recall_list_.begin();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ size_t recall_list_manager::find_index(const std::string & unit_id) const
|
|||
unit_ptr recall_list_manager::extract_if_matches_id(const std::string &unit_id)
|
||||
{
|
||||
std::vector<unit_ptr >::iterator it = std::find_if(recall_list_.begin(), recall_list_.end(),
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id(false) == unit_id; });
|
||||
[&unit_id](const unit_ptr & ptr) { return ptr->id() == unit_id; });
|
||||
if (it != recall_list_.end()) {
|
||||
unit_ptr ret = *it;
|
||||
recall_list_.erase(it);
|
||||
|
|
|
@ -262,15 +262,9 @@ public:
|
|||
*
|
||||
* This is a unique string usually set by WML. It should *not* be used for internal tracking in
|
||||
* the unit_map. Use @ref underlying_id for that.
|
||||
*
|
||||
* @param fallback If true (default), return this unit's type name if the id is empty.
|
||||
*/
|
||||
const std::string& id(bool fallback = true) const
|
||||
const std::string& id() const
|
||||
{
|
||||
if(fallback && id_.empty()) {
|
||||
return type_name();
|
||||
}
|
||||
|
||||
return id_;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue