Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
abma authored and hoijui committed Nov 10, 2010
1 parent cdec804 commit 3325583
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions rts/Sim/Units/UnitTypes/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,40 +299,40 @@ void CFactory::AssignBuildeeOrders(CUnit* unit) {
return;
}

if (unit->unitDef->canfly) {
return;
}
Command c;
c.id = CMD_MOVE;

// HACK: when a factory has a rallypoint set far enough away
// to trigger the non-admissable path estimators, we want to
// avoid units getting stuck inside by issuing them an extra
// move-order. However, this order can *itself* cause the PF
// system to consider the path blocked if the extra waypoint
// falls within the factory's confines, so use a wide berth.
const float xs = unitDef->xsize * SQUARE_SIZE * 0.5f;
const float zs = unitDef->zsize * SQUARE_SIZE * 0.5f;

float tmpDst = 2.0f;
float3 tmpPos = unit->pos + (frontdir * this->radius * tmpDst);

if (buildFacing == FACING_NORTH || buildFacing == FACING_SOUTH) {
while ((tmpPos.z >= unit->pos.z - zs && tmpPos.z <= unit->pos.z + zs)) {
tmpDst += 0.5f;
tmpPos = unit->pos + (frontdir * this->radius * tmpDst);
}
} else {
while ((tmpPos.x >= unit->pos.x - xs && tmpPos.x <= unit->pos.x + xs)) {
tmpDst += 0.5f;
tmpPos = unit->pos + (frontdir * this->radius * tmpDst);
if (!unit->unitDef->canfly) {

// HACK: when a factory has a rallypoint set far enough away
// to trigger the non-admissable path estimators, we want to
// avoid units getting stuck inside by issuing them an extra
// move-order. However, this order can *itself* cause the PF
// system to consider the path blocked if the extra waypoint
// falls within the factory's confines, so use a wide berth.
const float xs = unitDef->xsize * SQUARE_SIZE * 0.5f;
const float zs = unitDef->zsize * SQUARE_SIZE * 0.5f;

float tmpDst = 2.0f;
float3 tmpPos = unit->pos + (frontdir * this->radius * tmpDst);

if (buildFacing == FACING_NORTH || buildFacing == FACING_SOUTH) {
while ((tmpPos.z >= unit->pos.z - zs && tmpPos.z <= unit->pos.z + zs)) {
tmpDst += 0.5f;
tmpPos = unit->pos + (frontdir * this->radius * tmpDst);
}
} else {
while ((tmpPos.x >= unit->pos.x - xs && tmpPos.x <= unit->pos.x + xs)) {
tmpDst += 0.5f;
tmpPos = unit->pos + (frontdir * this->radius * tmpDst);
}
}
}

Command c;
c.id = CMD_MOVE;
c.params.push_back(tmpPos.x);
c.params.push_back(tmpPos.y);
c.params.push_back(tmpPos.z);
unit->commandAI->GiveCommand(c);
unit->commandAI->GiveCommand(c);
}

for (CCommandQueue::const_iterator ci = newUnitCmds.begin(); ci != newUnitCmds.end(); ++ci) {
c = *ci;
Expand Down

0 comments on commit 3325583

Please sign in to comment.