Skip to content

Commit

Permalink
UnitDelivery does not look for a better place for PlaceAnywhere build…
Browse files Browse the repository at this point in the history
…ings.
  • Loading branch information
AlexBx committed Sep 25, 2014
1 parent ec9c714 commit 0c187bb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Misc/SWTypes/UnitDelivery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ void UnitDeliveryStateMachine::PlaceUnits()
SpeedType SpeedType = SpeedType::Track;
MovementZone MovementZone = MovementZone::Normal;
bool buildable = false;
bool anywhere = false;

if(ItemBuilding) {
extentX = ItemBuilding->Type->GetFoundationWidth();
extentY = ItemBuilding->Type->GetFoundationHeight(true);
auto BuildingType = ItemBuilding->Type;
extentX = BuildingType->GetFoundationWidth();
extentY = BuildingType->GetFoundationHeight(true);
anywhere = BuildingType->PlaceAnywhere;
if(Type->SpeedType == SpeedType::Float) {
SpeedType = SpeedType::Float;
} else {
Expand All @@ -104,13 +107,15 @@ void UnitDeliveryStateMachine::PlaceUnits()
}

// move the target cell so this object is centered on the actual location
CellStruct CenteredOnCords = this->Coords - CellStruct{extentX / 2, extentY / 2};
auto PlaceCoords = this->Coords - CellStruct{extentX / 2, extentY / 2};

// find a place to put this
int a5 = -1; // usually MapClass::CanLocationBeReached call. see how far we can get without it
auto PlaceCoords = MapClass::Instance->Pathfinding_Find(CenteredOnCords,
SpeedType, a5, MovementZone, false, extentX, extentY, true, false,
false, false, CellStruct::Empty, false, buildable);
if(!anywhere) {
int a5 = -1; // usually MapClass::CanLocationBeReached call. see how far we can get without it
PlaceCoords = MapClass::Instance->Pathfinding_Find(PlaceCoords,
SpeedType, a5, MovementZone, false, extentX, extentY, true,
false, false, false, CellStruct::Empty, false, buildable);
}

if(auto pCell = MapClass::Instance->TryGetCellAt(PlaceCoords)) {
Item->OnBridge = pCell->ContainsBridge();
Expand Down

0 comments on commit 0c187bb

Please sign in to comment.