Skip to content

Instantly share code, notes, and snippets.

@LordAro
Last active January 3, 2020 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LordAro/12d22a1be441118aa951b4d9798051b0 to your computer and use it in GitHub Desktop.
Save LordAro/12d22a1be441118aa951b4d9798051b0 to your computer and use it in GitHub Desktop.
Compiling old OTTD with new compilers
diff --git a/src/cmd_helper.h b/src/cmd_helper.h
index 115b0e1cff..e994c0e91e 100644
--- a/src/cmd_helper.h
+++ b/src/cmd_helper.h
@@ -9,7 +9,7 @@
template<uint N> static inline void ExtractValid();
-template<> static inline void ExtractValid<1>() {}
+template<> inline void ExtractValid<1>() {}
template<typename T> struct ExtractBits;
diff --git a/src/console.cpp b/src/console.cpp
index 76c2562d82..e7a98c4564 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -1121,7 +1121,7 @@ void IConsoleCmdExec(const char *cmdstr)
}
}
- if (tokens[0] == '\0') return; // don't execute empty commands
+ if (tokens[0] == NULL) return; // don't execute empty commands
/* 2. Determine type of command (cmd, alias or variable) and execute
* First try commands, then aliases, and finally variables. Execute
* the found action taking into account its hooking code
diff --git a/src/fileio.cpp b/src/fileio.cpp
index a8cf964a03..10a1be1269 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -392,7 +392,7 @@ void ChangeWorkingDirectory(const char *exe)
if (app_bundle != NULL) app_bundle[0] = '\0';
#endif /* WITH_COCOA */
- char *s = strrchr(exe, PATHSEPCHAR);
+ char *s = const_cast<char *>(strrchr(exe, PATHSEPCHAR));
if (s != NULL) {
*s = '\0';
chdir(exe);
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index 360127dc5b..4ac5dff098 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -44,7 +44,7 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
png_bytep *row_pointers = NULL;
/* Get palette and convert it to grayscale */
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
int i;
int palette_size;
png_color *palette;
@@ -72,14 +72,14 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
row_pointers = png_get_rows(png_ptr, info_ptr);
/* Read the raw image data and convert in 8-bit grayscale */
- for (x = 0; x < info_ptr->width; x++) {
- for (y = 0; y < info_ptr->height; y++) {
- byte *pixel = &map[y * info_ptr->width + x];
- uint x_offset = x * info_ptr->channels;
+ for (x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
+ for (y = 0; y < png_get_image_height(png_ptr, info_ptr); y++) {
+ byte *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x];
+ uint x_offset = x * png_get_channels(png_ptr, info_ptr);
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
*pixel = gray_palette[row_pointers[y][x_offset]];
- } else if (info_ptr->channels == 3) {
+ } else if (png_get_channels(png_ptr, info_ptr) == 3) {
*pixel = RGBToGrayscale(row_pointers[y][x_offset + 0],
row_pointers[y][x_offset + 1], row_pointers[y][x_offset + 2]);
} else {
@@ -130,7 +130,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
/* Maps of wrong color-depth are not used.
* (this should have been taken care of by stripping alpha and 16-bit samples on load) */
- if ((info_ptr->channels != 1) && (info_ptr->channels != 3) && (info_ptr->bit_depth != 8)) {
+ if ((png_get_channels(png_ptr, info_ptr) != 1) && (png_get_channels(png_ptr, info_ptr) != 3) && (png_get_bit_depth(png_ptr, info_ptr) != 8)) {
ShowErrorMessage(STR_PNGMAP_ERR_IMAGE_TYPE, STR_PNGMAP_ERROR, 0, 0);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -138,7 +138,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
}
if (map != NULL) {
- *map = MallocT<byte>(info_ptr->width * info_ptr->height);
+ *map = MallocT<byte>(png_get_image_width(png_ptr, info_ptr) * png_get_image_height(png_ptr, info_ptr));
if (*map == NULL) {
ShowErrorMessage(STR_PNGMAP_ERR_MISC, STR_PNGMAP_ERROR, 0, 0);
@@ -150,8 +150,8 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
}
- *x = info_ptr->width;
- *y = info_ptr->height;
+ *x = png_get_image_width(png_ptr, info_ptr);
+ *y = png_get_image_height(png_ptr, info_ptr);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
diff --git a/src/macros.h b/src/macros.h
index e7944661a9..5b09714cb2 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -498,8 +498,6 @@ static inline int KillFirstBit2x64(int value)
for (_i = 0; _b != 0; _i++, _b >>= 1) \
if (_b & 1)
-#define abs myabs
-
static inline uint16 ReadLE16Aligned(const void* x)
{
diff --git a/src/misc/str.hpp b/src/misc/str.hpp
index e1138616af..f6800f6e96 100644
--- a/src/misc/str.hpp
+++ b/src/misc/str.hpp
@@ -124,7 +124,7 @@ struct CStrT : public CBlobT<Tchar>
int ret;
int err = 0;
for (;;) {
- Tchar *buf = MakeFreeSpace(addSize);
+ Tchar *buf = base::MakeFreeSpace(addSize);
ret = Api::SPrintFL(buf, base::GetReserve(), format, args);
if (ret >= base::GetReserve()) {
/* Greater return than given count means needed buffer size. */
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index f9ef1ec5c3..63297e56f6 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -161,7 +161,7 @@ public:
/* dummy operator delete to silence VC8:
* 'void *GRFText::operator new(size_t,size_t)' : no matching operator delete found;
* memory will not be freed if initialization throws an exception */
- void operator delete(void *p, size_t extra)
+ void operator delete(void *p)
{
return ::operator delete(p);
}
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 1e9a903df4..d2f292b967 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -166,7 +166,7 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
diff --git a/src/settings.cpp b/src/settings.cpp
index 1a64381bc8..56cd8a5f5f 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1551,7 +1551,7 @@ const SettingDesc _patch_settings[] = {
SDT_CONDVAR(Patches, land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR, NULL),
SDT_CONDVAR(Patches, oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
SDT_CONDVAR(Patches, tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN, NULL),
- SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(uint32), 0, STR_NULL, NULL),
+ SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(int32), 0, STR_NULL, NULL),
SDT_CONDVAR(Patches, tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_TREE_PLACER, NULL),
SDT_VAR (Patches, heightmap_rotation, SLE_UINT8, S, MS, 0, 0, 1, 0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION, NULL),
SDT_VAR (Patches, se_flat_world_height, SLE_UINT8, S, 0, 0, 0, 15, 0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT, NULL),
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index 6048c6fdd7..1c1bd782b9 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -22,7 +22,7 @@ static void PNGAPI png_my_read(png_structp png_ptr, png_bytep data, png_size_t l
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(sprite, 0, "ERROR (libpng): %s - %s", message, (char *)png_get_error_ptr(png_ptr));
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
@@ -100,8 +100,8 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
if (strcmp("y_offs", text_ptr[i].key) == 0) sprite->y_offs = strtol(text_ptr[i].text, NULL, 0);
}
- sprite->height = info_ptr->height;
- sprite->width = info_ptr->width;
+ sprite->height = png_get_image_height(png_ptr, info_ptr);
+ sprite->width = png_get_image_width(png_ptr, info_ptr);
sprite->data = CallocT<SpriteLoader::CommonPixel>(sprite->width * sprite->height);
}
@@ -144,18 +144,18 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
pixelsize = sizeof(uint8);
}
- row_pointer = (png_byte *)malloc(info_ptr->width * pixelsize);
+ row_pointer = (png_byte *)malloc(png_get_image_width(png_ptr, info_ptr) * pixelsize);
if (row_pointer == NULL) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return false;
}
- for (i = 0; i < info_ptr->height; i++) {
+ for (i = 0; i < png_get_image_height(png_ptr, info_ptr); i++) {
png_read_row(png_ptr, row_pointer, NULL);
- dst = sprite->data + i * info_ptr->width;
+ dst = sprite->data + i * png_get_image_width(png_ptr, info_ptr);
- for (uint x = 0; x < info_ptr->width; x++) {
+ for (uint x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
if (mask) {
if (row_pointer[x * sizeof(uint8)] != 0) {
dst[x].b = 0;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index d6b1d5e208..65bb5b9321 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -230,7 +230,7 @@ static bool GenerateStationName(Station *st, TileIndex tile, int flag)
1 << M(STR_SV_STNAME_OILFIELD), /* 2 */
1 << M(STR_SV_STNAME_DOCKS), /* 3 */
0x1FF << M(STR_SV_STNAME_BUOY_1), /* 4 */
- 1 << M(STR_SV_STNAME_HELIPORT), /* 5 */
+ 1u << M(STR_SV_STNAME_HELIPORT), /* 5 */
};
Town *t = st->town;
diff --git a/src/table/station_land.h b/src/table/station_land.h
index 6f955daf37..4cc663b690 100644
--- a/src/table/station_land.h
+++ b/src/table/station_land.h
@@ -1,6 +1,6 @@
/* $Id$ */
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, 0, 0 }
static const DrawTileSeqStruct _station_display_nothing[] = {
TILE_SEQ_END()
@@ -34,7 +34,7 @@ static const DrawTileSeqStruct _station_display_datas_4[] = {
{ 0, 0, 0, 16, 5, 7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
@@ -42,7 +42,7 @@ static const DrawTileSeqStruct _station_display_datas_5[] = {
{ 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
@@ -50,7 +50,7 @@ static const DrawTileSeqStruct _station_display_datas_6[] = {
{ 0, 0, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
@@ -58,7 +58,7 @@ static const DrawTileSeqStruct _station_display_datas_7[] = {
{ 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
diff --git a/src/table/track_land.h b/src/table/track_land.h
index 94eb15d534..99aff425f6 100644
--- a/src/table/track_land.h
+++ b/src/table/track_land.h
@@ -1,7 +1,7 @@
/* $Id$ */
#define TILE_SEQ_LINE(img, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 23, img, PAL_NONE },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, 0, 0 }
static const DrawTileSeqStruct _depot_gfx_NE[] = {
diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h
index 78585d5a79..155b9d4177 100644
--- a/src/table/unmovable_land.h
+++ b/src/table/unmovable_land.h
@@ -10,7 +10,7 @@ struct DrawTileUnmovableStruct {
byte unused;
};
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, 0, 0 }
static const DrawTileUnmovableStruct _draw_tile_unmovable_data[] = {
{0xA29, 7, 7, 2, 2, 70, 0},
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index 99bde7fdba..3c17ea5666 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -367,7 +367,7 @@ public:
// find the best path
bool bFound = Yapf().FindPath(v);
- if (!bFound) return false;
+ if (!bFound) return NULL;
// some path found
// get found depot tile
diff --git a/src/console.cpp b/src/console.cpp
index 0be9c8cbae..2f8ad75679 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -1136,7 +1136,7 @@ void IConsoleCmdExec(const char *cmdstr)
}
}
- if (tokens[0] == '\0') return; // don't execute empty commands
+ if (tokens[0] == NULL) return; // don't execute empty commands
/* 2. Determine type of command (cmd, alias or variable) and execute
* First try commands, then aliases, and finally variables. Execute
* the found action taking into account its hooking code
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 9dbef0da32..0cc2a8b40d 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -626,7 +626,7 @@ void ChangeWorkingDirectory(const char *exe)
if (app_bundle != NULL) app_bundle[0] = '\0';
#endif /* WITH_COCOA */
- char *s = strrchr(exe, PATHSEPCHAR);
+ char *s = const_cast<char *>(strrchr(exe, PATHSEPCHAR));
if (s != NULL) {
*s = '\0';
chdir(exe);
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index c04ebd83da..f37cd7e6b5 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -46,7 +46,7 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
png_bytep *row_pointers = NULL;
/* Get palette and convert it to grayscale */
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
int i;
int palette_size;
png_color *palette;
@@ -74,14 +74,14 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
row_pointers = png_get_rows(png_ptr, info_ptr);
/* Read the raw image data and convert in 8-bit grayscale */
- for (x = 0; x < info_ptr->width; x++) {
- for (y = 0; y < info_ptr->height; y++) {
- byte *pixel = &map[y * info_ptr->width + x];
- uint x_offset = x * info_ptr->channels;
+ for (x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
+ for (y = 0; y < png_get_image_height(png_ptr, info_ptr); y++) {
+ byte *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x];
+ uint x_offset = x * png_get_channels(png_ptr, info_ptr);
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
*pixel = gray_palette[row_pointers[y][x_offset]];
- } else if (info_ptr->channels == 3) {
+ } else if (png_get_channels(png_ptr, info_ptr) == 3) {
*pixel = RGBToGrayscale(row_pointers[y][x_offset + 0],
row_pointers[y][x_offset + 1], row_pointers[y][x_offset + 2]);
} else {
@@ -132,7 +132,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
/* Maps of wrong color-depth are not used.
* (this should have been taken care of by stripping alpha and 16-bit samples on load) */
- if ((info_ptr->channels != 1) && (info_ptr->channels != 3) && (info_ptr->bit_depth != 8)) {
+ if ((png_get_channels(png_ptr, info_ptr) != 1) && (png_get_channels(png_ptr, info_ptr) != 3) && (png_get_bit_depth(png_ptr, info_ptr) != 8)) {
ShowErrorMessage(STR_PNGMAP_ERR_IMAGE_TYPE, STR_PNGMAP_ERROR, 0, 0);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -140,7 +140,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
}
if (map != NULL) {
- *map = MallocT<byte>(info_ptr->width * info_ptr->height);
+ *map = MallocT<byte>(png_get_image_width(png_ptr, info_ptr) * png_get_image_height(png_ptr, info_ptr));
if (*map == NULL) {
ShowErrorMessage(STR_PNGMAP_ERR_MISC, STR_PNGMAP_ERROR, 0, 0);
@@ -152,8 +152,8 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
}
- *x = info_ptr->width;
- *y = info_ptr->height;
+ *x = png_get_image_width(png_ptr, info_ptr);
+ *y = png_get_image_height(png_ptr, info_ptr);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
diff --git a/src/misc/str.hpp b/src/misc/str.hpp
index e1138616af..f6800f6e96 100644
--- a/src/misc/str.hpp
+++ b/src/misc/str.hpp
@@ -124,7 +124,7 @@ struct CStrT : public CBlobT<Tchar>
int ret;
int err = 0;
for (;;) {
- Tchar *buf = MakeFreeSpace(addSize);
+ Tchar *buf = base::MakeFreeSpace(addSize);
ret = Api::SPrintFL(buf, base::GetReserve(), format, args);
if (ret >= base::GetReserve()) {
/* Greater return than given count means needed buffer size. */
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index f69ccda2af..b4eb6d4425 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -162,7 +162,7 @@ public:
/* dummy operator delete to silence VC8:
* 'void *GRFText::operator new(size_t,size_t)' : no matching operator delete found;
* memory will not be freed if initialization throws an exception */
- void operator delete(void *p, size_t extra)
+ void operator delete(void *p)
{
return ::operator delete(p);
}
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 68b9bc2770..b55f8f9b97 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -169,7 +169,7 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
diff --git a/src/settings.cpp b/src/settings.cpp
index bebdc1f11c..782732dd86 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1307,7 +1307,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_BOOL("large_aa", S, 0, _freetype.large_aa, false, STR_NULL, NULL),
#endif
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 4, 1, 64, 0, STR_NULL, NULL),
- SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0xFFFFFFFF,0, STR_NULL, NULL),
+ SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0x7FFFFFFF,0, STR_NULL, NULL),
SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_END()
@@ -1613,7 +1613,7 @@ const SettingDesc _patch_settings[] = {
SDT_CONDVAR(Patches, land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR, NULL),
SDT_CONDVAR(Patches, oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
SDT_CONDVAR(Patches, tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN, NULL),
- SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(uint32), 0, STR_NULL, NULL),
+ SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(int32), 0, STR_NULL, NULL),
SDT_CONDVAR(Patches, tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_TREE_PLACER, NULL),
SDT_VAR (Patches, heightmap_rotation, SLE_UINT8, S, MS, 0, 0, 1, 0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION, NULL),
SDT_VAR (Patches, se_flat_world_height, SLE_UINT8, S, 0, 0, 0, 15, 0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT, NULL),
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index 363dce46cf..43a2bc079f 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -22,7 +22,7 @@ static void PNGAPI png_my_read(png_structp png_ptr, png_bytep data, png_size_t l
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(sprite, 0, "ERROR (libpng): %s - %s", message, (char *)png_get_error_ptr(png_ptr));
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
@@ -100,8 +100,8 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
if (strcmp("y_offs", text_ptr[i].key) == 0) sprite->y_offs = strtol(text_ptr[i].text, NULL, 0);
}
- sprite->height = info_ptr->height;
- sprite->width = info_ptr->width;
+ sprite->height = png_get_image_height(png_ptr, info_ptr);
+ sprite->width = png_get_image_width(png_ptr, info_ptr);
sprite->data = CallocT<SpriteLoader::CommonPixel>(sprite->width * sprite->height);
}
@@ -134,18 +134,18 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
pixelsize = sizeof(uint8);
}
- row_pointer = (png_byte *)MallocT<byte>(info_ptr->width * pixelsize);
+ row_pointer = (png_byte *)MallocT<byte>(png_get_image_width(png_ptr, info_ptr) * pixelsize);
if (row_pointer == NULL) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return false;
}
- for (i = 0; i < info_ptr->height; i++) {
+ for (i = 0; i < png_get_image_height(png_ptr, info_ptr); i++) {
png_read_row(png_ptr, row_pointer, NULL);
- dst = sprite->data + i * info_ptr->width;
+ dst = sprite->data + i * png_get_image_width(png_ptr, info_ptr);
- for (uint x = 0; x < info_ptr->width; x++) {
+ for (uint x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
if (mask) {
if (row_pointer[x * sizeof(uint8)] != 0) {
dst[x].r = 0;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index abc05c681a..caf1674ac0 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -246,7 +246,7 @@ static void GenerateStationName(Station *st, TileIndex tile, int flag)
1 << M(STR_SV_STNAME_OILFIELD), /* 2 */
1 << M(STR_SV_STNAME_DOCKS), /* 3 */
0x1FF << M(STR_SV_STNAME_BUOY_1), /* 4 */
- 1 << M(STR_SV_STNAME_HELIPORT), /* 5 */
+ 1u << M(STR_SV_STNAME_HELIPORT), /* 5 */
};
Town *t = st->town;
diff --git a/src/table/station_land.h b/src/table/station_land.h
index b0fa4b3664..f4b2ca2951 100644
--- a/src/table/station_land.h
+++ b/src/table/station_land.h
@@ -2,7 +2,7 @@
#define TILE_SEQ_LINE(dx, dy, dz, sx, sy, sz, img) { dx, dy, dz, sx, sy, sz, {img, PAL_NONE} },
#define TILE_SEQ_LINE_PAL(dx, dy, dz, sx, sy, sz, img, pal) { dx, dy, dz, sx, sy, sz, {img, pal} },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
static const DrawTileSeqStruct _station_display_nothing[] = {
TILE_SEQ_END()
@@ -36,7 +36,7 @@ static const DrawTileSeqStruct _station_display_datas_4[] = {
TILE_SEQ_LINE( 0, 0, 0, 16, 5, 7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE( 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
@@ -44,7 +44,7 @@ static const DrawTileSeqStruct _station_display_datas_5[] = {
TILE_SEQ_LINE( 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE(11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
@@ -52,7 +52,7 @@ static const DrawTileSeqStruct _station_display_datas_6[] = {
TILE_SEQ_LINE( 0, 0, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_REAR | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE( 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B | (1 << PALETTE_MODIFIER_COLOR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
@@ -60,7 +60,7 @@ static const DrawTileSeqStruct _station_display_datas_7[] = {
TILE_SEQ_LINE( 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_REAR | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE(11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B | (1 << PALETTE_MODIFIER_COLOR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
diff --git a/src/table/track_land.h b/src/table/track_land.h
index 920595cb1b..8a4e602f2e 100644
--- a/src/table/track_land.h
+++ b/src/table/track_land.h
@@ -1,7 +1,7 @@
/* $Id$ */
#define TILE_SEQ_LINE(img, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 23, {img, PAL_NONE} },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
static const DrawTileSeqStruct _depot_gfx_NE[] = {
diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h
index e7a97cb896..04940b3684 100644
--- a/src/table/unmovable_land.h
+++ b/src/table/unmovable_land.h
@@ -1,13 +1,12 @@
/* $Id$ */
-
static const DrawTileSeqStruct _draw_tile_transmitterlighthouse_data[] = {
{ 7, 7, 0, 2, 2, 70, {SPR_UNMOVABLE_TRANSMITTER, PAL_NONE}},
{ 4, 4, 0, 7, 7, 61, {SPR_UNMOVABLE_LIGHTHOUSE, PAL_NONE}},
};
#define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
static const DrawTileSeqStruct _unmovable_display_nothing[] = {
TILE_SEQ_END()
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index cd41cf772c..31f21d7fbf 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -2020,27 +2020,27 @@ enum VehicleCommandTranslation {
/** Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type. */
static const uint32 _vehicle_command_translation_table[][4] = {
{ // VCT_CMD_START_STOP
- CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN),
- CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE),
- CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP),
- CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)
+ (uint32)CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN),
+ (uint32)CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE),
+ (uint32)CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP),
+ (uint32)CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)
},
{ // VCT_CMD_GOTO_DEPOT
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
- CMD_SEND_TRAIN_TO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT),
- CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT),
- CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT),
- CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)
+ (uint32)CMD_SEND_TRAIN_TO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT),
+ (uint32)CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT),
+ (uint32)CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT),
+ (uint32)CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)
},
{ // VCT_CMD_CLONE_VEH
- CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE),
- CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE),
- CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP),
- CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE),
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE),
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP),
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)
},
{ // VCT_CMD_TURN_AROUND
- CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION),
- CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN),
+ (uint32)CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION),
+ (uint32)CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN),
0xffffffff, // invalid for ships
0xffffffff // invalid for aircrafts
},
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index 52f5612499..90be931f16 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -365,7 +365,7 @@ public:
// find the best path
bool bFound = Yapf().FindPath(v);
- if (!bFound) return false;
+ if (!bFound) return NULL;
// some path found
// get found depot tile
diff --git a/src/3rdparty/squirrel/squirrel/squtils.h b/src/3rdparty/squirrel/squirrel/squtils.h
index 55febe38c9..5f7e2e2393 100644
--- a/src/3rdparty/squirrel/squirrel/squtils.h
+++ b/src/3rdparty/squirrel/squirrel/squtils.h
@@ -2,6 +2,10 @@
#ifndef _SQUTILS_H_
#define _SQUTILS_H_
+void *sq_vm_malloc(SQUnsignedInteger size);
+void *sq_vm_realloc(void *p,SQUnsignedInteger oldsize,SQUnsignedInteger size);
+void sq_vm_free(void *p,SQUnsignedInteger size);
+
#define sq_new(__ptr,__type) {__ptr=(__type *)sq_vm_malloc(sizeof(__type));new (__ptr) __type;}
#define sq_delete(__ptr,__type) {__ptr->~__type();sq_vm_free(__ptr,sizeof(__type));}
#define SQ_MALLOC(__size) sq_vm_malloc((__size));
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index a5d1929271..57201bc8e3 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -39,7 +39,7 @@ static void PlaceAirport(TileIndex tile)
uint32 p2 = _ctrl_pressed;
SB(p2, 16, 16, INVALID_STATION); // no station to join
- CommandContainer cmdcont = { tile, _selected_airport_type, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
+ CommandContainer cmdcont = { tile, _selected_airport_type, p2, (uint32)CMD_BUILD_AIRPORT | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
ShowSelectStationIfNeeded(cmdcont, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE);
}
diff --git a/src/cmd_helper.h b/src/cmd_helper.h
index 9b5c12a069..8e1778d4d3 100644
--- a/src/cmd_helper.h
+++ b/src/cmd_helper.h
@@ -8,6 +8,7 @@
#include "direction_type.h"
#include "road_type.h"
+#include "core/bitmath_func.hpp"
template<uint N> static inline void ExtractValid();
template<> inline void ExtractValid<1>() {}
diff --git a/src/console.cpp b/src/console.cpp
index 2f9553aa02..f75c17541f 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -824,7 +824,7 @@ void IConsoleCmdExec(const char *cmdstr)
}
}
- if (tokens[0] == '\0') return; // don't execute empty commands
+ if (tokens[0] == NULL) return; // don't execute empty commands
/* 2. Determine type of command (cmd, alias or variable) and execute
* First try commands, then aliases, and finally variables. Execute
* the found action taking into account its hooking code
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 5a93ff9439..24f0e3c06d 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -49,7 +49,7 @@ static void PlaceDocks_Dock(TileIndex tile)
uint32 p2 = INVALID_STATION << 16; // no station to join
/* tile is always the land tile, so need to evaluate _thd.pos */
- CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
+ CommandContainer cmdcont = { tile, _ctrl_pressed, p2, (uint32)CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
ShowSelectStationIfNeeded(cmdcont, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE);
}
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 7034409f5e..dcd30409a9 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -13,6 +13,7 @@
#include <windows.h>
#else
#include <pwd.h>
+#include <unistd.h>
#endif
#include <sys/stat.h>
#include <algorithm>
@@ -807,7 +808,7 @@ void ChangeWorkingDirectory(const char *exe)
if (app_bundle != NULL) app_bundle[0] = '\0';
#endif /* WITH_COCOA */
- char *s = (char*)strrchr(exe, PATHSEPCHAR);
+ char *s = const_cast<char *>(strrchr(exe, PATHSEPCHAR));
if (s != NULL) {
*s = '\0';
#if defined(__DJGPP__)
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index 04207cd2e4..e6d4142bf8 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -43,7 +43,7 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
png_bytep *row_pointers = NULL;
/* Get palette and convert it to grayscale */
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
int i;
int palette_size;
png_color *palette;
@@ -71,14 +71,14 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
row_pointers = png_get_rows(png_ptr, info_ptr);
/* Read the raw image data and convert in 8-bit grayscale */
- for (x = 0; x < info_ptr->width; x++) {
- for (y = 0; y < info_ptr->height; y++) {
- byte *pixel = &map[y * info_ptr->width + x];
- uint x_offset = x * info_ptr->channels;
+ for (x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
+ for (y = 0; y < png_get_image_height(png_ptr, info_ptr); y++) {
+ byte *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x];
+ uint x_offset = x * png_get_channels(png_ptr, info_ptr);
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
*pixel = gray_palette[row_pointers[y][x_offset]];
- } else if (info_ptr->channels == 3) {
+ } else if (png_get_channels(png_ptr, info_ptr) == 3) {
*pixel = RGBToGrayscale(row_pointers[y][x_offset + 0],
row_pointers[y][x_offset + 1], row_pointers[y][x_offset + 2]);
} else {
@@ -129,7 +129,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
/* Maps of wrong colour-depth are not used.
* (this should have been taken care of by stripping alpha and 16-bit samples on load) */
- if ((info_ptr->channels != 1) && (info_ptr->channels != 3) && (info_ptr->bit_depth != 8)) {
+ if ((png_get_channels(png_ptr, info_ptr) != 1) && (png_get_channels(png_ptr, info_ptr) != 3) && (png_get_bit_depth(png_ptr, info_ptr) != 8)) {
ShowErrorMessage(STR_PNGMAP_ERR_IMAGE_TYPE, STR_PNGMAP_ERROR, 0, 0);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -137,12 +137,12 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
}
if (map != NULL) {
- *map = MallocT<byte>(info_ptr->width * info_ptr->height);
+ *map = MallocT<byte>(png_get_image_width(png_ptr, info_ptr) * png_get_image_height(png_ptr, info_ptr));
ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
}
- *x = info_ptr->width;
- *y = info_ptr->height;
+ *x = png_get_image_width(png_ptr, info_ptr);
+ *y = png_get_image_height(png_ptr, info_ptr);
fclose(fp);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
diff --git a/src/misc/str.hpp b/src/misc/str.hpp
index 666c031875..2b2d2cebfb 100644
--- a/src/misc/str.hpp
+++ b/src/misc/str.hpp
@@ -124,7 +124,7 @@ struct CStrT : public CBlobT<Tchar>
int ret;
int err = 0;
for (;;) {
- Tchar *buf = MakeFreeSpace(addSize);
+ Tchar *buf = base::MakeFreeSpace(addSize);
ret = Api::SPrintFL(buf, base::GetReserve(), format, args);
if (ret >= base::GetReserve()) {
/* Greater return than given count means needed buffer size. */
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index cc3260e5b7..58f9d16d0f 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -204,7 +204,7 @@ static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *user
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(misc, 0, "[libpng] error: %s - %s", message, (char *)png_get_error_ptr(png_ptr));
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
diff --git a/src/settings.cpp b/src/settings.cpp
index 6549be66c0..7bc2cbe427 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1250,7 +1250,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_BOOL("large_aa", S, 0, _freetype.large_aa, false, STR_NULL, NULL),
#endif
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 4, 1, 64, 0, STR_NULL, NULL),
- SDTG_VAR("player_face", SLE_UINT32, S, 0, _company_manager_face,0,0,0xFFFFFFFF,0, STR_NULL, NULL),
+ SDTG_VAR("player_face", SLE_UINT32, S, 0, _company_manager_face,0,0,0x7FFFFFFF,0, STR_NULL, NULL),
SDTG_VAR("transparency_options", SLE_UINT, S, 0, _transparency_opt, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_VAR("transparency_locks", SLE_UINT, S, 0, _transparency_lock, 0,0,0x1FF,0, STR_NULL, NULL),
SDTG_VAR("invisibility_options", SLE_UINT, S, 0, _invisibility_opt, 0,0, 0xFF,0, STR_NULL, NULL),
@@ -1487,7 +1487,7 @@ const SettingDesc _settings[] = {
SDT_CONDVAR(GameSettings, game_creation.land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 1, 0, 1, 0, STR_CONFIG_SETTING_LAND_GENERATOR, NULL),
SDT_CONDVAR(GameSettings, game_creation.oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE, NULL),
SDT_CONDVAR(GameSettings, game_creation.tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 1, 0, 3, 0, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN, NULL),
- SDT_CONDVAR(GameSettings, game_creation.generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, UINT32_MAX, 0, STR_NULL, NULL),
+ SDT_CONDVAR(GameSettings, game_creation.generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, INT32_MAX, 0, STR_NULL, NULL),
SDT_CONDVAR(GameSettings, game_creation.tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 2, 0, 2, 0, STR_CONFIG_SETTING_TREE_PLACER, NULL),
SDT_VAR(GameSettings, game_creation.heightmap_rotation, SLE_UINT8, S,MS, 0, 0, 1, 0, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION, NULL),
SDT_VAR(GameSettings, game_creation.se_flat_world_height, SLE_UINT8, S, 0, 1, 0, 15, 0, STR_CONFIG_SETTING_SE_FLAT_WORLD_HEIGHT, NULL),
diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp
index f99237d920..9b5f3a916d 100644
--- a/src/spriteloader/png.cpp
+++ b/src/spriteloader/png.cpp
@@ -22,7 +22,7 @@ static void PNGAPI png_my_read(png_structp png_ptr, png_bytep data, png_size_t l
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(sprite, 0, "ERROR (libpng): %s - %s", message, (char *)png_get_error_ptr(png_ptr));
- longjmp(png_ptr->jmpbuf, 1);
+ longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
@@ -99,8 +99,8 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
if (strcmp("y_offs", text_ptr[i].key) == 0) sprite->y_offs = strtol(text_ptr[i].text, NULL, 0);
}
- sprite->height = info_ptr->height;
- sprite->width = info_ptr->width;
+ sprite->height = png_get_image_height(png_ptr, info_ptr);
+ sprite->width = png_get_image_width(png_ptr, info_ptr);
sprite->AllocateData(sprite->width * sprite->height);
}
@@ -133,14 +133,14 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i
pixelsize = sizeof(uint8);
}
- png_bytep row_pointer = AllocaM(png_byte, info_ptr->width * pixelsize);
+ png_bytep row_pointer = AllocaM(png_byte, png_get_image_width(png_ptr, info_ptr) * pixelsize);
- for (i = 0; i < info_ptr->height; i++) {
+ for (i = 0; i < png_get_image_height(png_ptr, info_ptr); i++) {
png_read_row(png_ptr, row_pointer, NULL);
- dst = sprite->data + i * info_ptr->width;
+ dst = sprite->data + i * png_get_image_width(png_ptr, info_ptr);
- for (uint x = 0; x < info_ptr->width; x++) {
+ for (uint x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
if (mask) {
if (row_pointer[x * sizeof(uint8)] != 0) {
dst[x].r = 0;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index f3f9dc631e..00839332fe 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -252,7 +252,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
1 << M(STR_SV_STNAME_OILFIELD), // 2
1 << M(STR_SV_STNAME_DOCKS), // 3
0x1FF << M(STR_SV_STNAME_BUOY_1), // 4
- 1 << M(STR_SV_STNAME_HELIPORT), // 5
+ 1u << M(STR_SV_STNAME_HELIPORT), // 5
};
const Town *t = st->town;
diff --git a/src/table/station_land.h b/src/table/station_land.h
index 5dfcddaf60..815fb07291 100644
--- a/src/table/station_land.h
+++ b/src/table/station_land.h
@@ -26,7 +26,7 @@
*/
#define TILE_SEQ_LINE_PAL(dx, dy, dz, sx, sy, sz, img, pal) { dx, dy, dz, sx, sy, sz, {img, pal} },
/** Constructor macro for a terminating DrawTileSeqStruct entry in an array */
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
static const DrawTileSeqStruct _station_display_nothing[] = {
TILE_SEQ_END()
@@ -60,7 +60,7 @@ static const DrawTileSeqStruct _station_display_datas_4[] = {
TILE_SEQ_LINE( 0, 0, 0, 16, 5, 7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE( 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOUR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
@@ -68,7 +68,7 @@ static const DrawTileSeqStruct _station_display_datas_5[] = {
TILE_SEQ_LINE( 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE(11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOUR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
@@ -76,7 +76,7 @@ static const DrawTileSeqStruct _station_display_datas_6[] = {
TILE_SEQ_LINE( 0, 0, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_REAR | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE( 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B | (1 << PALETTE_MODIFIER_COLOUR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
@@ -84,7 +84,7 @@ static const DrawTileSeqStruct _station_display_datas_7[] = {
TILE_SEQ_LINE( 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_REAR | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE(11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOUR))
TILE_SEQ_LINE( 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B | (1 << PALETTE_MODIFIER_COLOUR))
- TILE_SEQ_LINE_PAL( 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
+ TILE_SEQ_LINE_PAL( 0, 0, (int8)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1u << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT)
TILE_SEQ_END()
};
diff --git a/src/table/track_land.h b/src/table/track_land.h
index 39c4be8283..7c2a94e3c0 100644
--- a/src/table/track_land.h
+++ b/src/table/track_land.h
@@ -3,7 +3,7 @@
/** @file track_land.h Sprites to use and how to display them for train depot/waypoint tiles. */
#define TILE_SEQ_LINE(img, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 23, {img, PAL_NONE} },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
static const DrawTileSeqStruct _depot_gfx_NE[] = {
diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h
index a30a4b64b0..5ed6840fc8 100644
--- a/src/table/unmovable_land.h
+++ b/src/table/unmovable_land.h
@@ -8,7 +8,7 @@ static const DrawTileSeqStruct _draw_tile_transmitterlighthouse_data[] = {
};
#define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} },
-#define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, {0, 0} }
+#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} }
static const DrawTileSeqStruct _unmovable_display_nothing[] = {
TILE_SEQ_END()
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index b14cc92ec7..37390ffd31 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1639,27 +1639,27 @@ enum VehicleCommandTranslation {
/** Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type. */
static const uint32 _vehicle_command_translation_table[][4] = {
{ // VCT_CMD_START_STOP
- CMD_START_STOP_VEHICLE | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN),
- CMD_START_STOP_VEHICLE | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE),
- CMD_START_STOP_VEHICLE | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP),
- CMD_START_STOP_VEHICLE | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)
+ (uint32)CMD_START_STOP_VEHICLE | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN),
+ (uint32)CMD_START_STOP_VEHICLE | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE),
+ (uint32)CMD_START_STOP_VEHICLE | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP),
+ (uint32)CMD_START_STOP_VEHICLE | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)
},
{ // VCT_CMD_GOTO_DEPOT
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
- CMD_SEND_TRAIN_TO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT),
- CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT),
- CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT),
- CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)
+ (uint32)CMD_SEND_TRAIN_TO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT),
+ (uint32)CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT),
+ (uint32)CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT),
+ (uint32)CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)
},
{ // VCT_CMD_CLONE_VEH
- CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE),
- CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE),
- CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP),
- CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE),
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE),
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP),
+ (uint32)CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)
},
{ // VCT_CMD_TURN_AROUND
- CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN),
- CMD_TURN_ROADVEH | CMD_MSG(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN),
+ (uint32)CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN),
+ (uint32)CMD_TURN_ROADVEH | CMD_MSG(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN),
0xffffffff, // invalid for ships
0xffffffff // invalid for aircrafts
},
@@ -2029,7 +2029,6 @@ struct VehicleViewWindow : Window {
}
};
-
/** Shows the vehicle view window of the given vehicle. */
void ShowVehicleViewWindow(const Vehicle *v)
{
diff --git a/src/window.cpp b/src/window.cpp
index 10ee2591b4..c4a0aa7bcd 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -560,7 +560,7 @@ Window::~Window()
free(this->widget);
- this->window_class = WC_INVALID;
+ const_cast<volatile WindowClass &>(this->window_class) = WC_INVALID;
}
/**
diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp
index 1e5ba5ef20..10c5d918f4 100644
--- a/src/yapf/yapf_road.cpp
+++ b/src/yapf/yapf_road.cpp
@@ -471,7 +471,7 @@ public:
/* find the best path */
bool bFound = Yapf().FindPath(v);
- if (!bFound) return false;
+ if (!bFound) return NULL;
/* some path found
* get found depot tile */
diff --git a/src/3rdparty/squirrel/squirrel/squtils.h b/src/3rdparty/squirrel/squirrel/squtils.h
index 55febe38c9..5f7e2e2393 100644
--- a/src/3rdparty/squirrel/squirrel/squtils.h
+++ b/src/3rdparty/squirrel/squirrel/squtils.h
@@ -2,6 +2,10 @@
#ifndef _SQUTILS_H_
#define _SQUTILS_H_
+void *sq_vm_malloc(SQUnsignedInteger size);
+void *sq_vm_realloc(void *p,SQUnsignedInteger oldsize,SQUnsignedInteger size);
+void sq_vm_free(void *p,SQUnsignedInteger size);
+
#define sq_new(__ptr,__type) {__ptr=(__type *)sq_vm_malloc(sizeof(__type));new (__ptr) __type;}
#define sq_delete(__ptr,__type) {__ptr->~__type();sq_vm_free(__ptr,sizeof(__type));}
#define SQ_MALLOC(__size) sq_vm_malloc((__size));
diff --git a/src/cmd_helper.h b/src/cmd_helper.h
index 0b56fb7670..f5434a07af 100644
--- a/src/cmd_helper.h
+++ b/src/cmd_helper.h
@@ -13,6 +13,7 @@
#define CMD_HELPER_H
#include "core/enum_type.hpp"
+#include "core/bitmath_func.hpp"
template<typename T, uint S, uint N, typename U> static inline T Extract(U v)
{
diff --git a/src/console.cpp b/src/console.cpp
index 926a868c68..76f0126070 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -463,7 +463,7 @@ void IConsoleCmdExec(const char *cmdstr)
DEBUG(console, 8, "Token %d is: '%s'", i, tokens[i]);
}
- if (tokens[0] == '\0') return; // don't execute empty commands
+ if (tokens[0] == NULL) return; // don't execute empty commands
/* 2. Determine type of command (cmd or alias) and execute
* First try commands, then aliases. Execute
* the found action taking into account its hooking code
diff --git a/src/fileio.cpp b/src/fileio.cpp
index c43f87567c..145020ae1b 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -22,9 +22,7 @@
#include <Path.h>
#include <storage/FindDirectory.h>
#else
-#if defined(OPENBSD) || defined(DOS)
#include <unistd.h>
-#endif
#include <pwd.h>
#endif
#include <sys/stat.h>
diff --git a/src/misc/str.hpp b/src/misc/str.hpp
index 7f65f19583..2941d9cce8 100644
--- a/src/misc/str.hpp
+++ b/src/misc/str.hpp
@@ -98,7 +98,7 @@ struct CStrA : public CBlobT<char>
int ret;
int err = 0;
for (;;) {
- char *buf = MakeFreeSpace(addSize);
+ char *buf = base::MakeFreeSpace(addSize);
ret = vsnprintf(buf, base::GetReserve(), format, args);
if (ret >= base::GetReserve()) {
/* Greater return than given count means needed buffer size. */
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index baed8d4140..bcc28ed664 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -428,7 +428,7 @@ public:
/* find the best path */
bool bFound = Yapf().FindPath(v);
- if (!bFound) return false;
+ if (!bFound) return NULL;
/* some path found
* get found depot tile */
diff --git a/src/table/palettes.h b/src/table/palettes.h
index 5ab88df695..2e5dbccd8e 100644
--- a/src/table/palettes.h
+++ b/src/table/palettes.h
@@ -11,7 +11,7 @@
#include "../core/endian_type.hpp"
-#define M(r, g, b) { 0xff << 24 | (r) << 16 | (g) << 8 | (b) }
+#define M(r, g, b) { 0xffU << 24 | (r) << 16 | (g) << 8 | (b) }
static const Colour _palettes[][256] = {
/* palette 0 (mixed TTD DOS + TTD Windows palette */
diff --git a/src/window.cpp b/src/window.cpp
index cf25124f22..4511302e49 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -629,7 +629,7 @@ Window::~Window()
free(this->nested_array); // Contents is released through deletion of #nested_root.
delete this->nested_root;
- this->window_class = WC_INVALID;
+ const_cast<volatile WindowClass &>(this->window_class) = WC_INVALID;
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment