Changeset - r1239:7c49b1991142
[Not reviewed]
master
0 2 0
celestar - 20 years ago 2005-01-30 22:04:14
celestar@openttd.org
(svn r1743) -Fix: Multistop: Added some debug output and made sure that orphaned slots are cleared.
2 files changed with 39 insertions and 2 deletions:
0 comments (0 inline, 0 general)
roadveh_cmd.c
Show inline comments
 
@@ -1470,8 +1470,8 @@ 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, 2) ("Multistop: Wrong station, force a slot clearing");
 
			ClearSlot(v, rs);
 
 			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);
 
			ClearSlot(v, v->u.road.slot);
 
		}
 

	
 
		StartRoadVehSound(v);
station_cmd.c
Show inline comments
 
@@ -2398,6 +2398,43 @@ static void StationHandleBigTick(Station
 
		if (++st->delete_ctr >= 8)
 
			DeleteStation(st);
 
	}
 

	
 
	//Here we saveguard against orphaned slots
 
	{
 
		RoadStop *rs;
 

	
 
		for (rs = GetPrimaryRoadStop(st, RS_BUS); rs != NULL; rs = rs->next) {
 
			int k;
 
			for (k = 0; k < NUM_SLOTS; k++) {
 
				if (rs->slot[k] != INVALID_SLOT) {
 
					Vehicle *v = GetVehicle(rs->slot[k]);
 

	
 
					if (v->u.road.slot != rs) {
 
						DEBUG(misc, 1) ("Bus Slot Desync! cleaning up (Don't panic)");
 
						v->u.road.slot = NULL;
 
						v->u.road.slot_age = 0;
 
						rs->slot[k] = INVALID_SLOT;
 
					}
 
				}
 
			}
 
		}
 

	
 
		for (rs = GetPrimaryRoadStop(st, RS_TRUCK); rs != NULL; rs = rs->next) {
 
			int k;
 
			for (k = 0; k < NUM_SLOTS; k++) {
 
				if (rs->slot[k] != INVALID_SLOT) {
 
					Vehicle *v = GetVehicle(rs->slot[k]);
 

	
 
					if (v->u.road.slot != rs) {
 
						DEBUG(misc, 1) ("Truck Slot Desync! cleaning up (Don't panic)");
 
						v->u.road.slot = NULL;
 
						v->u.road.slot_age = 0;
 
						rs->slot[k] = INVALID_SLOT;
 
					}
 
				}
 
			}
 
		}
 
	}
 
}
 

	
 
static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; }
0 comments (0 inline, 0 general)