diff options
author | yexo <yexo@openttd.org> | 2010-12-29 23:20:12 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-12-29 23:20:12 +0000 |
commit | 5b25e620dd747d35b024d6d244be9fc7002e38b0 (patch) | |
tree | 6b50152523558815c8797d310f271816a6fd2dd0 /src/ai/api/ai_rail.cpp | |
parent | c986325763e1387b7e7fc358af91c2341a038dbe (diff) | |
download | openttd-5b25e620dd747d35b024d6d244be9fc7002e38b0.tar.xz |
(svn r21663) -Add: [NoAI]: AIRail::GetName() to get the name of a railtype
Diffstat (limited to 'src/ai/api/ai_rail.cpp')
-rw-r--r-- | src/ai/api/ai_rail.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp index 45cc78a3a..4f6c41376 100644 --- a/src/ai/api/ai_rail.cpp +++ b/src/ai/api/ai_rail.cpp @@ -19,6 +19,18 @@ #include "../../newgrf.h" #include "../../newgrf_generic.h" #include "../../newgrf_station.h" +#include "../../strings_func.h" + +/* static */ char *AIRail::GetName(RailType rail_type) +{ + if (!IsRailTypeAvailable(rail_type)) return NULL; + + static const int len = 64; + char *railtype_name = MallocT<char>(len); + + ::GetString(railtype_name, GetRailTypeInfo((::RailType)rail_type)->strings.menu_text, &railtype_name[len - 1]); + return railtype_name; +} /* static */ bool AIRail::IsRailTile(TileIndex tile) { |