Only include TBTR debug functions when debugging enabled.

Add an initial prefix for clarity.
Fix log print format codes.
This commit is contained in:
Jonathan G Rennison
2016-02-13 20:44:11 +00:00
parent a31e7ac87d
commit 1ebd0af2c6
2 changed files with 41 additions and 31 deletions

View File

@@ -45,42 +45,49 @@
Vehicle *vhead, *vtmp; Vehicle *vhead, *vtmp;
static const uint MAX_ARTICULATED_PARTS = 100; static const uint MAX_ARTICULATED_PARTS = 100;
#ifdef _DEBUG
// debugging printing functions for convenience, usually called from gdb // debugging printing functions for convenience, usually called from gdb
void pat() { void tbtr_debug_pat()
{
TemplateVehicle *tv; TemplateVehicle *tv;
FOR_ALL_TEMPLATES(tv) { FOR_ALL_TEMPLATES(tv) {
if (tv->Prev()) continue; if (tv->Prev()) continue;
ptv(tv); tbtr_debug_ptv(tv);
printf("__________\n"); printf("__________\n");
} }
} }
void pav() {
void tbtr_debug_pav()
{
Train *t; Train *t;
FOR_ALL_TRAINS(t) { FOR_ALL_TRAINS(t) {
if (t->Previous()) continue; if (t->Previous()) continue;
pvt(t); tbtr_debug_pvt(t);
printf("__________\n"); printf("__________\n");
} }
} }
void ptv(TemplateVehicle* tv) {
void tbtr_debug_ptv(TemplateVehicle* tv)
{
if (!tv) return; if (!tv) return;
while (tv->Next() ) { while (tv->Next() ) {
printf("eid:%3d st:%2d tv:%x next:%x cargo: %d cargo_sub: %d\n", tv->engine_type, tv->subtype, tv, tv->Next(), tv->cargo_type, tv->cargo_subtype); printf("eid:%3d st:%2d tv:%p next:%p cargo: %d cargo_sub: %d\n", tv->engine_type, tv->subtype, tv, tv->Next(), tv->cargo_type, tv->cargo_subtype);
tv = tv->Next(); tv = tv->Next();
} }
printf("eid:%3d st:%2d tv:%x next:%x cargo: %d cargo_sub: %d\n", tv->engine_type, tv->subtype, tv, tv->Next(), tv->cargo_type, tv->cargo_subtype); printf("eid:%3d st:%2d tv:%p next:%p cargo: %d cargo_sub: %d\n", tv->engine_type, tv->subtype, tv, tv->Next(), tv->cargo_type, tv->cargo_subtype);
} }
void pvt (const Train *printme) { void tbtr_debug_pvt (const Train *printme)
{
for (const Train *tmp = printme; tmp; tmp = tmp->Next()) { for (const Train *tmp = printme; tmp; tmp = tmp->Next()) {
if (tmp->index <= 0) { if (tmp->index <= 0) {
printf("train has weird index: %d %d %x\n", tmp->index, tmp->engine_type, (__int64)tmp); printf("train has weird index: %d %d %p\n", tmp->index, tmp->engine_type, tmp);
return; return;
} }
printf("eid:%3d index:%2d subtype:%2d vehstat: %d cargo_t: %d cargo_sub: %d ref:%x\n", tmp->engine_type, tmp->index, tmp->subtype, tmp->vehstatus, tmp->cargo_type, tmp->cargo_subtype, tmp); printf("eid:%3d index:%2d subtype:%2d vehstat: %d cargo_t: %d cargo_sub: %d ref:%p\n", tmp->engine_type, tmp->index, tmp->subtype, tmp->vehstatus, tmp->cargo_type, tmp->cargo_subtype, tmp);
} }
} }
#endif
void BuildTemplateGuiList(GUITemplateList *list, Scrollbar *vscroll, Owner oid, RailType railtype) void BuildTemplateGuiList(GUITemplateList *list, Scrollbar *vscroll, Owner oid, RailType railtype)
{ {

View File

@@ -48,11 +48,14 @@ Train* DeleteVirtualTrain(Train*, Train *);
CommandCost CmdTemplateReplaceVehicle(Train*, bool, DoCommandFlag); CommandCost CmdTemplateReplaceVehicle(Train*, bool, DoCommandFlag);
void pat(); #ifdef _DEBUG
void pav();
void ptv(TemplateVehicle*);
void pvt(const Train*);
// for testing // for testing
void tbtr_debug_pat();
void tbtr_debug_pav();
void tbtr_debug_ptv(TemplateVehicle*);
void tbtr_debug_pvt(const Train*);
#endif
TemplateVehicle* GetTemplateVehicleByGroupID(GroupID); TemplateVehicle* GetTemplateVehicleByGroupID(GroupID);
bool ChainContainsVehicle(Train*, Train*); bool ChainContainsVehicle(Train*, Train*);
Train* ChainContainsEngine(EngineID, Train*); Train* ChainContainsEngine(EngineID, Train*);