From 18597bacb1fd452ad184466ad7bc648456633ca6 Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 12 Jan 2017 17:36:05 +0000 Subject: [PATCH] Fix more warnings --- src/openrct2/network/TcpSocket.cpp | 2 +- src/openrct2/object/ObjectRepository.cpp | 18 ------------------ src/openrct2/paint/map_element/map_element.c | 10 +++++----- src/openrct2/paint/map_element/path.c | 17 +++++++++-------- src/openrct2/paint/map_element/scenery.c | 4 ++-- .../paint/map_element/scenery_multiple.c | 8 ++++---- src/openrct2/paint/map_element/surface.c | 10 +++++----- src/openrct2/paint/supports.c | 12 ++++++------ src/openrct2/peep/peep.c | 16 ++++++++-------- 9 files changed, 40 insertions(+), 57 deletions(-) diff --git a/src/openrct2/network/TcpSocket.cpp b/src/openrct2/network/TcpSocket.cpp index 717d7d849b..dfdb9d1404 100644 --- a/src/openrct2/network/TcpSocket.cpp +++ b/src/openrct2/network/TcpSocket.cpp @@ -294,7 +294,7 @@ public: if (select((int)(_socket + 1), nullptr, &writeFD, nullptr, &timeout) > 0) { error = 0; - socklen_t len = sizeof(error); + len = sizeof(error); if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char*)&error, &len) != 0) { throw SocketException("getsockopt failed with error: " + std::to_string(LAST_SOCKET_ERROR())); diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 35771ddbbb..209cf20a08 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -644,17 +644,6 @@ IObjectRepository * GetObjectRepository() return _objectRepository.get(); } -static int GetObjectEntryIndex(uint8 objectType, uint8 entryIndex) -{ - int result = 0; - for (uint8 i = 0; i < objectType; i++) - { - result += object_entry_group_counts[i]; - } - result += entryIndex; - return result; -} - extern "C" { rct_object_entry * object_list_find(rct_object_entry * entry) @@ -962,10 +951,3 @@ extern "C" return (int)checksum; } } - -static void ReportMissingObject(const rct_object_entry * entry) -{ - utf8 objName[9] = { 0 }; - Memory::Copy(objName, entry->name, 8); - Console::Error::WriteLine("[%s] Object not found.", objName); -} diff --git a/src/openrct2/paint/map_element/map_element.c b/src/openrct2/paint/map_element/map_element.c index d6dccbfec6..e8c198ba06 100644 --- a/src/openrct2/paint/map_element/map_element.c +++ b/src/openrct2/paint/map_element/map_element.c @@ -295,9 +295,9 @@ static void sub_68B3FB(int x, int y) {1, 7, 3}, }; - for (int y = 0; y < 3; y++) { - for (int x = 0; x < 3; x++) { - uint16 segmentHeight = gSupportSegments[segmentPositions[y][x]].height; + for (int sy = 0; sy < 3; sy++) { + for (int sx = 0; sx < 3; sx++) { + uint16 segmentHeight = gSupportSegments[segmentPositions[sy][sx]].height; int imageColourFlats = 0b101111 << 19 | 0x40000000; if (segmentHeight == 0xFFFF) { segmentHeight = gSupport.height; @@ -305,8 +305,8 @@ static void sub_68B3FB(int x, int y) imageColourFlats = 0b111011 << 19 | 0x40000000; } - int xOffset = y * 10; - int yOffset = -22 + x * 10; + int xOffset = sy * 10; + int yOffset = -22 + sx * 10; paint_struct * ps = sub_98197C(5504 | imageColourFlats, xOffset, yOffset, 10, 10, 1, segmentHeight, xOffset + 1, yOffset + 16, segmentHeight, get_current_rotation()); if (ps != NULL) { ps->flags &= PAINT_STRUCT_FLAG_IS_MASKED; diff --git a/src/openrct2/paint/map_element/path.c b/src/openrct2/paint/map_element/path.c index 628d57e31e..9185405eeb 100644 --- a/src/openrct2/paint/map_element/path.c +++ b/src/openrct2/paint/map_element/path.c @@ -727,7 +727,8 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) sint32 staffIndex = gStaffDrawPatrolAreas; uint8 staffType = staffIndex & 0x7FFF; bool is_staff_list = staffIndex & 0x8000; - sint16 x = gPaintMapPosition.x, y = gPaintMapPosition.y; + x = gPaintMapPosition.x; + y = gPaintMapPosition.y; uint8 patrolColour = COLOUR_LIGHT_BLUE; @@ -741,26 +742,26 @@ void path_paint(uint8 direction, uint16 height, rct_map_element * map_element) if (staff_is_patrol_area_set(200 + staffType, x, y)) { uint32 imageId = 2618; - int height = map_element->base_height * 8; + int height2 = map_element->base_height * 8; if (footpath_element_is_sloped(map_element)) { imageId = 2619 + ((map_element->properties.path.type + get_current_rotation()) & 3); - height += 16; + height2 += 16; } - sub_98196C(imageId | patrolColour << 19 | 0x20000000, 16, 16, 1, 1, 0, height + 2, get_current_rotation()); + sub_98196C(imageId | patrolColour << 19 | 0x20000000, 16, 16, 1, 1, 0, height2 + 2, get_current_rotation()); } } if (gCurrentViewportFlags & VIEWPORT_FLAG_PATH_HEIGHTS) { - uint16 height = 3 + map_element->base_height * 8; + uint16 height2 = 3 + map_element->base_height * 8; if (footpath_element_is_sloped(map_element)) { - height += 8; + height2 += 8; } - uint32 imageId = (SPR_HEIGHT_MARKER_BASE + height / 16) | COLOUR_GREY << 19 | 0x20000000; + uint32 imageId = (SPR_HEIGHT_MARKER_BASE + height2 / 16) | COLOUR_GREY << 19 | 0x20000000; imageId += get_height_marker_offset(); imageId -= gMapBaseZ; - sub_98196C(imageId, 16, 16, 1, 1, 0, height, get_current_rotation()); + sub_98196C(imageId, 16, 16, 1, 1, 0, height2, get_current_rotation()); } uint8 pathType = (map_element->properties.path.type & 0xF0) >> 4; diff --git a/src/openrct2/paint/map_element/scenery.c b/src/openrct2/paint/map_element/scenery.c index e4378f9d0d..2dbb61be8d 100644 --- a/src/openrct2/paint/map_element/scenery.c +++ b/src/openrct2/paint/map_element/scenery.c @@ -296,7 +296,7 @@ void scenery_paint(uint8 direction, int height, rct_map_element* mapElement) { } if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE) { // 6E075C: - uint8 direction = (map_element_get_scenery_quadrant(mapElement) + rotation) % 4; + direction = (map_element_get_scenery_quadrant(mapElement) + rotation) % 4; paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, direction), height, 0x20); return; } @@ -310,7 +310,7 @@ void scenery_paint(uint8 direction, int height, rct_map_element* mapElement) { return; } if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE) { - uint8 direction = (map_element_get_scenery_quadrant(mapElement) + rotation) % 4; + direction = (map_element_get_scenery_quadrant(mapElement) + rotation) % 4; paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0); return; } diff --git a/src/openrct2/paint/map_element/scenery_multiple.c b/src/openrct2/paint/map_element/scenery_multiple.c index 30ca855d14..440c2507dd 100644 --- a/src/openrct2/paint/map_element/scenery_multiple.c +++ b/src/openrct2/paint/map_element/scenery_multiple.c @@ -233,7 +233,7 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map return; } if (entry->large_scenery.flags & 0x4) { - if (entry->large_scenery.tiles[1].x_offset != (sint16)0xFFFF) { + if (entry->large_scenery.tiles[1].x_offset != (sint16)(uint16)0xFFFF) { int al = ((mapElement->properties.surface.terrain >> 2) - 1) & 3; if (al != direction) { scenery_multiple_paint_supports(direction, height, mapElement, dword_F4387C, tile); @@ -272,12 +272,12 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map utf8 fitStr[32]; const utf8 *fitStrPtr = fitStr; safe_strcpy(fitStr, scenery_multiple_sign_fit_text(signString, text, true), sizeof(fitStr)); - int height = scenery_multiple_sign_text_height(fitStr, text); + int height2 = scenery_multiple_sign_text_height(fitStr, text); uint32 codepoint; while ((codepoint = utf8_get_next(fitStrPtr, &fitStrPtr)) != 0) { utf8 str[5] = {0}; utf8_write_codepoint(str, codepoint); - scenery_multiple_sign_paint_line(str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - height); + scenery_multiple_sign_paint_line(str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - height2); y_offset += scenery_multiple_sign_get_glyph(text, codepoint)->height * 2; } } else { @@ -302,7 +302,7 @@ void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *map spacesrc = src; spacedst = dst; } - } while(w <= text->max_width && (dst = utf8_write_codepoint(dst, codepoint)) && (srcold = src) && (codepoint = utf8_get_next(src, (const utf8**)&src))); + } while(w <= text->max_width && (dst = utf8_write_codepoint(dst, codepoint)) != NULL && (srcold = src) != NULL && (codepoint = utf8_get_next(src, (const utf8**)&src)) != '\0'); src = srcold; if (spacesrc && codepoint) { *spacedst = 0; diff --git a/src/openrct2/paint/map_element/surface.c b/src/openrct2/paint/map_element/surface.c index 18117e137a..ef71e0811e 100644 --- a/src/openrct2/paint/map_element/surface.c +++ b/src/openrct2/paint/map_element/surface.c @@ -1014,7 +1014,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) tileDescriptors[i + 1].slope = ebx; uint8 baseHeight = surfaceElement->base_height / 2; - corner_height ch = corner_heights[ebx]; + ch = corner_heights[ebx]; tileDescriptors[i + 1].corner_heights.top = baseHeight + ch.top; tileDescriptors[i + 1].corner_heights.right = baseHeight + ch.right; tileDescriptors[i + 1].corner_heights.bottom = baseHeight + ch.bottom; @@ -1170,8 +1170,8 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } else if (mapElement->properties.surface.ownership & OWNERSHIP_AVAILABLE) { rct_xy16 pos = {gPaintMapPosition.x, gPaintMapPosition.y}; paint_struct * backup = g_ps_F1AD28; - int height = (map_element_height(pos.x + 16, pos.y + 16) & 0xFFFF) + 3; - sub_98196C(22955, 16, 16, 1, 1, 0, height, rotation); + int height2 = (map_element_height(pos.x + 16, pos.y + 16) & 0xFFFF) + 3; + sub_98196C(22955, 16, 16, 1, 1, 0, height2, rotation); g_ps_F1AD28 = backup; } } @@ -1185,8 +1185,8 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } else if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) { paint_struct * backup = g_ps_F1AD28; rct_xy16 pos = {gPaintMapPosition.x, gPaintMapPosition.y}; - int height = map_element_height(pos.x + 16, pos.y + 16) & 0xFFFF; - sub_98196C(22956, 16, 16, 1, 1, 0, height + 3, rotation); + int height2 = map_element_height(pos.x + 16, pos.y + 16) & 0xFFFF; + sub_98196C(22956, 16, 16, 1, 1, 0, height2 + 3, rotation); g_ps_F1AD28 = backup; } } diff --git a/src/openrct2/paint/supports.c b/src/openrct2/paint/supports.c index dec4d064bc..312e9fc7c6 100644 --- a/src/openrct2/paint/supports.c +++ b/src/openrct2/paint/supports.c @@ -911,14 +911,14 @@ bool metal_b_supports_paint_setup(uint8 supportType, uint8 segment, int special, uint8 ebp = _97AF32[baseIndex + segment * 8]; if (baseHeight <= gSupportSegments[ebp].height) { baseIndex += 9 * 4 * 2; // 9 segments, 4 directions, 2 values - uint8 ebp = _97AF32[baseIndex + segment * 8]; - if (baseHeight <= gSupportSegments[ebp].height) { + uint8 ebp2 = _97AF32[baseIndex + segment * 8]; + if (baseHeight <= gSupportSegments[ebp2].height) { baseIndex += 9 * 4 * 2; - uint8 ebp = _97AF32[baseIndex + segment * 8]; - if (baseHeight <= gSupportSegments[ebp].height) { + uint8 ebp3 = _97AF32[baseIndex + segment * 8]; + if (baseHeight <= gSupportSegments[ebp3].height) { baseIndex += 9 * 4 * 2; - uint8 ebp = _97AF32[baseIndex + segment * 8]; - if (baseHeight <= gSupportSegments[ebp].height) { + uint8 ebp4 = _97AF32[baseIndex + segment * 8]; + if (baseHeight <= gSupportSegments[ebp4].height) { return true; // STC } } diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index 80ce5e992f..6d1a867f91 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -982,7 +982,7 @@ static void sub_68F41A(rct_peep *peep, int index) } } - if (peep->peep_flags & PEEP_FLAGS_EXPLODE && peep->x != (sint16)0x8000){ + if (peep->peep_flags & PEEP_FLAGS_EXPLODE && peep->x != MAP_LOCATION_NULL){ audio_play_sound_at_location(SOUND_CRASH, peep->x, peep->y, peep->z); sprite_misc_explosion_cloud_create(peep->x, peep->y, peep->z + 16); @@ -1016,7 +1016,7 @@ static void sub_68F41A(rct_peep *peep, int index) peep->var_F2++; if (peep->var_F2 >= 18){ peep->var_F2 = 0; - if (peep->x != (sint16)0x8000){ + if (peep->x != MAP_LOCATION_NULL){ uint8 thought_type = peep_assess_surroundings(peep->x & 0xFFE0, peep->y & 0xFFE0, peep->z); @@ -2159,7 +2159,7 @@ static void peep_update_falling(rct_peep* peep){ if (peep->item_standard_flags & PEEP_ITEM_BALLOON) { peep->item_standard_flags &= ~PEEP_ITEM_BALLOON; - if (peep->sprite_type == PEEP_SPRITE_TYPE_BALLOON && peep->x != (sint16) 0x8000) { + if (peep->sprite_type == PEEP_SPRITE_TYPE_BALLOON && peep->x != MAP_LOCATION_NULL) { create_balloon(peep->x, peep->y, height, peep->balloon_colour, 0); peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; peep_update_sprite_type(peep); @@ -6971,7 +6971,7 @@ void peep_update_crowd_noise() visiblePeeps = 0; FOR_ALL_GUESTS(spriteIndex, peep) { - if (peep->sprite_left == (sint16)0x8000) + if (peep->sprite_left == (sint16)(uint16)0x8000) continue; if (viewport->view_x > peep->sprite_right) continue; @@ -7035,7 +7035,7 @@ void peep_applause() // Release balloon if (peep->item_standard_flags & PEEP_ITEM_BALLOON) { peep->item_standard_flags &= ~PEEP_ITEM_BALLOON; - if (peep->x != (sint16)0x8000) { + if (peep->x != MAP_LOCATION_NULL) { create_balloon(peep->x, peep->y, peep->z + 9, peep->balloon_colour, 0); peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY; peep_update_sprite_type(peep); @@ -7270,7 +7270,7 @@ rct_peep *peep_generate(int x, int y, int z) cash = 0; } - if (gGuestInitialCash == (money16)0xFFFF){ + if (gGuestInitialCash == (money16)(uint16)0xFFFF){ cash = 0; } @@ -9838,7 +9838,7 @@ static int guest_path_find_entering_park(rct_peep *peep, rct_map_element *map_el uint8 chosenEntrance = 0xFF; uint16 nearestDist = 0xFFFF; for (uint8 entranceNum = 0; entranceNum < 4; ++entranceNum){ - if (gParkEntranceX[entranceNum] == (sint16)0x8000) + if (gParkEntranceX[entranceNum] == MAP_LOCATION_NULL) continue; uint16 dist = abs(gParkEntranceX[entranceNum] - peep->next_x) + @@ -9910,7 +9910,7 @@ static int guest_path_find_park_entrance(rct_peep* peep, rct_map_element *map_el // Resolves already-corrupt guests (e.g. loaded from save) if (peep->peep_flags & PEEP_FLAGS_PARK_ENTRANCE_CHOSEN && - (peep->current_ride >= 4 || gParkEntranceX[peep->current_ride] == (sint16)0x8000) + (peep->current_ride >= 4 || gParkEntranceX[peep->current_ride] == MAP_LOCATION_NULL) ) { peep->peep_flags &= ~(PEEP_FLAGS_PARK_ENTRANCE_CHOSEN); }