diff options
author | rubidium <rubidium@openttd.org> | 2012-03-10 19:04:49 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2012-03-10 19:04:49 +0000 |
commit | 19923e81f97fe560ba102ebcbaf116634c68ccb6 (patch) | |
tree | 223a84d79848d39a08d969d116a13ada18c478f4 /src/strings.cpp | |
parent | b65c2def5c1510546e5b12ceca0beb92a8481994 (diff) | |
download | openttd-19923e81f97fe560ba102ebcbaf116634c68ccb6.tar.xz |
(svn r24022) -Add: CARGO_LIST control code for strings
Diffstat (limited to 'src/strings.cpp')
-rw-r--r-- | src/strings.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/strings.cpp b/src/strings.cpp index a1c147c83..954996d68 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1106,6 +1106,38 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg break; } + case SCC_CARGO_LIST: { // {CARGO_LIST} + uint32 cmask = args->GetInt32(SCC_CARGO_LIST); + bool first = true; + + const CargoSpec *cs; + FOR_ALL_SORTED_CARGOSPECS(cs) { + if (!HasBit(cmask, cs->Index())) continue; + + if (buff >= last - 2) break; // ',' and ' ' + + if (first) { + first = false; + } else { + /* Add a comma if this is not the first item */ + *buff++ = ','; + *buff++ = ' '; + } + + buff = GetStringWithArgs(buff, cs->name, args, last, next_substr_case_index, game_script); + } + + /* If first is still true then no cargo is accepted */ + if (first) buff = GetStringWithArgs(buff, STR_JUST_NOTHING, args, last, next_substr_case_index, game_script); + + *buff = '\0'; + next_substr_case_index = 0; + + /* Make sure we detect any buffer overflow */ + assert(buff < last); + break; + } + case SCC_CURRENCY_SHORT: // {CURRENCY_SHORT} buff = FormatGenericCurrency(buff, _currency, args->GetInt64(), true, last); break; |