diff options
author | rubidium <rubidium@openttd.org> | 2011-11-12 08:37:12 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-11-12 08:37:12 +0000 |
commit | c9a7f572ecb902304efe0c864f565e703c8e98c8 (patch) | |
tree | 24ade13ff9268018a5870d8dbeab3abbb223a0ff | |
parent | 4f87d2e88c4b42f4ae4a5c7956f2287740ef174b (diff) | |
download | openttd-c9a7f572ecb902304efe0c864f565e703c8e98c8.tar.xz |
(svn r23195) -Codechange: if we really need to cast away constness, use const_cast
-rw-r--r-- | src/ai/ai_instance.cpp | 2 | ||||
-rw-r--r-- | src/saveload/saveload.h | 2 | ||||
-rw-r--r-- | src/screenshot.cpp | 2 | ||||
-rw-r--r-- | src/vehicle.cpp | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 1cae588f7..dbc8970b1 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -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; } diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 0090b6be3..db3af4dd9 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -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); diff --git a/src/screenshot.cpp b/src/screenshot.cpp index dcf35127c..9cee75820 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -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); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index dd7186fc6..69c40975b 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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(); |