diff --git a/src/addresses.h b/src/addresses.h index 821ed5b982..b9ae89c63c 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -21,7 +21,9 @@ #ifndef _ADDRESSES_H_ #define _ADDRESSES_H_ +#ifdef _MSC_VER #pragma warning(disable : 4731) +#endif #define RCT2_ADDRESS(address, type) ((type*)(address)) #define RCT2_GLOBAL(address, type) (*((type*)(address))) diff --git a/src/config.c b/src/config.c index 060a4501dd..ada958cbc6 100644 --- a/src/config.c +++ b/src/config.c @@ -357,13 +357,13 @@ static void config_save_property_value(FILE *file, uint8 type, value_union *valu else fwrite("false", 5, 1, file); break; case CONFIG_VALUE_TYPE_UINT8: - fprintf(file, "%d", value->value_uint8); + fprintf(file, "%u", value->value_uint8); break; case CONFIG_VALUE_TYPE_UINT16: - fprintf(file, "%d", value->value_uint16); + fprintf(file, "%u", value->value_uint16); break; case CONFIG_VALUE_TYPE_UINT32: - fprintf(file, "%d", value->value_uint32); + fprintf(file, "%u", value->value_uint32); break; case CONFIG_VALUE_TYPE_SINT8: fprintf(file, "%d", value->value_sint8); diff --git a/src/drawing/sprite.c b/src/drawing/sprite.c index 007afbbd18..d2ee61e884 100644 --- a/src/drawing/sprite.c +++ b/src/drawing/sprite.c @@ -593,7 +593,7 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in ecx >>= 3;//SAR int eax = ((int)no_pixels)<<8; ecx = -ecx;//Odd - eax = eax & 0xFF00 + *(source_pointer+1); + eax = (eax & 0xFF00) + *(source_pointer+1); total_no_pixels -= ecx; source_pointer += 2; ebx = (uint32)new_source_pointer - eax; diff --git a/src/drawing/string.c b/src/drawing/string.c index 25bb526ed5..49c859be70 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -1044,7 +1044,7 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in uint32 char_offset = al - 0x20 + *current_font_sprite_base; RCT2_GLOBAL(0x00EDF81C, uint32) = (IMAGE_TYPE_USE_PALETTE << 28); - gfx_draw_sprite_palette_set(dpi, (IMAGE_TYPE_USE_PALETTE << 28) | char_offset + SPR_CHAR_START, max_x, max_y, palette_pointer, NULL); + gfx_draw_sprite_palette_set(dpi, ((IMAGE_TYPE_USE_PALETTE << 28) | char_offset) + SPR_CHAR_START, max_x, max_y, palette_pointer, NULL); max_x += (RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[char_offset] & 0xFF); continue; } diff --git a/src/interface/viewport.c b/src/interface/viewport.c index b9ec084b69..e0e629f45d 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -475,7 +475,7 @@ void viewport_update_position(rct_window *window) if (window->viewport_target_sprite != -1){ rct_sprite* sprite = &g_sprite_list[window->viewport_target_sprite]; - int height = map_element_height(0xFFFF & sprite->unknown.x, 0xFFFF & sprite->unknown.y) & 0xFFFF - 16; + int height = (map_element_height(0xFFFF & sprite->unknown.x, 0xFFFF & sprite->unknown.y) & 0xFFFF) - 16; int underground = sprite->unknown.z < height; viewport_set_underground_flag(underground, window, viewport); diff --git a/src/interface/window.c b/src/interface/window.c index 4b04ba54f3..a08b345796 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -41,23 +41,23 @@ rct_window* g_window_list = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); // converted from uint16 values at 0x009A41EC - 0x009A4230 // these are percentage coordinates of the viewport to center to, if a window is obscuring a location, the next is tried float window_scroll_locations[][2] = { - 0.5f, 0.5f, - 0.75f, 0.5f, - 0.25f, 0.5f, - 0.5f, 0.75f, - 0.5f, 0.25f, - 0.75f, 0.75f, - 0.75f, 0.25f, - 0.25f, 0.75f, - 0.25f, 0.25f, - 0.125f, 0.5f, - 0.875f, 0.5f, - 0.5f, 0.125f, - 0.5f, 0.875f, - 0.875f, 0.125f, - 0.875f, 0.875f, - 0.125f, 0.875f, - 0.125f, 0.125f, + {0.5f, 0.5f}, + {0.75f, 0.5f}, + {0.25f, 0.5f}, + {0.5f, 0.75f}, + {0.5f, 0.25f}, + {0.75f, 0.75f}, + {0.75f, 0.25f}, + {0.25f, 0.75f}, + {0.25f, 0.25f}, + {0.125f, 0.5f}, + {0.875f, 0.5f}, + {0.5f, 0.125f}, + {0.5f, 0.875f}, + {0.875f, 0.125f}, + {0.875f, 0.875f}, + {0.125f, 0.875f}, + {0.125f, 0.125f}, }; static void window_all_wheel_input(); diff --git a/src/management/award.c b/src/management/award.c index ba708796f7..98afa42785 100644 --- a/src/management/award.c +++ b/src/management/award.c @@ -519,7 +519,7 @@ static int award_is_deserved_most_confusing_layout(int awardType, int activeAwar continue; peepsCounted++; - if (peep->thoughts[0].var_2 <= 5 && peep->thoughts[0].type == PEEP_THOUGHT_TYPE_LOST || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_CANT_FIND) + if ((peep->thoughts[0].var_2 <= 5 && peep->thoughts[0].type == PEEP_THOUGHT_TYPE_LOST) || peep->thoughts[0].type == PEEP_THOUGHT_TYPE_CANT_FIND) peepsLost++; } diff --git a/src/management/research.c b/src/management/research.c index ab44463f25..366ddf30c2 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -31,7 +31,7 @@ const int _researchRate[] = { 0, 160, 250, 400 }; // 0x01358844[500] -extern rct_research_item *gResearchItems = (rct_research_item*)RCT2_RESEARCH_ITEMS; +rct_research_item *gResearchItems = (rct_research_item*)RCT2_RESEARCH_ITEMS; // 0x00EE787C uint8 gResearchUncompletedCategories; diff --git a/src/object.c b/src/object.c index 199f423fd3..4be671b373 100644 --- a/src/object.c +++ b/src/object.c @@ -1622,10 +1622,10 @@ rct_object_entry *object_get_next(rct_object_entry *entry) pos += 4; // Skip - pos += *pos++ * 16; + pos += *pos * 16 + 1; // Skip theme objects - pos += *pos++ * 16; + pos += *pos * 16 + 1; // Skip pos += 4; diff --git a/src/peep/peep.c b/src/peep/peep.c index cfe8554a1b..6aaf501778 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -293,7 +293,7 @@ int peep_update_action(sint16* x, sint16* y, sint16* xy_distance, rct_peep* peep return 1; } - int* edi = RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2]; + uint32* edi = RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2]; uint8* _edi = (uint8*)(edi[peep->action_sprite_type * 2 + 1]); peep->action_frame++; int ebx = _edi[peep->action_frame + 1]; @@ -1513,7 +1513,7 @@ static void peep_update_ride_sub_state_2(rct_peep* peep){ if (ride->status == RIDE_STATUS_OPEN && ++peep->var_AC != 0 && - !(GET_VEHICLE(ride->vehicles[peep->current_train]))->var_48 & (1 << 4)) + !((GET_VEHICLE(ride->vehicles[peep->current_train]))->var_48 & (1 << 4))) return; if (ride->mode != RIDE_MODE_FORWARD_ROTATION && @@ -3477,8 +3477,8 @@ static void peep_update_using_bin(rct_peep* peep){ uint8 bp = RCT2_ADDRESS(0x97EFCC, uint8)[cur_container]; int x, y; - x = peep->x + scenario_rand() & 7 - 3; - y = peep->y + scenario_rand() & 7 - 3; + x = peep->x + (scenario_rand() & 7) - 3; + y = peep->y + (scenario_rand() & 7) - 3; RCT2_CALLPROC_X(0x67375D, x, scenario_rand() & 3, y, peep->z, 0, 0, bp); peep->item_standard_flags &= ~(1 << cur_container); @@ -3508,8 +3508,8 @@ static void peep_update_using_bin(rct_peep* peep){ uint8 bp = RCT2_ADDRESS(0x97EFE8, uint8)[cur_container]; int x, y; - x = peep->x + scenario_rand() & 7 - 3; - y = peep->y + scenario_rand() & 7 - 3; + x = peep->x + (scenario_rand() & 7) - 3; + y = peep->y + (scenario_rand() & 7) - 3; RCT2_CALLPROC_X(0x67375D, x, scenario_rand() & 3, y, peep->z, 0, 0, bp); peep->item_extra_flags &= ~(1 << cur_container); diff --git a/src/ride/track.c b/src/ride/track.c index 8eabc9846f..27c128ef40 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -448,10 +448,10 @@ void track_load_list(ride_list_item item) //RCT2_CALLPROC_X(0x006CED50, 0, 0, 0, *((uint16*)&item), 0, 0, 0); } -static void read(void *dst, void **src, int length) +static void read(void *dst, char **src, int length) { memcpy(dst, *src, length); - *((char**)src) += length; + *src += length; } /** @@ -553,13 +553,13 @@ rct_track_td6* load_track_design(const char *path) // Edit the colours to use the new versions // Unsure why it is 67 edi = (uint8*)&track_design->vehicle_colours; - for (i = 0; i < 67; i++) - *edi++ = RCT2_ADDRESS(0x0097F0BC, uint8)[*edi]; + for (i = 0; i < 67; i++, edi++) + *edi = RCT2_ADDRESS(0x0097F0BC, uint8)[*edi]; // Edit the colours to use the new versions edi = (uint8*)&track_design->track_spine_colour; - for (i = 0; i < 12; i++) - *edi++ = RCT2_ADDRESS(0x0097F0BC, uint8)[*edi]; + for (i = 0; i < 12; i++, edi++) + *edi = RCT2_ADDRESS(0x0097F0BC, uint8)[*edi]; // Highest drop height is 1bit = 3/4 a meter in td6 // Highest drop height is 1bit = 1/3 a meter in td4 diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 4e8b969717..10d3243de9 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -229,7 +229,7 @@ void vehicle_sounds_update() vehicle_sound->id = (uint16)-1; } label26: - 1; + ; } //for (rct_vehicle_sound_params* vehicle_sound_params = &RCT2_GLOBAL(0x00F438B4, rct_vehicle_sound_params); ; vehicle_sound_params++) { @@ -534,7 +534,7 @@ void vehicle_sounds_update() } } label114: - 1; + ; } } } diff --git a/src/title.c b/src/title.c index ec5f436bae..d8ac62dd06 100644 --- a/src/title.c +++ b/src/title.c @@ -18,6 +18,7 @@ * along with this program. If not, see . *****************************************************************************/ +#include #include "addresses.h" #include "audio/audio.h" #include "config.h" diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 52d17873c5..ebd4dfa96c 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -606,8 +606,8 @@ static void window_editor_object_selection_paint() text++; } while (*(text - 1) != 0); text += 4; - text += *text++ * 16; - text += *text++ * 16; + text += *text * 16 + 1; + text += *text * 16 + 1; if (RCT2_GLOBAL(text, uint32) & 0x1000000) { strcpy(stringBuffer, name); diff --git a/src/windows/guest.c b/src/windows/guest.c index 754ea46e18..b644c00486 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -728,7 +728,7 @@ void window_guest_viewport_init(rct_window* w){ } if (peep->x == SPRITE_LOCATION_NULL && final_check){ rct_ride* ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]); - int x = ride->overall_view & 0xFF * 32 + 16; + int x = (ride->overall_view & 0xFF) * 32 + 16; int y = (ride->overall_view >> 8) * 32 + 16; int height = map_element_height(x, y); height += 32; diff --git a/src/windows/tooltip.c b/src/windows/tooltip.c index ac6b9159be..7163b93b52 100644 --- a/src/windows/tooltip.c +++ b/src/windows/tooltip.c @@ -79,7 +79,7 @@ void window_tooltip_reset(int x, int y) RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) &= ~(1 << 4); } -extern uint8* gTooltip_text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER, uint8); +uint8* gTooltip_text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_TOOLTIP_TEXT_BUFFER, uint8); /** * * rct2: 0x006EA10D diff --git a/src/world/mapgen.c b/src/world/mapgen.c index 80ce3a9f3c..b71fd3c6ca 100644 --- a/src/world/mapgen.c +++ b/src/world/mapgen.c @@ -22,6 +22,7 @@ #define _USE_MATH_DEFINES #endif #include +#include #include "../addresses.h" #include "../object.h" #include "map.h" @@ -445,7 +446,7 @@ static void mapgen_blob_fill(int height) for (int x = left; x <= right; x++) if (x >= firstLand && x <= lastLand) - landX[x, y] = 1; + landX[x * _heightSize + y] = 1; } // Do the same for Y @@ -474,7 +475,7 @@ static void mapgen_blob_fill(int height) } for (int y = top; y <= bottom; y++) { - if (y >= firstLand && y <= lastLand && landX[x, y]) { + if (y >= firstLand && y <= lastLand && landX[x * _heightSize + y]) { // Not only do we know its landlocked to both x and y // we can change the land too set_height(x, y, BLOB_HEIGHT);