Changeset - r18294:67a72ead8996
[Not reviewed]
master
0 4 0
frosch - 13 years ago 2011-11-08 17:24:15
frosch@openttd.org
(svn r23140) -Add: ErrorUnknownCallbackResult()
4 files changed with 40 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2520,6 +2520,7 @@ STR_BROKEN_VEHICLE_LENGTH               
 
STR_NEWGRF_BUGGY                                                :{WHITE}NewGRF '{0:RAW_STRING}' provides incorrect information
 
STR_NEWGRF_BUGGY_ARTICULATED_CARGO                              :{WHITE}Cargo/refit information for '{1:ENGINE}' differs from purchase list after construction. This might cause autorenew/-replace to fail refitting correctly
 
STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK                    :{WHITE}'{1:STRING}' caused an endless loop in the production callback
 
STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT                        :{WHITE}Callback 0x{HEX} returned unknown/invalid result 0x{HEX}
 

	
 
# 'User removed essential NewGRFs'-placeholders for stuff without specs
 
STR_NEWGRF_INVALID_CARGO                                        :<invalid cargo>
src/newgrf_commons.cpp
Show inline comments
 
@@ -13,10 +13,12 @@
 
 */
 

	
 
#include "stdafx.h"
 
#include "debug.h"
 
#include "landscape.h"
 
#include "house.h"
 
#include "industrytype.h"
 
#include "newgrf.h"
 
#include "newgrf_config.h"
 
#include "clear_map.h"
 
#include "station_map.h"
 
#include "tree_map.h"
 
@@ -27,6 +29,8 @@
 
#include "newgrf_text.h"
 
#include "livery.h"
 
#include "company_base.h"
 
#include "gui.h"
 
#include "strings_func.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -495,6 +499,38 @@ CommandCost GetErrorMessageFromLocationC
 
	return res;
 
}
 

	
 
/**
 
 * Record that a NewGRF returned an unknown/invalid callback result.
 
 * Also show an error to the user.
 
 * @param grfid ID of the NewGRF causing the problem.
 
 * @param cbid Callback causing the problem.
 
 * @param cb_res Invalid result returned by the callback.
 
 */
 
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
 
{
 
	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, "%s", buffer + 3);
 

	
 
	SetDParam(1, cbid);
 
	SetDParam(2, cb_res);
 
	GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
 
	DEBUG(grf, 0, "%s", buffer + 3);
 
}
 

	
 
/* static */ SmallVector<DrawTileSeqStruct, 8> NewGRFSpriteLayout::result_seq;
 

	
 
/**
src/newgrf_commons.h
Show inline comments
 
@@ -300,6 +300,8 @@ uint32 GetNearbyTileInformation(TileInde
 
uint32 GetCompanyInfo(CompanyID owner, const struct Livery *l = NULL);
 
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, uint32 grfid, StringID default_error);
 

	
 
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res);
 

	
 
/**
 
 * Data related to the handling of grf files.
 
 * @tparam Tcnt Number of spritegroups
src/newgrf_config.h
Show inline comments
 
@@ -44,6 +44,7 @@ enum GRFBugs {
 
	GBUG_VEH_LENGTH,        ///< Length of rail vehicle changes when not inside a depot
 
	GBUG_VEH_REFIT,         ///< Articulated vehicles carry different cargos resp. are differently refittable than specified in purchase list
 
	GBUG_VEH_POWERED_WAGON, ///< Powered wagon changed poweredness state when not inside a depot
 
	GBUG_UNKNOWN_CB_RESULT, ///< A callback returned an unknown/invalid result
 
};
 

	
 
/** Status of post-gameload GRF compatibility check */
0 comments (0 inline, 0 general)