From 2f457aeffcf77dc02227c5133573bf854b68d2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Wed, 28 Oct 2015 08:02:30 +0100 Subject: [PATCH] Cleanups * Remove unused function in config.c * Check handle *before* it is used * Provide explicit parentheses around unclear if statements --- src/config.c | 20 -------------------- src/peep/peep.c | 4 ++-- src/platform/linux.c | 9 ++++++--- src/ride/ride_data.c | 4 ++-- src/world/map.c | 10 +++++----- 5 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/config.c b/src/config.c index a293bac650..50dc70b522 100644 --- a/src/config.c +++ b/src/config.c @@ -692,26 +692,6 @@ static void config_write_enum(SDL_RWops *file, uint8 type, value_union *value, c config_save_property_value(file, type, value); } -static int utf8_read(utf8 **outch) -{ - int result; - int numBytes; - - utf8 *ch = *outch; - if (!(ch[0] & 0x80)) { - result = ch[0]; - numBytes = 1; - } else if (!(ch[0] & 0x20)) { - result = ((ch[0] & 0x1F) << 6) | (ch[1] & 0x3F); - numBytes = 2; - } else { - numBytes = 1; - } - - *outch = ch + numBytes; - return result; -} - static void utf8_skip_whitespace(utf8 **outch) { utf8 *ch; diff --git a/src/peep/peep.c b/src/peep/peep.c index 1f9c815739..b1a6979058 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -7905,10 +7905,10 @@ static bool sub_69AF1E(rct_peep *peep, int rideIndex, int shopItem, money32 pric if (shop_item_is_food_or_drink(shopItem)) { int food = -1; - if (food = peep_has_food_standard_flag(peep)) { + if ((food = peep_has_food_standard_flag(peep))) { peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_HAVENT_FINISHED, bitscanforward(food)); return 0; - } else if (food = peep_has_food_extra_flag(peep)) { + } else if ((food = peep_has_food_extra_flag(peep))) { peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_HAVENT_FINISHED, bitscanforward(food) + 32); return 0; } else if (peep->nausea >= 145) diff --git a/src/platform/linux.c b/src/platform/linux.c index bccad09470..4fd11fc530 100644 --- a/src/platform/linux.c +++ b/src/platform/linux.c @@ -317,13 +317,16 @@ int platform_enumerate_files_begin(const utf8 *pattern) bool platform_enumerate_files_next(int handle, file_info *outFileInfo) { - bool result; + bool result = true; enumerate_file_info *enumFileInfo; + if (handle < 0) + { + result = false; + } enumFileInfo = &_enumerateFileInfoList[handle]; - log_verbose("handle = %d", handle); - if ((handle >= 0) && (enumFileInfo->handle < enumFileInfo->cnt)) { + if (result && (enumFileInfo->handle < enumFileInfo->cnt)) { result = true; } else { result = false; diff --git a/src/ride/ride_data.c b/src/ride/ride_data.c index c3679300e7..41cfe8ac47 100644 --- a/src/ride/ride_data.c +++ b/src/ride/ride_data.c @@ -1291,8 +1291,8 @@ const rct_ride_type_vehicle CableLiftVehicle = { .powered_acceleration = 0, .powered_max_speed = 0, .car_visual = 0, - .pad_5E = { 1 }, + .pad_5E = 1, .draw_order = 14, .special_frames = 0, .peep_loading_positions = NULL -}; \ No newline at end of file +}; diff --git a/src/world/map.c b/src/world/map.c index 7f6af24a97..15b2bfe78b 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -912,7 +912,7 @@ void game_command_remove_scenery(int* eax, int* ebx, int* ecx, int* edx, int* es while(map_element->type != map_element_type || map_element->base_height != base_height || map_element->properties.scenery.type != scenery_type || - (*ebx & 0x40) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST)){ + ((*ebx & GAME_COMMAND_FLAG_GHOST) && !(map_element->flags & MAP_ELEMENT_FLAG_GHOST))){ map_element++; if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){ *ebx = 0; @@ -3844,10 +3844,10 @@ int map_can_construct_with_clear_at(int x, int y, int zLow, int zHigh, void *cle ch += 2; } int bh = zLow + 4; - if ((!(bl & 1) || (bl & 0x10 || zLow >= al) && bh >= al) && - (!(bl & 2) || (bl & 0x20 || zLow >= ah) && bh >= ah) && - (!(bl & 4) || (bl & 0x40 || zLow >= cl) && bh >= cl) && - (!(bl & 8) || (bl & 0x80 || zLow >= ch) && bh >= ch)) { + if ((!(bl & 1) || ((bl & 0x10 || zLow >= al) && bh >= al)) && + (!(bl & 2) || ((bl & 0x20 || zLow >= ah) && bh >= ah)) && + (!(bl & 4) || ((bl & 0x40 || zLow >= cl) && bh >= cl)) && + (!(bl & 8) || ((bl & 0x80 || zLow >= ch) && bh >= ch))) { continue; } loc_68BABC: