summaryrefslogtreecommitdiff
path: root/src/company_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-04 11:35:12 +0000
committerrubidium <rubidium@openttd.org>2010-01-04 11:35:12 +0000
commit3e481c4027b04ac85c6551e8a6e543ee0654b091 (patch)
tree23b0414ed5bd96a2499dd1cf05a6957ac55cbedd /src/company_cmd.cpp
parentabb147d9742f349513d076a76b2957eb573d78e7 (diff)
downloadopenttd-3e481c4027b04ac85c6551e8a6e543ee0654b091.tar.xz
(svn r18710) -Fix [FS#3478]: the wrong town is mentioned in the error when trying to make one way roads of town owned roads
Diffstat (limited to 'src/company_cmd.cpp')
-rw-r--r--src/company_cmd.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 44993becc..92e3c0d96 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -210,6 +210,12 @@ void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cst)
if (cost != 0) SubtractMoneyFromAnyCompany(c, CommandCost(cst.GetExpensesType(), cost));
}
+/**
+ * Set the right DParams to get the name of an owner.
+ * @param owner the owner to get the name of.
+ * @param tile optional tile to get the right town.
+ * @pre if tile == 0, then owner can't be OWNER_TOWN.
+ */
void GetNameOfOwner(Owner owner, TileIndex tile)
{
SetDParam(2, owner);
@@ -222,6 +228,7 @@ void GetNameOfOwner(Owner owner, TileIndex tile)
SetDParam(1, owner);
}
} else {
+ assert(tile != 0);
const Town *t = ClosestTownFromTile(tile, UINT_MAX);
SetDParam(0, STR_TOWN_NAME);
@@ -230,16 +237,32 @@ void GetNameOfOwner(Owner owner, TileIndex tile)
}
-bool CheckOwnership(Owner owner)
+/**
+ * Check whether the current owner owns something.
+ * If that isn't the case an appropriate error will be given.
+ * @param owner the owner of the thing to check.
+ * @param tile optional tile to get the right town.
+ * @pre if tile == 0 then the owner can't be OWNER_TOWN.
+ * @return true iff it's owned by the current company.
+ */
+bool CheckOwnership(Owner owner, TileIndex tile)
{
assert(owner < OWNER_END);
+ assert(owner != OWNER_TOWN || tile != 0);
if (owner == _current_company) return true;
_error_message = STR_ERROR_OWNED_BY;
- GetNameOfOwner(owner, 0);
+ GetNameOfOwner(owner, tile);
return false;
}
+/**
+ * Check whether the current owner owns the stuff on
+ * the given tile. If that isn't the case an
+ * appropriate error will be given.
+ * @param tile the tile to check.
+ * @return true iff it's owned by the current company.
+ */
bool CheckTileOwnership(TileIndex tile)
{
Owner owner = GetTileOwner(tile);