diff options
author | smatz <smatz@openttd.org> | 2009-05-18 19:32:16 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-18 19:32:16 +0000 |
commit | 70aab8bf0487ef506afbeaa6cb8e46309387df84 (patch) | |
tree | e0c2fdd130c4c93d249ca7ecb2860e454d6b4e7f /src/engine.cpp | |
parent | a0ff6363e6429fded7bd39adacd14a191ef00526 (diff) | |
download | openttd-70aab8bf0487ef506afbeaa6cb8e46309387df84.tar.xz |
(svn r16354) -Codechange: use 'new' pool accessors and methods for Engine too
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 0f641d016..24918c11c 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -620,11 +620,8 @@ void EnginesDailyLoop() */ CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - Engine *e; - - if (!IsEngineIndex(p1)) return CMD_ERROR; - e = Engine::Get(p1); - if (GetBestCompany(e->preview_company_rank) != _current_company) return CMD_ERROR; + Engine *e = Engine::GetIfValid(p1); + if (e == NULL || GetBestCompany(e->preview_company_rank) != _current_company) return CMD_ERROR; if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company); @@ -734,7 +731,8 @@ static bool IsUniqueEngineName(const char *name) */ CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - if (!IsEngineIndex(p1)) return CMD_ERROR; + Engine *e = Engine::GetIfValid(p1); + if (e == NULL) return CMD_ERROR; bool reset = StrEmpty(text); @@ -744,7 +742,6 @@ CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } if (flags & DC_EXEC) { - Engine *e = Engine::Get(p1); free(e->name); if (reset) { @@ -769,10 +766,10 @@ CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint */ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company) { - /* check if it's an engine that is in the engine array */ - if (!IsEngineIndex(engine)) return false; + const Engine *e = Engine::GetIfValid(engine); - const Engine *e = Engine::Get(engine); + /* check if it's an engine that is in the engine array */ + if (e == NULL) return false; /* check if it's an engine of specified type */ if (e->type != type) return false; @@ -797,10 +794,10 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company) */ bool IsEngineRefittable(EngineID engine) { - /* check if it's an engine that is in the engine array */ - if (!IsEngineIndex(engine)) return false; + const Engine *e = Engine::GetIfValid(engine); - const Engine *e = Engine::Get(engine); + /* check if it's an engine that is in the engine array */ + if (e == NULL) return false; if (e->type == VEH_SHIP && !e->u.ship.refittable) return false; |