add bounds check to prevent crashing (#992)

This commit is contained in:
Aaron Kimbrell 2023-02-16 11:14:23 -06:00 committed by GitHub
parent 72c93c8913
commit 484488e47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,9 +7,9 @@ void AgMonumentRaceGoal::OnStartup(Entity* self) {
}
void AgMonumentRaceGoal::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (name == "RaceGoal" && entering->IsPlayer() && status == "ENTER") {
auto* manager = EntityManager::Instance()->GetEntitiesInGroup("race_manager")[0];
manager->OnFireEventServerSide(entering, "course_finish");
if (name == "RaceGoal" && entering && entering->IsPlayer() && status == "ENTER") {
auto managers = EntityManager::Instance()->GetEntitiesInGroup("race_manager");
if (managers.empty() || !managers.at(0)) return;
managers.at(0)->OnFireEventServerSide(entering, "course_finish");
}
}