Split from #632 - may be related to other "incorrect tile coords" bugs, but this has a nice quick seemingly-guaranteed reproduction
"Select squad 1 and have them run to the nearest exit tile. The game will crash right before the squad gets there. The second nearest tile has the same effect, but seems to occur a few seconds later. If the unit does not run to the exit, the game continues to run normally. I was able to get this to repeat every time on stream."
Now the crash is gone, instead following the same instructions we get an error:
OpenApoc::Tile *OpenApoc::TileMap::getTile(int, int, int): Incorrect tile coordinates 32,18,4
Backtrace from run:
__semwait_signal + 10
frame #1: 0x00007fff59d8a914 libsystem_c.dylibnanosleep + 199SDL_Delay_REAL + 83
frame #3: 0x0000000104c70477 libSDL2-2.0.0.dylib-[SDLMessageBoxPresenter showAlert:] + 158-[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 1119
frame #5: 0x00007fff2fbee742 Foundation-[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 131Cocoa_ShowMessageBox + 470
frame #7: 0x0000000104c50740 libSDL2-2.0.0.dylibSDL_ShowMessageBox_REAL + 275SDL_ShowSimpleMessageBox_REAL + 118
frame #9: 0x000000010007918d OpenApocOpenApoc::Log(level=OpenApoc::TileMap::getTile(this=<unavailable>, x=<unavailable>, y=<unavailable>, z=<unavailable>) at tilemap.h:102:4 [opt]
frame #11: 0x0000000100220240 OpenApocOpenApoc::TileMap::getTile(this=OpenApoc::TileObject::setPosition(this=0x0000000141acc540, newPosition=<unavailable>)0>) at tileobject.cpp:110:25 [opt]
frame #13: 0x000000010062b879 OpenApocOpenApoc::TileMap::addObjectToMap(this=0x0000000140cc2960, doodad=std::__1::shared_ptrOpenApoc::Battle::placeDoodad(this=0x00000001397f2218, type=<unavailable>, position=OpenApoc::Vec3<float> @ 0x00007ffeefbfebf0)0>) at battle.cpp:1132:8 [opt]
frame #15: 0x0000000100203d3e OpenApocOpenApoc::BattleMapPart::die(this=0x000000013acd8928, state=0x0000000000000000, explosive=false, violently=OpenApoc::BattleMapPart::applyDamage(this=0x000000013acd8928, state=0x0000000107031a18, power=70, damageType=StateRef<OpenApoc::DamageType> @ 0x00007ffeefbfef50) at battlemappart.cpp:212:2 [opt]
frame #17: 0x00000001002047c4 OpenApocOpenApoc::BattleMapPart::handleCollision(this=OpenApoc::Battle::updateProjectiles(this=0x00000001397f2218, state=0x0000000107031a18, ticks=<unavailable>) at battle.cpp:1406:49 [opt]
frame #19: 0x00000001001a499a OpenApocOpenApoc::Battle::update(this=0x00000001397f2218, state=0x0000000107031a18, ticks=OpenApoc::GameState::update(this=0x0000000107031a18, ticks=1) at gamestate.cpp:960:25 [opt]
frame #21: 0x0000000100852522 OpenApocOpenApoc::BattleView::update(this=0x000000010ab6c018) at battleview.cpp:1452:10 [opt]OpenApoc::Framework::run(this=0x0000000106e00000, initialStage=<unavailable>) at framework.cpp:654:32 [opt]
frame #23: 0x0000000100004b40 OpenApocmain(argc=start + 1
frame #25: 0x00007fff59cc63d5 libdyld.dylibstart + 1So this is trying to spawn an explosition doodad at x=31.5, that's being pushed to x=32 for the tileObject (not sure why - as it seems 'left wall' explosions are set to the "position = position - (-0.5,0,0)" (note the double-negative) - not sure if that is intended?
An extremely quick test of #640 looks better to me - if people can test this and let me know please!
(Are the explosion doodads for each scenery tile death in about the right place? Are there any more "Invalid tile coordinate" errors caused by destroying objects/scenery at the edges of maps?)
Here's a zip from my stream today where I believe we were getting the same issue. The log file is included.
save_Coordinate Bug.zip
I think it's a different root cause - the report here was caused by destroying objects at the map edge, while QM's report seems to backtrace into the pathfinding code
Most helpful comment
An extremely quick test of #640 looks better to me - if people can test this and let me know please!
(Are the explosion doodads for each scenery tile death in about the right place? Are there any more "Invalid tile coordinate" errors caused by destroying objects/scenery at the edges of maps?)