summaryrefslogtreecommitdiff
path: root/src/unmovable_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-08-02 20:57:32 +0000
committerrubidium <rubidium@openttd.org>2010-08-02 20:57:32 +0000
commitf2edc728e6c8d8b74226058ab5842ef60bf34592 (patch)
tree049fe68fdfb81847b2d844f7b4847a7ef8fbf366 /src/unmovable_cmd.cpp
parent0e900039f3531f0f64e93e216eb44e45b463d5b7 (diff)
downloadopenttd-f2edc728e6c8d8b74226058ab5842ef60bf34592.tar.xz
(svn r20321) -Codechange: rename GetUnmovableSpec to UnmovableSpec::Get and add+use a ::GetByTile
Diffstat (limited to 'src/unmovable_cmd.cpp')
-rw-r--r--src/unmovable_cmd.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 27fbc6381..ce9bfb161 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -35,18 +35,15 @@
#include "table/sprites.h"
#include "table/unmovable_land.h"
-/**
- * Accessor for array _original_unmovable.
- * This will ensure at once : proper access and
- * not allowing modifications of it.
- * @param type of unmovable (which is the index in _original_unmovable)
- * @pre type < UNMOVABLE_MAX
- * @return a pointer to the corresponding unmovable spec
- */
-static inline const UnmovableSpec *GetUnmovableSpec(UnmovableType type)
+/* static */ const UnmovableSpec *UnmovableSpec::Get(int index)
+{
+ assert(index < UNMOVABLE_MAX);
+ return &_original_unmovable[index];
+}
+
+/* static */ const UnmovableSpec *UnmovableSpec::GetByTile(TileIndex tile)
{
- assert(type < UNMOVABLE_MAX);
- return &_original_unmovable[type];
+ return UnmovableSpec::Get(GetUnmovableType(tile));
}
/**
@@ -162,7 +159,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1,
MarkTileDirtyByTile(tile);
}
- cost.AddCost(GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetBuildCost());
+ cost.AddCost(UnmovableSpec::Get(UNMOVABLE_OWNED_LAND)->GetBuildCost());
return cost;
}
@@ -189,7 +186,7 @@ CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (flags & DC_EXEC) DoClearSquare(tile);
- return CommandCost(EXPENSES_CONSTRUCTION, -GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetClearCost());
+ return CommandCost(EXPENSES_CONSTRUCTION, -UnmovableSpec::Get(UNMOVABLE_OWNED_LAND)->GetClearCost());
}
static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
@@ -337,7 +334,7 @@ static void AddAcceptedCargo_Unmovable(TileIndex tile, CargoArray &acceptance, u
static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td)
{
- td->str = GetUnmovableSpec(GetUnmovableType(tile))->name;
+ td->str = UnmovableSpec::GetByTile(tile)->name;
td->owner[0] = GetTileOwner(tile);
}