summaryrefslogtreecommitdiff
path: root/src/newgrf_roadtype.cpp
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2020-01-26 13:45:51 +0100
committerGitHub <noreply@github.com>2020-01-26 13:45:51 +0100
commitc8779fb311c2665d3fc45c18b2f3460cd998d179 (patch)
tree15321da1e265a40fce50700182b218a87494d24a /src/newgrf_roadtype.cpp
parentf88ac83408bff58022699b4d9488818d509ef974 (diff)
downloadopenttd-c8779fb311c2665d3fc45c18b2f3460cd998d179.tar.xz
Feature: NewGRF callback profiling (#7868)
Adds a console command newgrf_profile to collect some profiling data about NewGRF action 2 callbacks and produce a CSV file.
Diffstat (limited to 'src/newgrf_roadtype.cpp')
-rw-r--r--src/newgrf_roadtype.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp
index 34a8eb11a..c49faa59f 100644
--- a/src/newgrf_roadtype.cpp
+++ b/src/newgrf_roadtype.cpp
@@ -65,16 +65,32 @@
return nullptr;
}
+GrfSpecFeature RoadTypeResolverObject::GetFeature() const
+{
+ RoadType rt = GetRoadTypeByLabel(this->roadtype_scope.rti->label, false);
+ switch (GetRoadTramType(rt)) {
+ case RTT_ROAD: return GSF_ROADTYPES;
+ case RTT_TRAM: return GSF_TRAMTYPES;
+ default: return GSF_INVALID;
+ }
+}
+
+uint32 RoadTypeResolverObject::GetDebugID() const
+{
+ return this->roadtype_scope.rti->label;
+}
+
/**
* Constructor of the roadtype scope resolvers.
* @param ro Surrounding resolver.
* @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
* @param context Are we resolving sprites for the upper halftile, or on a bridge?
*/
-RoadTypeScopeResolver::RoadTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context) : ScopeResolver(ro)
+RoadTypeScopeResolver::RoadTypeScopeResolver(ResolverObject &ro, const RoadTypeInfo *rti, TileIndex tile, TileContext context) : ScopeResolver(ro)
{
this->tile = tile;
this->context = context;
+ this->rti = rti;
}
/**
@@ -87,7 +103,7 @@ RoadTypeScopeResolver::RoadTypeScopeResolver(ResolverObject &ro, TileIndex tile,
* @param param2 Extra parameter (second parameter of the callback, except roadtypes do not have callbacks).
*/
RoadTypeResolverObject::RoadTypeResolverObject(const RoadTypeInfo *rti, TileIndex tile, TileContext context, RoadTypeSpriteGroup rtsg, uint32 param1, uint32 param2)
- : ResolverObject(rti != nullptr ? rti->grffile[rtsg] : nullptr, CBID_NO_CALLBACK, param1, param2), roadtype_scope(*this, tile, context)
+ : ResolverObject(rti != nullptr ? rti->grffile[rtsg] : nullptr, CBID_NO_CALLBACK, param1, param2), roadtype_scope(*this, rti, tile, context)
{
this->root_spritegroup = rti != nullptr ? rti->group[rtsg] : nullptr;
}