summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2012-01-15 19:29:49 +0000
committeryexo <yexo@openttd.org>2012-01-15 19:29:49 +0000
commitfab78a7bf2a900bc64de69a7dcdb4e558e2a1824 (patch)
treeef190938984d1ba6d560c86b916cecda76fd4e03 /src
parentc42e30927d497e52efab09caadcf1e8e624962d9 (diff)
downloadopenttd-fab78a7bf2a900bc64de69a7dcdb4e558e2a1824.tar.xz
(svn r23812) -Fix [FS#4977] (r23804): custom ActionB messages were broken
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt34
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/newgrf_gui.cpp16
-rw-r--r--src/newgrf_text.cpp7
-rw-r--r--src/newgrf_text.h3
5 files changed, 30 insertions, 32 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 9d94104d0..86d6fea50 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2529,27 +2529,27 @@ STR_NEWGRF_ERROR_MSG_INFO :{SILVER}{RAW_ST
STR_NEWGRF_ERROR_MSG_WARNING :{RED}Warning: {SILVER}{RAW_STRING}
STR_NEWGRF_ERROR_MSG_ERROR :{RED}Error: {SILVER}{RAW_STRING}
STR_NEWGRF_ERROR_MSG_FATAL :{RED}Fatal: {SILVER}{RAW_STRING}
-STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}A fatal NewGRF error has occurred: {}{STRING7}
-STR_NEWGRF_ERROR_VERSION_NUMBER :{1:STRING1} will not work with the TTDPatch version reported by OpenTTD
-STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:STRING1} is for the {STRING1} version of TTD
-STR_NEWGRF_ERROR_UNSET_SWITCH :{1:STRING1} is designed to be used with {STRING1}
-STR_NEWGRF_ERROR_INVALID_PARAMETER :Invalid parameter for {1:STRING1}: parameter {STRING1} ({NUM})
-STR_NEWGRF_ERROR_LOAD_BEFORE :{1:STRING1} must be loaded before {STRING1}
-STR_NEWGRF_ERROR_LOAD_AFTER :{1:STRING1} must be loaded after {STRING1}
-STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER :{1:STRING1} requires OpenTTD version {STRING1} or better
+STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}A fatal NewGRF error has occurred: {}{STRING5}
+STR_NEWGRF_ERROR_VERSION_NUMBER :{1:RAW_STRING} will not work with the TTDPatch version reported by OpenTTD
+STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:RAW_STRING} is for the {RAW_STRING} version of TTD
+STR_NEWGRF_ERROR_UNSET_SWITCH :{1:RAW_STRING} is designed to be used with {RAW_STRING}
+STR_NEWGRF_ERROR_INVALID_PARAMETER :Invalid parameter for {1:RAW_STRING}: parameter {RAW_STRING} ({NUM})
+STR_NEWGRF_ERROR_LOAD_BEFORE :{1:RAW_STRING} must be loaded before {RAW_STRING}
+STR_NEWGRF_ERROR_LOAD_AFTER :{1:RAW_STRING} must be loaded after {RAW_STRING}
+STR_NEWGRF_ERROR_OTTD_VERSION_NUMBER :{1:RAW_STRING} requires OpenTTD version {RAW_STRING} or better
STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE :the GRF file it was designed to translate
STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED :Too many NewGRFs are loaded
-STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC :Loading {2:RAW_STRING} as static NewGRF with {4:RAW_STRING} could cause desyncs
-STR_NEWGRF_ERROR_UNEXPECTED_SPRITE :Unexpected sprite (sprite {5:NUM})
-STR_NEWGRF_ERROR_UNKNOWN_PROPERTY :Unknown Action 0 property {6:HEX} (sprite {5:NUM})
-STR_NEWGRF_ERROR_INVALID_ID :Attempt to use invalid ID (sprite {5:NUM})
+STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC :Loading {1:RAW_STRING} as static NewGRF with {RAW_STRING} could cause desyncs
+STR_NEWGRF_ERROR_UNEXPECTED_SPRITE :Unexpected sprite (sprite {3:NUM})
+STR_NEWGRF_ERROR_UNKNOWN_PROPERTY :Unknown Action 0 property {4:HEX} (sprite {3:NUM})
+STR_NEWGRF_ERROR_INVALID_ID :Attempt to use invalid ID (sprite {3:NUM})
STR_NEWGRF_ERROR_CORRUPT_SPRITE :{YELLOW}{RAW_STRING} contains a corrupt sprite. All corrupt sprites will be shown as a red question mark (?)
-STR_NEWGRF_ERROR_MULTIPLE_ACTION_8 :Contains multiple Action 8 entries (sprite {5:NUM})
-STR_NEWGRF_ERROR_READ_BOUNDS :Read past end of pseudo-sprite (sprite {5:NUM})
+STR_NEWGRF_ERROR_MULTIPLE_ACTION_8 :Contains multiple Action 8 entries (sprite {3:NUM})
+STR_NEWGRF_ERROR_READ_BOUNDS :Read past end of pseudo-sprite (sprite {3:NUM})
STR_NEWGRF_ERROR_MISSING_SPRITES :{WHITE}The currently used base graphics set is missing a number of sprites.{}Please update the base graphics set
-STR_NEWGRF_ERROR_GRM_FAILED :Requested GRF resources not available (sprite {5:NUM})
-STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{2:RAW_STRING} was disabled by {4:RAW_STRING}
-STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Invalid/unknown sprite layout format (sprite {5:NUM})
+STR_NEWGRF_ERROR_GRM_FAILED :Requested GRF resources not available (sprite {3:NUM})
+STR_NEWGRF_ERROR_FORCEFULLY_DISABLED :{1:RAW_STRING} was disabled by {2:RAW_STRING}
+STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT :Invalid/unknown sprite layout format (sprite {3:NUM})
# NewGRF related 'general' warnings
STR_NEWGRF_POPUP_CAUTION_CAPTION :{WHITE}Caution!
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 9504220df..880933074 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -6179,7 +6179,7 @@ static void GRFLoadError(ByteReader *buf)
if (buf->HasData()) {
const char *message = buf->ReadString();
- error->custom_message = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, message);
+ error->custom_message = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, message, NULL, SCC_RAW_STRING_POINTER);
} else {
grfmsg(7, "GRFLoadError: No custom message supplied.");
error->custom_message = strdup("");
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index ed3dbe6cc..f39b30817 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -46,12 +46,10 @@ void ShowNewGRFError()
SetDParam (0, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING);
SetDParamStr(1, c->error->custom_message);
- SetDParam (2, STR_JUST_RAW_STRING);
- SetDParamStr(3, c->filename);
- SetDParam (4, STR_JUST_RAW_STRING);
- SetDParamStr(5, c->error->data);
+ SetDParamStr(2, c->filename);
+ SetDParamStr(3, c->error->data);
for (uint i = 0; i < lengthof(c->error->param_value); i++) {
- SetDParam(6 + i, c->error->param_value[i]);
+ SetDParam(4 + i, c->error->param_value[i]);
}
ShowErrorMessage(STR_NEWGRF_ERROR_FATAL_POPUP, INVALID_STRING_ID, WL_CRITICAL);
break;
@@ -63,12 +61,10 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint right, uint
if (c->error != NULL) {
char message[512];
SetDParamStr(0, c->error->custom_message); // is skipped by built-in messages
- SetDParam (1, STR_JUST_RAW_STRING);
- SetDParamStr(2, c->filename);
- SetDParam (3, STR_JUST_RAW_STRING);
- SetDParamStr(4, c->error->data);
+ SetDParamStr(1, c->filename);
+ SetDParamStr(2, c->error->data);
for (uint i = 0; i < lengthof(c->error->param_value); i++) {
- SetDParam(5 + i, c->error->param_value[i]);
+ SetDParam(3 + i, c->error->param_value[i]);
}
GetString(message, c->error->custom_message == NULL ? c->error->message : STR_JUST_RAW_STRING, lastof(message));
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index da18d2ceb..99a1cf29a 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -394,9 +394,10 @@ struct UnmappedChoiceList : ZeroedMemoryAllocator {
* @param allow_newlines Whether newlines are allowed in the string or not.
* @param str The string to translate.
* @param [out] olen The length of the final string.
+ * @param byte80 The control code to use as replacement for the 0x80-value.
* @return The translated string.
*/
-char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen)
+char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen, StringControlCode byte80)
{
char *tmp = MallocT<char>(strlen(str) * 10 + 1); // Allocate space to allow for expansion
char *d = tmp;
@@ -454,8 +455,8 @@ char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newline
case 0x7C:
case 0x7D:
case 0x7E:
- case 0x7F:
- case 0x80: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_SIGNED + c - 0x7B); break;
+ case 0x7F: d += Utf8Encode(d, SCC_NEWGRF_PRINT_DWORD_SIGNED + c - 0x7B); break;
+ case 0x80: d += Utf8Encode(d, byte80); break;
case 0x81: {
if (str[0] == '\0' || str[1] == '\0') goto string_end;
StringID string;
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index 338c61c7b..081e7e36c 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -15,6 +15,7 @@
#include "string_type.h"
#include "strings_type.h"
#include "core/smallvec_type.hpp"
+#include "table/control_codes.h"
/** This character, the thorn ('รพ'), indicates a unicode string to NFO. */
static const WChar NFO_UTF8_IDENTIFIER = 0x00DE;
@@ -25,7 +26,7 @@ const char *GetGRFStringFromGRFText(const struct GRFText *text);
const char *GetGRFStringPtr(uint16 stringid);
void CleanUpStrings();
void SetCurrentGrfLangID(byte language_id);
-char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen = NULL);
+char *TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const char *str, int *olen = NULL, StringControlCode byte80 = SCC_NEWGRF_PRINT_WORD_STRING_ID);
struct GRFText *DuplicateGRFText(struct GRFText *orig);
void AddGRFTextToList(struct GRFText **list, struct GRFText *text_to_add);
void AddGRFTextToList(struct GRFText **list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add);