mirror of https://github.com/OpenTTD/OpenTTD
(svn r20321) -Codechange: rename GetUnmovableSpec to UnmovableSpec::Get and add+use a ::GetByTile
parent
0e900039f3
commit
f2edc728e6
|
@ -34,6 +34,20 @@ struct UnmovableSpec {
|
||||||
* @return The cost for clearing.
|
* @return The cost for clearing.
|
||||||
*/
|
*/
|
||||||
Money GetClearCost() const { return (_price[PR_CLEAR_UNMOVABLE] * this->clear_cost_multiplier); }
|
Money GetClearCost() const { return (_price[PR_CLEAR_UNMOVABLE] * this->clear_cost_multiplier); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the specification associated with a specific UnmovableType.
|
||||||
|
* @param index The unmovable type to fetch.
|
||||||
|
* @return The specification.
|
||||||
|
*/
|
||||||
|
static const UnmovableSpec *Get(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the specification associated with a tile.
|
||||||
|
* @param tile The tile to fetch the data for.
|
||||||
|
* @return The specification.
|
||||||
|
*/
|
||||||
|
static const UnmovableSpec *GetByTile(TileIndex tile);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,18 +35,15 @@
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/unmovable_land.h"
|
#include "table/unmovable_land.h"
|
||||||
|
|
||||||
/**
|
/* static */ const UnmovableSpec *UnmovableSpec::Get(int index)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
assert(type < UNMOVABLE_MAX);
|
assert(index < UNMOVABLE_MAX);
|
||||||
return &_original_unmovable[type];
|
return &_original_unmovable[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */ const UnmovableSpec *UnmovableSpec::GetByTile(TileIndex tile)
|
||||||
|
{
|
||||||
|
return UnmovableSpec::Get(GetUnmovableType(tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +159,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
cost.AddCost(GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetBuildCost());
|
cost.AddCost(UnmovableSpec::Get(UNMOVABLE_OWNED_LAND)->GetBuildCost());
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +186,7 @@ CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
|
|
||||||
if (flags & DC_EXEC) DoClearSquare(tile);
|
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);
|
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)
|
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);
|
td->owner[0] = GetTileOwner(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue