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
 
@@ -18,24 +18,25 @@
 
#include "newgrf_config.h"
 
#include "clear_map.h"
 
#include "station_map.h"
 
#include "tree_map.h"
 
#include "tunnelbridge_map.h"
 
#include "newgrf_object.h"
 
#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"
 

	
 
/**
 
 * Constructor of generic class
 
 * @param offset end of original data for this entity. i.e: houses = 110
 
 * @param maximum of entities this manager can deal with. i.e: houses = 512
 
 * @param invalid is the ID used to identify an invalid entity id
 
 */
 
OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid)
 
@@ -499,34 +500,30 @@ void ErrorUnknownCallbackResult(uint32 g
 
{
 
	GRFConfig *grfconfig = GetGRFConfig(grfid);
 

	
 
	if (!HasBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT)) {
 
		SetBit(grfconfig->grf_bugs, GBUG_UNKNOWN_CB_RESULT);
 
		SetDParamStr(0, grfconfig->GetName());
 
		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.
 
 * @param grffile NewGRF returning the value.
 
 * @param cbid Callback returning the value.
 
 * @param cb_res Callback result.
 
 * @return Boolean value. True if cb_res != 0.
 
 */
 
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
src/vehicle.cpp
Show inline comments
 
@@ -306,33 +306,29 @@ void ShowNewGrfVehicleError(EngineID eng
 
	/* Missing GRF. Nothing useful can be done in this situation. */
 
	if (grfconfig == nullptr) return;
 

	
 
	if (!HasBit(grfconfig->grf_bugs, bug_type)) {
 
		SetBit(grfconfig->grf_bugs, bug_type);
 
		SetDParamStr(0, grfconfig->GetName());
 
		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
 
 */
 
void VehicleLengthChanged(const Vehicle *u)
 
{
 
	/* show a warning once for each engine in whole game and once for each GRF after each game load */
 
	const Engine *engine = u->GetEngine();
 
	uint32 grfid = engine->grf_prop.grffile->grfid;
0 comments (0 inline, 0 general)