Read acccess violation in Map::getRegionDistance
If i run the following
#include <mapgen/MapGenerator.hpp>
int main(int argc, char ** argv) {
MapGenerator * mapgen = new MapGenerator(1600, 900);
mapgen->setSeed(4000);
mapgen->update();
mapgen->startSimulation();
delete mapgen;
}
I get a read access violation in Map::getRegionDistance trying to read from std::shared_ptr<Region>r.
I think this may be related to passing in a raw pointer Region * in Simulator.cpp makeRoad
and then casting them back to shared_ptr in LeastCostEstimate?
Or in AdjactedCost the micropather is given a reference to n which immediatly falls out of scope?
I tried changing
int result = pather->Solve(c->region.get(), oc->region.get() &path, &totalCost);
to
int result = pather->Solve(&(c->region), &(oc->region), &path, &totalCost);
and
for (auto n : r->neighbors) {
to
for (auto &n : r->neighbors) {
in AdjacentCost but then it crashes while trying to delete cities in removeBadPorts
Seems like my recent commits which adds smart pointers are horrible =/
Try to use 121b512c155da94b59e7990f0a9226a19e78e2ed for mapgen-viewer
and dd14a6b5e491b0bce52b7f885f424e9621e0f740 for libmapgen
I am not very experienced c++ developer to fix segfaults quickly =( But if you can, i will be very grateful.
I use pathfinding in my other project and with possibly better approach: https://github.com/averrin/lss/blob/master/src/game/location.cpp#L285
The older commit without smart pointer works great
Nice. I will move recent commits to experimental branches. Thanks for using my code. Despite the problems.