Fix crash when sending non-player agents' info

This commit is contained in:
nsubiron 2017-08-30 14:21:01 +01:00
parent 7bca783ff0
commit 4fc0fe7b89
1 changed files with 8 additions and 6 deletions

View File

@ -206,12 +206,14 @@ template <typename T>
static void AddAgents(TArray<carla_agent> &Agents, const TArray<T> &Actors, uint32 type)
{
for (auto &&Actor : Actors) {
Agents.Emplace();
auto &values = Agents.Last();
values.id = GetTypeHash(Actor);
values.type = type;
Set(values.transform, Actor->GetActorTransform());
SetBoxAndSpeed(values, Actor);
if (Actor != nullptr) {
Agents.Emplace();
auto &values = Agents.Last();
values.id = GetTypeHash(Actor);
values.type = type;
Set(values.transform, Actor->GetActorTransform());
SetBoxAndSpeed(values, Actor);
}
}
}