diff options
author | frosch <frosch@openttd.org> | 2015-05-28 17:26:53 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2015-05-28 17:26:53 +0000 |
commit | 50a3f4453907447373e8aaa758ec08d9f4208c9d (patch) | |
tree | cea8ed0a40b6123d92bab4a356697288c559fcb5 /src/strgen | |
parent | 9b9785c195e1da440f2bd0557b02fd298cd80809 (diff) | |
download | openttd-50a3f4453907447373e8aaa758ec08d9f4208c9d.tar.xz |
(svn r27295) -Add: [strgen] Default plural subparameter positions for CARGO_xxx string control codes.
Diffstat (limited to 'src/strgen')
-rw-r--r-- | src/strgen/strgen_base.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index 95d3291e4..c41f3d9b4 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -388,7 +388,7 @@ static void EmitWordList(Buffer *buffer, const char * const *words, uint nw) void EmitPlural(Buffer *buffer, char *buf, int value) { int argidx = _cur_argidx; - int offset = 0; + int offset = -1; int expected = _plural_forms[_lang.plural_form].plural_count; const char **words = AllocaM(const char *, max(expected, MAX_PLURALS)); int nw = 0; @@ -396,6 +396,15 @@ void EmitPlural(Buffer *buffer, char *buf, int value) /* Parse out the number, if one exists. Otherwise default to prev arg. */ if (!ParseRelNum(&buf, &argidx, &offset)) argidx--; + const CmdStruct *cmd = _cur_pcs.cmd[argidx]; + if (offset == -1) { + /* Use default offset */ + if (cmd == NULL || cmd->default_plural_offset < 0) { + strgen_fatal("Command '%s' has no (default) plural position", cmd == NULL ? "<empty>" : cmd->cmd); + } + offset = cmd->default_plural_offset; + } + /* Parse each string */ for (nw = 0; nw < MAX_PLURALS; nw++) { words[nw] = ParseWord(&buf); |