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
 
@@ -118,25 +118,25 @@ void AirportOverrideManager::SetEntitySp
 
	for (int i = 0; i < max_offset; i++) {
 
		AirportSpec *overridden_as = AirportSpec::GetWithoutOverride(i);
 

	
 
		if (entity_overrides[i] != as->grf_prop.local_id || grfid_overrides[i] != as->grf_prop.grffile->grfid) continue;
 

	
 
		overridden_as->grf_prop.override = airport_id;
 
		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");
 
		*available = false;
 
		return UINT_MAX;
 
	}
 

	
 
	switch (variable) {
 
		case 0x40: return layout;
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -157,25 +157,25 @@ static uint32 GetAirportTileIDAtOffset(T
 
	/* Not an 'old type' tile */
 
	if (ats->grf_prop.spritegroup[0] != NULL) { // tile has a spritegroup ?
 
		if (ats->grf_prop.grffile->grfid == cur_grfid) { // same airport, same grf ?
 
			return ats->grf_prop.local_id;
 
		} else {
 
			return 0xFFFE; // Defined in another grf file
 
		}
 
	}
 
	/* 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) {
 
		DEBUG(grf, 1, "Parent scope for airport tiles unavailable");
 
		*available = false;
 
		return UINT_MAX;
 
	}
 

	
 
	extern uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile);
src/newgrf_canal.cpp
Show inline comments
 
@@ -32,25 +32,25 @@ static uint32 CanalGetRandomBits(const R
 
static uint32 CanalGetTriggers(const ResolverObject *object)
 
{
 
	return 0;
 
}
 

	
 

	
 
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: {
 
			int z = GetTileZ(tile);
 
			/* Return consistent height within locks */
 
			if (IsTileType(tile, MP_WATER) && IsLock(tile) && GetLockPart(tile) == LOCK_PART_UPPER) z--;
 
			return z;
 
		}
 

	
src/newgrf_cargo.cpp
Show inline comments
 
@@ -24,25 +24,25 @@ static uint32 CargoGetRandomBits(const R
 
static uint32 CargoGetTriggers(const ResolverObject *object)
 
{
 
	return 0;
 
}
 

	
 

	
 
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;
 
}
 

	
 

	
 
static const SpriteGroup *CargoResolveReal(const ResolverObject *object, const RealSpriteGroup *group)
 
{
 
	/* Cargo action 2s should always have only 1 "loaded" state, but some
 
	 * times things don't follow the spec... */
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -282,25 +282,25 @@ enum NewGRFInspectWidgets {
 
	NIW_MAINPANEL, ///< Panel widget containing the actual data
 
	NIW_SCROLLBAR, ///< Scrollbar
 
};
 

	
 
/** Window used for inspecting NewGRFs. */
 
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;
 

	
 
	Scrollbar *vscroll;
 

	
 
	/**
 
	 * Check whether the given variable has a parameter.
 
	 * @param variable the variable to check.
 
@@ -488,45 +488,45 @@ struct NewGRFInspectWindow : Window {
 

	
 
				/* Get the line, make sure it's within the boundaries. */
 
				int line = this->vscroll->GetScrolledRowFromWidget(pt.y, this, NIW_MAINPANEL, TOP_OFFSET);
 
				if (line == INT_MAX) return;
 

	
 
				/* Find the variable related to the line */
 
				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)
 
	{
 
		if (StrEmpty(str)) return;
 

	
 
		NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][this->current_edit_param - 0x60] = strtol(str, NULL, 16);
 
		this->SetDirty();
 
	}
 

	
 
	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),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_PANEL, COLOUR_GREY, NIW_MAINPANEL), SetMinimalSize(300, 0), SetScrollbar(NIW_SCROLLBAR), EndContainer(),
 
		NWidget(NWID_VERTICAL),
src/newgrf_engine.cpp
Show inline comments
 
@@ -451,25 +451,25 @@ static uint32 PositionHelper(const Vehic
 
		chain_before++;
 
		if (consecutive && u->engine_type != v->engine_type) chain_before = 0;
 
	}
 

	
 
	while (u->Next() != NULL && (!consecutive || u->Next()->engine_type == v->engine_type)) {
 
		chain_after++;
 
		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();
 

	
 
		case 0x40: // Get length of consist
 
			if (!HasBit(v->grf_cache.cache_valid, NCVV_POSITION_CONSIST_LENGTH)) {
 
				v->grf_cache.position_consist_length = PositionHelper(v, false);
 
				SetBit(v->grf_cache.cache_valid, NCVV_POSITION_CONSIST_LENGTH);
 
			}
 
			return v->grf_cache.position_consist_length;
 
@@ -828,25 +828,25 @@ static uint32 VehicleGetVariable(Vehicle
 
			break;
 
		}
 

	
 
		default: break;
 
	}
 

	
 
	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) {
 
			case 0x43: return GetCompanyInfo(_current_company, LiveryHelper(object->u.vehicle.self_type, NULL)); // Owner information
 
			case 0x46: return 0;               // Motion counter
 
			case 0x47: { // Vehicle cargo info
 
				const Engine *e = Engine::Get(object->u.vehicle.self_type);
 
				CargoID cargo_type = e->GetDefaultCargoType();
 
				if (cargo_type != CT_INVALID) {
src/newgrf_generic.cpp
Show inline comments
 
@@ -76,33 +76,33 @@ static uint32 GenericCallbackGetRandomBi
 
static uint32 GenericCallbackGetTriggers(const ResolverObject *object)
 
{
 
	return 0;
 
}
 

	
 

	
 
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;
 
		case 0x82: return object->u.generic.default_selection;
 
		case 0x83: return object->u.generic.src_industry;
 
		case 0x84: return object->u.generic.dst_industry;
 
		case 0x85: return object->u.generic.distance;
 
		case 0x86: return object->u.generic.event;
 
		case 0x87: return object->u.generic.count;
src/newgrf_house.cpp
Show inline comments
 
@@ -245,25 +245,25 @@ static uint32 GetDistanceFromNearbyHouse
 
	/* Use a pointer for the tile to start the search. Will be required for calculating the distance*/
 
	if (CircularTileSearch(&found_tile, 2 * searchradius + 1, search_procs[searchtype], &nbhd)) {
 
		return DistanceManhattan(found_tile, tile);
 
	}
 
	return 0;
 
}
 

	
 
/**
 
 * 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) {
 
		return TownGetVariable(variable, parameter, available, town, object->grffile);
 
	}
 

	
 
	switch (variable) {
 
		/* Construction stage. */
 
		case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | TileHash2Bit(TileX(tile), TileY(tile)) << 2;
src/newgrf_industries.cpp
Show inline comments
 
@@ -161,25 +161,25 @@ static uint32 GetCountAndDistanceOfClose
 

	
 
	return count << 16 | GB(closest_dist, 0, 16);
 
}
 

	
 
/**
 
 * This function implements the industries variables that newGRF defines.
 
 * @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);
 

	
 
	/* Shall the variable get resolved in parent scope and are we not yet in parent scope? */
 
	if (object->u.industry.gfx == INVALID_INDUSTRYTILE && object->scope == VSG_SCOPE_PARENT) {
 
		/* Pass the request on to the town of the industry */
 
		Town *t;
 

	
 
		if (industry != NULL) {
 
@@ -447,25 +447,25 @@ uint16 GetIndustryCallback(CallbackID ca
 

	
 
	NewIndustryResolver(&object, tile, industry, type);
 
	object.callback = callback;
 
	object.callback_param1 = param1;
 
	object.callback_param2 = param2;
 

	
 
	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);
 
	}
 

	
 
	switch (variable) {
 
		case 0x80: return tile;
 
		case 0x81: return GB(tile, 8, 8);
 

	
src/newgrf_industries.h
Show inline comments
 
@@ -26,25 +26,25 @@ enum IndustryTrigger {
 
	INDUSTRY_TRIGGER_CARGO_DELIVERY   = 4,
 
};
 

	
 
/** From where is callback CBID_INDUSTRY_AVAILABLE been called */
 
enum IndustryAvailabilityCallType {
 
	IACT_MAPGENERATION,    ///< during random map generation
 
	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);
 

	
 
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
 

	
 
/* in newgrf_industrytiles.cpp*/
 
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets = true);
 

	
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -52,25 +52,25 @@ uint32 GetNearbyIndustryTileInformation(
 
 * YY        same, but stored in a byte instead of a nibble
 
 * @param tile TileIndex of the tile to evaluate
 
 * @param ind_tile northernmost tile of the industry
 
 */
 
uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
 
{
 
	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);
 
	}
 

	
 
	switch (variable) {
 
		/* Construction state of the tile: a value between 0 and 3 */
 
		case 0x40: return (IsTileType(tile, MP_INDUSTRY)) ? GetIndustryConstructionStage(tile) : 0;
 

	
src/newgrf_object.cpp
Show inline comments
 
@@ -213,25 +213,25 @@ static uint32 GetCountAndDistanceOfClose
 
		default: // use the grfid specified in register 100h
 
			idx = _object_mngr.GetID(local_id, grf_id);
 
			break;
 
	}
 

	
 
	/* If the object type is invalid, there is none and the closest is far away. */
 
	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 */
 
		return TownGetVariable(variable, parameter, available, (o == NULL) ? ClosestTownFromTile(tile, UINT_MAX) : o->town, object->grffile);
 
	}
 

	
 
	/* We get the town from the object, or we calculate the closest
 
	 * town if we need to when there's no object. */
 
	const Town *t = NULL;
src/newgrf_railtype.cpp
Show inline comments
 
@@ -23,25 +23,25 @@ static uint32 RailTypeGetRandomBits(cons
 
	return GB(tmp, 0, 2);
 
}
 

	
 
static uint32 RailTypeGetTriggers(const ResolverObject *object)
 
{
 
	return 0;
 
}
 

	
 
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;
 
			case 0x41: return 0;
 
			case 0x42: return 0;
 
			case 0x43: return _date;
 
		}
 
	}
 

	
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -29,25 +29,25 @@ DeterministicSpriteGroup::~Deterministic
 
	free(this->adjusts);
 
	free(this->ranges);
 
}
 

	
 
RandomizedSpriteGroup::~RandomizedSpriteGroup()
 
{
 
	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 */
 
	switch (variable) {
 
		case 0x0C: return object->callback;
 
		case 0x10: return object->callback_param1;
 
		case 0x18: return object->callback_param2;
 
		case 0x1C: return object->last_value;
 

	
src/newgrf_spritegroup.h
Show inline comments
 
@@ -374,25 +374,25 @@ struct ResolverObject {
 
			TileIndex tile;                ///< Tile for the callback, only valid for airporttile callbacks.
 
		} airport;
 
		struct {
 
			struct Object *o;              ///< The object the callback is ran for.
 
			TileIndex tile;                ///< The tile related to the object.
 
			uint8 view;                    ///< The view of the object.
 
		} 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.
 
	 * @return OR-sum of the bits.
 
	 */
 
	uint32 GetReseedSum() const
 
	{
 
		uint32 sum = 0;
 
		for (VarSpriteGroupScope vsg = VSG_BEGIN; vsg < VSG_END; vsg++) {
src/newgrf_station.cpp
Show inline comments
 
@@ -248,25 +248,25 @@ static void StationSetTriggers(const Res
 
 * several tiles that may be called multiple times per Resolve().
 
 */
 
static struct {
 
	uint32 v40;
 
	uint32 v41;
 
	uint32 v45;
 
	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 */
 
		Town *t;
 

	
 
		if (st != NULL) {
 
			t = st->town;
 
		} else if (tile != INVALID_TILE) {
 
			t = ClosestTownFromTile(tile, UINT_MAX);
src/newgrf_town.cpp
Show inline comments
 
@@ -15,25 +15,25 @@
 
#include "newgrf.h"
 
#include "newgrf_spritegroup.h"
 

	
 
/**
 
 * This function implements the town variables that newGRF defines.
 
 * @param variable that is queried
 
 * @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;
 
			return 0;
 

	
 
		/* Town index */
 
		case 0x41: return t->index;
 

	
 
		/* Get a variable from the persistent storage */
src/newgrf_town.h
Show inline comments
 
@@ -8,16 +8,16 @@
 
 */
 

	
 
/** @file newgrf_town.h Functions to handle the town part of NewGRF towns. */
 

	
 
#ifndef NEWGRF_TOWN_H
 
#define NEWGRF_TOWN_H
 

	
 
#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)