Adjust format of vehicle scope dumping

This commit is contained in:
Jonathan G Rennison 2018-01-29 00:14:55 +00:00
parent 902fd73c47
commit 1615137481

View File

@ -54,6 +54,29 @@ const char *scope_dumper::VehicleInfo(const Vehicle *v)
{
char *b = this->buffer;
const char *last = lastof(this->buffer);
auto dump_flags = [&](const Vehicle *u) {
auto dump = [&](char c, bool flag) {
if (flag) b += seprintf(b, last, "%c", c);
};
b += seprintf(b, last, "st:");
dump('F', HasBit(u->subtype, GVSF_FRONT));
dump('A', HasBit(u->subtype, GVSF_ARTICULATED_PART));
dump('W', HasBit(u->subtype, GVSF_WAGON));
dump('E', HasBit(u->subtype, GVSF_ENGINE));
dump('f', HasBit(u->subtype, GVSF_FREE_WAGON));
dump('M', HasBit(u->subtype, GVSF_MULTIHEADED));
dump('V', HasBit(u->subtype, GVSF_VIRTUAL));
b += seprintf(b, last, ", vs:");
dump('H', u->vehstatus & VS_HIDDEN);
dump('S', u->vehstatus & VS_STOPPED);
dump('U', u->vehstatus & VS_UNCLICKABLE);
dump('D', u->vehstatus & VS_DEFPAL);
dump('s', u->vehstatus & VS_TRAIN_SLOWING);
dump('X', u->vehstatus & VS_SHADOW);
dump('B', u->vehstatus & VS_AIRCRAFT_BROKEN);
dump('C', u->vehstatus & VS_CRASHED);
b += seprintf(b, last, ", t:%X", u->tile);
};
if (v) {
b += seprintf(b, last, "veh: %u: (", v->index);
if (Vehicle::GetIfValid(v->index) != v) {
@ -62,10 +85,8 @@ const char *scope_dumper::VehicleInfo(const Vehicle *v)
}
SetDParam(0, v->index);
b = GetString(b, STR_VEHICLE_NAME, last);
b += seprintf(b, last, ", c:%d", (int) v->owner);
if (HasBit(v->subtype, GVSF_VIRTUAL)) {
b += seprintf(b, last, ", VIRT");
}
b += seprintf(b, last, ", c:%d, ", (int) v->owner);
dump_flags(v);
if (v->First() && v->First() != v) {
b += seprintf(b, last, ", front: %u: (", v->First()->index);
if (Vehicle::GetIfValid(v->First()->index) != v->First()) {
@ -74,6 +95,8 @@ const char *scope_dumper::VehicleInfo(const Vehicle *v)
}
SetDParam(0, v->First()->index);
b = GetString(b, STR_VEHICLE_NAME, last);
b += seprintf(b, last, ", ");
dump_flags(v->First());
b += seprintf(b, last, ")");
}
b += seprintf(b, last, ")");