Fix an infinite loop when setting up path for Vehicle

This commit is contained in:
smallmodel 2025-01-08 20:32:34 +01:00 committed by GitHub
parent 944e0f24ae
commit cd65424b00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3465,27 +3465,26 @@ void Vehicle::SetupPath(cVehicleSpline *pPath, SimpleEntity *se)
vLastOrigin = se->origin;
for (ent = se; ent != NULL; ent = ent->Next(), i++) {
for (ent = se; ent; ent = ent->Next(), i++) {
Vector vDelta = vLastOrigin - ent->origin;
float vTmp[4];
if (vDelta.length() == 0 && i > 1) {
Com_Printf("^~^~^Warning: Vehicle Driving with a Path that contains 2 equal points\n");
continue;
}
fCurLength += vDelta.length();
vTmp[0] = fCurLength;
VectorCopy(ent->origin, vTmp + 1);
if (ent->IsSubclassOfVehiclePoint()) {
pPath->Add(vTmp, static_cast<VehiclePoint*>(ent)->spawnflags);
} else {
pPath->Add(vTmp, 0);
}
fCurLength += vDelta.length();
vLastOrigin = ent->origin;
vTmp[0] = fCurLength;
VectorCopy(ent->origin, vTmp + 1);
if (ent->IsSubclassOfVehiclePoint()) {
pPath->Add(vTmp, static_cast<VehiclePoint*>(ent)->spawnflags);
} else {
pPath->Add(vTmp, 0);
}
vLastOrigin = ent->origin;
}
if (ent == se && i > 1) {
break;