(svn r19372) -Codechange: CheckTileOwnership() returns a CommandCost.

This commit is contained in:
alberth
2010-03-07 20:44:05 +00:00
parent 8f335d4cbd
commit 40f106ba7c
7 changed files with 74 additions and 26 deletions

View File

@@ -266,20 +266,19 @@ bool CheckOwnership(Owner owner, TileIndex tile)
* 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.
* @return A succeeded command iff it's owned by the current company, else a failed command.
*/
bool CheckTileOwnership(TileIndex tile)
CommandCost CheckTileOwnership(TileIndex tile)
{
Owner owner = GetTileOwner(tile);
assert(owner < OWNER_END);
if (owner == _current_company) return true;
_error_message = STR_ERROR_OWNED_BY;
if (owner == _current_company) return CommandCost();
/* no need to get the name of the owner unless we're the local company (saves some time) */
if (IsLocalCompany()) GetNameOfOwner(owner, tile);
return false;
return_cmd_error(STR_ERROR_OWNED_BY);
}
static void GenerateCompanyName(Company *c)