Debug: Add dumping of rail and road/tram sprite groups
This commit is contained in:
@@ -236,3 +236,46 @@ uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
|
||||
/* If not found, return as invalid */
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void DumpRailTypeSpriteGroup(RailType rt, DumpSpriteGroupPrinter print)
|
||||
{
|
||||
char buffer[64];
|
||||
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
||||
|
||||
static const char *sprite_group_names[] = {
|
||||
"RTSG_CURSORS",
|
||||
"RTSG_OVERLAY",
|
||||
"RTSG_GROUND",
|
||||
"RTSG_TUNNEL",
|
||||
"RTSG_WIRES",
|
||||
"RTSG_PYLONS",
|
||||
"RTSG_BRIDGE",
|
||||
"RTSG_CROSSING",
|
||||
"RTSG_DEPOT",
|
||||
"RTSG_FENCES",
|
||||
"RTSG_TUNNEL_PORTAL",
|
||||
"RTSG_SIGNALS",
|
||||
"RTSG_GROUND_COMPLETE"
|
||||
};
|
||||
static_assert(lengthof(sprite_group_names) == RTSG_END);
|
||||
|
||||
SpriteGroupDumper dumper(print);
|
||||
|
||||
bool non_first_group = false;
|
||||
for (RailTypeSpriteGroup rtsg = (RailTypeSpriteGroup)0; rtsg < RTSG_END; rtsg = (RailTypeSpriteGroup)(rtsg + 1)) {
|
||||
if (rti->group[rtsg] != nullptr) {
|
||||
if (non_first_group) {
|
||||
print(nullptr, DSGPO_PRINT, 0, "");
|
||||
} else {
|
||||
non_first_group = true;
|
||||
}
|
||||
char *b = buffer;
|
||||
b = strecpy(b, sprite_group_names[rtsg], lastof(buffer));
|
||||
if (rti->grffile[rtsg] != nullptr) {
|
||||
b += seprintf(b, lastof(buffer), ", GRF: %08X", BSWAP32(rti->grffile[rtsg]->grfid));
|
||||
}
|
||||
print(nullptr, DSGPO_PRINT, 0, buffer);
|
||||
dumper.DumpSpriteGroup(rti->group[rtsg], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -166,3 +166,40 @@ uint8 GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile)
|
||||
/* If not found, return as invalid */
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void DumpRoadTypeSpriteGroup(RoadType rt, DumpSpriteGroupPrinter print)
|
||||
{
|
||||
char buffer[64];
|
||||
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
|
||||
|
||||
static const char *sprite_group_names[] = {
|
||||
"ROTSG_CURSORS",
|
||||
"ROTSG_OVERLAY",
|
||||
"ROTSG_GROUND",
|
||||
"ROTSG_TUNNEL",
|
||||
"ROTSG_CATENARY_FRONT",
|
||||
"ROTSG_CATENARY_BACK",
|
||||
"ROTSG_BRIDGE",
|
||||
"ROTSG_reserved2",
|
||||
"ROTSG_DEPOT",
|
||||
"ROTSG_reserved3",
|
||||
"ROTSG_ROADSTOP",
|
||||
"ROTSG_ONEWAY"
|
||||
};
|
||||
static_assert(lengthof(sprite_group_names) == ROTSG_END);
|
||||
|
||||
SpriteGroupDumper dumper(print);
|
||||
|
||||
for (RoadTypeSpriteGroup rtsg = (RoadTypeSpriteGroup)0; rtsg < ROTSG_END; rtsg = (RoadTypeSpriteGroup)(rtsg + 1)) {
|
||||
if (rti->group[rtsg] != nullptr) {
|
||||
char *b = buffer;
|
||||
b += seprintf(b, lastof(buffer), "%s: %s", RoadTypeIsTram(rt) ? "Tram" : "Road", sprite_group_names[rtsg]);
|
||||
if (rti->grffile[rtsg] != nullptr) {
|
||||
b += seprintf(b, lastof(buffer), ", GRF: %08X", BSWAP32(rti->grffile[rtsg]->grfid));
|
||||
}
|
||||
print(nullptr, DSGPO_PRINT, 0, buffer);
|
||||
dumper.DumpSpriteGroup(rti->group[rtsg], 0);
|
||||
print(nullptr, DSGPO_PRINT, 0, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1440,6 +1440,7 @@ void PrintTypeLabels(char * buffer, const char *last, uint32 label, const uint3
|
||||
|
||||
class NIHRailType : public NIHelper {
|
||||
bool IsInspectable(uint index) const override { return true; }
|
||||
bool ShowSpriteDumpButton(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; }
|
||||
@@ -1505,6 +1506,12 @@ class NIHRailType : public NIHelper {
|
||||
output.print(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void SpriteDump(uint index, DumpSpriteGroupPrinter print) const override
|
||||
{
|
||||
extern void DumpRailTypeSpriteGroup(RailType rt, DumpSpriteGroupPrinter print);
|
||||
DumpRailTypeSpriteGroup(GetTileRailType(index), std::move(print));
|
||||
}
|
||||
};
|
||||
|
||||
static const NIFeature _nif_railtype = {
|
||||
@@ -1760,6 +1767,7 @@ static const NIVariable _niv_roadtypes[] = {
|
||||
|
||||
class NIHRoadType : public NIHelper {
|
||||
bool IsInspectable(uint index) const override { return true; }
|
||||
bool ShowSpriteDumpButton(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; }
|
||||
@@ -1809,6 +1817,17 @@ class NIHRoadType : public NIHelper {
|
||||
writeInfo(RTT_ROAD);
|
||||
writeInfo(RTT_TRAM);
|
||||
}
|
||||
|
||||
/* virtual */ void SpriteDump(uint index, DumpSpriteGroupPrinter print) const override
|
||||
{
|
||||
for (RoadTramType rtt : { RTT_ROAD, RTT_TRAM }) {
|
||||
RoadType rt = GetRoadType(index, rtt);
|
||||
if (rt == INVALID_ROADTYPE) continue;
|
||||
|
||||
extern void DumpRoadTypeSpriteGroup(RoadType rt, DumpSpriteGroupPrinter print);
|
||||
DumpRoadTypeSpriteGroup(rt, print);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const NIFeature _nif_roadtype = {
|
||||
|
Reference in New Issue
Block a user