Replace 1 and 0 constants with bool where applicable

This commit is contained in:
Hielke Morsink 2017-12-20 14:07:29 +01:00 committed by Michael Steenbeek
parent 628039dd8a
commit 3770b46e46
8 changed files with 67 additions and 67 deletions

View File

@ -193,10 +193,10 @@ typedef fixed64_1dp money64;
typedef void (EMPTY_ARGS_VOID_POINTER)();
typedef uint16 rct_string_id;
#define SafeFree(x) do { free(x); (x) = NULL; } while (0)
#define SafeFree(x) do { free(x); (x) = NULL; } while (false)
#define SafeDelete(x) do { delete (x); (x) = nullptr; } while (0)
#define SafeDeleteArray(x) do { delete[] (x); (x) = nullptr; } while (0)
#define SafeDelete(x) do { delete (x); (x) = nullptr; } while (false)
#define SafeDeleteArray(x) do { delete[] (x); (x) = nullptr; } while (false)
#ifndef interface
#define interface struct

View File

@ -145,7 +145,7 @@ bool language_open(sint32 id)
return true;
}
return 0;
return false;
}
void language_close_all()

View File

@ -151,13 +151,13 @@ static inline void set_format_arg_body(uint8 *args, size_t offset, uintptr_t val
#define set_format_arg(offset, type, value) \
do { static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \
set_format_arg_body(gCommonFormatArgs, offset, (uintptr_t)value, sizeof(type)); } while (0)
set_format_arg_body(gCommonFormatArgs, offset, (uintptr_t)value, sizeof(type)); } while (false)
#define set_format_arg_on(args, offset, type, value) \
set_format_arg_body(args, offset, (uintptr_t)value, sizeof(type))
#define set_map_tooltip_format_arg(offset, type, value) \
do { static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \
set_format_arg_body(gMapTooltipFormatArgs, offset, (uintptr_t)value, sizeof(type)); } while (0)
set_format_arg_body(gMapTooltipFormatArgs, offset, (uintptr_t)value, sizeof(type)); } while (false)
#endif

View File

@ -86,11 +86,11 @@ static bool award_is_deserved_most_untidy(sint32 awardType, sint32 activeAwardTy
sint32 negativeCount;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_BEAUTIFUL))
return 0;
return false;
if (activeAwardTypes & (1 << PARK_AWARD_BEST_STAFF))
return 0;
return false;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_TIDY))
return 0;
return false;
negativeCount = 0;
FOR_ALL_GUESTS(spriteIndex, peep)
@ -121,9 +121,9 @@ static bool award_is_deserved_most_tidy(sint32 awardType, sint32 activeAwardType
sint32 negativeCount;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_UNTIDY))
return 0;
return false;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
return false;
positiveCount = 0;
negativeCount = 0;
@ -186,21 +186,21 @@ static bool award_is_deserved_best_rollercoasters(sint32 awardType, sint32 activ
static bool award_is_deserved_best_value(sint32 awardType, sint32 activeAwardTypes)
{
if (activeAwardTypes & (1 << PARK_AWARD_WORST_VALUE))
return 0;
return false;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
return false;
if (gParkFlags & (PARK_FLAGS_NO_MONEY | PARK_FLAGS_PARK_FREE_ENTRY))
return 0;
return false;
if (gTotalRideValueForMoney < MONEY(10, 00))
return 0;
return false;
if (park_get_entrance_fee() + MONEY(0, 10) >= gTotalRideValueForMoney / 2)
return 0;
return false;
return 1;
return true;
}
/** More than 1/128 of the total guests must be thinking scenic thoughts and fewer than 16 untidy thoughts. */
@ -212,9 +212,9 @@ static bool award_is_deserved_most_beautiful(sint32 awardType, sint32 activeAwar
sint32 negativeCount;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_UNTIDY))
return 0;
return false;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
return false;
positiveCount = 0;
negativeCount = 0;
@ -244,16 +244,16 @@ static bool award_is_deserved_most_beautiful(sint32 awardType, sint32 activeAwar
static bool award_is_deserved_worst_value(sint32 awardType, sint32 activeAwardTypes)
{
if (activeAwardTypes & (1 << PARK_AWARD_BEST_VALUE))
return 0;
return false;
if (gParkFlags & PARK_FLAGS_NO_MONEY)
return 0;
return false;
money32 parkEntranceFee = park_get_entrance_fee();
if (parkEntranceFee == MONEY(0, 00))
return 0;
return false;
if (parkEntranceFee <= gTotalRideValueForMoney)
return 0;
return 1;
return false;
return true;
}
/** No more than 2 people who think the vandalism is bad and no crashes. */
@ -274,16 +274,16 @@ static bool award_is_deserved_safest(sint32 awardType, sint32 activeAwardTypes)
}
if (peepsWhoDislikeVandalism > 2)
return 0;
return false;
// Check for rides that have crashed maybe?
FOR_ALL_RIDES(i, ride)
{
if (ride->last_crash_type != RIDE_CRASH_TYPE_NONE)
return 0;
return false;
}
return 1;
return true;
}
/** All staff types, at least 20 staff, one staff per 32 peeps. */
@ -295,7 +295,7 @@ static bool award_is_deserved_best_staff(sint32 awardType, sint32 activeAwardTyp
sint32 staffTypeFlags;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_UNTIDY))
return 0;
return false;
peepCount = 0;
staffCount = 0;
@ -328,7 +328,7 @@ static bool award_is_deserved_best_food(sint32 awardType, sint32 activeAwardType
rct_peep * peep;
if (activeAwardTypes & (1 << PARK_AWARD_WORST_FOOD))
return 0;
return false;
shops = 0;
uniqueShops = 0;
@ -354,7 +354,7 @@ static bool award_is_deserved_best_food(sint32 awardType, sint32 activeAwardType
}
if (shops < 7 || uniqueShops < 4 || shops < gNumGuestsInPark / 128)
return 0;
return false;
// Count hungry peeps
hungryPeeps = 0;
@ -381,7 +381,7 @@ static bool award_is_deserved_worst_food(sint32 awardType, sint32 activeAwardTyp
rct_peep * peep;
if (activeAwardTypes & (1 << PARK_AWARD_BEST_FOOD))
return 0;
return false;
shops = 0;
uniqueShops = 0;
@ -407,7 +407,7 @@ static bool award_is_deserved_worst_food(sint32 awardType, sint32 activeAwardTyp
}
if (uniqueShops > 2 || shops > gNumGuestsInPark / 256)
return 0;
return false;
// Count hungry peeps
hungryPeeps = 0;
@ -441,11 +441,11 @@ static bool award_is_deserved_best_restrooms(sint32 awardType, sint32 activeAwar
// At least 4 open restrooms
if (numRestrooms < 4)
return 0;
return false;
// At least one open restroom for every 128 guests
if (numRestrooms < gNumGuestsInPark / 128U)
return 0;
return false;
// Count number of guests who are thinking they need the restroom
guestsWhoNeedRestroom = 0;
@ -468,9 +468,9 @@ static bool award_is_deserved_most_disappointing(sint32 awardType, sint32 active
Ride * ride;
if (activeAwardTypes & (1 << PARK_AWARD_BEST_VALUE))
return 0;
return false;
if (gParkRating > 650)
return 0;
return false;
// Count the number of disappointing rides
countedRides = 0;
@ -531,7 +531,7 @@ static bool award_is_deserved_best_custom_designed_rides(sint32 awardType, sint3
Ride * ride;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
return false;
customDesignedRides = 0;
FOR_ALL_RIDES(i, ride)
@ -561,7 +561,7 @@ static bool award_is_deserved_most_dazzling_ride_colours(sint32 awardType, sint3
uint8 mainTrackColour;
if (activeAwardTypes & (1 << PARK_AWARD_MOST_DISAPPOINTING))
return 0;
return false;
countedRides = 0;
colourfulRides = 0;

View File

@ -770,31 +770,31 @@ extern "C"
{
if ((a->flags & 0x0F) != (b->flags & 0x0F))
{
return 0;
return false;
}
sint32 match = memcmp(a->name, b->name, 8);
if (match)
{
return 0;
return false;
}
}
else
{
if (a->flags != b->flags)
{
return 0;
return false;
}
sint32 match = memcmp(a->name, b->name, 8);
if (match)
{
return 0;
return false;
}
if (a->checksum != b->checksum)
{
return 0;
return false;
}
}
return 1;
return true;
}
sint32 object_calculate_checksum(const rct_object_entry * entry, const void * data, size_t dataLength)

View File

@ -1907,7 +1907,7 @@ void peep_update_sprite_type(rct_peep * peep)
if (x < 0x1FFF && y < 0x1FFF)
{
rct_tile_element * tile_element = map_get_first_element_at(x / 32, y / 32);
while (1)
while (true)
{
if ((peep->z / 8) < tile_element->base_height)
break;
@ -5441,7 +5441,7 @@ static void peep_update_mowing(rct_peep * peep)
return;
invalidate_sprite_2((rct_sprite *)peep);
while (1)
while (true)
{
sint16 x = 0, y = 0, z, xy_distance;
if (peep_update_action(&x, &y, &xy_distance, peep))
@ -9209,7 +9209,7 @@ static sint32 peep_interact_with_path(rct_peep * peep, sint16 x, sint16 y, rct_t
if (footpath_element_has_path_scenery(tile_element) && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN) &&
(tile_element->properties.path.edges & 0xF) != 0xF)
{
vandalism_present = 1;
vandalism_present = true;
}
sint16 z = tile_element->base_height * 8;
@ -9799,7 +9799,7 @@ static sint32 guest_path_find_aimless(rct_peep * peep, uint8 edges)
}
}
while (1)
while (true)
{
uint8 direction = peep_rand() & 3;
// Otherwise go in a random direction allowed from the tile.
@ -11134,7 +11134,7 @@ static void get_ride_queue_end(sint16 * x, sint16 * y, sint16 * z)
sint16 baseZ = tileElement->base_height;
sint16 nextX = *x;
sint16 nextY = *y;
while (1)
while (true)
{
if (tile_element_get_type(tileElement) == TILE_ELEMENT_TYPE_PATH)
{
@ -12128,7 +12128,7 @@ static bool peep_decide_and_buy_item(rct_peep * peep, sint32 rideIndex, sint32 s
if (peep_has_item(peep, shopItem))
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_ALREADY_GOT, shopItem);
return 0;
return false;
}
if (shop_item_is_food_or_drink(shopItem))
@ -12137,40 +12137,40 @@ static bool peep_decide_and_buy_item(rct_peep * peep, sint32 rideIndex, sint32 s
if ((food = peep_has_food_standard_flag(peep)) != 0)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_HAVENT_FINISHED, bitscanforward(food));
return 0;
return false;
}
else if ((food = peep_has_food_extra_flag(peep)) != 0)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_HAVENT_FINISHED, bitscanforward(food) + 32);
return 0;
return false;
}
else if (peep->nausea >= 145)
return 0;
return false;
}
if ((shopItem == SHOP_ITEM_BALLOON) || (shopItem == SHOP_ITEM_ICE_CREAM) || (shopItem == SHOP_ITEM_CANDYFLOSS) ||
(shopItem == SHOP_ITEM_SUNGLASSES))
{
if (gClimateCurrentRainLevel != 0)
return 0;
return false;
}
if ((shopItem == SHOP_ITEM_SUNGLASSES) || (shopItem == SHOP_ITEM_ICE_CREAM))
{
if (gClimateCurrentTemperature < 12)
return 0;
return false;
}
if (shop_item_is_food(shopItem) && (peep->hunger > 75))
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_NOT_HUNGRY, 0xFF);
return 0;
return false;
}
if (shop_item_is_drink(shopItem) && (peep->thirst > 75))
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_NOT_THIRSTY, 0xFF);
return 0;
return false;
}
if ((shopItem == SHOP_ITEM_UMBRELLA) && (gClimateCurrentRainLevel != 0))
@ -12179,9 +12179,9 @@ static bool peep_decide_and_buy_item(rct_peep * peep, sint32 rideIndex, sint32 s
if ((shopItem != SHOP_ITEM_MAP) && shop_item_is_souvenir(shopItem) && !has_voucher)
{
if (((peep_rand() & 0x7F) + 0x73) > peep->happiness)
return 0;
return false;
else if (peep->no_of_rides < 3)
return 0;
return false;
}
loc_69B119:
@ -12192,12 +12192,12 @@ loc_69B119:
if (peep->cash_in_pocket == 0)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_SPENT_MONEY, 0xFF);
return 0;
return false;
}
if (price > peep->cash_in_pocket)
{
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_CANT_AFFORD, shopItem);
return 0;
return false;
}
}
@ -12230,7 +12230,7 @@ loc_69B119:
uint8 thought_type = (shopItem >= 32 ? (PEEP_THOUGHT_TYPE_PHOTO2_MUCH + (shopItem - 32))
: (PEEP_THOUGHT_TYPE_BALLOON_MUCH + shopItem));
peep_insert_new_thought(peep, thought_type, rideIndex);
return 0;
return false;
}
}
else
@ -12375,7 +12375,7 @@ loc_69B221:
ride->total_customers++;
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER;
return 1;
return true;
}
/**

View File

@ -1603,7 +1603,7 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin
if (cost == MONEY32_UNDEFINED)
{
_trackDesignPlaceCost = cost;
return 0;
return false;
}
_trackDesignPlaceStateEntranceExitPlaced = true;
break;
@ -1623,7 +1623,7 @@ static bool track_design_place_ride(rct_track_td6 * td6, sint16 x, sint16 y, sin
if (cost == MONEY32_UNDEFINED)
{
_trackDesignPlaceCost = cost;
return 0;
return false;
}
else
{

View File

@ -994,7 +994,7 @@ void vehicle_sounds_update()
g_music_tracking_viewport = NULL;
rct_viewport * viewport = NULL;
rct_window * window = gWindowNextSlot;
while (1)
while (true)
{
window--;
if (window < g_window_list)
@ -6340,7 +6340,7 @@ static sint32 vehicle_update_motion_dodgems(rct_vehicle * vehicle)
vehicle_invalidate(vehicle);
while (1)
while (true)
{
vehicle->var_35++;
uint8 direction = vehicle->sprite_direction;