(svn r23195) -Codechange: if we really need to cast away constness, use const_cast

This commit is contained in:
rubidium 2011-11-12 08:37:12 +00:00
parent 4f87d2e88c
commit c9a7f572ec
4 changed files with 5 additions and 5 deletions

View File

@ -511,7 +511,7 @@ static const uint AISAVE_MAX_DEPTH = 25; ///< The maximum recursive depth for it
if (!test) {
_ai_sl_byte = (byte)len;
SlObject(NULL, _ai_byte);
SlArray((void*)buf, len, SLE_CHAR);
SlArray(const_cast<char *>(buf), len, SLE_CHAR);
}
return true;
}

View File

@ -514,7 +514,7 @@ static inline bool IsNumericType(VarType conv)
*/
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
{
return (byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address;
return const_cast<byte *>((const byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address);
}
int64 ReadValue(const void *ptr, VarType conv);

View File

@ -275,7 +275,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, (void *)name, png_my_error, png_my_warning);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, const_cast<char *>(name), png_my_error, png_my_warning);
if (png_ptr == NULL) {
fclose(f);

View File

@ -480,8 +480,8 @@ CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle
* error message only (which may be different for different machines).
* Such a message does not affect MP synchronisation.
*/
Vehicle *v = VehicleFromPos(tile, (void *)ignore, &GetVehicleTunnelBridgeProc, true);
if (v == NULL) v = VehicleFromPos(endtile, (void *)ignore, &GetVehicleTunnelBridgeProc, true);
Vehicle *v = VehicleFromPos(tile, const_cast<Vehicle *>(ignore), &GetVehicleTunnelBridgeProc, true);
if (v == NULL) v = VehicleFromPos(endtile, const_cast<Vehicle *>(ignore), &GetVehicleTunnelBridgeProc, true);
if (v != NULL) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
return CommandCost();