Changeset - r6886:196d4023e490
[Not reviewed]
master
0 1 0
peter1138 - 17 years ago 2007-06-13 07:14:42
peter1138@openttd.org
(svn r10129) -Fix (r10111): Test for x == INVALID_COORD instead of v->tile == INVALID_TILE to determine if a vehicle should be removed from the has.
1 file changed with 3 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -453,18 +453,18 @@ void *VehicleFromPos(TileIndex tile, voi
 
		if (a != NULL) return a;
 
	}
 

	
 
	return NULL;
 
}
 

	
 
static void UpdateNewVehiclePosHash(Vehicle *v)
 
static void UpdateNewVehiclePosHash(Vehicle *v, bool remove)
 
{
 
	Vehicle **old_hash = v->old_new_hash;
 
	Vehicle **new_hash;
 

	
 
	if (v->tile == INVALID_TILE || v->tile == 0) {
 
	if (remove) {
 
		new_hash = NULL;
 
	} else {
 
		int x = GB(TileX(v->tile), HASH_RES, HASH_BITS);
 
		int y = GB(TileY(v->tile), HASH_RES, HASH_BITS) << HASH_BITS;
 
		new_hash = &_new_vehicle_position_hash[(x + y) & TOTAL_HASH_MASK];
 
	}
 
@@ -500,13 +500,13 @@ static void UpdateNewVehiclePosHash(Vehi
 
}
 

	
 
static Vehicle *_vehicle_position_hash[0x1000];
 

	
 
static void UpdateVehiclePosHash(Vehicle* v, int x, int y)
 
{
 
	UpdateNewVehiclePosHash(v);
 
	UpdateNewVehiclePosHash(v, x == INVALID_COORD);
 

	
 
	Vehicle **old_hash, **new_hash;
 
	int old_x = v->left_coord;
 
	int old_y = v->top_coord;
 

	
 
	new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x, y)];
 
@@ -684,13 +684,12 @@ void DestroyVehicle(Vehicle *v)
 
	if (v->type == VEH_ROAD) ClearSlot(v);
 

	
 
	if (v->type != VEH_TRAIN || (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v)))) {
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
	}
 

	
 
	v->tile = INVALID_TILE;
 
	UpdateVehiclePosHash(v, INVALID_COORD, 0);
 
	v->next_hash = NULL;
 
	v->next_new_hash = NULL;
 
	if (IsPlayerBuildableVehicleType(v)) DeleteVehicleOrders(v);
 

	
 
	/* Now remove any artic part. This will trigger an other
0 comments (0 inline, 0 general)