Skip to content
Snippets Groups Projects
Commit a28847c9 authored by David Bergström's avatar David Bergström
Browse files

Warn instead of crash whenever (0,0) is sent

parent c9df0252
No related branches found
No related tags found
No related merge requests found
...@@ -121,6 +121,7 @@ CCTilePosition BuildingPlacer::getBuildLocationNear(const CCTilePosition & p, co ...@@ -121,6 +121,7 @@ CCTilePosition BuildingPlacer::getBuildLocationNear(const CCTilePosition & p, co
//double ms = t.getElapsedTimeInMilliSec(); //double ms = t.getElapsedTimeInMilliSec();
//printf("Building Placer Failure: %s - Took %lf ms\n", b.type.getName().c_str(), ms); //printf("Building Placer Failure: %s - Took %lf ms\n", b.type.getName().c_str(), ms);
std::cout << "Warning! Could not find valid placement for " << t.getName() << " near (" << p.x << ", " << p.y << "). Returning (0, 0) instead.";
return CCTilePosition(0, 0); return CCTilePosition(0, 0);
} }
......
...@@ -269,13 +269,15 @@ void Unit::repair(const Unit & target) const ...@@ -269,13 +269,15 @@ void Unit::repair(const Unit & target) const
void Unit::build(const UnitType & buildingType, CCTilePosition pos) const void Unit::build(const UnitType & buildingType, CCTilePosition pos) const
{ {
BOT_ASSERT(m_bot->Map().isConnected(getTilePosition(), pos), "Error: Build Position is not connected to worker");
BOT_ASSERT(isValid(), "Unit is not valid"); BOT_ASSERT(isValid(), "Unit is not valid");
#ifdef SC2API if (m_bot->Map().isConnected(getTilePosition(), pos))
m_bot->Actions()->UnitCommand(m_unit, m_bot->Data(buildingType).buildAbility, Util::GetPosition(pos)); {
#else m_bot->Actions()->UnitCommand(m_unit, m_bot->Data(buildingType).buildAbility, Util::GetPosition(pos));
m_unit->build(buildingType.getAPIUnitType(), pos); }
#endif else
{
printf("Warning! Cannot build at location (%d, %d) and therefore ignoring command.", pos.x, pos.y);
}
} }
void Unit::buildTarget(const UnitType & buildingType, const Unit & target) const void Unit::buildTarget(const UnitType & buildingType, const Unit & target) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment