Changeset - r27412:e80c11e22792
[Not reviewed]
master
0 2 0
Rubidium - 16 months ago 2023-05-19 12:35:10
rubidium@openttd.org
Codechange: use GetString + StrMakeValid to pass string without colours/font sizes to Debug
2 files changed with 5 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/newgrf_commons.cpp
Show inline comments
 
@@ -24,12 +24,13 @@
 
#include "genworld.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_text.h"
 
#include "company_base.h"
 
#include "error.h"
 
#include "strings_func.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
@@ -505,22 +506,18 @@ void ErrorUnknownCallbackResult(uint32 g
 
		SetDParam(1, cbid);
 
		SetDParam(2, cb_res);
 
		ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, WL_CRITICAL);
 
	}
 

	
 
	/* debug output */
 
	char buffer[512];
 

	
 
	SetDParamStr(0, grfconfig->GetName());
 
	GetString(buffer, STR_NEWGRF_BUGGY, lastof(buffer));
 
	Debug(grf, 0, "{}", buffer + 3);
 
	Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY)));
 

	
 
	SetDParam(1, cbid);
 
	SetDParam(2, cb_res);
 
	GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
 
	Debug(grf, 0, "{}", buffer + 3);
 
	Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT)));
 
}
 

	
 
/**
 
 * Converts a callback result into a boolean.
 
 * For grf version < 8 the result is checked for zero or non-zero.
 
 * For grf version >= 8 the callback result must be 0 or 1.
src/vehicle.cpp
Show inline comments
 
@@ -312,21 +312,17 @@ void ShowNewGrfVehicleError(EngineID eng
 
		SetDParam(1, engine);
 
		ShowErrorMessage(part1, part2, WL_CRITICAL);
 
		if (!_networking) Command<CMD_PAUSE>::Do(DC_EXEC, critical ? PM_PAUSED_ERROR : PM_PAUSED_NORMAL, true);
 
	}
 

	
 
	/* debug output */
 
	char buffer[512];
 

	
 
	SetDParamStr(0, grfconfig->GetName());
 
	GetString(buffer, part1, lastof(buffer));
 
	Debug(grf, 0, "{}", buffer + 3);
 
	Debug(grf, 0, "{}", StrMakeValid(GetString(part1)));
 

	
 
	SetDParam(1, engine);
 
	GetString(buffer, part2, lastof(buffer));
 
	Debug(grf, 0, "{}", buffer + 3);
 
	Debug(grf, 0, "{}", StrMakeValid(GetString(part2)));
 
}
 

	
 
/**
 
 * Logs a bug in GRF and shows a warning message if this
 
 * is for the first time this happened.
 
 * @param u first vehicle of chain
0 comments (0 inline, 0 general)