summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2005-02-05 12:10:09 +0000
committercelestar <celestar@openttd.org>2005-02-05 12:10:09 +0000
commit422ebcf8e0aad014d3590b883db8a79f28fdf9d6 (patch)
tree97994e24b8d1471604bfb15cdaa87858bc54e454
parent4b71f9126e69aa1cb9c8293bc836401dfe7bdda4 (diff)
downloadopenttd-422ebcf8e0aad014d3590b883db8a79f28fdf9d6.tar.xz
(svn r1799) -Codechange: [ Multistop ] Added debug class "ms" and more debugging
output for multistops
-rw-r--r--roadveh_cmd.c12
-rw-r--r--station_cmd.c4
-rw-r--r--ttd.c1
-rw-r--r--variables.h1
4 files changed, 13 insertions, 5 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 563ccc7a3..bdeac3757 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1206,6 +1206,7 @@ static const byte _roadveh_data_2[4] = { 0,1,8,9 };
static inline void ClearSlot(Vehicle *v, RoadStop *rs)
{
+ DEBUG(ms, 3) ("Multistop: Clearing slot %d at 0x%x", v->u.road.slotindex, rs->xy);
v->u.road.slot = NULL;
v->u.road.slot_age = 0;
rs->slot[v->u.road.slotindex] = INVALID_SLOT;
@@ -1513,7 +1514,7 @@ again:
//we have arrived at the wrong station
//XXX The question is .. what to do? Actually we shouldn't be here
//but I guess we need to clear the slot
- DEBUG(misc, 1) ("Multistop: Wrong station, force a slot clearing. Vehicle %d at 0x%x, should go to 0x%x of station %d (%x), destination 0x%x", v->unitnumber, v->tile, v->u.road.slot->xy, st->index, st->xy, v->dest_tile);
+ DEBUG(ms, 1) ("Multistop: Wrong station, force a slot clearing. Vehicle %d at 0x%x, should go to 0x%x of station %d (%x), destination 0x%x", v->unitnumber, v->tile, v->u.road.slot->xy, st->index, st->xy, v->dest_tile);
ClearSlot(v, v->u.road.slot);
}
@@ -1696,6 +1697,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
if ( rs == NULL )
goto no_stop;
+ DEBUG(ms, 2) ("Multistop: Attempting to obtain a slot for vehicle %d at station %d (0x%x)", v->unitnumber, st->index, st->xy);
do {
stop->dist = 0xFFFFFFFF;
@@ -1703,6 +1705,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
//to one tile BEFORE the stop in question and doesn't
//regard the direction of the exit
stop->dist = RoadFindPathToStation(v, rs->xy);
+ DEBUG(ms, 3) ("Multistop: Distance to stop at 0x%x is %d", rs->xy, stop->dist);
stop->rs = rs;
if (stop->dist < mindist) {
@@ -1724,6 +1727,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
if ((stop->rs->slot[i] == INVALID_SLOT) && (stop->dist < 120)) {
//Hooray we found a free slot. Assign it
+ DEBUG(ms, 1) ("Multistop: Slot %d at 0x%x assigned to vehicle %d", i, stop->rs->xy, v->unitnumber);
stop->rs->slot[i] = v->index;
v->u.road.slot = stop->rs;
@@ -1742,8 +1746,10 @@ void OnNewDay_RoadVeh(Vehicle *v)
have_slot:
//now we couldn't assign a slot for one reason or another.
//so we just go to the nearest station
- if (v->u.road.slot == NULL)
- v->dest_tile = firststop->rs->xy;
+ if (v->u.road.slot == NULL) {
+ DEBUG(ms, 1) ("Multistop: No free slot found for vehicle %d, going to default station", v->unitnumber);
+ v->dest_tile = firststop->rs->xy;
+ }
}
free(firststop);
diff --git a/station_cmd.c b/station_cmd.c
index 8290a5bb8..587c6acf4 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2441,7 +2441,7 @@ static void StationHandleBigTick(Station *st)
Vehicle *v = GetVehicle(rs->slot[k]);
if (v->u.road.slot != rs) {
- DEBUG(misc, 1) ("Bus Slot Desync! cleaning up (Don't panic)");
+ DEBUG(ms, 0) ("Multistop: Bus Slot Desync! cleaning up (Don't panic)");
v->u.road.slot = NULL;
v->u.road.slot_age = 0;
rs->slot[k] = INVALID_SLOT;
@@ -2457,7 +2457,7 @@ static void StationHandleBigTick(Station *st)
Vehicle *v = GetVehicle(rs->slot[k]);
if (v->u.road.slot != rs) {
- DEBUG(misc, 1) ("Truck Slot Desync! cleaning up (Don't panic)");
+ DEBUG(ms, 0) ("Multistop: Truck Slot Desync! cleaning up (Don't panic)");
v->u.road.slot = NULL;
v->u.road.slot_age = 0;
rs->slot[k] = INVALID_SLOT;
diff --git a/ttd.c b/ttd.c
index 789a68b41..cd7faef4b 100644
--- a/ttd.c
+++ b/ttd.c
@@ -468,6 +468,7 @@ void SetDebugString(const char *s)
else if IS_LVL("ai") p = &_debug_ai_level;
else if IS_LVL("net") p = &_debug_net_level;
else if IS_LVL("map") p = &_debug_map_level;
+ else if IS_LVL("ms") p = &_debug_ms_level;
else {
ShowInfoF("Unknown debug level '%.*s'", s-t, t);
return;
diff --git a/variables.h b/variables.h
index 69fab868b..c28105e5f 100644
--- a/variables.h
+++ b/variables.h
@@ -459,6 +459,7 @@ VARDEF int _debug_grf_level;
VARDEF int _debug_ai_level;
VARDEF int _debug_net_level;
VARDEF int _debug_map_level;
+VARDEF int _debug_ms_level;
/* Forking stuff */
VARDEF bool _dedicated_forks;