summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-01-06 22:37:57 +0100
committerGitHub <noreply@github.com>2021-01-06 22:37:57 +0100
commit28c13ec90fbdc55d27d31652d31a48198b5d2492 (patch)
tree7cf25f74e7fc4a70e712ff758756cb004336bcec
parenta4e34e824c481a7d3390c2739146192ac827533e (diff)
downloadopenttd-28c13ec90fbdc55d27d31652d31a48198b5d2492.tar.xz
Fix #8168: allow relocating of HQ partial over existing HQ (#8510)
Just in case you want to move it SLIGHTLY to the right.
-rw-r--r--regression/regression/main.nut2
-rw-r--r--src/object_cmd.cpp9
2 files changed, 9 insertions, 2 deletions
diff --git a/regression/regression/main.nut b/regression/regression/main.nut
index 0434524d2..5eb65b08f 100644
--- a/regression/regression/main.nut
+++ b/regression/regression/main.nut
@@ -426,7 +426,7 @@ function Regression::Company()
print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 129)));
print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
- print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 128)));
+ print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(239, 76)));
print(" GetLastErrorString(): " + AIError.GetLastErrorString());
print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF));
print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true));
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 3fb61d647..479f3b0d1 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -248,7 +248,14 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
} else {
if (!allow_ground) return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
/* For non-water tiles, we'll have to clear it before building. */
- cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
+
+ /* When relocating HQ, allow it to be relocated (partial) on itself. */
+ if (!(type == OBJECT_HQ &&
+ IsTileType(t, MP_OBJECT) &&
+ IsTileOwner(t, _current_company) &&
+ IsObjectType(t, OBJECT_HQ))) {
+ cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR));
+ }
}
}