allow using the builder itself in distance building restrictions
This commit is contained in:
parent
b8a8a453d9
commit
d78078888a
3 changed files with 6 additions and 2 deletions
|
@ -413,7 +413,7 @@ public:
|
|||
class CBuildRestrictionDistance : public CBuildRestriction
|
||||
{
|
||||
public:
|
||||
CBuildRestrictionDistance() : Distance(0), RestrictType(NULL) {};
|
||||
CBuildRestrictionDistance() : Distance(0), CheckBuilder(false), RestrictType(NULL) {};
|
||||
virtual ~CBuildRestrictionDistance() {};
|
||||
virtual void Init() {this->RestrictType = UnitTypeByIdent(this->RestrictTypeName);};
|
||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||
|
@ -423,6 +423,7 @@ public:
|
|||
std::string RestrictTypeName;
|
||||
std::string RestrictTypeOwner;
|
||||
CUnitType *RestrictType;
|
||||
bool CheckBuilder;
|
||||
};
|
||||
|
||||
class CBuildRestrictionHasUnit : public CBuildRestriction
|
||||
|
|
|
@ -135,7 +135,8 @@ bool CBuildRestrictionDistance::Check(const CUnit *builder, const CUnitType &typ
|
|||
Select(pos1, pos2, table);
|
||||
|
||||
for (size_t i = 0; i != table.size(); ++i) {
|
||||
if (builder != table[i] &&
|
||||
bool isorctownhall = table[i]->Type->Ident.compare("unit-orc-town-hall");
|
||||
if ((builder != table[i] || this->CheckBuilder) &&
|
||||
// unit has RestrictType or no RestrictType was set, but a RestrictTypeOwner
|
||||
(this->RestrictType == table[i]->Type || (!this->RestrictType && this->RestrictTypeOwner.size() > 0)) &&
|
||||
// RestrictTypeOwner is not set or unit belongs to a suitable player
|
||||
|
|
|
@ -266,6 +266,8 @@ static void ParseBuildingRules(lua_State *l, std::vector<CBuildRestriction *> &b
|
|||
b->RestrictTypeName = LuaToString(l, -1);
|
||||
} else if (!strcmp(value, "Owner")) {
|
||||
b->RestrictTypeOwner = LuaToString(l, -1);
|
||||
} else if (!strcmp(value, "CheckBuilder")) {
|
||||
b->CheckBuilder = LuaToBoolean(l, -1);
|
||||
} else {
|
||||
LuaError(l, "Unsupported BuildingRules distance tag: %s" _C_ value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue