Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix this crash but in AI update_player_buildings #367

@tlongstretch

Description

@tlongstretch
  MapPos pos = building->get_position();
// apr13 2024 - got a crash here where building->get_position() returned bad_map_pos instead of a valid pos, not sure why
//  for now, at least skip any buildings with bad_map_pos
if (pos == bad_map_pos){
  AILogError["util_update_buildings"] << "ERROR - building->get_position() returned bad_map_pos as its position!  skipping this building";
  continue;
}
  MapPos flag_pos = map->move_down_right(building->get_position());
// saw a weird exception where building 'type' was... 10117???  if this keeps happening start dumping building type before it crashes
// again, same deal.  adding debugging
// debugging confirms seeing buildings with weird high invalid types >1024, maybe bitmath explanation??? look at any place in code
//  that 'type' is modified to find out
// I can't find anywhere in the original code that building type is modified... I think this is a bug and it is pointing
//  to a wrong object?? that is worrying
// first time logging enabled, the building with invalid type used to have a flag at same pos, which was attached a building of TypeHut up-left one pos
// second time, was a Hut again
// third time, never seen before, totally invalid map pos.  this is very likely a wrong pointer
// fourth time, just like 1st and 2nd, knight hut
// 5th, knight hut stub road, had a spiderweb road built to it
// 6th, can't tell.  
// bypassing this error for now
if (type > Building::TypeCastle){
  AILogError["util_update_buildings"] << "RECURRING BUG! has a building of invalid type " << type << " at pos " << pos << ", with flag_pos " << flag_pos << "! bypassing error";
  continue;
}
AILogDebug["util_update_buildings"] << "debug has a building of type " << type << " at pos " << pos << ", with flag_pos " << flag_pos;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions