Changeset - r16586:a5cff32dd5d2
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-11-25 23:10:35
rubidium@openttd.org
(svn r21326) -Fix: off-by-one in case choice list construction causing case lists to fail completely
1 file changed with 2 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -318,39 +318,37 @@ struct UnmappedChoiceList : ZeroedMemory
 
			*d++ = count;
 

	
 
			for (uint8 i = 0; i < _current_language->num_cases; i++) {
 
				/* Resolve the string we're looking for. */
 
				int idx = lm->GetReverseMapping(i, false);
 
				if (!this->strings.Contains(idx)) continue;
 
				char *str = this->strings[idx];
 

	
 
				/* "<CASEn>" */
 
				*d++ = i;
 

	
 
				/* "<LENn>" */
 
				size_t len = strlen(str);
 
				size_t len = strlen(str) + 1;
 
				*d++ = GB(len, 8, 8);
 
				*d++ = GB(len, 0, 8);
 

	
 
				/* "<STRINGn>" */
 
				memcpy(d, str, len);
 
				d += len;
 
				*d++ = '\0';
 
			}
 

	
 
			/* "<STRINGDEFAULT>" */
 
			size_t len = strlen(this->strings[0]);
 
			size_t len = strlen(this->strings[0]) + 1;
 
			memcpy(d, this->strings[0], len);
 
			d += len;
 
			*d++ = '\0';
 
		} else {
 
			if (this->type == SCC_PLURAL_LIST) {
 
				*d++ = lm->plural_form;
 
			}
 

	
 
			/*
 
			 * Format for choice list:
 
			 * <OFFSET> <NUM CHOICES> <LENs> <STRINGs>
 
			 */
 

	
 
			/* "<OFFSET>" */
 
			*d++ = this->offset - 0x80;
0 comments (0 inline, 0 general)