summaryrefslogtreecommitdiff
path: root/strings.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-11-14 19:48:04 +0000
committertron <tron@openttd.org>2005-11-14 19:48:04 +0000
commitf7abff5f963cddfdd134ac52ffd8e72e3ed88f0c (patch)
treea9ba5d4f3c5c47ab3857060c5f95ed482530ed97 /strings.c
parentd8b56c123eab7f7b48f2af3579130e366f6106ab (diff)
downloadopenttd-f7abff5f963cddfdd134ac52ffd8e72e3ed88f0c.tar.xz
(svn r3181) -Bracing
-Indentation -Whitespace -DeMorgan's Law -Test with NULL or 0 for non-booleans -'\0' instead of 0 for chars -Remove redundantly redundant comments (like DoFoo(); // Do foo) -Join multiple short lines with a single statement -Split single lines with multiple statements -Avoid assignments in if
Diffstat (limited to 'strings.c')
-rw-r--r--strings.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/strings.c b/strings.c
index cde711a47..ee03b9978 100644
--- a/strings.c
+++ b/strings.c
@@ -188,11 +188,12 @@ char *GetStringWithArgs(char *buffr, uint string, const int32 *argv)
return FormatString(buffr, _userstring, NULL, 0);
}
- if (index >= _langtab_num[tab])
+ if (index >= _langtab_num[tab]) {
error(
"!String 0x%X is invalid. "
"Probably because an old version of the .lng file.\n", string
);
+ }
return FormatString(buffr, GetStringPtr(GB(string, 0, 16)), argv, GB(string, 24, 8));
}
@@ -317,7 +318,7 @@ static char *FormatYmdString(char *buff, uint16 number)
memcpy(buff, GetStringPtr(STR_0162_JAN + ymd.month), 4);
buff[3] = ' ';
- return FormatNoCommaNumber(buff+4, ymd.year + MAX_YEAR_BEGIN_REAL);
+ return FormatNoCommaNumber(buff + 4, ymd.year + MAX_YEAR_BEGIN_REAL);
}
static char *FormatMonthAndYear(char *buff, uint16 number)
@@ -615,8 +616,7 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
byte *s = (byte*)GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
int len;
int gender = 0;
- if (s && s[0] == 0x87)
- gender = s[1];
+ if (s != NULL && s[0] == 0x87) gender = s[1];
str = ParseStringChoice(str, gender, buff, &len);
buff += len;
break;
@@ -715,7 +715,8 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
case 0x9B: { // {TOWN}
const Town* t = GetTown(GetInt32(&argv));
int32 temp[1];
- assert(t->xy);
+
+ assert(t->xy != 0);
temp[0] = t->townnameparts;
buff = GetStringWithArgs(buff, t->townnametype, temp);
@@ -728,7 +729,7 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
}
case 0x9D: { // {SETCASE}
- // This is a pseudo command, it's outputted when someone does {STRING.ack}
+ // This is a pseudo command, it's outputted when someone does {STRING.ack}
// The modifier is added to all subsequent GetStringWithArgs that accept the modifier.
modifier = (byte)*str++ << 24;
break;