File diff r23496:661d21df67d7 → r23497:a0ab44ebd2fa
src/table/newgrf_debug_data.h
Show inline comments
 
@@ -66,20 +66,20 @@ static const NIVariable _niv_vehicles[] 
 
	// 0x61 not useful, since it requires register 0x10F
 
	NIV(0x62, "Curvature/position difference to other vehicle"),
 
	NIV_END()
 
};
 

	
 
class NIHVehicle : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return Vehicle::Get(index)->GetGRF() != NULL; }
 
	uint GetParent(uint index) const                     { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); }
 
	const void *GetInstance(uint index)const             { return Vehicle::Get(index); }
 
	const void *GetSpec(uint index) const                { return Vehicle::Get(index)->GetEngine(); }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return Vehicle::Get(index)->GetGRFID(); }
 
	bool IsInspectable(uint index) const override        { return Vehicle::Get(index)->GetGRF() != NULL; }
 
	uint GetParent(uint index) const override            { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); }
 
	const void *GetInstance(uint index)const override    { return Vehicle::Get(index); }
 
	const void *GetSpec(uint index) const override       { return Vehicle::Get(index)->GetEngine(); }
 
	void SetStringParameters(uint index) const override  { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); }
 
	uint32 GetGRFID(uint index) const override                   { return Vehicle::Get(index)->GetGRFID(); }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		Vehicle *v = Vehicle::Get(index);
 
		VehicleResolverObject ro(v->engine_type, v, VehicleResolverObject::WO_CACHED);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 
@@ -129,20 +129,20 @@ static const NIVariable _niv_stations[] 
 
	NIV(0x68, "station info of nearby tiles"),
 
	NIV(0x69, "information about cargo accepted in the past"),
 
	NIV_END()
 
};
 

	
 
class NIHStation : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return GetStationSpec(index) != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return GetStationSpec(index); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return GetStationSpec(index) != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return GetStationSpec(index); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		StationResolverObject ro(GetStationSpec(index), Station::GetByTile(index), index);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
@@ -194,20 +194,20 @@ static const NIVariable _niv_house[] = {
 
	NIV(0x66, "class and ID of nearby house tile"),
 
	NIV(0x67, "GRFID of nearby house tile"),
 
	NIV_END()
 
};
 

	
 
class NIHHouse : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return HouseSpec::Get(GetHouseType(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return HouseSpec::Get(GetHouseType(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return HouseSpec::Get(GetHouseType(index)); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		HouseResolverObject ro(GetHouseType(index), index, Town::GetByTile(index));
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
@@ -244,20 +244,20 @@ static const NIVariable _niv_industrytil
 
	NIV(0x61, "animation stage of nearby tiles"),
 
	NIV(0x62, "get industry or airport tile ID at offset"),
 
	NIV_END()
 
};
 

	
 
class NIHIndustryTile : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return GetIndustryTileSpec(GetIndustryGfx(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return GetIndustryTileSpec(GetIndustryGfx(index)); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		IndustryTileResolverObject ro(GetIndustryGfx(index), index, Industry::GetByTile(index));
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
@@ -343,29 +343,29 @@ static const NIVariable _niv_industries[
 
	NIV(0x67, "count of industry and distance of closest instance"),
 
	NIV(0x68, "count of industry and distance of closest instance with layout filter"),
 
	NIV_END()
 
};
 

	
 
class NIHIndustry : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return Industry::Get(index); }
 
	const void *GetSpec(uint index) const                { return GetIndustrySpec(Industry::Get(index)->type); }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return Industry::Get(index); }
 
	const void *GetSpec(uint index) const override       { return GetIndustrySpec(Industry::Get(index)->type); }
 
	void SetStringParameters(uint index) const override  { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		Industry *i = Industry::Get(index);
 
		IndustriesResolverObject ro(i->location.tile, i, i->type);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 

	
 
	uint GetPSASize(uint index, uint32 grfid) const      { return cpp_lengthof(PersistentStorage, storage); }
 
	uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); }
 

	
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override
 
	{
 
		const Industry *i = (const Industry *)this->GetInstance(index);
 
		if (i->psa == NULL) return NULL;
 
		return (int32 *)(&i->psa->storage);
 
	}
 
};
 
@@ -408,20 +408,20 @@ static const NIVariable _niv_objects[] =
 
	NIV(0x63, "animation stage of nearby tiles"),
 
	NIV(0x64, "distance on nearest object with given type"),
 
	NIV_END()
 
};
 

	
 
class NIHObject : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return ObjectSpec::GetByTile(index)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return Object::GetByTile(index); }
 
	const void *GetSpec(uint index) const                { return ObjectSpec::GetByTile(index); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return ObjectSpec::GetByTile(index)->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return Object::GetByTile(index); }
 
	const void *GetSpec(uint index) const override       { return ObjectSpec::GetByTile(index); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		ObjectResolverObject ro(ObjectSpec::GetByTile(index), Object::GetByTile(index), index);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
@@ -442,20 +442,20 @@ static const NIVariable _niv_railtypes[]
 
	NIV(0x43, "construction date"),
 
	NIV(0x44, "town zone"),
 
	NIV_END()
 
};
 

	
 
class NIHRailType : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return true; }
 
	uint GetParent(uint index) const                     { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return NULL; }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const                    { return 0; }
 
	bool IsInspectable(uint index) const override        { return true; }
 
	uint GetParent(uint index) const override            { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return NULL; }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
 
	uint32 GetGRFID(uint index) const override           { return 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		/* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype.
 
		 * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */
 
		RailTypeResolverObject ro(NULL, index, TCX_NORMAL, RTSG_END);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
@@ -478,20 +478,20 @@ static const NICallback _nic_airporttile
 
	NICAT(CBID_AIRPTILE_ANIM_NEXT_FRAME,  CBM_AIRT_ANIM_NEXT_FRAME),
 
	NICAT(CBID_AIRPTILE_ANIMATION_SPEED,  CBM_AIRT_ANIM_SPEED),
 
	NIC_END()
 
};
 

	
 
class NIHAirportTile : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const                     { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const             { return NULL; }
 
	const void *GetSpec(uint index) const                { return AirportTileSpec::Get(GetAirportGfx(index)); }
 
	void SetStringParameters(uint index) const           { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const                    { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; }
 
	bool IsInspectable(uint index) const override        { return AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile != NULL; }
 
	uint GetParent(uint index) const override            { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
 
	const void *GetInstance(uint index)const override    { return NULL; }
 
	const void *GetSpec(uint index) const override       { return AirportTileSpec::Get(GetAirportGfx(index)); }
 
	void SetStringParameters(uint index) const override  { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
 
	uint32 GetGRFID(uint index) const override           { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		AirportTileResolverObject ro(AirportTileSpec::GetByTile(index), index, Station::GetByTile(index));
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 
};
 

	
 
@@ -516,28 +516,28 @@ static const NIVariable _niv_towns[] = {
 
	NIV(0x9C, "zone radius 4"),
 
	NIV(0xB6, "number of buildings"),
 
	NIV_END()
 
};
 

	
 
class NIHTown : public NIHelper {
 
	bool IsInspectable(uint index) const                 { return Town::IsValidID(index); }
 
	uint GetParent(uint index) const                     { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const             { return Town::Get(index); }
 
	const void *GetSpec(uint index) const                { return NULL; }
 
	void SetStringParameters(uint index) const           { this->SetSimpleStringParameters(STR_TOWN_NAME, index); }
 
	uint32 GetGRFID(uint index) const                    { return 0; }
 
	bool PSAWithParameter() const                        { return true; }
 
	uint GetPSASize(uint index, uint32 grfid) const      { return cpp_lengthof(PersistentStorage, storage); }
 
	bool IsInspectable(uint index) const override        { return Town::IsValidID(index); }
 
	uint GetParent(uint index) const override            { return UINT32_MAX; }
 
	const void *GetInstance(uint index)const override    { return Town::Get(index); }
 
	const void *GetSpec(uint index) const override       { return NULL; }
 
	void SetStringParameters(uint index) const override  { this->SetSimpleStringParameters(STR_TOWN_NAME, index); }
 
	uint32 GetGRFID(uint index) const override           { return 0; }
 
	bool PSAWithParameter() const override               { return true; }
 
	uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); }
 

	
 
	/* virtual */ uint Resolve(uint index, uint var, uint param, bool *avail) const
 
	uint Resolve(uint index, uint var, uint param, bool *avail) const override
 
	{
 
		TownResolverObject ro(NULL, Town::Get(index), true);
 
		return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
 
	}
 

	
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const
 
	const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override
 
	{
 
		Town *t = Town::Get(index);
 

	
 
		std::list<PersistentStorage *>::iterator iter;
 
		for (iter = t->psa_list.begin(); iter != t->psa_list.end(); iter++) {
 
			if ((*iter)->grfid == grfid) return (int32 *)(&(*iter)->storage[0]);