Fix crash when client sends an invalid player start
This commit is contained in:
parent
3850f9e1c5
commit
d8d9d991dd
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue