diff options
author | tron <tron@openttd.org> | 2005-07-26 19:04:19 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-07-26 19:04:19 +0000 |
commit | a16418266e0cb317b2f338e5ca6e3d1aabdf67c5 (patch) | |
tree | dbb913c2b20dd2004ca5b9c2607ba47217ab2ca4 | |
parent | 7e65f441689917d9d476bc458dec303a0d4e4b7c (diff) | |
download | openttd-a16418266e0cb317b2f338e5ca6e3d1aabdf67c5.tar.xz |
(svn r2717) Move _userstring to strings.[ch]
-rw-r--r-- | engine.c | 5 | ||||
-rw-r--r-- | misc_gui.c | 2 | ||||
-rw-r--r-- | settings_gui.c | 2 | ||||
-rw-r--r-- | strings.c | 2 | ||||
-rw-r--r-- | variables.h | 2 |
5 files changed, 7 insertions, 6 deletions
@@ -4,6 +4,8 @@ #include "openttd.h" #include "debug.h" #include "functions.h" +#include "string.h" +#include "strings.h" #include "table/strings.h" #include "engine.h" #include "table/engines.h" @@ -747,8 +749,7 @@ StringID GetCustomEngineName(int engine) { if (!_engine_custom_names[engine]) return _engine_name_strings[engine]; - strncpy(_userstring, _engine_custom_names[engine], USERSTRING_LEN); - _userstring[USERSTRING_LEN - 1] = '\0'; + ttd_strlcpy(_userstring, _engine_custom_names[engine], lengthof(_userstring)); return STR_SPEC_USERSTRING; } diff --git a/misc_gui.c b/misc_gui.c index 76aedeca0..3f679a5d4 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -66,7 +66,7 @@ static void LandInfoWndProc(Window *w, WindowEvent *e) } DrawStringCentered(140, 38, str, 0); - snprintf(_userstring, USERSTRING_LEN, "%.4X", lid->tile); + snprintf(_userstring, lengthof(_userstring), "%.4X", lid->tile); SetDParam(0, TileX(lid->tile)); SetDParam(1, TileY(lid->tile)); SetDParam(2, STR_SPEC_USERSTRING); diff --git a/settings_gui.c b/settings_gui.c index cc3b22555..17a6a67bf 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -1199,7 +1199,7 @@ static void NewgrfWndProc(Window *w, WindowEvent *e) // draw grf id x = DrawString(5, 209, STR_NEWGRF_GRF_ID, 0); - snprintf(_userstring, USERSTRING_LEN, "%08X", _sel_grffile->grfid); + snprintf(_userstring, lengthof(_userstring), "%08X", _sel_grffile->grfid); DrawString(x + 2, 209, STR_SPEC_USERSTRING, 0x01); } } break; @@ -16,6 +16,8 @@ #include "industry.h" #include "variables.h" +char _userstring[128]; + static char *StationGetSpecialString(char *buff, int x); static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed); static char *GetSpecialPlayerNameString(char *buff, int ind, const int32 *argv); diff --git a/variables.h b/variables.h index bbc9eee1e..e2c06af39 100644 --- a/variables.h +++ b/variables.h @@ -440,8 +440,6 @@ extern const byte _airport_size_y[]; /* misc */ VARDEF char _screenshot_name[128]; -#define USERSTRING_LEN 128 -VARDEF char _userstring[USERSTRING_LEN]; VARDEF byte _vehicle_design_names; /* tunnelbridge */ |