Changeset - r7371:d19698ba3220
[Not reviewed]
master
0 3 0
peter1138 - 17 years ago 2007-07-30 08:49:41
peter1138@openttd.org
(svn r10734) -Fix [FS#1030]: Revert r10513) and add special cases for collision detection on bridges/tunnels.
3 files changed with 15 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -1666,19 +1666,16 @@ static bool SignalVehicleCheck(TileIndex
 
		/* check for a vehicle with that trackdir on the start tile of the tunnel */
 
		if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
 

	
 
		/* check for a vehicle with that trackdir on the end tile of the tunnel */
 
		if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
 

	
 
		/* now check all tiles from start to end for a warping vehicle
 
		 * NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? */
 
		/* now check all tiles from start to end for a warping vehicle */
 
		dest.track = 0x40;   //Vehicle inside a tunnel or on a bridge
 
		for (; tile != end; tile += TileOffsByDiagDir(direction)) {
 
			if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL)
 
				return true;
 
		}
 
		if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
 
		if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
 

	
 
		/* no vehicle found */
 
		return false;
 
	}
 

	
 
	return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL;
src/train_cmd.cpp
Show inline comments
 
@@ -2757,13 +2757,22 @@ static void CheckTrainCollision(Vehicle 
 
	TrainCollideChecker tcc;
 
	tcc.v = v;
 
	tcc.v_skip = v->next;
 
	tcc.num = 0;
 

	
 
	/* find colliding vehicles */
 
	VehicleFromPosXY(v->x_pos, v->y_pos, &tcc, FindTrainCollideEnum);
 
	if (v->u.rail.track == TRACK_BIT_WORMHOLE) {
 
		VehicleFromPos(v->tile, &tcc, FindTrainCollideEnum);
 
		if (IsBridgeTile(v->tile)) {
 
			VehicleFromPos(GetOtherBridgeEnd(v->tile), &tcc, FindTrainCollideEnum);
 
		} else {
 
			VehicleFromPos(GetOtherTunnelEnd(v->tile), &tcc, FindTrainCollideEnum);
 
		}
 
	} else {
 
		VehicleFromPosXY(v->x_pos, v->y_pos, &tcc, FindTrainCollideEnum);
 
	}
 

	
 
	/* any dead -> no crash */
 
	if (tcc.num == 0) return;
 

	
 
	SetDParam(0, tcc.num);
 
	AddNewsItem(STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL,
src/vehicle.cpp
Show inline comments
 
@@ -468,14 +468,14 @@ static void UpdateNewVehiclePosHash(Vehi
 
	Vehicle **old_hash = v->old_new_hash;
 
	Vehicle **new_hash;
 

	
 
	if (remove) {
 
		new_hash = NULL;
 
	} else {
 
		int x = GB(v->x_pos / TILE_SIZE, HASH_RES, HASH_BITS);
 
		int y = GB(v->y_pos / TILE_SIZE, HASH_RES, HASH_BITS) << HASH_BITS;
 
		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];
 
	}
 

	
 
	if (old_hash == new_hash) return;
 

	
 
	/* Remove from the old position in the hash table */
0 comments (0 inline, 0 general)