Changeset - r14689:0182d3477904
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2010-02-27 19:53:37
alberth@openttd.org
(svn r19282) -Doc: Add some doxygen doc markup.
1 file changed with 22 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -215,23 +215,32 @@ void ShowNewGrfVehicleError(EngineID eng
 

	
 
	SetDParam(1, engine);
 
	GetString(buffer, part2, lastof(buffer));
 
	DEBUG(grf, 0, "%s", buffer + 3);
 
}
 

	
 
/** Callback that returns 'real' vehicles lower or at height \c *(byte*)data .
 
 * @param v Vehicle to examine.
 
 * @param data Pointer to height data.
 
 * @return \a v if conditions are met, else \c NULL.
 
 */
 
static Vehicle *EnsureNoVehicleProcZ(Vehicle *v, void *data)
 
{
 
	byte z = *(byte*)data;
 

	
 
	if (v->type == VEH_DISASTER || (v->type == VEH_AIRCRAFT && v->subtype == AIR_SHADOW)) return NULL;
 
	if (v->z_pos > z) return NULL;
 

	
 
	_error_message = STR_ERROR_TRAIN_IN_THE_WAY + v->type;
 
	return v;
 
}
 

	
 
/* Ensure there is no vehicle at the ground at the given position.
 
 * @param tile Position to examine.
 
 * @return A vehicle has been found.
 
 */
 
bool EnsureNoVehicleOnGround(TileIndex tile)
 
{
 
	byte z = GetTileMaxZ(tile);
 
	return !HasVehicleOnPos(tile, &z, &EnsureNoVehicleProcZ);
 
}
 

	
 
@@ -255,13 +264,16 @@ static Vehicle *GetVehicleTunnelBridgePr
 
bool HasVehicleOnTunnelBridge(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
 
{
 
	return HasVehicleOnPos(tile, (void *)ignore, &GetVehicleTunnelBridgeProc) ||
 
			HasVehicleOnPos(endtile, (void *)ignore, &GetVehicleTunnelBridgeProc);
 
}
 

	
 

	
 
/**
 
 * Vehicle constructor.
 
 * @param type Type of the new vehicle.
 
 */
 
Vehicle::Vehicle(VehicleType type)
 
{
 
	this->type               = type;
 
	this->coord.left         = INVALID_COORD;
 
	this->group_id           = DEFAULT_GROUP;
 
	this->fill_percent_te_id = INVALID_TE_ID;
 
@@ -370,13 +382,13 @@ bool HasVehicleOnPosXY(int x, int y, voi
 
}
 

	
 
/**
 
 * Helper function for FindVehicleOnPos/HasVehicleOnPos.
 
 * @note Do not call this function directly!
 
 * @param tile The location on the map
 
 * @param data Arbitrary data passed to proc
 
 * @param data Arbitrary data passed to \a proc.
 
 * @param proc The proc that determines whether a vehicle will be "found".
 
 * @param find_first Whether to return on the first found or iterate over
 
 *                   all vehicles
 
 * @return the best matching or first vehicle (depending on find_first).
 
 */
 
static Vehicle *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc, bool find_first)
 
@@ -393,37 +405,37 @@ static Vehicle *VehicleFromPos(TileIndex
 
	}
 

	
 
	return NULL;
 
}
 

	
 
/**
 
 * Find a vehicle from a specific location. It will call proc for ALL vehicles
 
 * Find a vehicle from a specific location. It will call \a proc for ALL vehicles
 
 * on the tile and YOU must make SURE that the "best one" is stored in the
 
 * data value and is ALWAYS the same regardless of the order of the vehicles
 
 * where proc was called on!
 
 * When you fail to do this properly you create an almost untraceable DESYNC!
 
 * @note The return value of proc will be ignored.
 
 * @note Use this when you have the intention that all vehicles
 
 * @note The return value of \a proc will be ignored.
 
 * @note Use this function when you have the intention that all vehicles
 
 *       should be iterated over.
 
 * @param tile The location on the map
 
 * @param data Arbitrary data passed to proc
 
 * @param data Arbitrary data passed to \a proc.
 
 * @param proc The proc that determines whether a vehicle will be "found".
 
 */
 
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
 
{
 
	VehicleFromPos(tile, data, proc, false);
 
}
 

	
 
/**
 
 * Checks whether a vehicle in on a specific location. It will call proc for
 
 * Checks whether a vehicle is on a specific location. It will call \a proc for
 
 * vehicles until it returns non-NULL.
 
 * @note Use FindVehicleOnPos when you have the intention that all vehicles
 
 * @note Use #FindVehicleOnPos when you have the intention that all vehicles
 
 *       should be iterated over.
 
 * @param tile The location on the map
 
 * @param data Arbitrary data passed to proc
 
 * @param proc The proc that determines whether a vehicle will be "found".
 
 * @param data Arbitrary data passed to \a proc.
 
 * @param proc The \a proc that determines whether a vehicle will be "found".
 
 * @return True if proc returned non-NULL.
 
 */
 
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
 
{
 
	return VehicleFromPos(tile, data, proc, true) != NULL;
 
}
0 comments (0 inline, 0 general)