Merge pull request #1896 from janisozaur/some_fixes

assorted fixes
This commit is contained in:
Ted John committed 2015-09-07 20:11:29 +01:00
commit 2a0366721e
12 files changed
+39 -30

No files matched your search

+3 -3
View File
@@ -407,8 +407,8 @@ int cmdline_for_sprite(const char **argv, int argc)
return -1;
}
printf("sprites: %d\n", spriteFileHeader.num_entries);
printf("data size: %d\n", spriteFileHeader.total_size);
printf("sprites: %lu\n", spriteFileHeader.num_entries);
printf("data size: %lu\n", spriteFileHeader.total_size);
sprite_file_close();
return 1;
@@ -432,7 +432,7 @@ int cmdline_for_sprite(const char **argv, int argc)
printf("height: %d\n", g1->height);
printf("x offset: %d\n", g1->x_offset);
printf("y offset: %d\n", g1->y_offset);
printf("data offset: 0x%X\n", (uint32)g1->offset);
printf("data offset: 0x%lX\n", (uint32)g1->offset);
sprite_file_close();
return 1;
+2 -2
View File
@@ -471,7 +471,7 @@ static void config_save_property_value(SDL_RWops *file, uint8 type, value_union
rwopsprintf(file, "%u", value->value_uint16);
break;
case CONFIG_VALUE_TYPE_UINT32:
rwopsprintf(file, "%u", value->value_uint32);
rwopsprintf(file, "%lu", value->value_uint32);
break;
case CONFIG_VALUE_TYPE_SINT8:
rwopsprintf(file, "%d", value->value_sint8);
@@ -480,7 +480,7 @@ static void config_save_property_value(SDL_RWops *file, uint8 type, value_union
rwopsprintf(file, "%d", value->value_sint16);
break;
case CONFIG_VALUE_TYPE_SINT32:
rwopsprintf(file, "%d", value->value_sint32);
rwopsprintf(file, "%ld", value->value_sint32);
break;
case CONFIG_VALUE_TYPE_FLOAT:
rwopsprintf(file, "%.3f", value->value_float);
+8 -4
View File
@@ -275,7 +275,7 @@ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args
void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width)
{
char* buffer;
short text_width;
int text_width;
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
format_string(buffer, format, args);
@@ -286,9 +286,11 @@ void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *a
text_width = gfx_clip_string(buffer, width);
// Draw the text centred
if (text_width <= 0xFFFF) {
if (text_width <= 0xFFFF && text_width >= 0) {
x -= (text_width - 1) / 2;
gfx_draw_string(dpi, buffer, colour, x, y);
} else {
log_warning("improper text width %d for string %s", text_width, buffer);
}
}
@@ -331,7 +333,7 @@ void gfx_draw_string_right(rct_drawpixelinfo* dpi, int format, void* args, int c
void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args)
{
char* buffer;
short text_width;
int text_width;
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
format_string(buffer, format, args);
@@ -342,9 +344,11 @@ void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, i
text_width = gfx_get_string_width(buffer);
// Draw the text centred
if (text_width <= 0xFFFF) {
if (text_width <= 0xFFFF && text_width >= 0) {
x -= text_width / 2;
gfx_draw_string(dpi, buffer, colour, x, y);
} else {
log_warning("improper text width %d for string %s", text_width, buffer);
}
}
+1
View File
@@ -1,4 +1,5 @@
#include "localisation.h"
#include <wchar.h>
uint32 utf8_get_next(const utf8 *char_ptr, const utf8 **nextchar_ptr)
{
+1 -1
View File
@@ -414,7 +414,7 @@ static int award_is_deserved_most_disappointing(int awardType, int activeAwardTy
disappointingRides = 0;
FOR_ALL_RIDES(i, ride) {
if (ride->excitement == 0xFFFF || ride->popularity == 0xFF)
if (ride->excitement == (ride_rating)0xFFFF || ride->popularity == 0xFF)
continue;
countedRides++;
+3 -3
View File
@@ -5394,7 +5394,7 @@ rct_peep *peep_generate(int x, int y, int z)
cash = 0;
}
if (RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_CASH, money16) == 0xFFFF){
if (RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_CASH, money16) == (money16)0xFFFF){
cash = 0;
}
@@ -7030,7 +7030,7 @@ static int guest_path_find_leaving_park(rct_peep *peep, rct_map_element *map_ele
RCT2_GLOBAL(0x00F1AEE0, uint8) = 1;
RCT2_GLOBAL(0x00F1AEE1, uint8) = 0xFF;
direction = sub_69A5F0(peep->next_x, peep->next_y, peep->next_z, peep, map_element);
if (direction == -1)
if (direction == 0xFF)
return guest_path_find_aimless(peep, edges);
else
return peep_move_one_tile(direction, peep);
@@ -8003,7 +8003,7 @@ static bool sub_6960AB(rct_peep *peep, int rideIndex, int dh, int bp)
goto loc_696658;
}
}
if (ride->excitement != 0xFFFF) {
if (ride->excitement != (ride_rating)0xFFFF) {
if (rideIndex == peep->guest_heading_to_ride_id) {
if (ride->intensity > RIDE_RATING(10, 00) && !gConfigCheat.ignore_ride_intensity) goto loc_6965F1;
goto loc_696387;
+6 -6
View File
@@ -2989,9 +2989,9 @@ static void ride_entrance_exit_connected(rct_ride* ride, int ride_idx)
entrance = ride->entrances[i],
exit = ride->exits[i];
if (station_start == -1 )
if (station_start == 0xFFFF )
continue;
if (entrance != -1 && !ride_entrance_exit_is_reachable(entrance, ride, i)) {
if (entrance != 0xFFFF && !ride_entrance_exit_is_reachable(entrance, ride, i)) {
// name of ride is parameter of the format string
RCT2_GLOBAL(0x013CE952, uint16) = ride->name;
RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments;
@@ -2999,7 +2999,7 @@ static void ride_entrance_exit_connected(rct_ride* ride, int ride_idx)
ride->connected_message_throttle = 3;
}
if (exit != -1 && !ride_entrance_exit_is_reachable(exit, ride, i)) {
if (exit != 0xFFFF && !ride_entrance_exit_is_reachable(exit, ride, i)) {
// name of ride is parameter of the format string
RCT2_GLOBAL(0x013CE952, uint16) = ride->name;
RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments;
@@ -5222,17 +5222,17 @@ void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi
peep->item_standard_flags &= ~PEEP_ITEM_PHOTO;
}
}
if(peep->item_extra_flags && PEEP_ITEM_PHOTO2){
if(peep->item_extra_flags & PEEP_ITEM_PHOTO2){
if(peep->photo2_ride_ref == ride_id){
peep->item_extra_flags &= ~PEEP_ITEM_PHOTO2;
}
}
if(peep->item_extra_flags && PEEP_ITEM_PHOTO3){
if(peep->item_extra_flags & PEEP_ITEM_PHOTO3){
if(peep->photo3_ride_ref == ride_id){
peep->item_extra_flags &= ~PEEP_ITEM_PHOTO3;
}
}
if(peep->item_extra_flags && PEEP_ITEM_PHOTO4){
if(peep->item_extra_flags & PEEP_ITEM_PHOTO4){
if(peep->photo4_ride_ref == ride_id){
peep->item_extra_flags &= ~PEEP_ITEM_PHOTO4;
}
+7 -3
View File
@@ -543,7 +543,11 @@ rct_track_td6* load_track_design(const char *path)
// Decode the track data
decoded = malloc(0x10000);
decodedLength = sawyercoding_decode_td6(fpBuffer, decoded, fpLength);
realloc(decoded, decodedLength);
decoded = realloc(decoded, decodedLength);
if (decoded == NULL) {
log_error("failed to realloc");
return 0;
}
free(fpBuffer);
rct_track_td6* track_design = RCT2_ADDRESS(0x009D8178, rct_track_td6);
@@ -2733,7 +2737,7 @@ int tracked_ride_to_td6(uint8 rideIndex, rct_track_td6* track_design, uint8* tra
bh = trackElement.element->properties.track.colour >> 4;
}
uint8 flags = trackElement.element->type & (1 << 7) | bh;
uint8 flags = (trackElement.element->type & (1 << 7)) | bh;
flags |= (trackElement.element->properties.track.colour & 3) << 4;
if (RCT2_ADDRESS(0x0097D4F2, uint16)[ride->type * 4] & (1 << 3) &&
@@ -2990,7 +2994,7 @@ int save_track_design(uint8 rideIndex){
return 0;
}
if (ride->ratings.excitement == 0xFFFF){
if (ride->ratings.excitement == (ride_rating)0xFFFF){
window_error_open(STR_CANT_SAVE_TRACK_DESIGN, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id));
return 0;
}
+1 -1
View File
@@ -185,4 +185,4 @@ bool utf8_is_bom(const char *str)
bool str_is_null_or_empty(const char *str)
{
return str == NULL || str[0] == 0;
}
}
+2 -2
View File
@@ -400,7 +400,7 @@ static void window_editor_bottom_toolbar_mouseup(rct_window *w, int widgetIndex)
{
if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON) {
if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) ||
RCT2_GLOBAL(0x13573C8, uint16) == 0x2710 && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_18)) {
(RCT2_GLOBAL(0x13573C8, uint16) == 0x2710 && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_18))) {
previous_button_mouseup_events[g_editor_step]();
}
} else if (widgetIndex == WIDX_NEXT_STEP_BUTTON) {
@@ -573,4 +573,4 @@ void window_editor_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi)
}
}
}
}
+4 -4
View File
@@ -429,8 +429,8 @@ static void window_loadsave_textinput(rct_window *w, int widgetIndex, char *text
}
strncpy(path, _directory, sizeof(path));
strncat(path, text, sizeof(path));
strncat(path, _extension, sizeof(path));
strncat(path, text, sizeof(path) - strnlen(path, MAX_PATH) - 1);
strncat(path, _extension, sizeof(path) - strnlen(path, MAX_PATH) - 1);
overwrite = 0;
for (i = 0; i < _listItemsCount; i++) {
@@ -604,8 +604,8 @@ static void window_loadsave_populate_list(int includeNewItem, bool browsable, co
_shortenedDirectory[0] = '\0';
strncpy(filter, directory, sizeof(filter));
strncat(filter, "*", sizeof(filter));
strncat(filter, extension, sizeof(filter));
strncat(filter, "*", sizeof(filter) - strnlen(filter, MAX_PATH) - 1);
strncat(filter, extension, sizeof(filter) - strnlen(filter, MAX_PATH) - 1);
if (_listItems != NULL)
free(_listItems);
+1 -1
View File
@@ -595,7 +595,7 @@ static void window_themes_dropdown(rct_window *w, int widgetIndex, int dropdownI
switch (widgetIndex) {
case WIDX_THEMES_LIST:
if (dropdownIndex != -1) {
get_colour_scheme_tab()->colours[_color_index_2] = dropdownIndex | get_colour_scheme_tab()->colours[_color_index_2] & 0x80;
get_colour_scheme_tab()->colours[_color_index_2] = dropdownIndex | (get_colour_scheme_tab()->colours[_color_index_2] & 0x80);
window_invalidate_all();
_color_index_1 = -1;
_color_index_2 = -1;