Fix crash when client sends an invalid player start

This commit is contained in:
nsubiron 2017-09-26 18:13:23 +02:00
parent 3850f9e1c5
commit d8d9d991dd
1 changed files with 6 additions and 0 deletions

View File

@ -41,6 +41,7 @@ void CarlaGameController::Initialize(UCarlaSettings &InCarlaSettings)
APlayerStart *CarlaGameController::ChoosePlayerStart(
const TArray<APlayerStart *> &AvailableStartSpots)
{
check(AvailableStartSpots.Num() > 0);
// Send scene description.
if (Server != nullptr) {
if (Errc::Success != Server->SendSceneDescription(AvailableStartSpots, BLOCKING)) {
@ -58,6 +59,11 @@ APlayerStart *CarlaGameController::ChoosePlayerStart(
}
}
if (StartIndex >= AvailableStartSpots.Num()) {
UE_LOG(LogCarlaServer, Warning, TEXT("Client requested an invalid player start, using default one instead."));
StartIndex = 0u;
}
return AvailableStartSpots[StartIndex];
}