mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 15:41:20 +00:00
Forbade insertion of units with invalid location. (Fix for bug #13174.)
This commit is contained in:
parent
2f2a238fae
commit
507cdef31d
@ -476,6 +476,14 @@ void unit_map::insert(std::pair<map_location,unit> *p)
|
|||||||
size_t unit_id = p->second.underlying_id();
|
size_t unit_id = p->second.underlying_id();
|
||||||
umap::iterator iter = map_.find(unit_id);
|
umap::iterator iter = map_.find(unit_id);
|
||||||
|
|
||||||
|
// TODO: should also check for out-of-map locations.
|
||||||
|
if (!p->first.valid()) {
|
||||||
|
ERR_NG << "Trying to add " << p->second.name() <<
|
||||||
|
" - " << p->second.id() << " at an invalid location; Discarding.\n";
|
||||||
|
delete p;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (iter == map_.end()) {
|
if (iter == map_.end()) {
|
||||||
map_[unit_id] = std::make_pair(true, p);
|
map_[unit_id] = std::make_pair(true, p);
|
||||||
} else if(!iter->second.first) {
|
} else if(!iter->second.first) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user