diff -r 9a27928bcd5e -r ebf0ece7d8f6 src/strings.cpp --- a/src/strings.cpp Thu Nov 22 23:01:41 2007 +0000 +++ b/src/strings.cpp Fri Nov 23 16:59:30 2007 +0000 @@ -116,12 +116,12 @@ */ static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, const char* last) { + if (GB(string, 0, 16) == 0) return GetStringWithArgs(buffr, STR_UNDEFINED, argv, last); + uint index = GB(string, 0, 11); uint tab = GB(string, 11, 5); char buff[512]; - if (GB(string, 0, 16) == 0) error("!invalid string id 0 in GetString"); - switch (tab) { case 4: if (index >= 0xC0) @@ -139,7 +139,7 @@ case 26: /* Include string within newgrf text (format code 81) */ - if (HASBIT(index, 10)) { + if (HasBit(index, 10)) { StringID string = GetGRFStringID(0, 0xD000 + GB(index, 0, 10)); return GetStringWithArgs(buffr, string, argv, last); } @@ -331,15 +331,15 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money number, bool compact, const char* last) { - const char* multiplier = ""; + /* We are going to make number absolute for printing, so + * keep this piece of data as we need it later on */ + bool negative = number < 0; + const char *multiplier = ""; char buf[40]; - char* p; + char *p; int j; - /* Multiply by exchange rate, but do it safely. */ - CommandCost cs(number); - cs.MultiplyCost(spec->rate); - number = cs.GetCost(); + number *= spec->rate; /* convert from negative */ if (number < 0) { @@ -374,7 +374,7 @@ *--p = spec->separator; j = 3; } - *--p = '0' + number % 10; + *--p = '0' + (char)(number % 10); } while ((number /= 10) != 0); buff = strecpy(buff, p, last); @@ -385,7 +385,7 @@ * The only remaining value is 1 (prefix), so everything that is not 0 */ if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last); - if (cs.GetCost() < 0) { + if (negative) { if (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff; buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR); *buff = '\0'; @@ -691,7 +691,8 @@ } case SCC_GENDER_LIST: { // {G 0 Der Die Das} - const char* s = GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender. + char buffr[512]; + const char *s = GetStringWithArgs(buffr, argv_orig[(byte)*str++], argv, last); // contains the string that determines gender. int len; int gender = 0; if (s != NULL) {