Tags: jakecoffman/cp
Tags
fix index out of range panic in ProcessComponents (#47) * Fix index out of range panic in ProcessComponents This fixes a regression introduced in commit f1e35a6 (modernize for loops 2). When modernizing the for loop from traditional style to range syntax, the manual i++ increment was not removed, causing a double-increment bug. The for..range statement automatically increments the index variable, so the manual i++ at line 606 caused the loop to skip indices and eventually panic with 'index out of range'. Fixes the panic that occurs when SleepTimeThreshold != INFINITY. * Revert to original loop pattern for consistency Instead of removing the manual i++ increment, revert the for loop to its original pattern before PR #43. This maintains consistency with the pre-modernization code structure where loops with conditional continue statements use manual index management. The original pattern was: for i := 0; i < len(space.dynamicBodies); { if condition { continue // Skip i++ } i++ // Increment only when not skipping }
PreviousNext