Scope info: Add station/waypoint info dumper
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
|
#include "station_base.h"
|
||||||
|
#include "waypoint_base.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
@@ -78,4 +80,29 @@ const char *scope_dumper::VehicleInfo(const Vehicle *v)
|
|||||||
return this->buffer;
|
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);
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
b += seprintf(b, last, "station/waypoint: NULL");
|
||||||
|
}
|
||||||
|
return this->buffer;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct Vehicle;
|
struct Vehicle;
|
||||||
|
struct BaseStation;
|
||||||
|
|
||||||
extern std::vector<std::function<int(char *, const char *)>> _scope_stack;
|
extern std::vector<std::function<int(char *, const char *)>> _scope_stack;
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@ int WriteScopeLog(char *buf, const char *last);
|
|||||||
struct scope_dumper {
|
struct scope_dumper {
|
||||||
const char *CompanyInfo(int company_id);
|
const char *CompanyInfo(int company_id);
|
||||||
const char *VehicleInfo(const Vehicle *v);
|
const char *VehicleInfo(const Vehicle *v);
|
||||||
|
const char *StationInfo(const BaseStation *st);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|||||||
Reference in New Issue
Block a user