(svn r1799) -Codechange: [ Multistop ] Added debug class "ms" and more debugging
authorcelestar
Sat, 05 Feb 2005 12:10:09 +0000
changeset 1295 ae28afd6267e
parent 1294 4cdf0e76c093
child 1296 3c9e4c7fea2d
(svn r1799) -Codechange: [ Multistop ] Added debug class "ms" and more debugging
output for multistops
roadveh_cmd.c
station_cmd.c
ttd.c
variables.h
--- a/roadveh_cmd.c	Fri Feb 04 20:40:04 2005 +0000
+++ b/roadveh_cmd.c	Sat Feb 05 12:10:09 2005 +0000
@@ -1206,6 +1206,7 @@
 
 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 @@
 			//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 @@
 			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 @@
 				//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 @@
 						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 @@
 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);
--- a/station_cmd.c	Fri Feb 04 20:40:04 2005 +0000
+++ b/station_cmd.c	Sat Feb 05 12:10:09 2005 +0000
@@ -2441,7 +2441,7 @@
 					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 @@
 					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;
--- a/ttd.c	Fri Feb 04 20:40:04 2005 +0000
+++ b/ttd.c	Sat Feb 05 12:10:09 2005 +0000
@@ -468,6 +468,7 @@
 		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;
--- a/variables.h	Fri Feb 04 20:40:04 2005 +0000
+++ b/variables.h	Sat Feb 05 12:10:09 2005 +0000
@@ -459,6 +459,7 @@
 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;