Skip to content

Read acccess violation in Map::getRegionDistance #3

@spacehamster

Description

@spacehamster

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_ptrr.
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions