summaryrefslogtreecommitdiff
path: root/src/script/api/script_town.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-01-08 21:48:05 +0000
committerrubidium <rubidium@openttd.org>2012-01-08 21:48:05 +0000
commit4479f90843d3597268f889a3955f3c5289b92e0a (patch)
tree969e79bea4a892f189791f593751fa0ff463240e /src/script/api/script_town.cpp
parentab38e3227dbbefab952530c4ddf5408605187fcb (diff)
downloadopenttd-4479f90843d3597268f889a3955f3c5289b92e0a.tar.xz
(svn r23777) -Codechange: refactor allocating memory and fetching strings into a single function for scripts
Diffstat (limited to 'src/script/api/script_town.cpp')
-rw-r--r--src/script/api/script_town.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index 63093ecd5..331b98891 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -14,6 +14,7 @@
#include "script_map.hpp"
#include "script_error.hpp"
#include "../../town.h"
+#include "../../string_func.h"
#include "../../strings_func.h"
#include "../../station_base.h"
#include "../../landscape.h"
@@ -32,13 +33,9 @@
/* static */ char *ScriptTown::GetName(TownID town_id)
{
if (!IsValidTown(town_id)) return NULL;
- static const int len = 64;
- char *town_name = MallocT<char>(len);
::SetDParam(0, town_id);
- ::GetString(town_name, STR_TOWN_NAME, &town_name[len - 1]);
-
- return town_name;
+ return GetString(STR_TOWN_NAME);
}
/* static */ bool ScriptTown::SetText(TownID town_id, Text *text)