Skip to content

Commit

Permalink
fix #5728
Browse files Browse the repository at this point in the history
  • Loading branch information
rt committed Aug 28, 2017
1 parent 3ecdc56 commit 062c88a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rts/Lua/LuaSyncedCtrl.cpp
Expand Up @@ -1260,7 +1260,7 @@ int LuaSyncedCtrl::CreateUnit(lua_State* L)
if (unit == nullptr)
return 0;

unit->SetSoloBuilder(builder);
unit->SetSoloBuilder(builder, unitDef);

lua_pushnumber(L, unit->id);
return 1;
Expand Down
12 changes: 6 additions & 6 deletions rts/Sim/Units/Unit.cpp
Expand Up @@ -1770,15 +1770,15 @@ void CUnit::DropCurrentAttackTarget()
}


void CUnit::SetSoloBuilder(CUnit* builder)
bool CUnit::SetSoloBuilder(CUnit* builder, const UnitDef* buildeeDef)
{
if (builder == nullptr)
return;
if (unitDef->canBeAssisted)
return;
return false;
if (buildeeDef->canBeAssisted)
return false;

soloBuilder = builder;
AddDeathDependence(builder, DEPENDENCE_BUILDER);
AddDeathDependence(soloBuilder = builder, DEPENDENCE_BUILDER);
return true;
}

void CUnit::SetLastAttacker(CUnit* attacker)
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/Unit.h
Expand Up @@ -198,7 +198,7 @@ class CUnit : public CSolidObject
int piece;
};

void SetSoloBuilder(CUnit* builder);
bool SetSoloBuilder(CUnit* builder, const UnitDef* buildeeDef);
void SetLastAttacker(CUnit* attacker);

void SetTransporter(CUnit* trans) { transporter = trans; }
Expand Down
9 changes: 6 additions & 3 deletions rts/Sim/Units/UnitTypes/Builder.cpp
Expand Up @@ -120,7 +120,7 @@ bool CBuilder::CanAssistUnit(const CUnit* u, const UnitDef* def) const
if (!unitDef->canAssist)
return false;

return ((def == nullptr || u->unitDef == def) && u->beingBuilt && (u->buildProgress < 1.0f) && (!u->soloBuilder || u->soloBuilder == this));
return ((def == nullptr || u->unitDef == def) && u->beingBuilt && (u->buildProgress < 1.0f) && (u->soloBuilder == nullptr || u->soloBuilder == this));
}


Expand Down Expand Up @@ -427,7 +427,7 @@ bool CBuilder::UpdateResurrect(const Command& fCommand)
CUnit* resurrectee = unitLoader->LoadUnit(resurrecteeParams);

assert(resurrecteeDef == resurrectee->unitDef);
resurrectee->SetSoloBuilder(this);
resurrectee->SetSoloBuilder(this, resurrecteeDef);

// TODO: make configurable if this should happen
resurrectee->health *= 0.05f;
Expand Down Expand Up @@ -780,7 +780,10 @@ bool CBuilder::StartBuild(BuildInfo& buildInfo, CFeature*& feature, bool& waitSt
terraformCenter = buildee->pos;
}

buildee->SetSoloBuilder(this);
// pass the *builder*'s udef for checking canBeAssisted; if buildee
// happens to be a non-assistable factory then it would also become
// impossible to *construct* with multiple builders
buildee->SetSoloBuilder(this, this->unitDef);
AddDeathDependence(curBuild = buildee, DEPENDENCE_BUILD);

// if the ground is not going to be terraformed the buildee would
Expand Down

0 comments on commit 062c88a

Please sign in to comment.