summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine.c14
-rw-r--r--engine.h2
-rw-r--r--train_cmd.c2
-rw-r--r--vehicle.c15
-rw-r--r--vehicle.h6
5 files changed, 18 insertions, 21 deletions
diff --git a/engine.c b/engine.c
index 932917624..ecd92addc 100644
--- a/engine.c
+++ b/engine.c
@@ -275,13 +275,11 @@ void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group)
_engine_custom_sprites[engine][cargo] = *group;
}
-typedef struct RealSpriteGroup *(*resolve_callback)(struct SpriteGroup *spritegroup,
- struct Vehicle *veh,
- void *callback); /* XXX data pointer used as function pointer */
+typedef struct RealSpriteGroup *(*resolve_callback)(
+ struct SpriteGroup *spritegroup, const Vehicle *veh, void *callback); /* XXX data pointer used as function pointer */
-static struct RealSpriteGroup *
-ResolveVehicleSpriteGroup(struct SpriteGroup *spritegroup, struct Vehicle *veh,
- resolve_callback callback)
+static struct RealSpriteGroup* ResolveVehicleSpriteGroup(
+ struct SpriteGroup *spritegroup, const Vehicle *veh, resolve_callback callback)
{
//debug("spgt %d", spritegroup->type);
switch (spritegroup->type) {
@@ -460,7 +458,7 @@ ResolveVehicleSpriteGroup(struct SpriteGroup *spritegroup, struct Vehicle *veh,
}
}
-static struct SpriteGroup *GetVehicleSpriteGroup(byte engine, Vehicle *v)
+static struct SpriteGroup *GetVehicleSpriteGroup(byte engine, const Vehicle *v)
{
struct SpriteGroup *group;
uint16 overriding_engine = -1;
@@ -483,7 +481,7 @@ static struct SpriteGroup *GetVehicleSpriteGroup(byte engine, Vehicle *v)
return group;
}
-int GetCustomEngineSprite(byte engine, Vehicle *v, byte direction)
+int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction)
{
struct SpriteGroup *group;
struct RealSpriteGroup *rsg;
diff --git a/engine.h b/engine.h
index c7ab673dc..9632e4272 100644
--- a/engine.h
+++ b/engine.h
@@ -99,7 +99,7 @@ extern byte _engine_original_sprites[256];
void SetWagonOverrideSprites(byte engine, struct SpriteGroup *group, byte *train_id, int trains);
void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group);
// loaded is in percents, overriding_engine 0xffff is none
-int GetCustomEngineSprite(byte engine, Vehicle *v, byte direction);
+int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction);
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
diff --git a/train_cmd.c b/train_cmd.c
index b7da037f8..409c9525b 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -281,7 +281,7 @@ void UpdateTrainAcceleration(Vehicle *v)
v->acceleration = clamp(power / weight * 4, 1, 255);
}
-int GetTrainImage(Vehicle *v, byte direction)
+int GetTrainImage(const Vehicle *v, byte direction)
{
int img = v->spritenum;
int base;
diff --git a/vehicle.c b/vehicle.c
index 1fdbd670c..9faf679e6 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -365,29 +365,28 @@ Vehicle *GetLastVehicleInChain(Vehicle *v)
return v;
}
-Vehicle *GetPrevVehicleInChain(Vehicle *v)
+Vehicle *GetPrevVehicleInChain(const Vehicle *v)
{
- Vehicle *org = v;
+ const Vehicle *org = v;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Train && org == v->next)
- return v;
+ return (Vehicle*)v;
}
return NULL;
}
-Vehicle *GetFirstVehicleInChain(Vehicle *v)
+Vehicle *GetFirstVehicleInChain(const Vehicle *v)
{
- Vehicle *u;
-
while (true) {
- u = v;
+ const Vehicle* u = v;
+
v = GetPrevVehicleInChain(v);
/* If there is no such vehicle,
'v' == NULL and so 'u' is the first vehicle in chain */
if (v == NULL)
- return u;
+ return (Vehicle*)u;
}
}
diff --git a/vehicle.h b/vehicle.h
index 94c9bcc8f..f0a8abf6c 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -262,8 +262,8 @@ void UpdateVehiclePosHash(Vehicle *v, int x, int y);
void VehiclePositionChanged(Vehicle *v);
void AfterLoadVehicles(void);
Vehicle *GetLastVehicleInChain(Vehicle *v);
-Vehicle *GetPrevVehicleInChain(Vehicle *v);
-Vehicle *GetFirstVehicleInChain(Vehicle *v);
+Vehicle *GetPrevVehicleInChain(const Vehicle *v);
+Vehicle *GetFirstVehicleInChain(const Vehicle *v);
int CountVehiclesInChain(Vehicle *v);
void DeleteVehicle(Vehicle *v);
void DeleteVehicleChain(Vehicle *v);
@@ -285,7 +285,7 @@ void TrainEnterDepot(Vehicle *v, uint tile);
void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building) ;
/* train_cmd.h */
-int GetTrainImage(Vehicle *v, byte direction);
+int GetTrainImage(const Vehicle *v, byte direction);
int GetAircraftImage(Vehicle *v, byte direction);
int GetRoadVehImage(Vehicle *v, byte direction);
int GetShipImage(Vehicle *v, byte direction);