namelessvoid / qrwar

:european_castle: Pen&Paper like quad ruled war game.
MIT License
6 stars 0 forks source link

Fix 'std::out_of_range' crash #67

Closed namelessvoid closed 10 years ago

namelessvoid commented 10 years ago

Sometimes the game crashes with an out_of_range exception (pretty sure thrown in BoardWidget::drawPath()) after attacking an enemy unit.

Reproduce bug:

  1. Move a unit towards an enemy: Distance has to be at least 2 squares so the footsteps are printed
  2. Attack this enemy
  3. Hit "next turn"
  4. Select attacked unit and move cursor to an neighbouring square (so pathfinding is triggered)
  5. Game crashes
namelessvoid commented 10 years ago

Bug reproduction not quite correct. The bug appears sometimes when a path to a neighbouring square which is occupied by a unit (friend or foe) is calculated. AStar::getPath() returns a valid Path which only contains the start square instead of a null-pointer. The BoardWidget::drawPath() tries now to access the second step via path->getSetp(1) which results in a segfault.

Reproduce bug:

  1. Deploy two units next to each other
  2. Start game
  3. Click unit A, move Cursor to unit B, right click
  4. Click unit B, move Cursor to unit A
  5. Segfault