Debug: Add NewGRF inspector support for road stops
This commit is contained in:
@@ -965,7 +965,14 @@ GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
|
|||||||
switch (GetStationType(tile)) {
|
switch (GetStationType(tile)) {
|
||||||
case STATION_RAIL: return GSF_STATIONS;
|
case STATION_RAIL: return GSF_STATIONS;
|
||||||
case STATION_AIRPORT: return GSF_AIRPORTTILES;
|
case STATION_AIRPORT: return GSF_AIRPORTTILES;
|
||||||
default: return GSF_INVALID;
|
|
||||||
|
case STATION_BUS:
|
||||||
|
case STATION_TRUCK:
|
||||||
|
case STATION_ROADWAYPOINT:
|
||||||
|
return GSF_ROADSTOPS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return GSF_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -459,3 +459,29 @@ void StationUpdateRoadStopCachedTriggers(BaseStation *st)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DumpRoadStopSpriteGroup(const BaseStation *st, const RoadStopSpec *spec, std::function<void(const char *)> print)
|
||||||
|
{
|
||||||
|
CargoID ctype = CT_DEFAULT_NA;
|
||||||
|
|
||||||
|
if (st == nullptr) {
|
||||||
|
/* No station, so we are in a purchase list */
|
||||||
|
ctype = CT_PURCHASE;
|
||||||
|
} else if (Station::IsExpected(st)) {
|
||||||
|
const Station *station = Station::From(st);
|
||||||
|
/* Pick the first cargo that we have waiting */
|
||||||
|
for (const CargoSpec *cs : CargoSpec::Iterate()) {
|
||||||
|
if (spec->grf_prop.spritegroup[cs->Index()] != nullptr &&
|
||||||
|
station->goods[cs->Index()].cargo.TotalCount() > 0) {
|
||||||
|
ctype = cs->Index();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spec->grf_prop.spritegroup[ctype] == nullptr) {
|
||||||
|
ctype = CT_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
DumpSpriteGroup(spec->grf_prop.spritegroup[ctype], std::move(print));
|
||||||
|
}
|
||||||
|
@@ -2247,6 +2247,8 @@ CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags)
|
|||||||
|
|
||||||
uint specindex = GetCustomRoadStopSpecIndex(tile);
|
uint specindex = GetCustomRoadStopSpecIndex(tile);
|
||||||
|
|
||||||
|
DeleteNewGRFInspectWindow(GSF_ROADSTOPS, tile);
|
||||||
|
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
|
|
||||||
wp->rect.AfterRemoveTile(wp, tile);
|
wp->rect.AfterRemoveTile(wp, tile);
|
||||||
@@ -2341,6 +2343,8 @@ CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
|
|||||||
|
|
||||||
uint specindex = GetCustomRoadStopSpecIndex(tile);
|
uint specindex = GetCustomRoadStopSpecIndex(tile);
|
||||||
|
|
||||||
|
DeleteNewGRFInspectWindow(GSF_ROADSTOPS, tile);
|
||||||
|
|
||||||
if (IsDriveThroughStopTile(tile)) {
|
if (IsDriveThroughStopTile(tile)) {
|
||||||
/* Clears the tile for us */
|
/* Clears the tile for us */
|
||||||
cur_stop->ClearDriveThrough();
|
cur_stop->ClearDriveThrough();
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "../newgrf_house.h"
|
#include "../newgrf_house.h"
|
||||||
#include "../newgrf_engine.h"
|
#include "../newgrf_engine.h"
|
||||||
#include "../newgrf_roadtype.h"
|
#include "../newgrf_roadtype.h"
|
||||||
|
#include "../newgrf_roadstop.h"
|
||||||
#include "../newgrf_cargo.h"
|
#include "../newgrf_cargo.h"
|
||||||
#include "../date_func.h"
|
#include "../date_func.h"
|
||||||
#include "../timetable.h"
|
#include "../timetable.h"
|
||||||
@@ -1370,24 +1371,64 @@ static const NIFeature _nif_roadtype = {
|
|||||||
new NIHRoadType(),
|
new NIHRoadType(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/*** ***/
|
|
||||||
|
|
||||||
static const NIVariable _nif_roadstops[] = {
|
static const NIVariable _nif_roadstops[] = {
|
||||||
NIV(0x40, "test"),
|
NIV(0x40, "view/rotation"),
|
||||||
|
NIV(0x41, "stop type"),
|
||||||
|
NIV(0x42, "terrain type"),
|
||||||
|
NIV(0x43, "road type"),
|
||||||
|
NIV(0x44, "tram type"),
|
||||||
|
NIV(0x45, "town zone"),
|
||||||
|
NIV(0x46, "player info"),
|
||||||
|
NIV(0x48, "bitmask of accepted cargoes"),
|
||||||
|
NIV(0x60, "amount of cargo waiting"),
|
||||||
|
NIV(0x61, "time since last cargo pickup"),
|
||||||
|
NIV(0x62, "rating of cargo"),
|
||||||
|
NIV(0x63, "time spent on route"),
|
||||||
|
NIV(0x64, "information about last vehicle picking cargo up"),
|
||||||
|
NIV(0x65, "amount of cargo acceptance"),
|
||||||
|
NIV(0x69, "information about cargo accepted in the past"),
|
||||||
NIV_END(),
|
NIV_END(),
|
||||||
};
|
};
|
||||||
|
|
||||||
class NIHRoadStop : public NIHelper {
|
class NIHRoadStop : public NIHelper {
|
||||||
bool IsInspectable(uint index) const override { return false; }
|
bool IsInspectable(uint index) const override { return GetRoadStopSpec(index) != nullptr; }
|
||||||
uint GetParent(uint index) const override { return UINT32_MAX; }
|
bool ShowSpriteDumpButton(uint index) const override { return true; }
|
||||||
const void *GetInstance(uint index)const override { return nullptr; }
|
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, BaseStation::GetByTile(index)->town->index); }
|
||||||
const void *GetSpec(uint index) const override { return nullptr; }
|
const void *GetInstance(uint index)const override { return nullptr; }
|
||||||
void SetStringParameters(uint index) const override { }
|
const void *GetSpec(uint index) const override { return GetRoadStopSpec(index); }
|
||||||
uint32 GetGRFID(uint index) const override { return 0; }
|
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
|
||||||
|
uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(index)->grf_prop.grffile->grfid : 0; }
|
||||||
|
|
||||||
uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override
|
uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override
|
||||||
{
|
{
|
||||||
return UINT32_MAX;
|
int view = GetRoadStopDir(index);
|
||||||
|
if (IsDriveThroughStopTile(index)) view += 4;
|
||||||
|
RoadStopResolverObject ro(GetRoadStopSpec(index), BaseStation::GetByTile(index), index, nullptr, GetStationType(index), view);
|
||||||
|
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtraInfo(uint index, NIExtraInfoOutput &output) const override
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
output.print("Debug Info:");
|
||||||
|
const RoadStopSpec *spec = GetRoadStopSpec(index);
|
||||||
|
if (spec) {
|
||||||
|
uint class_id = RoadStopClass::Get(spec->cls_id)->global_id;
|
||||||
|
seprintf(buffer, lastof(buffer), " class ID: %c%c%c%c, spec ID: %u", class_id >> 24, class_id >> 16, class_id >> 8, class_id, spec->spec_id);
|
||||||
|
output.print(buffer);
|
||||||
|
seprintf(buffer, lastof(buffer), " spec: stop type: %u, draw mode: %u, cargo triggers: 0x" OTTD_PRINTFHEX64, spec->stop_type, spec->draw_mode, spec->cargo_triggers);
|
||||||
|
output.print(buffer);
|
||||||
|
|
||||||
|
const BaseStation *st = BaseStation::GetByTile(index);
|
||||||
|
seprintf(buffer, lastof(buffer), " stop random bits: %02X", st->GetRoadStopRandomBits(index));
|
||||||
|
output.print(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* virtual */ void SpriteDump(uint index, std::function<void(const char *)> print) const override
|
||||||
|
{
|
||||||
|
extern void DumpRoadStopSpriteGroup(const BaseStation *st, const RoadStopSpec *spec, std::function<void(const char *)> print);
|
||||||
|
DumpRoadStopSpriteGroup(BaseStation::GetByTile(index), GetRoadStopSpec(index), std::move(print));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1420,7 +1461,7 @@ static const NIFeature * const _nifeatures[] = {
|
|||||||
&_nif_airporttile, // GSF_AIRPORTTILES
|
&_nif_airporttile, // GSF_AIRPORTTILES
|
||||||
&_nif_roadtype, // GSF_ROADTYPES
|
&_nif_roadtype, // GSF_ROADTYPES
|
||||||
&_nif_roadtype, // GSF_TRAMTYPES
|
&_nif_roadtype, // GSF_TRAMTYPES
|
||||||
&_nif_roadstop, // GSF_ROADSTATIONS
|
&_nif_roadstop, // GSF_ROADSTOPS
|
||||||
&_nif_town, // GSF_FAKE_TOWNS
|
&_nif_town, // GSF_FAKE_TOWNS
|
||||||
&_nif_station_struct, // GSF_FAKE_STATION_STRUCT
|
&_nif_station_struct, // GSF_FAKE_STATION_STRUCT
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user