I can't edit my previous coment so I'll just make another one
The crash hadn't happened again, my solution was the following: I was using this source (
Fir3element/3777 (https://github.com/Fir3element/3777/)) but for some reason It would always crash on start up so I changed it's exception.cpp and .h with the ones of an older source I had and it worked like a charm, but since the crash happenned I wen't back to fi3element's exception.cpp and .h and the crash haven't happened since then.
I'll be giving Mustafa the best answer since he really helped with the debug idea
@Mustafa1337 in the debug mode, I got the message "creature::updatetilecache out of range" before the
terminate called after throwing an istance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >' what(): call to empty boost::function
any ideia what it could be? sems like the crash ain't gone..
edit: looking here (
otland/tfs-old-svn (https://github.com/otland/tfs-old-svn/blob/master/creature.cpp)) I've found
C++:
void Creature::updateTileCache(const Tile* tile, int32_t dx, int32_t dy)
{
if((std::abs(dx) <= (mapWalkWidth - 1) / 2) &&
(std::abs(dy) <= (mapWalkHeight - 1) / 2))
{
int32_t x = (mapWalkWidth - 1) / 2 + dx;
int32_t y = (mapWalkHeight - 1) / 2 + dy;
localMapCache[y][x] = (tile && tile->__queryAdd(0, this, 1,
FLAG_PATHFINDING | FLAG_IGNOREFIELDDAMAGE) == RET_NOERROR);
}
#ifdef [B]DEBUG[/B]
else
std::cout << "Creature::updateTileCache out of range." << std::endl;
#endif
}
may be a monster dying to fire?
on my sources I have the following code:
C++:
void Creature::updateTileCache(const Tile* tile)
{
if(isMapLoaded && tile->getPosition().z == getPosition().z)
updateTileCache(tile, tile->getPosition());
}
void Creature::updateTileCache(const Tile* tile, int32_t dx, int32_t dy)
{
if((std::abs(dx) <= (mapWalkWidth - 1) / 2) && (std::abs(dy) <= (mapWalkHeight - 1) / 2))
{
int32_t x = (mapWalkWidth - 1) / 2 + dx, y = (mapWalkHeight - 1) / 2 + dy;
localMapCache[y][x] = (tile && tile->__queryAdd(0, this, 1,
FLAG_PATHFINDING | FLAG_IGNOREFIELDDAMAGE) == RET_NOERROR);
}
#ifdef [B]DEBUG[/B]
else
std::clog << "Creature::updateTileCache out of range." << std::endl;
#endif
}
}
edit: I think I might know what the problem is, a creature is trying to spawn without having room to do so, and when that happens the source is trying to find another location for the creature, but only loking to x position, the first code I mentioned also looks for Y
C++:
int32_t y = (mapWalkHeight - 1) / 2 + dy;
I'll add that and see if it fixes the problem, will take time to know for sure tho since it's hard to make the crash happen
edit: Just happened again.. I'm back to my original creature.cpp:
//////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com (https://pastebin.com/GtKsKVHz) I'll try to adapt some stuff from otx to see if it will fix the issue... dunno, I'm really out of ideas