--- a/src/newgrf_text.cpp Fri Nov 23 16:59:30 2007 +0000
+++ b/src/newgrf_text.cpp Wed Jan 09 18:11:12 2008 +0000
@@ -12,16 +12,15 @@
#include "stdafx.h"
#include "debug.h"
#include "openttd.h"
-#include "string.h"
-#include "strings.h"
#include "variables.h"
-#include "macros.h"
#include "table/strings.h"
#include "newgrf.h"
#include "newgrf_text.h"
#include "table/control_codes.h"
-#include "helpers.hpp"
-#include "date.h"
+#include "strings_func.h"
+#include "core/alloc_func.hpp"
+#include "newgrf_storage.h"
+#include "string_func.h"
#define GRFTAB 28
#define TABSIZE 11
@@ -207,9 +206,13 @@
}
for (;;) {
- const char *tmp = str; // Used for UTF-8 decoding
-
- c = (byte)*str++;
+ if (unicode && Utf8EncodedCharLen(*str) != 0) {
+ c = Utf8Consume(&str);
+ /* 'Magic' range of control codes. */
+ if (GB(c, 8, 8) == 0xE0) c = GB(c, 0, 8);
+ } else {
+ c = (byte)*str++;
+ }
if (c == 0) break;
switch (c) {
@@ -290,12 +293,6 @@
case 0xB7: d += Utf8Encode(d, SCC_PLANE); break;
case 0xB8: d += Utf8Encode(d, SCC_SHIP); break;
default:
- if (unicode) {
- d += Utf8Encode(d, Utf8Consume(&tmp));
- str = tmp;
- break;
- }
-
/* Validate any unhandled character */
if (!IsValidChar(c, CS_ALPHANUMERAL)) c = '?';
d += Utf8Encode(d, c);
@@ -507,13 +504,25 @@
uint8 PopUnsignedByte() { assert(this->position < lengthof(this->stack)); return this->stack[this->position++]; }
int8 PopSignedByte() { return (int8)this->PopUnsignedByte(); }
- uint16 PopUnsignedWord() { return this->PopUnsignedByte() | (((uint16)this->PopUnsignedByte()) << 8); }
+ uint16 PopUnsignedWord()
+ {
+ uint16 val = this->PopUnsignedByte();
+ return val | (this->PopUnsignedByte() << 8);
+ }
int16 PopSignedWord() { return (int32)this->PopUnsignedWord(); }
- uint32 PopUnsignedDWord() { return this->PopUnsignedWord() | (((uint32)this->PopUnsignedWord()) << 16); }
+ uint32 PopUnsignedDWord()
+ {
+ uint32 val = this->PopUnsignedWord();
+ return val | (this->PopUnsignedWord() << 16);
+ }
int32 PopSignedDWord() { return (int32)this->PopUnsignedDWord(); }
- uint64 PopUnsignedQWord() { return this->PopUnsignedDWord() | (((uint64)this->PopUnsignedDWord()) << 32); }
+ uint64 PopUnsignedQWord()
+ {
+ uint64 val = this->PopUnsignedDWord();
+ return val | (((uint64)this->PopUnsignedDWord()) << 32);
+ }
int64 PopSignedQWord() { return (int64)this->PopUnsignedQWord(); }
/** Rotate the top four words down: W1, W2, W3, W4 -> W4, W1, W2, W3 */