summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-01 15:07:31 +0000
committerrubidium <rubidium@openttd.org>2008-08-01 15:07:31 +0000
commitad36ea6b29f42d33e1600a131b0cbea615899272 (patch)
tree576a694ab2c4d476304db029d7a6e392d43aa596 /src
parent7c0b1172e1e793d9674f5e69cf17c1f202b99369 (diff)
downloadopenttd-ad36ea6b29f42d33e1600a131b0cbea615899272.tar.xz
(svn r13912) -Codechange: remove some casts by returning the proper type instead of void*.
Diffstat (limited to 'src')
-rw-r--r--src/rail.h4
-rw-r--r--src/rail_cmd.cpp4
-rw-r--r--src/roadveh_cmd.cpp14
-rw-r--r--src/signal.cpp20
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/train_cmd.cpp14
-rw-r--r--src/vehicle.cpp14
-rw-r--r--src/vehicle_func.h6
8 files changed, 39 insertions, 39 deletions
diff --git a/src/rail.h b/src/rail.h
index 894dd244b..f5ee6b14f 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -193,10 +193,10 @@ static inline Money RailConvertCost(RailType from, RailType to)
return RailBuildCost(to) + _price.remove_rail;
}
-void *UpdateTrainPowerProc(Vehicle *v, void *data);
+Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data);
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
-void *EnsureNoTrainOnTrackProc(Vehicle *v, void *data);
+Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data);
int TicksToLeaveDepot(const Vehicle *v);
Foundation GetRailFoundation(Slope tileh, TrackBits bits);
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 38e8cf7fe..8fa027a6d 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -92,7 +92,7 @@ const byte _track_sloped_sprites[14] = {
*/
-void *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
+Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
{
TrackBits rail_bits = *(TrackBits *)data;
@@ -1162,7 +1162,7 @@ CommandCost CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32
}
/** Update power of train under which is the railtype being converted */
-void *UpdateTrainPowerProc(Vehicle *v, void *data)
+Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
{
/* Similiar checks as in TrainPowerChanged() */
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 0da65c5cb..1bdbf9a2c 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -630,9 +630,9 @@ static void RoadVehIsCrashed(Vehicle *v)
}
}
-static void* EnumCheckRoadVehCrashTrain(Vehicle* v, void* data)
+static Vehicle *EnumCheckRoadVehCrashTrain(Vehicle *v, void *data)
{
- const Vehicle* u = (Vehicle*)data;
+ const Vehicle *u = (Vehicle*)data;
return
v->type == VEH_TRAIN &&
@@ -765,12 +765,12 @@ struct RoadVehFindData {
Direction dir;
};
-static void* EnumCheckRoadVehClose(Vehicle *v, void* data)
+static Vehicle *EnumCheckRoadVehClose(Vehicle *v, void *data)
{
static const int8 dist_x[] = { -4, -8, -4, -1, 4, 8, 4, 1 };
static const int8 dist_y[] = { -4, -1, 4, 8, 4, 1, -4, -8 };
- const RoadVehFindData* rvf = (RoadVehFindData*)data;
+ const RoadVehFindData *rvf = (RoadVehFindData*)data;
short x_diff = v->x_pos - rvf->x;
short y_diff = v->y_pos - rvf->y;
@@ -801,10 +801,10 @@ static Vehicle* RoadVehFindCloseTo(Vehicle* v, int x, int y, Direction dir)
rvf.dir = dir;
rvf.veh = v;
if (front->u.road.state == RVSB_WORMHOLE) {
- u = (Vehicle*)VehicleFromPos(v->tile, &rvf, EnumCheckRoadVehClose);
+ u = VehicleFromPos(v->tile, &rvf, EnumCheckRoadVehClose);
if (u == NULL) u = (Vehicle*)VehicleFromPos(GetOtherTunnelBridgeEnd(v->tile), &rvf, EnumCheckRoadVehClose);
} else {
- u = (Vehicle*)VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
+ u = VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
}
/* This code protects a roadvehicle from being blocked for ever
@@ -913,7 +913,7 @@ struct OvertakeData {
Trackdir trackdir;
};
-static void* EnumFindVehBlockingOvertake(Vehicle* v, void* data)
+static Vehicle *EnumFindVehBlockingOvertake(Vehicle *v, void* data)
{
const OvertakeData* od = (OvertakeData*)data;
diff --git a/src/signal.cpp b/src/signal.cpp
index f0622b7ed..1177b2ee2 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -192,7 +192,7 @@ static SmallSet<DiagDirection, SIG_GLOB_SIZE> _globset("_globset"); ///< set of
/** Check whether there is a train on rail, not in a depot */
-static void *TrainOnTileEnum(Vehicle *v, void *)
+static Vehicle *TrainOnTileEnum(Vehicle *v, void *)
{
if (v->type != VEH_TRAIN || v->u.rail.track == TRACK_BIT_DEPOT) return NULL;
@@ -284,13 +284,13 @@ static SigFlags ExploreSegment(Owner owner)
if (IsRailDepot(tile)) {
if (enterdir == INVALID_DIAGDIR) { // from 'inside' - train just entered or left the depot
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
exitdir = GetRailDepotDirection(tile);
tile += TileOffsByDiagDir(exitdir);
enterdir = ReverseDiagDir(exitdir);
break;
} else if (enterdir == GetRailDepotDirection(tile)) { // entered a depot
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
continue;
} else {
continue;
@@ -299,7 +299,7 @@ static SigFlags ExploreSegment(Owner owner)
if (GetRailTileType(tile) == RAIL_TILE_WAYPOINT) {
if (GetWaypointAxis(tile) != DiagDirToAxis(enterdir)) continue;
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
tile += TileOffsByDiagDir(exitdir);
/* enterdir and exitdir stay the same */
break;
@@ -310,10 +310,10 @@ static SigFlags ExploreSegment(Owner owner)
if (tracks == TRACK_BIT_HORZ || tracks == TRACK_BIT_VERT) { // there is exactly one incidating track, no need to check
tracks = tracks_masked;
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, &tracks, &EnsureNoTrainOnTrackProc)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, &tracks, &EnsureNoTrainOnTrackProc) != NULL) flags |= SF_TRAIN;
} else {
if (tracks_masked == TRACK_BIT_NONE) continue; // no incidating track
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
}
if (HasSignals(tile)) { // there is exactly one track - not zero, because there is exit from this tile
@@ -358,7 +358,7 @@ static SigFlags ExploreSegment(Owner owner)
if (DiagDirToAxis(enterdir) != GetRailStationAxis(tile)) continue; // different axis
if (IsStationTileBlocked(tile)) continue; // 'eye-candy' station tile
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
tile += TileOffsByDiagDir(exitdir);
break;
@@ -367,7 +367,7 @@ static SigFlags ExploreSegment(Owner owner)
if (GetTileOwner(tile) != owner) continue;
if (DiagDirToAxis(enterdir) == GetCrossingRoadAxis(tile)) continue; // different axis
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
tile += TileOffsByDiagDir(exitdir);
break;
@@ -377,13 +377,13 @@ static SigFlags ExploreSegment(Owner owner)
DiagDirection dir = GetTunnelBridgeDirection(tile);
if (enterdir == INVALID_DIAGDIR) { // incoming from the wormhole
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
enterdir = dir;
exitdir = ReverseDiagDir(dir);
tile += TileOffsByDiagDir(exitdir); // just skip to next tile
} else { // NOT incoming from the wormhole!
if (ReverseDiagDir(enterdir) != dir) continue;
- if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
+ if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL) flags |= SF_TRAIN;
tile = GetOtherTunnelBridgeEnd(tile); // just skip to exit tile
enterdir = INVALID_DIAGDIR;
exitdir = INVALID_DIAGDIR;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 95c8ae5e7..53ad81fc7 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1419,7 +1419,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
-static void *ClearRoadStopStatusEnum(Vehicle *v, void *)
+static Vehicle *ClearRoadStopStatusEnum(Vehicle *v, void *)
{
if (v->type == VEH_ROAD) ClrBit(v->u.road.state, RVS_IN_DT_ROAD_STOP);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 431ff0de1..229f70d30 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1692,7 +1692,7 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
* @param v vehicle on tile
* @return v if it is a train, NULL otherwise
*/
-static void *TrainOnTileEnum(Vehicle *v, void *)
+static Vehicle *TrainOnTileEnum(Vehicle *v, void *)
{
return (v->type == VEH_TRAIN) ? v : NULL;
}
@@ -1704,7 +1704,7 @@ static void *TrainOnTileEnum(Vehicle *v, void *)
* @param data tile with crossing we are testing
* @return v if it is approaching a crossing, NULL otherwise
*/
-static void *TrainApproachingCrossingEnum(Vehicle *v, void *data)
+static Vehicle *TrainApproachingCrossingEnum(Vehicle *v, void *data)
{
/* not a train || not front engine || crashed */
if (v->type != VEH_TRAIN || !IsFrontEngine(v) || v->vehstatus & VS_CRASHED) return NULL;
@@ -1730,14 +1730,14 @@ static Vehicle *TrainApproachingCrossing(TileIndex tile)
DiagDirection dir = AxisToDiagDir(GetCrossingRailAxis(tile));
TileIndex tile_from = tile + TileOffsByDiagDir(dir);
- Vehicle *v = (Vehicle*)VehicleFromPos(tile_from, &tile, &TrainApproachingCrossingEnum);
+ Vehicle *v = VehicleFromPos(tile_from, &tile, &TrainApproachingCrossingEnum);
if (v != NULL) return v;
dir = ReverseDiagDir(dir);
tile_from = tile + TileOffsByDiagDir(dir);
- return (Vehicle*)VehicleFromPos(tile_from, &tile, &TrainApproachingCrossingEnum);
+ return VehicleFromPos(tile_from, &tile, &TrainApproachingCrossingEnum);
}
@@ -1752,7 +1752,7 @@ void UpdateLevelCrossing(TileIndex tile, bool sound)
assert(IsLevelCrossingTile(tile));
/* train on crossing || train approaching crossing */
- bool new_state = VehicleFromPos(tile, NULL, &TrainOnTileEnum) || TrainApproachingCrossing(tile);
+ bool new_state = VehicleFromPos(tile, NULL, &TrainOnTileEnum) != NULL || TrainApproachingCrossing(tile);
if (new_state != IsCrossingBarred(tile)) {
if (new_state && sound) {
@@ -2896,7 +2896,7 @@ struct TrainCollideChecker {
uint num; ///< number of dead if train collided
};
-static void *FindTrainCollideEnum(Vehicle *v, void *data)
+static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data)
{
TrainCollideChecker *tcc = (TrainCollideChecker*)data;
@@ -2968,7 +2968,7 @@ static void CheckTrainCollision(Vehicle *v)
SndPlayVehicleFx(SND_13_BIG_CRASH, v);
}
-static void *CheckVehicleAtSignal(Vehicle *v, void *data)
+static Vehicle *CheckVehicleAtSignal(Vehicle *v, void *data)
{
DiagDirection exitdir = *(DiagDirection *)data;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 46866fa0e..18195eef2 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -156,7 +156,7 @@ StringID VehicleInTheWayErrMsg(const Vehicle* v)
}
}
-static void *EnsureNoVehicleProcZ(Vehicle *v, void *data)
+static Vehicle *EnsureNoVehicleProcZ(Vehicle *v, void *data)
{
byte z = *(byte*)data;
@@ -204,7 +204,7 @@ Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z, bool without_c
/** Procedure called for every vehicle found in tunnel/bridge in the hash map */
-static void *GetVehicleTunnelBridgeProc(Vehicle *v, void *data)
+static Vehicle *GetVehicleTunnelBridgeProc(Vehicle *v, void *data)
{
if (v->type != VEH_TRAIN && v->type != VEH_ROAD && v->type != VEH_SHIP) return NULL;
@@ -374,13 +374,13 @@ const int HASH_RES = 0;
static Vehicle *_new_vehicle_position_hash[TOTAL_HASH_SIZE];
-static void *VehicleFromHash(int xl, int yl, int xu, int yu, void *data, VehicleFromPosProc *proc)
+static Vehicle *VehicleFromHash(int xl, int yl, int xu, int yu, void *data, VehicleFromPosProc *proc)
{
for (int y = yl; ; y = (y + (1 << HASH_BITS)) & (HASH_MASK << HASH_BITS)) {
for (int x = xl; ; x = (x + 1) & HASH_MASK) {
Vehicle *v = _new_vehicle_position_hash[(x + y) & TOTAL_HASH_MASK];
for (; v != NULL; v = v->next_new_hash) {
- void *a = proc(v, data);
+ Vehicle *a = proc(v, data);
if (a != NULL) return a;
}
if (x == xu) break;
@@ -392,7 +392,7 @@ static void *VehicleFromHash(int xl, int yl, int xu, int yu, void *data, Vehicle
}
-void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
+Vehicle *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
{
const int COLL_DIST = 6;
@@ -406,7 +406,7 @@ void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc)
}
-void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
+Vehicle *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
{
int x = GB(TileX(tile), HASH_RES, HASH_BITS);
int y = GB(TileY(tile), HASH_RES, HASH_BITS) << HASH_BITS;
@@ -415,7 +415,7 @@ void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
for (; v != NULL; v = v->next_new_hash) {
if (v->tile != tile) continue;
- void *a = proc(v, data);
+ Vehicle *a = proc(v, data);
if (a != NULL) return a;
}
diff --git a/src/vehicle_func.h b/src/vehicle_func.h
index 61c941548..89862b8e7 100644
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -19,7 +19,7 @@
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
-typedef void *VehicleFromPosProc(Vehicle *v, void *data);
+typedef Vehicle *VehicleFromPosProc(Vehicle *v, void *data);
void VehicleServiceInDepot(Vehicle *v);
void VehiclePositionChanged(Vehicle *v);
@@ -28,8 +28,8 @@ const Vehicle *GetLastVehicleInChain(const Vehicle *v);
uint CountVehiclesInChain(const Vehicle *v);
bool IsEngineCountable(const Vehicle *v);
void DeleteVehicleChain(Vehicle *v);
-void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
-void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
+Vehicle *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
+Vehicle *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
void CallVehicleTicks();
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *color);