summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/ai_info.cpp4
-rw-r--r--src/ai/api/ai_vehicle.cpp14
-rw-r--r--src/aircraft_gui.cpp2
-rw-r--r--src/articulated_vehicles.cpp4
-rw-r--r--src/depot_gui.cpp10
-rw-r--r--src/driver.cpp2
-rw-r--r--src/driver.h2
-rw-r--r--src/fileio.cpp2
-rw-r--r--src/gfxinit.cpp3
-rw-r--r--src/newgrf.cpp8
-rw-r--r--src/newgrf_engine.cpp12
-rw-r--r--src/newgrf_spritegroup.cpp6
-rw-r--r--src/npf.cpp4
-rw-r--r--src/openttd.cpp10
-rw-r--r--src/roadveh_gui.cpp2
-rw-r--r--src/screenshot.cpp10
-rw-r--r--src/settings.cpp2
-rw-r--r--src/spritecache.cpp4
-rw-r--r--src/spritecache.h2
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/string_func.h6
-rw-r--r--src/strings.cpp22
-rw-r--r--src/train_cmd.cpp8
-rw-r--r--src/train_gui.cpp6
-rw-r--r--src/vehicle.cpp6
-rw-r--r--src/vehicle_cmd.cpp4
-rw-r--r--src/vehicle_gui.cpp16
-rw-r--r--src/vehiclelist.cpp2
-rw-r--r--src/yapf/follow_track.hpp8
-rw-r--r--src/yapf/yapf_costrail.hpp4
-rw-r--r--src/yapf/yapf_destrail.hpp8
-rw-r--r--src/yapf/yapf_rail.cpp12
-rw-r--r--src/yapf/yapf_road.cpp10
33 files changed, 108 insertions, 109 deletions
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index da9522d8d..2e6b052de 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -106,8 +106,8 @@ AIInfo::~AIInfo()
{
/* Free all allocated strings */
for (AIConfigItemList::iterator it = this->config_list.begin(); it != this->config_list.end(); it++) {
- free((char *)(*it).name);
- free((char *)(*it).description);
+ free((void*)(*it).name);
+ free((void*)(*it).description);
if (it->labels != NULL) {
for (LabelMapping::iterator it2 = (*it).labels->Begin(); it2 != (*it).labels->End(); it2++) {
free(it2->second);
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index 6df24b875..fb6c8abdc 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -45,11 +45,11 @@
case VEH_ROAD: {
uint total_length = 0;
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
- total_length += ((RoadVehicle*)u)->rcache.cached_veh_length;
+ total_length += ((const RoadVehicle *)u)->rcache.cached_veh_length;
}
return total_length;
}
- case VEH_TRAIN: return ((Train *)v)->tcache.cached_total_length;
+ case VEH_TRAIN: return ((const Train *)v)->tcache.cached_total_length;
default: return -1;
}
}
@@ -85,11 +85,11 @@
EnforcePrecondition(false, ::Vehicle::Get(source_vehicle_id)->type == VEH_TRAIN);
EnforcePrecondition(false, dest_vehicle_id == -1 || ::Vehicle::Get(dest_vehicle_id)->type == VEH_TRAIN);
- const Train *v = (Train *)::Vehicle::Get(source_vehicle_id);
+ const Train *v = (const Train *)::Vehicle::Get(source_vehicle_id);
while (source_wagon-- > 0) v = GetNextUnit(v);
const Train *w = NULL;
if (dest_vehicle_id != -1) {
- w = (Train *)::Vehicle::Get(dest_vehicle_id);
+ w = (const Train *)::Vehicle::Get(dest_vehicle_id);
while (dest_wagon-- > 0) w = GetNextUnit(w);
}
@@ -136,7 +136,7 @@
EnforcePrecondition(false, IsValidVehicle(vehicle_id) && wagon < GetNumWagons(vehicle_id));
EnforcePrecondition(false, ::Vehicle::Get(vehicle_id)->type == VEH_TRAIN);
- const Train *v = (Train *)::Vehicle::Get(vehicle_id);
+ const Train *v = (const Train *)::Vehicle::Get(vehicle_id);
while (wagon-- > 0) v = GetNextUnit(v);
return AIObject::DoCommand(0, v->index, sell_attached_wagons ? 1 : 0, CMD_SELL_RAIL_WAGON);
@@ -243,7 +243,7 @@
const Vehicle *v = ::Vehicle::Get(vehicle_id);
if (v->type == VEH_TRAIN) {
- while (wagon-- > 0) v = GetNextUnit((Train *)v);
+ while (wagon-- > 0) v = GetNextUnit((const Train *)v);
}
return v->engine_type;
}
@@ -281,7 +281,7 @@
const Vehicle *v = ::Vehicle::Get(vehicle_id);
if (v->type == VEH_TRAIN) {
- while (wagon-- > 0) v = GetNextUnit((Train *)v);
+ while (wagon-- > 0) v = GetNextUnit((const Train *)v);
}
return v->age;
}
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index e06f7a355..f2c0bf771 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -67,7 +67,7 @@ void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
DrawSprite(v->GetImage(DIR_W), pal, x + 25, y + 10);
if (v->subtype == AIR_HELICOPTER) {
- Aircraft *a = (Aircraft *)v;
+ const Aircraft *a = (const Aircraft *)v;
SpriteID rotor_sprite = GetCustomRotorSprite(a, true);
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
DrawSprite(rotor_sprite, PAL_NONE, x + 25, y + 5);
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index e06d6a217..4aabc955e 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -208,7 +208,7 @@ bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *carg
switch (v->type) {
case VEH_TRAIN:
- v = (EngineHasArticPart((Train *)v) ? GetNextArticPart((Train *)v) : NULL);
+ v = (EngineHasArticPart((const Train *)v) ? GetNextArticPart((const Train *)v) : NULL);
break;
case VEH_ROAD:
@@ -256,7 +256,7 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
switch (v->type) {
case VEH_TRAIN:
- v = (EngineHasArticPart((Train *)v) ? GetNextArticPart((Train *)v) : NULL);
+ v = (EngineHasArticPart((const Train *)v) ? GetNextArticPart((const Train *)v) : NULL);
break;
case VEH_ROAD:
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 98d771830..512254c12 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -272,7 +272,7 @@ struct DepotWindow : Window {
DrawTrainImage(v, x + 21, sprite_y, this->sel, this->hscroll.cap + 4, this->hscroll.pos);
/* Number of wagons relative to a standard length wagon (rounded up) */
- SetDParam(0, (((Train *)v)->tcache.cached_total_length + 7) / 8);
+ SetDParam(0, (((const Train *)v)->tcache.cached_total_length + 7) / 8);
DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING, SA_RIGHT); // Draw the counter
break;
@@ -328,7 +328,7 @@ struct DepotWindow : Window {
hnum = 8;
for (uint num = 0; num < this->vehicle_list.Length(); num++) {
const Vehicle *v = this->vehicle_list[num];
- hnum = max(hnum, ((Train *)v)->tcache.cached_total_length);
+ hnum = max(hnum, ((const Train *)v)->tcache.cached_total_length);
}
/* Always have 1 empty row, so people can change the setting of the train */
SetVScrollCount(w, this->vehicle_list.Length() + this->wagon_list.Length() + 1);
@@ -450,7 +450,7 @@ struct DepotWindow : Window {
x += skip;
/* find the vehicle in this row that was clicked */
- while (v != NULL && (x -= ((Train *)v)->tcache.cached_veh_length) >= 0) v = v->Next();
+ while (v != NULL && (x -= ((const Train *)v)->tcache.cached_veh_length) >= 0) v = v->Next();
/* if an articulated part was selected, find its parent */
while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
@@ -514,11 +514,11 @@ struct DepotWindow : Window {
switch (v->type) {
case VEH_TRAIN:
- _cursor.short_vehicle_offset = 16 - ((Train *)v)->tcache.cached_veh_length * 2;
+ _cursor.short_vehicle_offset = 16 - ((const Train *)v)->tcache.cached_veh_length * 2;
break;
case VEH_ROAD:
- _cursor.short_vehicle_offset = 16 - ((RoadVehicle *)v)->rcache.cached_veh_length * 2;
+ _cursor.short_vehicle_offset = 16 - ((const RoadVehicle *)v)->rcache.cached_veh_length * 2;
break;
default:
diff --git a/src/driver.cpp b/src/driver.cpp
index 5d5a86cd9..1feffcc54 100644
--- a/src/driver.cpp
+++ b/src/driver.cpp
@@ -56,7 +56,7 @@ int GetDriverParamInt(const char * const *parm, const char *name, int def)
* @param name the driver to select.
* @post Sets the driver so GetCurrentDriver() returns it too.
*/
-const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
+Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
{
if (GetDrivers().size() == 0) return NULL;
diff --git a/src/driver.h b/src/driver.h
index b2a359b97..d4f520e66 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -80,7 +80,7 @@ public:
}
}
- static const Driver *SelectDriver(const char *name, Driver::Type type);
+ static Driver *SelectDriver(const char *name, Driver::Type type);
static char *GetDriversInfo(char *p, const char *last);
/**
diff --git a/src/fileio.cpp b/src/fileio.cpp
index ff165d6f6..154bd6c9e 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -862,7 +862,7 @@ void DetermineBasePaths(const char *exe)
#endif
/* Change the working directory to that one of the executable */
- ChangeWorkingDirectory((char*)exe);
+ ChangeWorkingDirectory(exe);
if (getcwd(tmp, MAX_PATH) == NULL) *tmp = '\0';
AppendPathSeparator(tmp, MAX_PATH);
_searchpaths[SP_BINARY_DIR] = strdup(tmp);
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 9619b4e87..0554eee9b 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -378,8 +378,7 @@ static bool FillGraphicsSetDetails(GraphicsSet *graphics, IniFile *ini, const ch
}
const char *filename = item->value;
- file->filename = MallocT<char>(strlen(filename) + strlen(path) + 1);
- sprintf((char*)file->filename, "%s%s", path, filename);
+ file->filename = str_fmt("%s%s", path, filename);
/* Then find the MD5 checksum */
item = md5s->GetItem(filename, false);
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d54ed27eb..a510f2daa 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2247,7 +2247,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
IndustryTileTable **tile_table = CallocT<IndustryTileTable*>(indsp->num_table); // Table with tiles to compose an industry
IndustryTileTable *itt = CallocT<IndustryTileTable>(defsize); // Temporary array to read the tile layouts from the GRF
int size;
- IndustryTileTable *copy_from;
+ const IndustryTileTable *copy_from;
for (byte j = 0; j < indsp->num_table; j++) {
for (int k = 0;; k++) {
@@ -2258,7 +2258,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
IndustryType type = grf_load_byte(&buf); // industry holding required layout
byte laynbr = grf_load_byte(&buf); // layout number to borrow
- copy_from = (IndustryTileTable*)_origin_industry_specs[type].table[laynbr];
+ copy_from = _origin_industry_specs[type].table[laynbr];
for (size = 1;; size++) {
if (copy_from[size - 1].ti.x == -0x80 && copy_from[size - 1].ti.y == 0) break;
}
@@ -5455,11 +5455,11 @@ static void ResetCustomIndustries()
for (int j = 0; j < ind->num_table; j++) {
/* remove the individual layouts */
if (ind->table[j] != NULL) {
- free((IndustryTileTable*)ind->table[j]);
+ free((void*)ind->table[j]);
}
}
/* remove the layouts pointers */
- free((IndustryTileTable**)ind->table);
+ free((void*)ind->table);
ind->table = NULL;
}
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 087877058..60529f09c 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -434,9 +434,9 @@ static uint8 LiveryHelper(EngineID engine, const Vehicle *v)
if (!Company::IsValidID(_current_company)) return 0;
l = GetEngineLivery(engine, _current_company, INVALID_ENGINE, NULL);
} else if (v->type == VEH_TRAIN) {
- l = GetEngineLivery(v->engine_type, v->owner, ((Train *)v)->tcache.first_engine, v);
+ l = GetEngineLivery(v->engine_type, v->owner, ((const Train *)v)->tcache.first_engine, v);
} else if (v->type == VEH_ROAD) {
- l = GetEngineLivery(v->engine_type, v->owner, ((RoadVehicle *)v)->rcache.first_engine, v);
+ l = GetEngineLivery(v->engine_type, v->owner, ((const RoadVehicle *)v)->rcache.first_engine, v);
} else {
l = GetEngineLivery(v->engine_type, v->owner, INVALID_ENGINE, v);
}
@@ -536,7 +536,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
memset(common_subtypes, 0, sizeof(common_subtypes));
for (u = v; u != NULL; u = u->Next()) {
- if (v->type == VEH_TRAIN) user_def_data |= ((Train *)u)->tcache.user_def_data;
+ if (v->type == VEH_TRAIN) user_def_data |= ((const Train *)u)->tcache.user_def_data;
/* Skip empty engines */
if (u->cargo_cap == 0) continue;
@@ -886,10 +886,10 @@ static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *
/* We always use cached value, except for callbacks because the override spriteset
* to use may be different than the one cached. It happens for callback 0x15 (refit engine),
* as v->cargo_type is temporary changed to the new type */
- group = use_cache ? ((Train *)v)->tcache.cached_override : GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, ((Train *)v)->tcache.first_engine);
+ group = use_cache ? ((const Train *)v)->tcache.cached_override : GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, ((const Train *)v)->tcache.first_engine);
if (group != NULL) return group;
} else if (v->type == VEH_ROAD) {
- group = GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, ((RoadVehicle *)v)->rcache.first_engine);
+ group = GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, ((const RoadVehicle *)v)->rcache.first_engine);
if (group != NULL) return group;
}
}
@@ -952,7 +952,7 @@ SpriteID GetRotorOverrideSprite(EngineID engine, const Aircraft *v, bool info_vi
bool UsesWagonOverride(const Vehicle *v)
{
assert(v->type == VEH_TRAIN);
- return ((Train *)v)->tcache.cached_override != NULL;
+ return ((const Train *)v)->tcache.cached_override != NULL;
}
/**
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index f6dc2aa13..a2dc720e6 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -13,8 +13,8 @@ INSTANTIATE_POOL_METHODS(SpriteGroup)
RealSpriteGroup::~RealSpriteGroup()
{
- free((SpriteGroup**)this->loaded);
- free((SpriteGroup**)this->loading);
+ free((void*)this->loaded);
+ free((void*)this->loading);
}
DeterministicSpriteGroup::~DeterministicSpriteGroup()
@@ -25,7 +25,7 @@ DeterministicSpriteGroup::~DeterministicSpriteGroup()
RandomizedSpriteGroup::~RandomizedSpriteGroup()
{
- free((SpriteGroup**)this->groups);
+ free((void*)this->groups);
}
TileLayoutSpriteGroup::~TileLayoutSpriteGroup()
diff --git a/src/npf.cpp b/src/npf.cpp
index 65e3faa66..dbd9875ed 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -425,7 +425,7 @@ static int32 NPFFindDepot(AyStar *as, OpenListNode *current)
/** Find any safe and free tile. */
static int32 NPFFindSafeTile(AyStar *as, OpenListNode *current)
{
- const Train *v = (Train *)((NPFFindStationOrTileData*)as->user_target)->v;
+ const Train *v = (const Train *)((NPFFindStationOrTileData*)as->user_target)->v;
return
IsSafeWaitingPosition(v, current->path.node.tile, current->path.node.direction, true, _settings_game.pf.forbid_90_deg) &&
@@ -506,7 +506,7 @@ static void NPFSaveTargetData(AyStar *as, OpenListNode *current)
if (as->user_target != NULL && ((NPFFindStationOrTileData*)as->user_target)->reserve_path && as->user_data[NPF_TYPE] == TRANSPORT_RAIL) {
/* Path reservation is requested. */
- const Train *v = (Train *)((NPFFindStationOrTileData*)as->user_target)->v;
+ const Train *v = (const Train *)((NPFFindStationOrTileData*)as->user_target)->v;
const PathNode *target = FindSafePosition(&current->path, v);
ftd->node = target->node;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index a357d9803..3504bb76d 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -206,7 +206,7 @@ struct MyGetOptData {
int numleft;
char **argv;
const char *options;
- const char *cont;
+ char *cont;
MyGetOptData(int argc, char **argv, const char *options)
{
@@ -220,9 +220,7 @@ struct MyGetOptData {
static int MyGetOpt(MyGetOptData *md)
{
- const char *s, *r, *t;
-
- s = md->cont;
+ char *s = md->cont;
if (s != NULL)
goto md_continue_here;
@@ -234,12 +232,14 @@ static int MyGetOpt(MyGetOptData *md)
md_continue_here:;
s++;
if (*s != 0) {
+ const char *r;
/* Found argument, try to locate it in options. */
if (*s == ':' || (r = strchr(md->options, *s)) == NULL) {
/* ERROR! */
return -2;
}
if (r[1] == ':') {
+ char *t;
/* Item wants an argument. Check if the argument follows, or if it comes as a separate arg. */
if (!*(t = s + 1)) {
/* It comes as a separate arg. Check if out of args? */
@@ -253,7 +253,7 @@ md_continue_here:;
md->argv++;
}
}
- md->opt = (char*)t;
+ md->opt = t;
md->cont = NULL;
return *s;
}
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 5d0f950f2..09ebd1fc9 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -130,7 +130,7 @@ void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int c
int highlight_w = 0;
for (int dx = 0; v != NULL && dx < max_length ; v = v->Next()) {
- int width = ((RoadVehicle *)v)->rcache.cached_veh_length;
+ int width = ((const RoadVehicle *)v)->rcache.cached_veh_length;
if (dx + width > 0 && dx <= max_length) {
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 17b18993e..ae7bac0df 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -26,7 +26,7 @@ ScreenshotType current_screenshot_type;
/* called by the ScreenShot proc to generate screenshot lines. */
typedef void ScreenshotCallback(void *userdata, void *buf, uint y, uint pitch, uint n);
-typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette);
+typedef bool ScreenshotHandlerProc(char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette);
struct ScreenshotFormat {
const char *name;
@@ -67,7 +67,7 @@ struct RgbQuad {
assert_compile(sizeof(RgbQuad) == 4);
/* generic .BMP writer */
-static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
+static bool MakeBmpImage(char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
{
BitmapFileHeader bfh;
BitmapInfoHeader bih;
@@ -170,7 +170,7 @@ static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
}
-static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
+static bool MakePNGImage(char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
{
png_color rq[256];
FILE *f;
@@ -186,7 +186,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
f = fopen(name, "wb");
if (f == NULL) return false;
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (char *)name, png_my_error, png_my_warning);
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, name, png_my_error, png_my_warning);
if (png_ptr == NULL) {
fclose(f);
@@ -299,7 +299,7 @@ struct PcxHeader {
};
assert_compile(sizeof(PcxHeader) == 128);
-static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
+static bool MakePCXImage(char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
{
FILE *f;
uint maxlines;
diff --git a/src/settings.cpp b/src/settings.cpp
index b5fc8db82..4a1c0e042 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -214,7 +214,7 @@ static bool load_intlist(const char *str, void *array, int nelems, VarType type)
static void make_intlist(char *buf, const char *last, const void *array, int nelems, VarType type)
{
int i, v = 0;
- const byte *p = (const byte*)array;
+ byte *p = (byte*)array;
for (i = 0; i != nelems; i++) {
switch (type) {
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 1470522d2..1be68f681 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -489,7 +489,7 @@ void *AllocSprite(size_t mem_req)
* @param available available sprite type
* @return fallback sprite
* @note this function will do usererror() in the case the fallback sprite isn't available */
-static const void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, SpriteCache *sc)
+static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, SpriteCache *sc)
{
static const char *sprite_types[] = {
"normal", // ST_NORMAL
@@ -525,7 +525,7 @@ static const void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType reques
}
}
-const void *GetRawSprite(SpriteID sprite, SpriteType type)
+void *GetRawSprite(SpriteID sprite, SpriteType type)
{
assert(IsMapgenSpriteID(sprite) == (type == ST_MAPGEN));
assert(type < ST_INVALID);
diff --git a/src/spritecache.h b/src/spritecache.h
index 76f1073cb..a8d0ce144 100644
--- a/src/spritecache.h
+++ b/src/spritecache.h
@@ -17,7 +17,7 @@ struct Sprite {
extern uint _sprite_cache_size;
-const void *GetRawSprite(SpriteID sprite, SpriteType type);
+void *GetRawSprite(SpriteID sprite, SpriteType type);
bool SpriteExists(SpriteID sprite);
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 5e66232dc..85fdde83f 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1968,7 +1968,7 @@ static CommandCost RemoveAirport(Station *st, DoCommandFlag flags)
FOR_ALL_VEHICLES(v) {
if (!(v->type == VEH_AIRCRAFT && IsNormalAircraft(v))) continue;
- Aircraft *a = (Aircraft *)v;
+ const Aircraft *a = (const Aircraft *)v;
if (a->targetairport == st->index && a->state != FLYING) return CMD_ERROR;
}
diff --git a/src/string_func.h b/src/string_func.h
index 10203047b..fbf532b7a 100644
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -208,11 +208,11 @@ static inline bool IsUtf8Part(char c)
* @note The function should not be used to determine the length of the previous
* encoded char because it might be an invalid/corrupt start-sequence
*/
-static inline char *Utf8PrevChar(const char *s)
+static inline char *Utf8PrevChar(char *s)
{
- const char *ret = s;
+ char *ret = s;
while (IsUtf8Part(*--ret)) {}
- return (char*)ret;
+ return ret;
}
diff --git a/src/strings.cpp b/src/strings.cpp
index 8b2c4e3a3..3adcc949d 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -40,9 +40,9 @@ uint64 _decode_parameters[20];
static char *StationGetSpecialString(char *buff, int x, const char *last);
static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char *last);
-static char *GetSpecialNameString(char *buff, int ind, const int64 *argv, const char *last);
+static char *GetSpecialNameString(char *buff, int ind, int64 *argv, const char *last);
-static char *FormatString(char *buff, const char *str, const int64 *argv, uint casei, const char *last);
+static char *FormatString(char *buff, const char *str, int64 *argv, uint casei, const char *last);
struct LanguagePack : public LanguagePackHeader {
char data[VARARRAY_SIZE]; // list of strings
@@ -55,22 +55,22 @@ static uint _langtab_start[32]; // Offset into langpack offs
/** Read an int64 from the argv array. */
-static inline int64 GetInt64(const int64 **argv)
+static inline int64 GetInt64(int64 **argv)
{
assert(argv);
return *(*argv)++;
}
/** Read an int32 from the argv array. */
-static inline int32 GetInt32(const int64 **argv)
+static inline int32 GetInt32(int64 **argv)
{
return (int32)GetInt64(argv);
}
/** Read an array from the argv array. */
-static inline const int64 *GetArgvPtr(const int64 **argv, int n)
+static inline int64 *GetArgvPtr(int64 **argv, int n)
{
- const int64 *result;
+ int64 *result;
assert(*argv);
result = *argv;
(*argv) += n;
@@ -98,7 +98,7 @@ const char *GetStringPtr(StringID string)
* @param last
* @return a formatted string of char
*/
-static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, const char *last)
+static char *GetStringWithArgs(char *buffr, uint string, int64 *argv, const char *last)
{
if (GB(string, 0, 16) == 0) return GetStringWithArgs(buffr, STR_UNDEFINED, argv, last);
@@ -517,16 +517,16 @@ uint ConvertDisplaySpeedToSpeed(uint speed)
return ((speed << units[_settings_game.locale.units].s_s) + units[_settings_game.locale.units].s_m / 2) / units[_settings_game.locale.units].s_m;
}
-static char *FormatString(char *buff, const char *str, const int64 *argv, uint casei, const char *last)
+static char *FormatString(char *buff, const char *str, int64 *argv, uint casei, const char *last)
{
WChar b;
- const int64 *argv_orig = argv;
+ int64 *argv_orig = argv;
uint modifier = 0;
while ((b = Utf8Consume(&str)) != '\0') {
if (SCC_NEWGRF_FIRST <= b && b <= SCC_NEWGRF_LAST) {
/* We need to pass some stuff as it might be modified; oh boy. */
- b = RemapNewGRFStringControlCode(b, &buff, &str, (int64*)argv);
+ b = RemapNewGRFStringControlCode(b, &buff, &str, argv);
if (b == 0) continue;
}
@@ -1177,7 +1177,7 @@ static char *GenPresidentName(char *buff, uint32 x, const char *last)
return buff;
}
-static char *GetSpecialNameString(char *buff, int ind, const int64 *argv, const char *last)
+static char *GetSpecialNameString(char *buff, int ind, int64 *argv, const char *last)
{
switch (ind) {
case 1: // not used
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 481064abf..8f635b0db 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -189,7 +189,7 @@ void CheckTrainsLengths()
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && v->First() == v && !(v->vehstatus & VS_CRASHED)) {
- for (const Train *u = (Train *)v, *w = (Train *)v->Next(); w != NULL; u = w, w = w->Next()) {
+ for (const Train *u = (const Train *)v, *w = (const Train *)v->Next(); w != NULL; u = w, w = w->Next()) {
if (u->track != TRACK_BIT_DEPOT) {
if ((w->track != TRACK_BIT_DEPOT &&
max(abs(u->x_pos - w->x_pos), abs(u->y_pos - w->y_pos)) != u->tcache.cached_veh_length) ||
@@ -732,7 +732,7 @@ static void NormalizeTrainVehInDepot(const Train *u)
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFreeWagon(v) &&
v->tile == u->tile &&
- ((Train *)v)->track == TRACK_BIT_DEPOT) {
+ ((const Train *)v)->track == TRACK_BIT_DEPOT) {
if (CmdFailed(DoCommand(0, v->index | (u->index << 16), 1, DC_EXEC,
CMD_MOVE_RAIL_VEHICLE)))
break;
@@ -3572,8 +3572,8 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data)
* As there might be more than two trains involved, we have to do that for all vehicles */
const Vehicle *u;
FOR_ALL_VEHICLES(u) {
- if (u->type == VEH_TRAIN && HASBITS(u->vehstatus, VS_CRASHED) && (((Train *)u)->track & TRACK_BIT_DEPOT) == TRACK_BIT_NONE) {
- TrackBits trackbits = ((Train *)u)->track;
+ if (u->type == VEH_TRAIN && HASBITS(u->vehstatus, VS_CRASHED) && (((const Train *)u)->track & TRACK_BIT_DEPOT) == TRACK_BIT_NONE) {
+ TrackBits trackbits = ((const Train *)u)->track;
if ((trackbits & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) {
/* Vehicle is inside a wormhole, v->track contains no useful value then. */
trackbits |= DiagDirToDiagTrackBits(GetTunnelBridgeDirection(u->tile));
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index bda118815..bf16234f2 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -28,7 +28,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
v->tile == tile &&
- ((Train *)v)->track == TRACK_BIT_DEPOT) {
+ ((const Train *)v)->track == TRACK_BIT_DEPOT) {
if (found != NULL) return; // must be exactly one.
found = v;
}
@@ -81,7 +81,7 @@ void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int cou
_cur_dpi = &tmp_dpi;
do {
- int width = ((Train *)v)->tcache.cached_veh_length;
+ int width = ((const Train *)v)->tcache.cached_veh_length;
if (dx + width > 0) {
if (dx <= count) {
@@ -228,7 +228,7 @@ void DrawTrainDetails(const Vehicle *v, int left, int right, int y, int vscroll_
do {
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
DrawSprite(u->GetImage(DIR_W), pal, x + WagonLengthToPixels(4 + dx), y + 6 + (is_custom_sprite(RailVehInfo(u->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
- dx += ((Train *)u)->tcache.cached_veh_length;
+ dx += ((const Train *)u)->tcache.cached_veh_length;
u = u->Next();
} while (u != NULL && IsArticulatedPart(u) && u->cargo_cap == 0);
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index ca448d83b..73887577b 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1424,9 +1424,9 @@ SpriteID GetEnginePalette(EngineID engine_type, CompanyID company)
SpriteID GetVehiclePalette(const Vehicle *v)
{
if (v->type == VEH_TRAIN) {
- return GetEngineColourMap(v->engine_type, v->owner, ((Train *)v)->tcache.first_engine, v);
+ return GetEngineColourMap(v->engine_type, v->owner, ((const Train *)v)->tcache.first_engine, v);
} else if (v->type == VEH_ROAD) {
- return GetEngineColourMap(v->engine_type, v->owner, ((RoadVehicle *)v)->rcache.first_engine, v);
+ return GetEngineColourMap(v->engine_type, v->owner, ((const RoadVehicle *)v)->rcache.first_engine, v);
}
return GetEngineColourMap(v->engine_type, v->owner, INVALID_ENGINE, v);
@@ -1742,7 +1742,7 @@ bool CanVehicleUseStation(EngineID engine_type, const Station *st)
*/
bool CanVehicleUseStation(const Vehicle *v, const Station *st)
{
- if (v->type == VEH_ROAD) return st->GetPrimaryRoadStop((RoadVehicle *)v) != NULL;
+ if (v->type == VEH_ROAD) return st->GetPrimaryRoadStop((const RoadVehicle *)v) != NULL;
return CanVehicleUseStation(v->engine_type, st);
}
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 658f00268..e2556e04c 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -152,7 +152,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32
if (!vehicle_list_window) {
if (vehicle_type == VEH_TRAIN) {
- if (CheckTrainInDepot((Train *)v, false) == -1) continue;
+ if (CheckTrainInDepot((const Train *)v, false) == -1) continue;
} else {
if (!(v->vehstatus & VS_HIDDEN)) continue;
}
@@ -229,7 +229,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32
bool did_something = false;
for (uint i = 0; i < list.Length(); i++) {
- Vehicle *v = (Vehicle*)list[i];
+ const Vehicle *v = list[i];
/* Ensure that the vehicle completely in the depot */
if (!v->IsInDepot()) continue;
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index e2030df89..e1cc4aef0 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -641,8 +641,8 @@ static int CDECL VehicleLengthSorter(const Vehicle * const *a, const Vehicle * c
case VEH_ROAD: {
const RoadVehicle *u;
- for (u = (RoadVehicle *)*a; u != NULL; u = u->Next()) r += u->rcache.cached_veh_length;
- for (u = (RoadVehicle *)*b; u != NULL; u = u->Next()) r -= u->rcache.cached_veh_length;
+ for (u = (const RoadVehicle *)*a; u != NULL; u = u->Next()) r += u->rcache.cached_veh_length;
+ for (u = (const RoadVehicle *)*b; u != NULL; u = u->Next()) r -= u->rcache.cached_veh_length;
} break;
default: NOT_REACHED();
@@ -1466,10 +1466,10 @@ struct VehicleDetailsWindow : Window {
switch (v->type) {
case VEH_TRAIN:
SetDParam(2, v->GetDisplayMaxSpeed());
- SetDParam(1, ((Train *)v)->tcache.cached_power);
- SetDParam(0, ((Train *)v)->tcache.cached_weight);
- SetDParam(3, ((Train *)v)->tcache.cached_max_te / 1000);
- DrawString(2, this->width - 2, 25, (_settings_game.vehicle.train_acceleration_model != TAM_ORIGINAL && ((Train *)v)->railtype != RAILTYPE_MAGLEV) ?
+ SetDParam(1, ((const Train *)v)->tcache.cached_power);
+ SetDParam(0, ((const Train *)v)->tcache.cached_weight);
+ SetDParam(3, ((const Train *)v)->tcache.cached_max_te / 1000);
+ DrawString(2, this->width - 2, 25, (_settings_game.vehicle.train_acceleration_model != TAM_ORIGINAL && ((const Train *)v)->railtype != RAILTYPE_MAGLEV) ?
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED);
break;
@@ -1937,7 +1937,7 @@ struct VehicleViewWindow : Window {
} else if (v->vehstatus & VS_STOPPED) {
if (v->type == VEH_TRAIN) {
if (v->cur_speed == 0) {
- if (((Train *)v)->tcache.cached_power == 0) {
+ if (((const Train *)v)->tcache.cached_power == 0) {
str = STR_TRAIN_NO_POWER;
} else {
str = STR_VEHICLE_STATUS_STOPPED;
@@ -1949,7 +1949,7 @@ struct VehicleViewWindow : Window {
} else { // no train
str = STR_VEHICLE_STATUS_STOPPED;
}
- } else if (v->type == VEH_TRAIN && HasBit(((Train *)v)->flags, VRF_TRAIN_STUCK)) {
+ } else if (v->type == VEH_TRAIN && HasBit(((const Train *)v)->flags, VRF_TRAIN_STUCK)) {
str = STR_TRAIN_STUCK;
} else { // vehicle is in a "normal" state, show current order
switch (v->current_order.GetType()) {
diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp
index 332ecf1be..38e1b4f67 100644
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -29,7 +29,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
switch (type) {
case VEH_TRAIN:
if (IsArticulatedPart(v) || IsRearDualheaded(v)) continue;
- if (((Train *)v)->track != TRACK_BIT_DEPOT) continue;
+ if (((const Train *)v)->track != TRACK_BIT_DEPOT) continue;
if (wagons != NULL && IsFreeWagon(v->First())) {
if (individual_wagons || IsFreeWagon(v)) *wagons->Append() = v;
continue;
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp
index 0263150fe..f670ac82d 100644
--- a/src/yapf/follow_track.hpp
+++ b/src/yapf/follow_track.hpp
@@ -55,7 +55,7 @@ struct CFollowTrackT
{
assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN));
m_veh = v;
- Init(v != NULL ? v->owner : INVALID_OWNER, railtype_override == INVALID_RAILTYPES ? ((Train *)v)->compatible_railtypes : railtype_override, pPerf);
+ Init(v != NULL ? v->owner : INVALID_OWNER, railtype_override == INVALID_RAILTYPES ? ((const Train *)v)->compatible_railtypes : railtype_override, pPerf);
}
FORCEINLINE void Init(Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf)
@@ -76,7 +76,7 @@ struct CFollowTrackT
FORCEINLINE static TransportType TT() {return Ttr_type_;}
FORCEINLINE static bool IsWaterTT() {return TT() == TRANSPORT_WATER;}
FORCEINLINE static bool IsRailTT() {return TT() == TRANSPORT_RAIL;}
- FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(((RoadVehicle *)m_veh)->compatible_roadtypes, ROADTYPE_TRAM);}
+ FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(((const RoadVehicle *)m_veh)->compatible_roadtypes, ROADTYPE_TRAM);}
FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;}
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
FORCEINLINE static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;}
@@ -106,7 +106,7 @@ struct CFollowTrackT
m_old_tile = old_tile;
m_old_td = old_td;
m_err = EC_NONE;
- assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh ? ((RoadVehicle *)m_veh)->compatible_roadtypes : 0)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
+ assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh ? ((const RoadVehicle *)m_veh)->compatible_roadtypes : 0)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
(IsTram() && GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR)); // Disable the assertion for single tram bits
m_exitdir = TrackdirToExitdir(m_old_td);
if (ForcedReverse()) return true;
@@ -207,7 +207,7 @@ protected:
if (IsRailTT() && IsPlainRailTile(m_new_tile)) {
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
} else {
- m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh != NULL ? ((RoadVehicle *)m_veh)->compatible_roadtypes : 0));
+ m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh != NULL ? ((const RoadVehicle *)m_veh)->compatible_roadtypes : 0));
if (IsTram() && m_new_td_bits == 0) {
/* GetTileTrackStatus() returns 0 for single tram bits.
diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp
index 2d6d78191..9504beced 100644
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -247,8 +247,8 @@ public:
const Vehicle *v = Yapf().GetVehicle();
assert(v != NULL);
assert(v->type == VEH_TRAIN);
- assert(((Train *)v)->tcache.cached_total_length != 0);
- int missing_platform_length = (((Train *)v)->tcache.cached_total_length + TILE_SIZE - 1) / TILE_SIZE - platform_length;
+ assert(((const Train *)v)->tcache.cached_total_length != 0);
+ int missing_platform_length = (((const Train *)v)->tcache.cached_total_length + TILE_SIZE - 1) / TILE_SIZE - platform_length;
if (missing_platform_length < 0) {
/* apply penalty for longer platform than needed */
cost += Yapf().PfGetSettings().rail_longer_platform_penalty + Yapf().PfGetSettings().rail_longer_platform_per_tile_penalty * -missing_platform_length;
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index 99aa4ea48..498cc5975 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -13,8 +13,8 @@ protected:
public:
void SetDestination(const Vehicle *v, bool override_rail_type = false)
{
- m_compatible_railtypes = ((Train *)v)->compatible_railtypes;
- if (override_rail_type) m_compatible_railtypes |= GetRailTypeInfo(((Train *)v)->railtype)->compatible_railtypes;
+ m_compatible_railtypes = ((const Train *)v)->compatible_railtypes;
+ if (override_rail_type) m_compatible_railtypes |= GetRailTypeInfo(((const Train *)v)->railtype)->compatible_railtypes;
}
bool IsCompatibleRailType(RailType rt)
@@ -91,8 +91,8 @@ public:
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
{
return
- IsSafeWaitingPosition((Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
- IsWaitingPositionFree((Train *)Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
+ IsSafeWaitingPosition((const Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
+ IsWaitingPositionFree((const Train *)Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
}
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
diff --git a/src/yapf/yapf_rail.cpp b/src/yapf/yapf_rail.cpp
index 7b4e4e9bb..71e272038 100644
--- a/src/yapf/yapf_rail.cpp
+++ b/src/yapf/yapf_rail.cpp
@@ -54,7 +54,7 @@ private:
bool FindSafePositionProc(TileIndex tile, Trackdir td)
{
- if (IsSafeWaitingPosition((Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns())) {
+ if (IsSafeWaitingPosition((const Train *)Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns())) {
m_res_dest = tile;
m_res_dest_td = td;
return false; // Stop iterating segment
@@ -149,7 +149,7 @@ public:
}
/* Don't bother if the target is reserved. */
- if (!IsWaitingPositionFree((Train *)Yapf().GetVehicle(), m_res_dest, m_res_dest_td)) return false;
+ if (!IsWaitingPositionFree((const Train *)Yapf().GetVehicle(), m_res_dest, m_res_dest_td)) return false;
for (Node *node = m_res_node; node->m_parent != NULL; node = node->m_parent) {
node->IterateTiles(Yapf().GetVehicle(), Yapf(), *this, &CYapfReserveTrack<Types>::ReserveSingleTrack);
@@ -411,7 +411,7 @@ public:
if (target != NULL) target->tile = INVALID_TILE;
/* set origin and destination nodes */
- PBSTileInfo origin = FollowTrainReservation((Train *)v);
+ PBSTileInfo origin = FollowTrainReservation((const Train *)v);
Yapf().SetOrigin(origin.tile, origin.trackdir, INVALID_TILE, INVALID_TRACKDIR, 1, true);
Yapf().SetDestination(v);
@@ -536,9 +536,9 @@ Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection ent
bool YapfCheckReverseTrain(const Vehicle *vt)
{
- Train *v = (Train *)vt;
+ const Train *v = (const Train *)vt;
/* last wagon */
- const Train *last_veh = (Train *)GetLastVehicleInChain(v);
+ const Train *last_veh = (const Train *)GetLastVehicleInChain(v);
/* get trackdirs of both ends */
Trackdir td = v->GetVehicleTrackdir();
@@ -602,7 +602,7 @@ bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reve
const Vehicle *last_veh = GetLastVehicleInChain(v);
- PBSTileInfo origin = FollowTrainReservation((Train *)v);
+ PBSTileInfo origin = FollowTrainReservation((const Train *)v);
TileIndex last_tile = last_veh->tile;
Trackdir td_rev = ReverseTrackdir(last_veh->GetVehicleTrackdir());
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index 75dbc9e27..ce627b1f0 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -299,13 +299,13 @@ public:
/* our source tile will be the next vehicle tile (should be the given one) */
TileIndex src_tile = tile;
/* get available trackdirs on the start tile */
- TrackdirBits src_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes));
+ TrackdirBits src_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes));
/* select reachable trackdirs only */
src_trackdirs &= DiagdirReachesTrackdirs(enterdir);
/* get available trackdirs on the destination tile */
TileIndex dest_tile = v->dest_tile;
- TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes));
+ TrackdirBits dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes));
/* set origin and destination nodes */
Yapf().SetOrigin(src_tile, src_trackdirs);
@@ -349,7 +349,7 @@ public:
/* set destination tile, trackdir
* get available trackdirs on the destination tile */
- TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes));
+ TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes));
Yapf().SetDestination(dst_tile, dst_td_bits);
/* if path not found - return distance = UINT_MAX */
@@ -374,7 +374,7 @@ public:
/* set origin (tile, trackdir) */
TileIndex src_tile = v->tile;
Trackdir src_td = v->GetVehicleTrackdir();
- if ((TrackStatusToTrackdirBits(GetTileTrackStatus(src_tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(src_td)) == 0) {
+ if ((TrackStatusToTrackdirBits(GetTileTrackStatus(src_tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(src_td)) == 0) {
/* sometimes the roadveh is not on the road (it resides on non-existing track)
* how should we handle that situation? */
return false;
@@ -471,7 +471,7 @@ Depot *YapfFindNearestRoadDepot(const Vehicle *v)
{
TileIndex tile = v->tile;
Trackdir trackdir = v->GetVehicleTrackdir();
- if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
+ if ((TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ((const RoadVehicle *)v)->compatible_roadtypes)) & TrackdirToTrackdirBits(trackdir)) == 0) {
return NULL;
}