summaryrefslogtreecommitdiff
path: root/src/newgrf_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-07-17 13:47:04 +0000
committerrubidium <rubidium@openttd.org>2008-07-17 13:47:04 +0000
commit5a94972c2db660c9cc5fe5d79ea095af04456a21 (patch)
treec5968a407194cba5120766750d96971df91cde2f /src/newgrf_gui.cpp
parent31d283c6c88464837dd57b78f75394367c4d40f7 (diff)
downloadopenttd-5a94972c2db660c9cc5fe5d79ea095af04456a21.tar.xz
(svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
-Codechange: remove all BindCString and related functions and replace it by RAW_STRING which prints the C-string raw pointer that is on the 'print stack'.
Diffstat (limited to 'src/newgrf_gui.cpp')
-rw-r--r--src/newgrf_gui.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 4b4765fe2..74affa4dd 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -50,19 +50,24 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bott
char buff[256];
if (c->error != NULL) {
- SetDParamStr(0, c->filename);
- SetDParamStr(1, c->error->data);
- for (uint i = 0; i < c->error->num_params; i++) {
- uint32 param = 0;
- byte param_number = c->error->param_number[i];
+ char message[512];
+ if (c->error->custom_message == NULL) {
+ SetDParamStr(0, c->filename);
+ SetDParamStr(1, c->error->data);
+ for (uint i = 0; i < c->error->num_params; i++) {
+ uint32 param = 0;
+ byte param_number = c->error->param_number[i];
- if (param_number < c->num_params) param = c->param[param_number];
+ if (param_number < c->num_params) param = c->param[param_number];
- SetDParam(2 + i, param);
- }
+ SetDParam(2 + i, param);
+ }
- char message[512];
- GetString(message, c->error->custom_message != NULL ? BindCString(c->error->custom_message) : c->error->message, lastof(message));
+ GetString(message, c->error->message, lastof(message));
+ } else {
+ SetDParamStr(0, c->error->custom_message);
+ GetString(message, STR_JUST_RAW_STRING, lastof(message));
+ }
SetDParamStr(0, message);
y += DrawStringMultiLine(x, y, c->error->severity, w, bottom - y);
@@ -88,7 +93,8 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bott
if (show_params) {
if (c->num_params > 0) {
GRFBuildParamList(buff, c, lastof(buff));
- SetDParamStr(0, buff);
+ SetDParam(0, STR_JUST_RAW_STRING);
+ SetDParamStr(1, buff);
} else {
SetDParam(0, STR_01A9_NONE);
}
@@ -102,7 +108,8 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, uint bott
/* Draw GRF info if it exists */
if (c->info != NULL && !StrEmpty(c->info)) {
- SetDParamStr(0, c->info);
+ SetDParam(0, STR_JUST_RAW_STRING);
+ SetDParamStr(1, c->info);
y += DrawStringMultiLine(x, y, STR_02BD, w, bottom - y);
} else {
y += DrawStringMultiLine(x, y, STR_NEWGRF_NO_INFO, w, bottom - y);
@@ -487,9 +494,10 @@ struct NewGRFWindow : public Window {
case SNGRFS_SET_PARAMETERS: { // Edit parameters
if (this->sel == NULL) break;
- char buff[512];
+ static char buff[512];
GRFBuildParamList(buff, this->sel, lastof(buff));
- ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL);
+ SetDParamStr(0, buff);
+ ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL);
break;
}
}