Mercurial > hg > openttd
changeset 18359:58955df25ef4 draft
(svn r23195) -Codechange: if we really need to cast away constness, use const_cast
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 12 Nov 2011 08:37:12 +0000 |
parents | 90d7214be2a3 |
children | a7a3ea5915bd |
files | src/ai/ai_instance.cpp src/saveload/saveload.h src/screenshot.cpp src/vehicle.cpp |
diffstat | 4 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -511,7 +511,7 @@ 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; }
--- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -514,7 +514,7 @@ */ 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);
--- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -275,7 +275,7 @@ 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);
--- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -480,8 +480,8 @@ * 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();