summaryrefslogtreecommitdiff
path: root/src/table/newgrf_debug_data.h
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-04-06 07:46:15 +0100
committerMichael Lutz <michi@icosahedron.de>2019-05-01 21:36:27 +0200
commitc02ef3e4564b7b54d49f0827d2d7625cbc38f335 (patch)
tree1c0ee62b6ce55124b247daaafa42300bfaa932e7 /src/table/newgrf_debug_data.h
parent21edf67f89c60351d5a0d84625455aa296b6b950 (diff)
downloadopenttd-c02ef3e4564b7b54d49f0827d2d7625cbc38f335.tar.xz
Feature: Add NotRoadTypes (NRT)
Diffstat (limited to 'src/table/newgrf_debug_data.h')
-rw-r--r--src/table/newgrf_debug_data.h47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h
index 0b3c92499..89c289355 100644
--- a/src/table/newgrf_debug_data.h
+++ b/src/table/newgrf_debug_data.h
@@ -11,6 +11,7 @@
#include "../newgrf_house.h"
#include "../newgrf_engine.h"
+#include "../newgrf_roadtype.h"
/* Helper for filling property tables */
#define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type }
@@ -58,7 +59,7 @@ static const NIVariable _niv_vehicles[] = {
NIV(0x47, "vehicle cargo info"),
NIV(0x48, "vehicle type info"),
NIV(0x49, "year of construction"),
- NIV(0x4A, "current rail type info"),
+ NIV(0x4A, "current rail/road type info"),
NIV(0x4B, "long date of last service"),
NIV(0x4C, "current max speed"),
NIV(0x4D, "position in articulated vehicle"),
@@ -554,6 +555,48 @@ static const NIFeature _nif_town = {
new NIHTown(),
};
+/*** NewGRF road types ***/
+
+static const NIVariable _niv_roadtypes[] = {
+ NIV(0x40, "terrain type"),
+ NIV(0x41, "enhanced tunnels"),
+ NIV(0x42, "level crossing status"),
+ NIV(0x43, "construction date"),
+ NIV(0x44, "town zone"),
+ NIV_END()
+};
+
+class NIHRoadType : public NIHelper {
+ 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 nullptr; }
+ const void *GetSpec(uint index) const override { return nullptr; }
+ 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; }
+
+ 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. */
+ RoadTypeResolverObject ro(nullptr, index, TCX_NORMAL, ROTSG_END);
+ return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
+ }
+};
+
+static const NIFeature _nif_roadtype = {
+ nullptr,
+ nullptr,
+ _niv_roadtypes,
+ new NIHRoadType(),
+};
+
+static const NIFeature _nif_tramtype = {
+ nullptr,
+ nullptr,
+ _niv_roadtypes,
+ new NIHRoadType(),
+};
+
/** Table with all NIFeatures. */
static const NIFeature * const _nifeatures[] = {
&_nif_vehicle, // GSF_TRAINS
@@ -574,6 +617,8 @@ static const NIFeature * const _nifeatures[] = {
&_nif_object, // GSF_OBJECTS
&_nif_railtype, // GSF_RAILTYPES
&_nif_airporttile, // GSF_AIRPORTTILES
+ &_nif_roadtype, // GSF_ROADTYPES
+ &_nif_tramtype, // GSF_TRAMTYPES
&_nif_town, // GSF_FAKE_TOWNS
};
assert_compile(lengthof(_nifeatures) == GSF_FAKE_END);