diff --git a/src/scope_info.cpp b/src/scope_info.cpp index a838a9b2ce..f963757687 100644 --- a/src/scope_info.cpp +++ b/src/scope_info.cpp @@ -15,6 +15,8 @@ #include "strings_func.h" #include "company_base.h" #include "vehicle_base.h" +#include "station_base.h" +#include "waypoint_base.h" #include "table/strings.h" #include "safeguards.h" @@ -106,4 +108,31 @@ const char *scope_dumper::VehicleInfo(const Vehicle *v) return this->buffer; } +const char *scope_dumper::StationInfo(const BaseStation *st) +{ + char *b = this->buffer; + const char *last = lastof(this->buffer); + + if (st) { + const bool waypoint = Waypoint::IsExpected(st); + b += seprintf(b, last, "%s: %u: (", waypoint ? "waypoint" : "station", st->index); + SetDParam(0, st->index); + b = GetString(b, waypoint ? STR_WAYPOINT_NAME : STR_STATION_NAME, last); + b += seprintf(b, last, ", c:%d, facil: ", (int) st->owner); + auto dump_facil = [&](char c, StationFacility flag) { + if (st->facilities & flag) b += seprintf(b, last, "%c", c); + }; + dump_facil('R', FACIL_TRAIN); + dump_facil('T', FACIL_TRUCK_STOP); + dump_facil('B', FACIL_BUS_STOP); + dump_facil('A', FACIL_AIRPORT); + dump_facil('D', FACIL_DOCK); + dump_facil('W', FACIL_WAYPOINT); + b += seprintf(b, last, ")"); + } else { + b += seprintf(b, last, "station/waypoint: NULL"); + } + return this->buffer; +} + #endif diff --git a/src/scope_info.h b/src/scope_info.h index 89ed4f6571..4cc772ff1d 100644 --- a/src/scope_info.h +++ b/src/scope_info.h @@ -17,6 +17,7 @@ #include struct Vehicle; +struct BaseStation; extern std::vector> _scope_stack; @@ -61,6 +62,7 @@ int WriteScopeLog(char *buf, const char *last); struct scope_dumper { const char *CompanyInfo(int company_id); const char *VehicleInfo(const Vehicle *v); + const char *StationInfo(const BaseStation *st); private: char buffer[256]; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 7f864b6495..8ae6b569f0 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1094,8 +1094,11 @@ void CallVehicleTicks() if (_tick_skip_counter == 0) RunVehicleDayProc(); - Station *st; - FOR_ALL_STATIONS(st) LoadUnloadStation(st); + { + Station *st = nullptr; + SCOPE_INFO_FMT([&st], "CallVehicleTicks: LoadUnloadStation: %s", scope_dumper().StationInfo(st)); + FOR_ALL_STATIONS(st) LoadUnloadStation(st); + } Vehicle *v = NULL; SCOPE_INFO_FMT([&v], "CallVehicleTicks: %s", scope_dumper().VehicleInfo(v));