Changeset - r18292:67d22b89b6c6
[Not reviewed]
master
0 18 0
frosch - 13 years ago 2011-11-08 17:23:30
frosch@openttd.org
(svn r23138) -Feature: [NewGRF] Allow passing 32bit parameters to 60+x variables (using var 7B). Currently most useful for vehicle var 60.
18 files changed with 23 insertions and 23 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airport.cpp
Show inline comments
 
@@ -124,13 +124,13 @@ void AirportOverrideManager::SetEntitySp
 
		overridden_as->enabled = false;
 
		entity_overrides[i] = invalid_ID;
 
		grfid_overrides[i] = 0;
 
	}
 
}
 

	
 
uint32 AirportGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
uint32 AirportGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const Station *st = object->u.airport.st;
 
	byte layout       = object->u.airport.layout;
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
 
		DEBUG(grf, 1, "Parent scope for airports unavailable");
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -163,13 +163,13 @@ static uint32 GetAirportTileIDAtOffset(T
 
		}
 
	}
 
	/* The tile has no spritegroup */
 
	return 0xFF << 8 | ats->grf_prop.subst_id; // so just give him the substitute
 
}
 

	
 
static uint32 AirportTileGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 AirportTileGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const Station *st = object->u.airport.st;
 
	TileIndex tile    = object->u.airport.tile;
 
	assert(st != NULL);
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
src/newgrf_canal.cpp
Show inline comments
 
@@ -38,13 +38,13 @@ static uint32 CanalGetTriggers(const Res
 
static void CanalSetTriggers(const ResolverObject *object, int triggers)
 
{
 
	return;
 
}
 

	
 

	
 
static uint32 CanalGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 CanalGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	TileIndex tile = object->u.canal.tile;
 

	
 
	switch (variable) {
 
		/* Height of tile */
 
		case 0x80: {
src/newgrf_cargo.cpp
Show inline comments
 
@@ -30,13 +30,13 @@ static uint32 CargoGetTriggers(const Res
 
static void CargoSetTriggers(const ResolverObject *object, int triggers)
 
{
 
	return;
 
}
 

	
 

	
 
static uint32 CargoGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 CargoGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	DEBUG(grf, 1, "Unhandled cargo variable 0x%X", variable);
 

	
 
	*available = false;
 
	return UINT_MAX;
 
}
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -288,13 +288,13 @@ struct NewGRFInspectWindow : Window {
 
	static const int LEFT_OFFSET   = 5; ///< Position of left edge
 
	static const int RIGHT_OFFSET  = 5; ///< Position of right edge
 
	static const int TOP_OFFSET    = 5; ///< Position of top edge
 
	static const int BOTTOM_OFFSET = 5; ///< Position of bottom edge
 

	
 
	/** The value for the variable 60 parameters. */
 
	static byte var60params[GSF_FAKE_END][0x20];
 
	static uint32 var60params[GSF_FAKE_END][0x20];
 

	
 
	/** GRFID of the caller of this window, 0 if it has no caller. */
 
	uint32 caller_grfid;
 

	
 
	/** The currently editted parameter, to update the right one. */
 
	byte current_edit_param;
 
@@ -494,13 +494,13 @@ struct NewGRFInspectWindow : Window {
 
				for (const NIVariable *niv = nif->variables; niv->name != NULL; niv++, line--) {
 
					if (line != 1) continue; // 1 because of the "Variables:" line
 

	
 
					if (!HasVariableParameter(niv->var)) break;
 

	
 
					this->current_edit_param = niv->var;
 
					ShowQueryString(STR_EMPTY, STR_NEWGRF_INSPECT_QUERY_CAPTION, 3, this, CS_HEXADECIMAL, QSF_NONE);
 
					ShowQueryString(STR_EMPTY, STR_NEWGRF_INSPECT_QUERY_CAPTION, 9, this, CS_HEXADECIMAL, QSF_NONE);
 
				}
 
			}
 
		}
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
@@ -514,13 +514,13 @@ struct NewGRFInspectWindow : Window {
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, NIW_MAINPANEL, TOP_OFFSET + BOTTOM_OFFSET);
 
	}
 
};
 

	
 
/* static */ byte NewGRFInspectWindow::var60params[GSF_FAKE_END][0x20] = { {0} }; // Use spec to have 0s in whole array
 
/* static */ uint32 NewGRFInspectWindow::var60params[GSF_FAKE_END][0x20] = { {0} }; // Use spec to have 0s in whole array
 

	
 
static const NWidgetPart _nested_newgrf_inspect_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, NIW_CAPTION), SetDataTip(STR_NEWGRF_INSPECT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, NIW_PARENT), SetDataTip(STR_NEWGRF_INSPECT_PARENT_BUTTON, STR_NEWGRF_INSPECT_PARENT_TOOLTIP),
src/newgrf_engine.cpp
Show inline comments
 
@@ -457,13 +457,13 @@ static uint32 PositionHelper(const Vehic
 
		u = u->Next();
 
	}
 

	
 
	return chain_before | chain_after << 8 | (chain_before + chain_after + consecutive) << 16;
 
}
 

	
 
static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	/* Calculated vehicle parameters */
 
	switch (variable) {
 
		case 0x25: // Get engine GRF ID
 
			return v->GetGRFID();
 

	
 
@@ -834,13 +834,13 @@ static uint32 VehicleGetVariable(Vehicle
 
	DEBUG(grf, 1, "Unhandled vehicle variable 0x%X, type 0x%X", variable, (uint)v->type);
 

	
 
	*available = false;
 
	return UINT_MAX;
 
}
 

	
 
static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	Vehicle *v = const_cast<Vehicle*>(GRV(object));
 

	
 
	if (v == NULL) {
 
		/* Vehicle does not exist, so we're in a purchase list */
 
		switch (variable) {
src/newgrf_generic.cpp
Show inline comments
 
@@ -82,21 +82,21 @@ static uint32 GenericCallbackGetTriggers
 
static void GenericCallbackSetTriggers(const ResolverObject *object, int triggers)
 
{
 
	return;
 
}
 

	
 

	
 
static uint32 GenericCallbackGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 GenericCallbackGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	DEBUG(grf, 1, "Unhandled generic feature variable 0x%02X", variable);
 

	
 
	*available = false;
 
	return UINT_MAX;
 
}
 

	
 
static uint32 GenericAiCallbackGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 GenericAiCallbackGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	switch (variable) {
 
		case 0x40: return object->grffile->cargo_map[object->u.generic.cargo_type];
 

	
 
		case 0x80: return object->u.generic.cargo_type;
 
		case 0x81: return CargoSpec::Get(object->u.generic.cargo_type)->bitnum;
src/newgrf_house.cpp
Show inline comments
 
@@ -251,13 +251,13 @@ static uint32 GetDistanceFromNearbyHouse
 

	
 
/**
 
 * HouseGetVariable():
 
 *
 
 * Used by the resolver to get values for feature 07 deterministic spritegroups.
 
 */
 
static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 HouseGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	Town *town = object->u.house.town;
 
	TileIndex tile   = object->u.house.tile;
 
	HouseID house_id = object->u.house.house_id;
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
src/newgrf_industries.cpp
Show inline comments
 
@@ -167,13 +167,13 @@ static uint32 GetCountAndDistanceOfClose
 
 * @param object the object that we want to query
 
 * @param variable that is queried
 
 * @param parameter unused
 
 * @param available will return false if ever the variable asked for does not exist
 
 * @return the value stored in the corresponding variable
 
 */
 
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const Industry *industry = object->u.industry.ind;
 
	TileIndex tile = object->u.industry.tile;
 
	IndustryType type = object->u.industry.type;
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 

	
 
@@ -453,13 +453,13 @@ uint16 GetIndustryCallback(CallbackID ca
 
	group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], &object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
}
 

	
 
uint32 IndustryLocationGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
uint32 IndustryLocationGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const Industry *industry = object->u.industry.ind;
 
	TileIndex tile = object->u.industry.tile;
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
 
		return TownGetVariable(variable, parameter, available, industry->town, object->grffile);
src/newgrf_industries.h
Show inline comments
 
@@ -32,13 +32,13 @@ enum IndustryAvailabilityCallType {
 
	IACT_RANDOMCREATION,   ///< during creation of random ingame industry
 
	IACT_USERCREATION,     ///< from the Fund/build window
 
	IACT_PROSPECTCREATION, ///< from the Fund/build using prospecting
 
};
 

	
 
/* in newgrf_industry.cpp */
 
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available);
 
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available);
 
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile);
 
uint32 GetIndustryIDAtOffset(TileIndex new_tile, const Industry *i, uint32 cur_grfid);
 
void IndustryProductionCallback(Industry *ind, int reason);
 
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
 
bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCallType creation_type);
 
bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type);
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -58,13 +58,13 @@ uint32 GetRelativePosition(TileIndex til
 
	byte x = TileX(tile) - TileX(ind_tile);
 
	byte y = TileY(tile) - TileY(ind_tile);
 

	
 
	return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
 
}
 

	
 
static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const Industry *inds = object->u.industry.ind;
 
	TileIndex tile       = object->u.industry.tile;
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
 
		return IndustryGetVariable(object, variable, parameter, available);
src/newgrf_object.cpp
Show inline comments
 
@@ -219,13 +219,13 @@ static uint32 GetCountAndDistanceOfClose
 
	if (idx >= NUM_OBJECTS) return 0 | 0xFFFF;
 

	
 
	return Object::GetTypeCount(idx) << 16 | min(GetClosestObject(tile, idx, current), 0xFFFF);
 
}
 

	
 
/** Used by the resolver to get values for feature 0F deterministic spritegroups. */
 
static uint32 ObjectGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 ObjectGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const Object *o = object->u.object.o;
 
	TileIndex tile = object->u.object.tile;
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
 
		/* Pass the request on to the town of the object */
src/newgrf_railtype.cpp
Show inline comments
 
@@ -29,13 +29,13 @@ static uint32 RailTypeGetTriggers(const 
 
}
 

	
 
static void RailTypeSetTriggers(const ResolverObject *object, int triggers)
 
{
 
}
 

	
 
static uint32 RailTypeGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 RailTypeGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	TileIndex tile = object->u.routes.tile;
 

	
 
	if (tile == INVALID_TILE) {
 
		switch (variable) {
 
			case 0x40: return 0;
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -35,13 +35,13 @@ RandomizedSpriteGroup::~RandomizedSprite
 
	free((void*)this->groups);
 
}
 

	
 
TemporaryStorageArray<int32, 0x110> _temp_store;
 

	
 

	
 
static inline uint32 GetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static inline uint32 GetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	/* First handle variables common with Action7/9/D */
 
	uint32 value;
 
	if (GetGlobalVariable(variable, &value)) return value;
 

	
 
	/* Non-common variable */
src/newgrf_spritegroup.h
Show inline comments
 
@@ -380,13 +380,13 @@ struct ResolverObject {
 
		} object;
 
	} u;
 

	
 
	uint32 (*GetRandomBits)(const struct ResolverObject*);
 
	uint32 (*GetTriggers)(const struct ResolverObject*);
 
	void (*SetTriggers)(const struct ResolverObject*, int);
 
	uint32 (*GetVariable)(const struct ResolverObject*, byte, byte, bool*);
 
	uint32 (*GetVariable)(const struct ResolverObject *object, byte variable, uint32 parameter, bool *available);
 
	const SpriteGroup *(*ResolveReal)(const struct ResolverObject*, const RealSpriteGroup*);
 
	void (*StorePSA)(struct ResolverObject*, uint, int32);
 

	
 
	/**
 
	 * Returns the OR-sum of all bits that need reseeding
 
	 * independent of the scope they were accessed with.
src/newgrf_station.cpp
Show inline comments
 
@@ -254,13 +254,13 @@ static struct {
 
	uint32 v46;
 
	uint32 v47;
 
	uint32 v49;
 
	uint8 valid; ///< Bits indicating what variable is valid (for each bit, \c 0 is invalid, \c 1 is valid).
 
} _svc;
 

	
 
static uint32 StationGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
 
static uint32 StationGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
 
{
 
	const BaseStation *st = object->u.station.st;
 
	TileIndex tile = object->u.station.tile;
 

	
 
	if (object->scope == VSG_SCOPE_PARENT) {
 
		/* Pass the request on to the town of the station */
src/newgrf_town.cpp
Show inline comments
 
@@ -21,13 +21,13 @@
 
 * @param parameter unused
 
 * @param available will return false if ever the variable asked for does not exist
 
 * @param t is of course the town we are inquiring
 
 * @param caller_grffile #GRFFile of the entity asking for a town variable.
 
 * @return the value stored in the corresponding variable
 
 */
 
uint32 TownGetVariable(byte variable, byte parameter, bool *available, Town *t, const GRFFile *caller_grffile)
 
uint32 TownGetVariable(byte variable, uint32 parameter, bool *available, Town *t, const GRFFile *caller_grffile)
 
{
 
	switch (variable) {
 
		/* Larger towns */
 
		case 0x40:
 
			if (_settings_game.economy.larger_towns == 0) return 2;
 
			if (t->larger_town) return 1;
src/newgrf_town.h
Show inline comments
 
@@ -14,10 +14,10 @@
 

	
 
#include "town_type.h"
 

	
 
/* Currently there is no direct town resolver; we only need to get town
 
 * variable results from inside stations, house tiles and industries,
 
 * and to check the town's persistent storage. */
 
uint32 TownGetVariable(byte variable, byte parameter, bool *available, Town *t, const GRFFile *caller_grffile);
 
uint32 TownGetVariable(byte variable, uint32 parameter, bool *available, Town *t, const GRFFile *caller_grffile);
 
void TownStorePSA(Town *t, const GRFFile *caller_grffile, uint pos, int32 value);
 

	
 
#endif /* NEWGRF_TOWN_H */
0 comments (0 inline, 0 general)