Merge pull request #2291 from janisozaur/fixes

Minor cleanups
This commit is contained in:
Duncan 2015-11-12 21:40:57 +00:00
commit 1963d98a71
14 changed files with 39 additions and 29 deletions

View File

@ -264,6 +264,7 @@ bool sprite_file_import(const char *path, rct_g1_element *outElement, uint8 **ou
// A larger range is needed for proper dithering
sint16 *src = malloc(height * width * 4 * 2);
sint16 *src_orig = src;
for (uint32 x = 0; x < height * width * 4; x++){
src[x] = (sint16) pixels[x];
}
@ -375,7 +376,7 @@ bool sprite_file_import(const char *path, rct_g1_element *outElement, uint8 **ou
}
}
free(pixels);
free(src);
free(src_orig);
int bufferLength = (int)(dst - buffer);
buffer = realloc(buffer, bufferLength);

View File

@ -1493,7 +1493,7 @@ static void title_sequence_open(const char *path, const char *customName)
token = &parts[0 * 128];
part1 = &parts[1 * 128];
part2 = &parts[2 * 128];
title_command command;
title_command command = { 0 };
command.command = 0xFF;
if (token[0] != 0) {

View File

@ -4147,7 +4147,7 @@ static void peep_update_using_bin(rct_peep* peep){
uint32 empty_containers = peep_empty_container_standard_flag(peep);
for (uint8 cur_container = 0; cur_container < 32; cur_container++){
if (!(empty_containers & (1 << cur_container))) continue;
if (!(empty_containers & (1u << cur_container))) continue;
if (rubbish_in_bin != 0){
// OpenRCT2 modification: This previously used
@ -4177,7 +4177,7 @@ static void peep_update_using_bin(rct_peep* peep){
empty_containers = peep_empty_container_extra_flag(peep);
for (uint8 cur_container = 0; cur_container < 32; cur_container++){
if (!(empty_containers & (1 << cur_container))) continue;
if (!(empty_containers & (1u << cur_container))) continue;
if (rubbish_in_bin != 0){
// OpenRCT2 modification: This previously used
@ -5741,9 +5741,9 @@ int peep_is_mechanic(rct_peep *peep)
bool peep_has_item(rct_peep *peep, int peepItem)
{
if (peepItem < 32) {
return peep->item_standard_flags & (1 << peepItem);
return peep->item_standard_flags & (1u << peepItem);
} else {
return peep->item_extra_flags & (1 << peepItem);
return peep->item_extra_flags & (1u << (peepItem - 32));
}
}
@ -8608,7 +8608,7 @@ static void peep_pick_ride_to_go_on(rct_peep *peep)
int i;
FOR_ALL_RIDES(i, ride) {
if (!peep_has_ridden(peep, i)) {
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1 << (i & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1u << (i & 0x1F));
}
}
} else {
@ -8623,7 +8623,7 @@ static void peep_pick_ride_to_go_on(rct_peep *peep)
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
int rideIndex = mapElement->properties.track.ride_index;
RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1 << (rideIndex & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1u << (rideIndex & 0x1F));
} while (!map_element_is_last_for_tile(mapElement++));
}
}
@ -8636,7 +8636,7 @@ static void peep_pick_ride_to_go_on(rct_peep *peep)
if (ride->excitement == (ride_rating)0xFFFF) continue;
if (ride->highest_drop_height <= 66 && ride->excitement < RIDE_RATING(8,00)) continue;
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1 << (i & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1u << (i & 0x1F));
}
}
@ -8645,7 +8645,7 @@ static void peep_pick_ride_to_go_on(rct_peep *peep)
uint8 *nextPotentialRide = potentialRides;
int numPotentialRides = 0;
for (int i = 0; i < MAX_RIDES; i++) {
if (!(RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] & (1 << (i & 0x1F))))
if (!(RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] & (1u << (i & 0x1F))))
continue;
rct_ride *ride = GET_RIDE(i);
@ -8724,7 +8724,7 @@ static void peep_head_for_nearest_ride_type(rct_peep *peep, int rideType)
int i;
FOR_ALL_RIDES(i, ride) {
if (ride->type == rideType) {
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1 << (i & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1u << (i & 0x1F));
}
}
} else {
@ -8741,7 +8741,7 @@ static void peep_head_for_nearest_ride_type(rct_peep *peep, int rideType)
int rideIndex = mapElement->properties.track.ride_index;
ride = GET_RIDE(rideIndex);
if (ride->type == rideType) {
RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1 << (rideIndex & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1u << (rideIndex & 0x1F));
}
} while (!map_element_is_last_for_tile(mapElement++));
}
@ -8754,7 +8754,7 @@ static void peep_head_for_nearest_ride_type(rct_peep *peep, int rideType)
uint8 *nextPotentialRide = potentialRides;
int numPotentialRides = 0;
for (int i = 0; i < MAX_RIDES; i++) {
if (!(RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] & (1 << (i & 0x1F))))
if (!(RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] & (1u << (i & 0x1F))))
continue;
rct_ride *ride = GET_RIDE(i);
@ -8836,7 +8836,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep *peep, int rideTypeFl
int i;
FOR_ALL_RIDES(i, ride) {
if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & rideTypeFlags) {
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1 << (i & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] |= (1u << (i & 0x1F));
}
}
} else {
@ -8853,7 +8853,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep *peep, int rideTypeFl
int rideIndex = mapElement->properties.track.ride_index;
ride = GET_RIDE(rideIndex);
if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & rideTypeFlags) {
RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1 << (rideIndex & 0x1F));
RCT2_ADDRESS(0x00F1AD98, uint32)[rideIndex >> 5] |= (1u << (rideIndex & 0x1F));
}
} while (!map_element_is_last_for_tile(mapElement++));
}
@ -8866,7 +8866,7 @@ static void peep_head_for_nearest_ride_with_flags(rct_peep *peep, int rideTypeFl
uint8 *nextPotentialRide = potentialRides;
int numPotentialRides = 0;
for (int i = 0; i < MAX_RIDES; i++) {
if (!(RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] & (1 << (i & 0x1F))))
if (!(RCT2_ADDRESS(0x00F1AD98, uint32)[i >> 5] & (1u << (i & 0x1F))))
continue;
rct_ride *ride = GET_RIDE(i);

View File

@ -389,6 +389,7 @@ uint16 hire_new_staff_member(uint8 staffType)
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_HIRE_NEW_STAFF;
int eax, ebx, ecx, edx, esi, edi, ebp;
ecx = edx = esi = edi = ebp = 0;
eax = 0x8000;
ebx = staffType << 8 | GAME_COMMAND_FLAG_APPLY;

View File

@ -850,6 +850,7 @@ int ride_create_ride(ride_list_item listItem)
ebx = GAME_COMMAND_FLAG_APPLY;
edi = 0;
esi = 0;
ebp = 0;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = 0x3DC;
@ -1194,7 +1195,7 @@ int sub_6C683D(int* x, int* y, int* z, int direction, int type, uint16 extra_par
mapElement->properties.track.colour &= 0x0F;
mapElement->properties.track.colour |= (extra_params & 0xFF) << 4;
}
if (flags & (1 << 3)) {
track_element_set_cable_lift(mapElement);
}
@ -5562,7 +5563,7 @@ void game_command_callback_ride_remove_track_piece(int eax, int ebx, int ecx, in
z = gRideRemoveTrackPieceCallbackZ;
direction = gRideRemoveTrackPieceCallbackDirection;
type = gRideRemoveTrackPieceCallbackType;
window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type);
}
@ -6412,9 +6413,9 @@ static void ride_update_vehicle_colours(int rideIndex)
{
rct_ride *ride;
rct_vehicle *vehicle;
rct_vehicle_colour colours;
rct_vehicle_colour colours = { 0 };
uint16 spriteIndex;
uint8 coloursExtended;
uint8 coloursExtended = 0;
ride = GET_RIDE(rideIndex);
if (ride->type == RIDE_TYPE_SPACE_RINGS || ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_16)) {

View File

@ -497,7 +497,7 @@ void scenario_success_submit_name(const char *name)
**/
void scenario_entrance_fee_too_high_check()
{
uint16 x, y;
uint16 x = 0, y = 0;
uint16 totalRideValue = RCT2_GLOBAL(RCT2_TOTAL_RIDE_VALUE, uint16);
uint16 park_entrance_fee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16);
int max_fee = totalRideValue + (totalRideValue / 2);

View File

@ -146,7 +146,7 @@ int bitscanforward(int source)
return success != 0 ? i : -1;
#else
for (i = 0; i < 32; i++)
if (source & (1 << i))
if (source & (1u << i))
return i;
return -1;
@ -157,7 +157,7 @@ int bitcount(int source)
{
int result = 0;
for (int i = 0; i < 32; i++) {
if (source & (1 << i)) {
if (source & (1u << i)) {
result++;
}
}

View File

@ -1597,7 +1597,7 @@ static uint16 map_window_get_pixel_colour_ride(int x, int y)
static void map_window_set_pixels(rct_window *w)
{
uint16 colour, *destination;
uint16 colour = 0, *destination;
int x, y, dx, dy;
destination = (uint16*)((RCT2_GLOBAL(0x00F1AD6C, uint32) * 511) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_IMAGE_DATA, uint32) + 255);

View File

@ -1053,6 +1053,7 @@ static void window_park_entrance_paint(rct_window *w, rct_drawpixelinfo *dpi)
static void window_park_init_viewport(rct_window *w)
{
int i, x, y, z, r, xy, zr, viewportFlags;
x = y = z = r = xy = zr = 0;
rct_viewport *viewport;
rct_widget *viewportWidget;

View File

@ -5341,6 +5341,9 @@ static void window_ride_graphs_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi
top = measurement->lateral[x] + 52;
bottom = measurement->lateral[x + 1] + 52;
break;
default:
log_error("Wrong graph type %d", listType);
top = bottom = 0;
}
top = widget->bottom - widget->top - top - 13;

View File

@ -2273,7 +2273,7 @@ static void sub_6CBCE2(
offsetX = -trackBlock->y;
offsetY = trackBlock->x;
bl = rol8(bl, 3);
bh |= bl;
bh = bl;
bh = ror8(bh, 4);
bl &= 0x88;
bh &= 0x77;

View File

@ -188,7 +188,7 @@ void window_scenery_update_scroll(rct_window *w);
* The same code repeated five times for every scenery entry type
*/
void init_scenery_entry(rct_scenery_entry *sceneryEntry, int index, uint8 sceneryTabId) {
if (RCT2_ADDRESS(0x01357BD0, sint32)[index >> 5] & (1 << (index & 0x1F))) {
if (RCT2_ADDRESS(0x01357BD0, sint32)[index >> 5] & (1u << (index & 0x1F))) {
if (sceneryTabId != 0xFF) {
for (int i = 0; i < SCENERY_ENTRIES_BY_TAB; i++) {
if (window_scenery_tab_entries[sceneryTabId][i] == -1)
@ -246,7 +246,7 @@ void init_scenery()
for (int i = 0; i < scenerySetEntry->entry_count; i++) {
uint16 sceneryEntryId = scenerySetEntry->scenery_entries[i];
uint32 ecx = RCT2_ADDRESS(0x01357BD0, uint32)[sceneryEntryId >> 5];
uint32 edx = 1 << (sceneryEntryId & 0x1F);
uint32 edx = 1u << (sceneryEntryId & 0x1F);
if (ecx & edx) {
window_scenery_tab_entries[scenerySetIndex][sceneryTabEntryCount] = sceneryEntryId;
window_scenery_tab_entries[scenerySetIndex][++sceneryTabEntryCount] = -1;
@ -1185,4 +1185,4 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
}
sceneryTabItemIndex++;
}
}
}

View File

@ -943,7 +943,7 @@ void window_title_editor_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int
gfx_fill_rect(dpi, x, y, x + SCROLL_WIDTH + 100, y + ROW_HEIGHT - 1, ColourMapA[w->colours[1]].lighter | 0x1000000);
}
rct_string_id commandName;
rct_string_id commandName = STR_NONE;
switch (command->command) {
case TITLE_SCRIPT_LOAD:
commandName = 5415;
@ -984,6 +984,8 @@ void window_title_editor_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int
case TITLE_SCRIPT_END:
commandName = 5426;
break;
default:
log_warning("Unknown command %d", command->command);
}
if ((selected || hover) && !error) {

View File

@ -352,6 +352,7 @@ static void window_track_place_attempt_placement(int x, int y, int z, int bl, mo
int eax, ebx, ecx, edx, esi, edi, ebp;
money32 result;
edx = esi = ebp = 0;
eax = x;
ebx = bl;
ecx = y;