summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-03-04 00:14:28 +0000
committerDarkvater <Darkvater@openttd.org>2005-03-04 00:14:28 +0000
commit4713b11ffe72e232811b7328bf41279df46cc1cb (patch)
treefcc6d97f369d597dda4bc87f2070d21459f9a495
parent5a24ba51c818e629a39551313280a29848ecbeb7 (diff)
downloadopenttd-4713b11ffe72e232811b7328bf41279df46cc1cb.tar.xz
(svn r1923) - Fix: [ 1155696 ] Crash with german umlauts in station names. The width was not calculated using unsigned values, so all characters above 128 were "negative"
- Codechange: a more proper check for a null pointer in tunnelbridge_cmd.c should have gone in with the previous commit
-rw-r--r--misc_gui.c8
-rw-r--r--tunnelbridge_cmd.c3
2 files changed, 6 insertions, 5 deletions
diff --git a/misc_gui.c b/misc_gui.c
index 68792f808..788aac809 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -765,7 +765,7 @@ void SetHScrollCount(Window *w, int num)
static void DelChar(Textbuf *tb)
{
- tb->width -= GetCharacterWidth(tb->buf[tb->caretpos]);
+ tb->width -= GetCharacterWidth((byte)tb->buf[tb->caretpos]);
memmove(tb->buf + tb->caretpos, tb->buf + tb->caretpos + 1, tb->length - tb->caretpos);
tb->length--;
}
@@ -781,7 +781,7 @@ bool DeleteTextBufferChar(Textbuf *tb, int delmode)
{
if (delmode == WKC_BACKSPACE && tb->caretpos != 0) {
tb->caretpos--;
- tb->caretxoffs -= GetCharacterWidth(tb->buf[tb->caretpos]);
+ tb->caretxoffs -= GetCharacterWidth((byte)tb->buf[tb->caretpos]);
DelChar(tb);
return true;
@@ -829,13 +829,13 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode)
case WKC_LEFT:
if (tb->caretpos != 0) {
tb->caretpos--;
- tb->caretxoffs -= GetCharacterWidth(tb->buf[tb->caretpos]);
+ tb->caretxoffs -= GetCharacterWidth((byte)tb->buf[tb->caretpos]);
return true;
}
break;
case WKC_RIGHT:
if (tb->caretpos < tb->length) {
- tb->caretxoffs += GetCharacterWidth(tb->buf[tb->caretpos]);
+ tb->caretxoffs += GetCharacterWidth((byte)tb->buf[tb->caretpos]);
tb->caretpos++;
return true;
}
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index a639bc673..29e218d3e 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -609,7 +609,8 @@ uint CheckTunnelBusy(uint tile, int *length)
return (uint)-1;
}
- if (length) *length = len;
+ if (length != NULL)
+ *length = len;
return tile;
}