From df009178d487767375b9482e86465d527f041439 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 16 Jul 2007 09:16:58 +0000 Subject: (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h --- src/aircraft_cmd.cpp | 1 + src/aircraft_gui.cpp | 1 + src/autoreplace_gui.cpp | 1 + src/bridge_gui.cpp | 1 + src/command.cpp | 1 + src/depot_gui.cpp | 1 + src/disaster_cmd.cpp | 1 + src/economy.cpp | 14 ++++----- src/engine_gui.cpp | 1 + src/graph_gui.cpp | 1 + src/industry_cmd.cpp | 1 + src/intro_gui.cpp | 1 + src/main_gui.cpp | 2 +- src/misc_gui.cpp | 13 ++++---- src/music_gui.cpp | 1 + src/network/network_client.cpp | 1 + src/news_gui.cpp | 12 +++---- src/openttd.cpp | 2 +- src/order_gui.cpp | 1 + src/player_gui.cpp | 1 + src/rail_gui.cpp | 1 + src/road_cmd.cpp | 1 + src/road_gui.cpp | 1 + src/roadveh_cmd.cpp | 1 + src/settings.cpp | 1 + src/ship_cmd.cpp | 1 + src/ship_gui.cpp | 1 + src/signs.cpp | 1 + src/smallmap_gui.cpp | 1 + src/stdafx.h | 4 +++ src/strings.cpp | 1 + src/strings.h | 71 ++++++++++++++++++++++++++++++++++++++++-- src/subsidy_gui.cpp | 1 + src/timetable_gui.cpp | 1 + src/train_cmd.cpp | 1 + src/train_gui.cpp | 1 + src/tunnelbridge_cmd.cpp | 1 + src/variables.h | 59 ----------------------------------- src/water_cmd.cpp | 1 + 39 files changed, 125 insertions(+), 83 deletions(-) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 8e06f31cb..d12114d3f 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -10,6 +10,7 @@ #include "functions.h" #include "landscape.h" #include "station_map.h" +#include "strings.h" #include "table/strings.h" #include "map.h" #include "tile.h" diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index c02a21346..c3c1c2bdd 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -9,6 +9,7 @@ #include "functions.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "map.h" #include "window.h" #include "gui.h" diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index d8bfd11cf..8db0c0475 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -8,6 +8,7 @@ #include "functions.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "window.h" #include "gui.h" #include "command.h" diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 238ac1698..6bc8b94a3 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "map.h" #include "window.h" diff --git a/src/command.cpp b/src/command.cpp index 8216bd840..8d7c745c7 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "landscape.h" #include "map.h" diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 2f63a0945..d5a86fe09 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -10,6 +10,7 @@ #include "ship.h" #include "aircraft.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "gui.h" #include "gfx.h" diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 41956ae63..5be1730ab 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -23,6 +23,7 @@ #include "industry_map.h" #include "station_map.h" #include "table/strings.h" +#include "strings.h" #include "map.h" #include "tile.h" #include "vehicle.h" diff --git a/src/economy.cpp b/src/economy.cpp index a8aef3542..4f6136923 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -538,7 +538,7 @@ void DrawNewsBankrupcy(Window *w) int32 price; DrawStringCentered(w->width>>1, 1, STR_7059_TRANSPORT_COMPANY_MERGER, 0); - COPY_IN_DPARAM(0,WP(w,news_d).ni->params, 2); + CopyInDParam(0,WP(w,news_d).ni->params, 2); SetDParam(2, p->index); price = WP(w,news_d).ni->params[2]; SetDParam(3, price); @@ -552,7 +552,7 @@ void DrawNewsBankrupcy(Window *w) case NB_BBANKRUPT: DrawStringCentered(w->width>>1, 1, STR_705C_BANKRUPT, 0); - COPY_IN_DPARAM(0,WP(w,news_d).ni->params, 2); + CopyInDParam(0,WP(w,news_d).ni->params, 2); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, 90, @@ -563,7 +563,7 @@ void DrawNewsBankrupcy(Window *w) case NB_BNEWCOMPANY: DrawStringCentered(w->width>>1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, 0); SetDParam(0, p->index); - COPY_IN_DPARAM(1,WP(w,news_d).ni->params, 2); + CopyInDParam(1,WP(w,news_d).ni->params, 2); DrawStringMultiCenter( ((w->width - 101) >> 1) + 98, 90, @@ -589,20 +589,20 @@ StringID GetNewsStringBankrupcy(const NewsItem *ni) case NB_BMERGER: SetDParam(0, STR_7059_TRANSPORT_COMPANY_MERGER); SetDParam(1, STR_705A_HAS_BEEN_SOLD_TO_FOR); - COPY_IN_DPARAM(2,ni->params, 2); + CopyInDParam(2,ni->params, 2); SetDParam(4, p->index); - COPY_IN_DPARAM(5,ni->params + 2, 1); + CopyInDParam(5,ni->params + 2, 1); return STR_02B6; case NB_BBANKRUPT: SetDParam(0, STR_705C_BANKRUPT); SetDParam(1, STR_705D_HAS_BEEN_CLOSED_DOWN_BY); - COPY_IN_DPARAM(2,ni->params, 2); + CopyInDParam(2,ni->params, 2); return STR_02B6; case NB_BNEWCOMPANY: SetDParam(0, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED); SetDParam(1, STR_705F_STARTS_CONSTRUCTION_NEAR); SetDParam(2, p->index); - COPY_IN_DPARAM(3,ni->params, 2); + CopyInDParam(3,ni->params, 2); return STR_02B6; default: NOT_REACHED(); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 4421f1f5f..fa29fc0df 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "functions.h" #include "window.h" diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 1e5d84580..6a50aae18 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "functions.h" #include "window.h" diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index f18000661..ab0a66b3a 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -9,6 +9,7 @@ #include "industry_map.h" #include "station_map.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "map.h" #include "tile.h" diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 6378d0252..21fc0dba7 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "functions.h" #include "window.h" diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 8c06ccacd..92be8bf6d 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -1917,7 +1917,7 @@ static bool DrawScrollingStatusText(const NewsItem *ni, int pos) if (ni->display_mode == 3) { str = _get_news_string_callback[ni->callback](ni); } else { - COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); + CopyInDParam(0, ni->params, lengthof(ni->params)); str = ni->string_id; } diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index f3b14639c..5d842a43a 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -13,6 +13,7 @@ #include "strings.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "table/tree_land.h" #include "map.h" #include "window.h" @@ -500,9 +501,9 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e) { switch (e->event) { case WE_PAINT: - COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); + CopyInDParam(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); DrawWindowWidgets(w); - COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); + CopyInDParam(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); if (!IsWindowOfPrototype(w, _errmsg_face_widgets)) { DrawStringMultiCenter( 120, @@ -569,7 +570,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y) _errmsg_message_1 = msg_1; _errmsg_message_2 = msg_2; - COPY_OUT_DPARAM(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params)); + CopyOutDParam(_errmsg_decode_params, 0, lengthof(_errmsg_decode_params)); _errmsg_duration = _patches.errmsg_duration; if (!_errmsg_duration) return; @@ -1235,9 +1236,9 @@ static void QueryWndProc(Window *w, WindowEvent *e) switch (e->event) { case WE_PAINT: - COPY_IN_DPARAM(0, q->params, lengthof(q->params)); + CopyInDParam(0, q->params, lengthof(q->params)); DrawWindowWidgets(w); - COPY_IN_DPARAM(0, q->params, lengthof(q->params)); + CopyInDParam(0, q->params, lengthof(q->params)); DrawStringMultiCenter(w->width / 2, (w->height / 2) - 10, q->message, w->width - 2); break; @@ -1315,7 +1316,7 @@ void ShowQuery(StringID caption, StringID message, Window *parent, void (*callba /* Create a backup of the variadic arguments to strings because it will be * overridden pretty often. We will copy these back for drawing */ - COPY_OUT_DPARAM(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params)); + CopyOutDParam(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params)); w->widget[QUERY_WIDGET_CAPTION].data = caption; WP(w, query_d).message = message; WP(w, query_d).proc = callback; diff --git a/src/music_gui.cpp b/src/music_gui.cpp index ea05bbe69..9bce16090 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -6,6 +6,7 @@ #include "openttd.h" #include "table/strings.h" #include "table/sprites.h" +#include "strings.h" #include "functions.h" #include "fileio.h" #include "window.h" diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 495181d76..7f7566963 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -5,6 +5,7 @@ #include "../stdafx.h" #include "../debug.h" #include "../string.h" +#include "../openttd.h" #include "../strings.h" #include "network_data.h" #include "core/tcp.h" diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 58ba6d7cc..27ec0a1e7 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -124,7 +124,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e) DrawStringRightAligned(428, 1, STR_01FF, 0); if (!(ni->flags & NF_VIEWPORT)) { - COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); + CopyInDParam(0, ni->params, lengthof(ni->params)); DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56, ni->string_id, w->width - 4); } else { @@ -141,7 +141,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e) (ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE) ); - COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); + CopyInDParam(0, ni->params, lengthof(ni->params)); DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4); } break; @@ -155,11 +155,11 @@ static void NewsWindowProc(Window *w, WindowEvent *e) default: { DrawWindowWidgets(w); if (!(ni->flags & NF_VIEWPORT)) { - COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); + CopyInDParam(0, ni->params, lengthof(ni->params)); DrawStringMultiCenter(140, 38, ni->string_id, 276); } else { DrawWindowViewport(w); - COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); + CopyInDParam(0, ni->params, lengthof(ni->params)); DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4); } break; @@ -300,7 +300,7 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b) ni->data_a = data_a; ni->data_b = data_b; ni->date = _date; - COPY_OUT_DPARAM(ni->params, 0, lengthof(ni->params)); + CopyOutDParam(ni->params, 0, lengthof(ni->params)); w = FindWindowById(WC_MESSAGE_HISTORY, 0); if (w == NULL) return; @@ -611,7 +611,7 @@ static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint if (ni->display_mode == 3) { str = _get_news_string_callback[ni->callback](ni); } else { - COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); + CopyInDParam(0, ni->params, lengthof(ni->params)); str = ni->string_id; } diff --git a/src/openttd.cpp b/src/openttd.cpp index bdec37c94..931651577 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -9,13 +9,13 @@ #include "debug.h" #include "driver.h" #include "saveload.h" -#include "strings.h" #include "map.h" #include "tile.h" #include "void_map.h" #include "helpers.hpp" #include "openttd.h" +#include "strings.h" #include "bridge_map.h" #include "functions.h" #include "mixer.h" diff --git a/src/order_gui.cpp b/src/order_gui.cpp index ac08f9538..6da0298ec 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -8,6 +8,7 @@ #include "station_map.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "map.h" #include "tile.h" diff --git a/src/player_gui.cpp b/src/player_gui.cpp index b753034b8..ae9e60259 100644 --- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -6,6 +6,7 @@ #include "openttd.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "window.h" #include "gui.h" diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index b595d5c50..705768705 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -6,6 +6,7 @@ #include "openttd.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "landscape.h" #include "date.h" diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index c5e0622e8..36336c33c 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -12,6 +12,7 @@ #include "sprite.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "window.h" #include "map.h" diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 43c5e5b80..69c54dfeb 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -6,6 +6,7 @@ #include "openttd.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "map.h" #include "tile.h" diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index c7c38c04b..b09bc3ab2 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -11,6 +11,7 @@ #include "roadveh.h" #include "station_map.h" #include "table/strings.h" +#include "strings.h" #include "map.h" #include "tile.h" #include "vehicle.h" diff --git a/src/settings.cpp b/src/settings.cpp index 83e5e4895..ec558e6f0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -29,6 +29,7 @@ #include "string.h" #include "variables.h" #include "network/network.h" +#include "strings.h" #include "settings.h" #include "command.h" #include "console.h" diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index b71d00b02..94ac8c9f8 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -6,6 +6,7 @@ #include "openttd.h" #include "ship.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "landscape.h" #include "map.h" diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index dcfb61d7d..ed9ca529d 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -8,6 +8,7 @@ #include "functions.h" #include "ship.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "gui.h" #include "vehicle.h" diff --git a/src/signs.cpp b/src/signs.cpp index 355a20748..3d342ac89 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "landscape.h" #include "player.h" diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 585913c5b..12ebeeba0 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -10,6 +10,7 @@ #include "industry_map.h" #include "station_map.h" #include "table/strings.h" +#include "strings.h" #include "table/sprites.h" #include "landscape.h" #include "map.h" diff --git a/src/stdafx.h b/src/stdafx.h index 57db80c57..7c34a7e4c 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -349,4 +349,8 @@ CDECL error(const char *str, ...); #define _stricmp stricmp #endif /* !defined(MORHPOS) */ +#if !defined(MAX_PATH) +# define MAX_PATH 260 +#endif + #endif /* STDAFX_H */ diff --git a/src/strings.cpp b/src/strings.cpp index c9495b89f..03ee082b8 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -38,6 +38,7 @@ DynamicLanguages _dynlang; char _userstring[128]; +uint64 _decode_parameters[20]; static char *StationGetSpecialString(char *buff, int x, const char* last); static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char* last); diff --git a/src/strings.h b/src/strings.h index 22ec9f39d..0f2665e99 100644 --- a/src/strings.h +++ b/src/strings.h @@ -5,13 +5,78 @@ #ifndef STRINGS_H #define STRINGS_H -char *InlineString(char *buf, uint16 string); -char *GetString(char *buffr, uint16 string, const char* last); +char *InlineString(char *buf, StringID string); +char *GetString(char *buffr, StringID string, const char* last); extern char _userstring[128]; void InjectDParam(int amount); -int32 GetParamInt32(); + +static inline void SetDParamX(uint64 *s, uint n, uint64 v) +{ + s[n] = v; +} + +static inline void SetDParam(uint n, uint64 v) +{ + extern uint64 _decode_parameters[20]; + + assert(n < lengthof(_decode_parameters)); + _decode_parameters[n] = v; +} + +/* Used to bind a C string name to a dparam number. + * NOTE: This has a short lifetime. You can't + * use this string much later or it will be gone. */ +void SetDParamStr(uint n, const char *str); + +/** This function takes a C-string and allocates a temporary string ID. + * The duration of the bound string is valid only until the next call to GetString, + * so be careful. */ +StringID BindCString(const char *str); + +static inline uint64 GetDParamX(const uint64 *s, uint n) +{ + return s[n]; +} + +static inline uint64 GetDParam(uint n) +{ + extern uint64 _decode_parameters[20]; + + assert(n < lengthof(_decode_parameters)); + return _decode_parameters[n]; +} + +static inline void CopyInDParam(int offs, const uint64 *src, int num) +{ + extern uint64 _decode_parameters[20]; + memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num)); +} + +static inline void CopyOutDParam(uint64 *dst, int offs, int num) +{ + extern uint64 _decode_parameters[20]; + memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num)); +} + + +/** Information about a language */ +struct Language { + char *name; ///< The internal name of the language + char *file; ///< The name of the language as it appears on disk +}; + +/** Used for dynamic language support */ +struct DynamicLanguages { + int num; ///< Number of languages + int curr; ///< Currently selected language index + char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language). + StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui + Language ent[MAX_LANG]; ///< Information about the languages +}; + +extern DynamicLanguages _dynlang; // defined in strings.cpp bool ReadLanguagePack(int index); void InitializeLanguagePacks(); diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 5bd5178c2..8f1fe1e82 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -5,6 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "window.h" #include "station.h" diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 27d615b98..a978e559c 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -7,6 +7,7 @@ #include "functions.h" #include "variables.h" #include "table/strings.h" +#include "strings.h" #include "command.h" #include "date.h" #include "engine.h" diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index db1250b62..4f1d7f3c9 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -11,6 +11,7 @@ #include "gui.h" #include "station_map.h" #include "table/strings.h" +#include "strings.h" #include "map.h" #include "tile.h" #include "tunnel_map.h" diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 699feb4b1..f4236d84c 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -8,6 +8,7 @@ #include "functions.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "window.h" #include "gui.h" #include "vehicle.h" diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 8a49808bf..5a038caf9 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -12,6 +12,7 @@ #include "road_map.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "map.h" #include "landscape.h" diff --git a/src/variables.h b/src/variables.h index 9a825354c..574291397 100644 --- a/src/variables.h +++ b/src/variables.h @@ -8,9 +8,6 @@ #include "yapf/yapf_settings.h" /* ********* START OF SAVE REGION */ -#if !defined(MAX_PATH) -# define MAX_PATH 260 -#endif #include "gfx.h" @@ -292,8 +289,6 @@ VARDEF bool _news_ticker_sound; VARDEF StringID _error_message; VARDEF Money _additional_cash_required; -VARDEF uint64 _decode_parameters[20]; - VARDEF bool _rightclick_emulate; /* IN/OUT parameters to commands */ @@ -320,23 +315,6 @@ VARDEF Vehicle *_place_clicked_vehicle; VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32]; -/** Information about a language */ -struct Language { - char *name; ///< The internal name of the language - char *file; ///< The name of the language as it appears on disk -}; - -/** Used for dynamic language support */ -struct DynamicLanguages { - int num; ///< Number of languages - int curr; ///< Currently selected language index - char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language). - StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui - Language ent[MAX_LANG]; ///< Information about the languages -}; - -extern DynamicLanguages _dynlang; // defined in strings.cpp - VARDEF int _num_resolutions; VARDEF uint16 _resolutions[32][2]; VARDEF uint16 _cur_resolution[2]; @@ -348,43 +326,6 @@ VARDEF char *_highscore_file; VARDEF char *_log_file; -static inline void SetDParamX(uint64 *s, uint n, uint64 v) -{ - s[n] = v; -} - -static inline uint64 GetDParamX(const uint64 *s, uint n) -{ - return s[n]; -} - -static inline void SetDParam(uint n, uint64 v) -{ - assert(n < lengthof(_decode_parameters)); - _decode_parameters[n] = v; -} - -static inline uint64 GetDParam(uint n) -{ - assert(n < lengthof(_decode_parameters)); - return _decode_parameters[n]; -} - -/* Used to bind a C string name to a dparam number. - * NOTE: This has a short lifetime. You can't - * use this string much later or it will be gone. */ -void SetDParamStr(uint n, const char *str); - -/** This function takes a C-string and allocates a temporary string ID. - * The duration of the bound string is valid only until the next acll to GetString, - * so be careful. */ -StringID BindCString(const char *str); - - -#define COPY_IN_DPARAM(offs, src, num) memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num)) -#define COPY_OUT_DPARAM(dst, offs, num) memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num)) - - #define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x; /* landscape.cpp */ diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 27001c8dc..e8d201c3a 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -10,6 +10,7 @@ #include "station_map.h" #include "table/sprites.h" #include "table/strings.h" +#include "strings.h" #include "functions.h" #include "landscape.h" #include "map.h" -- cgit v1.2.3-70-g09d2