mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
fix: UB with LivingEntities::pushEntities
This commit is contained in:
parent
76788f1708
commit
f7e555ea6b
|
|
@ -485,7 +485,7 @@ File Minecraft::getWorkingDirectory(const std::string& applicationName) {
|
||||||
|
|
||||||
return workingDirectory;
|
return workingDirectory;
|
||||||
} else {
|
} else {
|
||||||
Log::info("Could not locate user's home directory. This platform is likely missing an implementation of Minecraft::getWorkingDirectory.");
|
Log::info("Could not locate user's home directory. This platform is likely missing an implementation of Minecraft::getWorkingDirectory.\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1604,11 +1604,15 @@ void LivingEntity::pushEntities() {
|
||||||
AABB grown = bb.grow(0.2, 0, 0.2);
|
AABB grown = bb.grow(0.2, 0, 0.2);
|
||||||
std::vector<std::shared_ptr<Entity>>* entities =
|
std::vector<std::shared_ptr<Entity>>* entities =
|
||||||
level->getEntities(shared_from_this(), &grown);
|
level->getEntities(shared_from_this(), &grown);
|
||||||
if (entities != nullptr && !entities->empty()) {
|
|
||||||
auto itEnd = entities->end();
|
if (entities == nullptr || entities->empty()) {
|
||||||
for (auto it = entities->begin(); it != itEnd; it++) {
|
return;
|
||||||
std::shared_ptr<Entity> e = *it; // entities->at(i);
|
}
|
||||||
if (e and !e->removed and e->isPushable()) push(e);
|
|
||||||
|
std::vector<std::shared_ptr<Entity>> prev_entities = *entities;
|
||||||
|
for (const std::shared_ptr<Entity>& e : prev_entities) {
|
||||||
|
if (e && !e->removed && e->isPushable()) {
|
||||||
|
push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue