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
 
@@ -2511,24 +2511,25 @@ STR_NEWGRF_LIST_ALL_FOUND               
 
STR_NEWGRF_LIST_COMPATIBLE                                      :{YELLOW}Found compatible files
 
STR_NEWGRF_LIST_MISSING                                         :{RED}Missing files
 

	
 
# NewGRF 'it's broken' warnings
 
STR_NEWGRF_BROKEN                                               :{WHITE}Behaviour of NewGRF '{0:RAW_STRING}' is likely to cause desyncs and/or crashes
 
STR_NEWGRF_BROKEN_POWERED_WAGON                                 :{WHITE}It changed powered-wagon state for '{1:ENGINE}' when not inside a depot
 
STR_NEWGRF_BROKEN_VEHICLE_LENGTH                                :{WHITE}It changed vehicle length for '{1:ENGINE}' when not inside a depot
 
STR_BROKEN_VEHICLE_LENGTH                                       :{WHITE}Train '{VEHICLE}' belonging to '{COMPANY}' has invalid length. It is probably caused by problems with NewGRFs. Game may desync or crash
 

	
 
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>
 
STR_NEWGRF_INVALID_CARGO_ABBREV                                 :??
 
STR_NEWGRF_INVALID_CARGO_QUANTITY                               :{COMMA} of <invalid cargo>
 
STR_NEWGRF_INVALID_ENGINE                                       :<invalid vehicle model>
 
STR_NEWGRF_INVALID_INDUSTRYTYPE                                 :<invalid industry>
 

	
 
# NewGRF scanning window
 
STR_NEWGRF_SCAN_CAPTION                                         :{WHITE}Scanning NewGRFs
 
STR_NEWGRF_SCAN_MESSAGE                                         :{BLACK}Scanning NewGRFs. Depending on the amount this can take a while...
 
STR_NEWGRF_SCAN_STATUS                                          :{BLACK}{NUM} NewGRF{P "" s} scanned out of an estimated {NUM} NewGRF{P "" s}
src/newgrf_commons.cpp
Show inline comments
 
@@ -4,38 +4,42 @@
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/**
 
 * @file newgrf_commons.cpp Implementation of the class OverrideManagerBase
 
 * and its descendance, present and futur
 
 */
 

	
 
#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"
 
#include "tunnelbridge_map.h"
 
#include "newgrf_object.h"
 
#include "genworld.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_text.h"
 
#include "livery.h"
 
#include "company_base.h"
 
#include "gui.h"
 
#include "strings_func.h"
 

	
 
#include "table/strings.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)
 
{
 
	max_offset = offset;
 
@@ -486,24 +490,56 @@ CommandCost GetErrorMessageFromLocationC
 
		case 0x406: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_SEA); break;
 
		case 0x407: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_CANAL); break;
 
		case 0x408: res = CommandCost(STR_ERROR_CAN_T_BUILD_ON_RIVER); break;
 
		default:    res = CommandCost(GetGRFStringID(grfid, 0xD000 + cb_res)); break;
 
	}
 

	
 
	/* Copy some parameters from the registers to the error message text ref. stack */
 
	res.UseTextRefStack(4);
 

	
 
	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;
 

	
 
/**
 
 * Clone the building sprites of a spritelayout.
 
 * @param source The building sprites to copy.
 
 */
 
void NewGRFSpriteLayout::Clone(const DrawTileSeqStruct *source)
 
{
 
	assert(this->seq == NULL);
 
	assert(source != NULL);
 

	
 
	size_t count = 1; // 1 for the terminator
src/newgrf_commons.h
Show inline comments
 
@@ -291,24 +291,26 @@ extern HouseOverrideManager _house_mngr;
 
extern IndustryOverrideManager _industry_mngr;
 
extern IndustryTileOverrideManager _industile_mngr;
 
extern AirportOverrideManager _airport_mngr;
 
extern AirportTileOverrideManager _airporttile_mngr;
 
extern ObjectOverrideManager _object_mngr;
 

	
 
uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
 
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true, Axis axis = INVALID_AXIS);
 
uint32 GetNearbyTileInformation(TileIndex tile);
 
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
 
 */
 
template <size_t Tcnt>
 
struct GRFFilePropsBase {
 
	GRFFilePropsBase() : local_id(0), grffile(0)
 
	{
 
		/* The lack of some compilers to provide default constructors complying to the specs
 
		 * requires us to zero the stuff ourself. */
 
		memset(spritegroup, 0, sizeof(spritegroup));
 
	}
src/newgrf_config.h
Show inline comments
 
@@ -35,24 +35,25 @@ enum GRFStatus {
 
	GCS_UNKNOWN,      ///< The status of this grf file is unknown
 
	GCS_DISABLED,     ///< GRF file is disabled
 
	GCS_NOT_FOUND,    ///< GRF file was not found in the local cache
 
	GCS_INITIALISED,  ///< GRF file has been initialised
 
	GCS_ACTIVATED     ///< GRF file has been activated
 
};
 

	
 
/** Encountered GRF bugs */
 
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 */
 
enum GRFListCompatibility {
 
	GLC_ALL_GOOD,   ///< All GRF needed by game are present
 
	GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different chacksum) GRF found in at least one case
 
	GLC_NOT_FOUND   ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
 
};
 

	
 
/** Information that can/has to be stored about a GRF's palette. */
 
enum GRFPalette {
 
	GRFP_USE_BIT     = 0,   ///< The bit used for storing the palette to use.
0 comments (0 inline, 0 general)