Skip to content

Commit

Permalink
Fix an infinite loop when setting up path for Vehicle
Browse files Browse the repository at this point in the history
  • Loading branch information
smallmodel authored Jan 8, 2025
1 parent 944e0f2 commit cd65424
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions code/fgame/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3465,28 +3465,27 @@ 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;
}
} else {
fCurLength += vDelta.length();

fCurLength += vDelta.length();
vTmp[0] = fCurLength;
VectorCopy(ent->origin, vTmp + 1);

vTmp[0] = fCurLength;
VectorCopy(ent->origin, vTmp + 1);
if (ent->IsSubclassOfVehiclePoint()) {
pPath->Add(vTmp, static_cast<VehiclePoint*>(ent)->spawnflags);
} else {
pPath->Add(vTmp, 0);
}

if (ent->IsSubclassOfVehiclePoint()) {
pPath->Add(vTmp, static_cast<VehiclePoint*>(ent)->spawnflags);
} else {
pPath->Add(vTmp, 0);
vLastOrigin = ent->origin;
}

vLastOrigin = ent->origin;

if (ent == se && i > 1) {
break;
}
Expand Down

0 comments on commit cd65424

Please sign in to comment.