Changeset - r18188:a37b227e087c
[Not reviewed]
master
0 3 0
yexo - 13 years ago 2011-10-12 19:25:52
yexo@openttd.org
(svn r23027) -Fix: in some cases NewGRF string arguments were popped twice from the newgrf textstack
3 files changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -1020,11 +1020,12 @@ void RewindTextRefStack()
 
 * @param buff  the buffer we're writing to
 
 * @param str   the string that we need to write
 
 * @param argv  the OpenTTD stack of values
 
 * @param modify_argv When true, modify the OpenTTD stack.
 
 * @return the string control code to "execute" now
 
 */
 
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv)
 
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv, bool modify_argv)
 
{
 
	if (_newgrf_textrefstack.used) {
 
	if (_newgrf_textrefstack.used && modify_argv) {
 
		switch (scc) {
 
			default: NOT_REACHED();
 
			case SCC_NEWGRF_PRINT_BYTE_SIGNED:      *argv = _newgrf_textrefstack.PopSignedByte();    break;
src/newgrf_text.h
Show inline comments
 
@@ -40,7 +40,7 @@ void RewindTextRefStack();
 
bool UsingNewGRFTextStack();
 
struct TextRefStack *CreateTextRefStackBackup();
 
void RestoreTextRefStackBackup(struct TextRefStack *backup);
 
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv);
 
uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const char **str, int64 *argv, bool modify_argv);
 

	
 
StringID TTDPStringIDToOTTDStringIDMapping(StringID string);
 

	
src/strings.cpp
Show inline comments
 
@@ -668,7 +668,7 @@ static char *FormatString(char *buff, co
 
	uint orig_offset = args->offset;
 

	
 
	/* When there is no array with types there is no need to do a dry run. */
 
	if (!args->HasTypeInformation()) dry_run = true;
 
	if (!args->HasTypeInformation() && !UsingNewGRFTextStack()) dry_run = true;
 
	if (!dry_run) {
 
		if (UsingNewGRFTextStack()) {
 
			/* Values from the NewGRF text stack are only copied to the normal
 
@@ -702,7 +702,7 @@ static char *FormatString(char *buff, co
 
		if (SCC_NEWGRF_FIRST <= b && b <= SCC_NEWGRF_LAST) {
 
			/* We need to pass some stuff as it might be modified; oh boy. */
 
			//todo: should argve be passed here too?
 
			b = RemapNewGRFStringControlCode(b, buf_start, &buff, &str, (int64 *)args->GetDataPointer());
 
			b = RemapNewGRFStringControlCode(b, buf_start, &buff, &str, (int64 *)args->GetDataPointer(), dry_run);
 
			if (b == 0) continue;
 
		}
 

	
0 comments (0 inline, 0 general)