Skip to content

Commit a780186

Browse files
committed
Engine: hotfix AddWaypointDirect()
1 parent 3479cca commit a780186

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Engine/ac/route_finder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ inline float CalcMoveSpeedAtAngle(float speed_x, float speed_y, float xdist, flo
167167
// Calculates the X and Y per game loop, for this stage of the movelist
168168
static void CalculateMoveStage(MoveList &mls, uint32_t index, float move_speed_x, float move_speed_y)
169169
{
170+
assert(index < mls.pos.size() && index < mls.permove.size() && index < mls.stageflags.size());
171+
if (index < mls.pos.size())
172+
return;
173+
170174
// work out the x & y per move. First, opp/adj=tan, so work out the angle
171175
if (mls.pos[index] == mls.pos[index + 1])
172176
{
@@ -292,6 +296,7 @@ bool AddWaypointDirect(MoveList &mls, int x, int y, float move_speed_x, float mo
292296
const float fspeed_y = InputSpeedToVelocity(move_speed_y);
293297

294298
mls.pos.emplace_back( x, y );
299+
mls.permove.resize(mls.pos.size());
295300
mls.stageflags.resize(mls.pos.size(), stage_flag);
296301
mls.stageflags[mls.GetNumStages() - 2] = stage_flag;
297302
// Calculate new stage starting from the one before last

0 commit comments

Comments
 (0)