Merge branch 'develop' into pre-release-0.0.3

This commit is contained in:
duncanspumpkin 2015-11-13 23:30:13 +00:00
commit 45c4dfe12d
23 changed files with 167 additions and 162 deletions

View File

@ -13,7 +13,7 @@ if [[ ! -d build ]]; then
fi
# keep in sync with version in install.sh
sha256sum=0a7b5ea46e9cb4b19000b69690eae0b75929752f7db192c78bd7ffb61d696835
sha256sum=69ff98c9544838fb16384bc78af9dc1c452b9d01d919e43f5fec686d02c9bdd8
libVFile="./libversion"
libdir="./lib"
currentversion=0

View File

@ -3864,8 +3864,8 @@ STR_5521 :{SMALLFONT}{BLACK}明紫色
STR_5522 :{SMALLFONT}{BLACK}暗藍色
STR_5523 :{SMALLFONT}{BLACK}淺藍色
STR_5524 :{SMALLFONT}{BLACK}冰藍色
STR_5525 :{SMALLFONT}{BLACK}鴨綠
STR_5526 :{SMALLFONT}{BLACK}藍綠
STR_5525 :{SMALLFONT}{BLACK}深水配
STR_5526 :{SMALLFONT}{BLACK}淺水配
STR_5527 :{SMALLFONT}{BLACK}深綠色
STR_5528 :{SMALLFONT}{BLACK}暗綠色
STR_5529 :{SMALLFONT}{BLACK}苔蘚綠色

View File

@ -2723,8 +2723,8 @@ STR_2714 :-
STR_2715 :.
STR_2716 :/
STR_2717 :'
STR_2718 :(up)
STR_2719 :(new file)
STR_2718 :Up
STR_2719 :New file
STR_2720 :{UINT16}sec
STR_2721 :{UINT16}secs
STR_2722 :{UINT16}min:{UINT16}sec

View File

@ -3907,7 +3907,7 @@ STR_5563 :This feature is currently unstable, take extra caution.
STR_5564 :Insert Corrupt Element
STR_5565 :{SMALLFONT}{BLACK}Inserts a corrupt map element at top of tile. This will hide any element above the corrupt element.
STR_5566 :Password:
STR_5567 :Advertize
STR_5567 :Advertise
STR_5568 :Password Required
STR_5569 :This server requires a password
STR_5570 :Fetch Servers

View File

@ -4,7 +4,7 @@ SDL2_PV=2.0.3
SDL2_TTF_PV=2.0.12
cachedir=.cache
liburl=https://openrct.net/launcher/libs/orctlibs.zip
liburl=https://openrct2.website/files/orctlibs.zip
mkdir -p $cachedir
echo $(uname)

View File

@ -1,10 +1,10 @@
#init
$libversion = 3
$libversion = 4
$path = Split-Path $Script:MyInvocation.MyCommand.Path
$zip = $path+'\orctlibs.zip'
$libs = $path+'\lib'
$libsVFile = $path+'\libversion'
$liburl = 'https://openrct.net/launcher/libs/orctlibs_vs.zip'
$liburl = 'https://openrct2.website/files/orctlibs-vs.zip'
$libsTest = Test-Path $libs
#libs version test

View File

@ -5,8 +5,12 @@ An open source clone of RollerCoaster Tycoon 2 built by decompiling the original
- [Screenshot 3, high resolution](http://i.imgur.com/yFzNyVu.jpg)
- [Screenshot 4, resizable window](http://imgur.com/a/3GDuT)
[![Travis CI](https://travis-ci.org/OpenRCT2/OpenRCT2.svg)](https://travis-ci.org/OpenRCT2/OpenRCT2) [![AppVeyor](https://ci.appveyor.com/api/projects/status/fib6re830brysuo2?svg=true)](https://ci.appveyor.com/project/IntelOrca/openrct2)
Linux Build:
[![Travis CI](https://travis-ci.org/OpenRCT2/OpenRCT2.svg)](https://travis-ci.org/OpenRCT2/OpenRCT2)
Windows Build:
[![AppVeyor](https://ci.appveyor.com/api/projects/status/fib6re830brysuo2?svg=true)](https://ci.appveyor.com/project/IntelOrca/openrct2)
Come talk with us if you have any questions:
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/OpenRCT2/OpenRCT2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Contents

View File

@ -260,10 +260,12 @@ bool sprite_file_import(const char *path, rct_g1_element *outElement, uint8 **ou
}
uint8 *buffer = malloc((height * 2) + (width * height * 16));
memset(buffer, 0, (height * 2) + (width * height * 16));
uint16 *yOffsets = (uint16*)buffer;
// 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 +377,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

@ -1494,7 +1494,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

@ -209,10 +209,10 @@ int platform_enumerate_files_begin(const utf8 *pattern)
enumerate_file_info *enumFileInfo;
wchar_t *wpattern = utf8_to_widechar(pattern);
int length = min(utf8_length(pattern), MAX_PATH);
char *npattern = malloc(length);
char *npattern = malloc(length+1);
int converted;
converted = wcstombs(npattern, wpattern, length);
npattern[length - 1] = '\0';
npattern[length] = '\0';
if (converted == MAX_PATH) {
log_warning("truncated string %s", npattern);
}
@ -271,7 +271,7 @@ int platform_enumerate_files_begin(const utf8 *pattern)
for (int i = 0; i < countof(_enumerateFileInfoList); i++) {
enumFileInfo = &_enumerateFileInfoList[i];
if (!enumFileInfo->active) {
safe_strncpy(enumFileInfo->pattern, npattern, length);
safe_strncpy(enumFileInfo->pattern, npattern, sizeof(enumFileInfo->pattern));
cnt = scandir(dir_name, &enumFileInfo->fileListTemp, winfilter, alphasort);
if (cnt < 0)
{
@ -395,10 +395,10 @@ int platform_enumerate_directories_begin(const utf8 *directory)
enumerate_file_info *enumFileInfo;
wchar_t *wpattern = utf8_to_widechar(directory);
int length = min(utf8_length(directory), MAX_PATH);
char *npattern = malloc(length);
char *npattern = malloc(length+1);
int converted;
converted = wcstombs(npattern, wpattern, length);
npattern[length - 1] = '\0';
npattern[length] = '\0';
if (converted == MAX_PATH) {
log_warning("truncated string %s", npattern);
}
@ -477,7 +477,7 @@ bool platform_enumerate_directories_next(int handle, utf8 *path)
log_error("failed to stat file '%s'! errno = %i", fileName, errno);
return false;
}
// so very, very wrong
// so very, very wrong
safe_strncpy(path, basename(fileName), MAX_PATH);
strncat(path, "/", MAX_PATH);
path[MAX_PATH - 1] = '\0';

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

@ -43,6 +43,8 @@ enum {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_UP,
WIDX_NEW,
WIDX_SORT_NAME,
WIDX_SORT_DATE,
WIDX_SCROLL,
@ -53,10 +55,12 @@ enum {
static rct_widget window_loadsave_widgets[] = {
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE },
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_NONE, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
{ WWT_CLOSEBOX, 0, 4, (WW - 5) / 2, 36, 47, STR_NONE, STR_NONE },
{ WWT_CLOSEBOX, 0, (WW - 5) / 2 + 1, WW - 5 - 1, 36, 47, STR_NONE, STR_NONE },
{ WWT_SCROLL, 0, 4, WW - 5, 47, WH - 40, 2, STR_NONE },
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, //Window close button
{ WWT_CLOSEBOX, 0, 4, 104, 36, 47, 2718, STR_NONE}, // Up
{ WWT_CLOSEBOX, 0, 105, 205, 36, 47, 2719, STR_NONE}, // New
{ WWT_CLOSEBOX, 0, 4, (WW - 5) / 2, 50, 61, STR_NONE, STR_NONE }, // Name
{ WWT_CLOSEBOX, 0, (WW - 5) / 2 + 1, WW - 5 - 1, 50, 61, STR_NONE, STR_NONE }, // Date
{ WWT_SCROLL, 0, 4, WW - 5, 61, WH - 40, 2, STR_NONE }, // File list
{ WWT_CLOSEBOX, 0, 4, 200, WH - 36, WH - 18, 2707, STR_NONE }, // Use native browser
{ WIDGETS_END }
};
@ -111,8 +115,6 @@ static rct_window_event_list window_loadsave_events = {
#pragma endregion
enum {
TYPE_UP,
TYPE_NEW_FILE,
TYPE_DIRECTORY,
TYPE_FILE,
};
@ -130,12 +132,13 @@ int _listItemsCount = 0;
loadsave_list_item *_listItems = NULL;
char _directory[MAX_PATH];
char _shortenedDirectory[MAX_PATH];
static char _parentDirectory[MAX_PATH];
char _extension[32];
char _defaultName[MAX_PATH];
int _loadsaveType;
int _type;
static void window_loadsave_populate_list(int includeNewItem, bool browsable, const char *directory, const char *extension);
static void window_loadsave_populate_list(rct_window *w, int includeNewItem, const char *directory, const char *extension);
static void window_loadsave_select(rct_window *w, const char *path);
static void window_loadsave_sort_list(int index, int endIndex);
@ -164,7 +167,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
if (w == NULL) {
w = window_create_centred(WW, WH, &window_loadsave_events, WC_LOADSAVE, WF_STICK_TO_FRONT);
w->widgets = window_loadsave_widgets;
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_SORT_NAME) | (1 << WIDX_SORT_DATE) | (1 << WIDX_BROWSE);
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_UP) | (1 << WIDX_NEW) | (1 << WIDX_SORT_NAME) | (1 << WIDX_SORT_DATE) | (1 << WIDX_BROWSE);
w->colours[0] = 7;
w->colours[1] = 7;
w->colours[2] = 7;
@ -205,7 +208,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
return NULL;
}
window_loadsave_populate_list(includeNewItem, true, path, ".sv6");
window_loadsave_populate_list(w, includeNewItem, path, ".sv6");
break;
case LOADSAVETYPE_LANDSCAPE:
platform_get_user_directory(path, "landscape");
@ -215,7 +218,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
return NULL;
}
window_loadsave_populate_list(includeNewItem, true, path, ".sc6");
window_loadsave_populate_list(w, includeNewItem, path, ".sc6");
break;
case LOADSAVETYPE_SCENARIO:
/*
@ -234,7 +237,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
if (ch != NULL)
*ch = 0;
window_loadsave_populate_list(includeNewItem, true, path, ".sc6");
window_loadsave_populate_list(w, includeNewItem, path, ".sc6");
break;
case LOADSAVETYPE_TRACK:
/*
@ -253,7 +256,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
if (ch != NULL)
*ch = 0;
window_loadsave_populate_list(includeNewItem, true, path, ".td?");
window_loadsave_populate_list(w, includeNewItem, path, ".td?");
break;
}
w->no_list_items = _listItemsCount;
@ -280,6 +283,27 @@ static void window_loadsave_mouseup(rct_window *w, int widgetIndex)
case WIDX_CLOSE:
window_close(w);
break;
case WIDX_UP:
{
char directory[MAX_PATH];
int includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
safe_strncpy(directory, _parentDirectory, sizeof(directory));
window_loadsave_populate_list(w, includeNewItem, directory, _extension);
window_init_scroll_widgets(w);
w->no_list_items = _listItemsCount;
break;
}
case WIDX_NEW:
{
rct_string_id templateStringId = 3165;
char *templateString;
templateString = (char *)language_get_string(templateStringId);
strcpy(templateString, _defaultName);
window_text_input_open(w, WIDX_NEW, STR_NONE, 2710, templateStringId, 0, 64);
break;
}
case WIDX_BROWSE:
safe_strncpy(filename, _directory, MAX_PATH);
if (_type & LOADSAVETYPE_SAVE)
@ -363,40 +387,28 @@ static void window_loadsave_scrollmousedown(rct_window *w, int scrollIndex, int
selectedItem = y / 10;
if (selectedItem >= w->no_list_items)
return;
if (_listItems[selectedItem].type == TYPE_DIRECTORY){
// The selected item is a folder
int includeNewItem;
if (_listItems[selectedItem].type == TYPE_NEW_FILE) {
rct_string_id templateStringId = 3165;
char *templateString;
w->no_list_items = 0;
w->selected_list_item = -1;
includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
templateString = (char*)language_get_string(templateStringId);
strcpy(templateString, _defaultName);
char directory[MAX_PATH];
safe_strncpy(directory, _listItems[selectedItem].path, sizeof(directory));
window_text_input_open(w, WIDX_SCROLL, STR_NONE, 2710, templateStringId, 0, 64);
window_loadsave_populate_list(w, includeNewItem, directory, _extension);
window_init_scroll_widgets(w);
w->no_list_items = _listItemsCount;
} else {
if (_listItems[selectedItem].type == TYPE_DIRECTORY || _listItems[selectedItem].type == TYPE_UP){
// The selected item is a folder
int includeNewItem;
w->no_list_items = 0;
w->selected_list_item = -1;
includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
char directory[MAX_PATH];
safe_strncpy(directory, _listItems[selectedItem].path, sizeof(directory));
window_loadsave_populate_list(includeNewItem, true, directory, _extension);
window_init_scroll_widgets(w);
w->no_list_items = _listItemsCount;
} else {
// TYPE_FILE
// Load or overwrite
if ((_loadsaveType & 0x01) == LOADSAVETYPE_SAVE)
window_overwrite_prompt_open(_listItems[selectedItem].name, _listItems[selectedItem].path);
else
window_loadsave_select(w, _listItems[selectedItem].path);
}
// TYPE_FILE
// Load or overwrite
if ((_loadsaveType & 0x01) == LOADSAVETYPE_SAVE)
window_overwrite_prompt_open(_listItems[selectedItem].name, _listItems[selectedItem].path);
else
window_loadsave_select(w, _listItems[selectedItem].path);
}
}
@ -482,18 +494,20 @@ static void window_loadsave_paint(rct_window *w, rct_drawpixelinfo *dpi)
// Draw shadow
gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 20);
rct_string_id id = STR_NONE;
// Name button text
if (gConfigGeneral.load_save_sort == SORT_NAME_ASCENDING)
id = STR_UP;
else if (gConfigGeneral.load_save_sort == SORT_NAME_DESCENDING)
id = STR_DOWN;
gfx_draw_string_centred_clipped(dpi, STR_NAME, &id, 1, w->x + 4 + (w->width - 8) / 4, w->y + 36, (w->width - 8) / 2);
gfx_draw_string_centred_clipped(dpi, STR_NAME, &id, 1, w->x + 4 + (w->width - 8) / 4, w->y + 50, (w->width - 8) / 2);
// Date button text
if (gConfigGeneral.load_save_sort == SORT_DATE_ASCENDING)
id = STR_UP;
else if (gConfigGeneral.load_save_sort == SORT_DATE_DESCENDING)
id = STR_DOWN;
else
id = STR_NONE;
gfx_draw_string_centred_clipped(dpi, STR_DATE, &id, 1, w->x + 4 + (w->width - 8) * 3 / 4, w->y + 36, (w->width - 8) / 2);
gfx_draw_string_centred_clipped(dpi, STR_DATE, &id, 1, w->x + 4 + (w->width - 8) * 3 / 4, w->y + 50, (w->width - 8) / 2);
}
static void shorten_path(char* path, char* buffer, int available_width){
@ -599,14 +613,14 @@ static void window_loadsave_sort_list(int index, int endIndex)
qsort(_listItems + index, count, sizeof(loadsave_list_item), list_item_sort);
}
static void window_loadsave_populate_list(int includeNewItem, bool browsable, const char *directory, const char *extension)
static void window_loadsave_populate_list(rct_window *w, int includeNewItem, const char *directory, const char *extension)
{
int i, listItemCapacity, fileEnumHandle;
file_info fileInfo;
int i;
int sortStartIndex = 0;
int listItemCapacity = 8;
loadsave_list_item *listItem;
const char *src;
char *dst, *last_dot_in_filename, filter[MAX_PATH], subDir[MAX_PATH];
char filter[MAX_PATH];
safe_strncpy(_directory, directory, sizeof(_directory));
if (_extension != extension) {
safe_strncpy(_extension, extension, sizeof(_extension));
@ -620,58 +634,55 @@ static void window_loadsave_populate_list(int includeNewItem, bool browsable, co
if (_listItems != NULL)
free(_listItems);
listItemCapacity = 8;
_listItems = (loadsave_list_item*)malloc(listItemCapacity * sizeof(loadsave_list_item));
_listItemsCount = 0;
window_loadsave_widgets[WIDX_NEW].type = includeNewItem?WWT_CLOSEBOX:WWT_EMPTY; // Hide/Show "new" button
if(directory[0]=='\0' && platform_get_drives()!=0) // List Windows drives
{
w->disabled_widgets |= (1<<WIDX_NEW) | (1<<WIDX_UP);
for (int x = 0; x < 32; x++){
if (listItemCapacity <= _listItemsCount) {
listItemCapacity *= 2;
_listItems = realloc(_listItems, listItemCapacity * sizeof(loadsave_list_item));
}
bool drivesList = false;
if (browsable) {
int directoryLength = strlen(directory);
int topLevel = 1;
int lastSlash = directoryLength;
for (int index = directoryLength; index >= 0; index--) {
if (directory[index] == platform_get_path_separator()) {
if (lastSlash != directoryLength){
// The last slash has been changed before, we're now one up
lastSlash = index;
topLevel = 0;
break;
} else {
// The last slash, after the whole path
lastSlash = index;
}
if (platform_get_drives() & (1 << (x))){
listItem = &_listItems[_listItemsCount];
memset(listItem->path, '\0', MAX_PATH);
listItem->path[0] = 'A' + x;
listItem->path[1] = ':';
listItem->path[2] = platform_get_path_separator();
strcpy(listItem->name, listItem->path);
listItem->type = TYPE_DIRECTORY;
_listItemsCount++;
}
}
if (!topLevel){
listItem = &_listItems[_listItemsCount];
safe_strncpy(listItem->name, language_get_string(2718), sizeof(listItem->name));
memset(listItem->path, '\0', sizeof(listItem->path));
strncpy(listItem->path, directory, lastSlash + 1);
listItem->type = TYPE_UP;
_listItemsCount++;
} else if (platform_get_drives() != 0 && directory[0] != '\0'){
includeNewItem = false;
listItem = &_listItems[_listItemsCount];
safe_strncpy(listItem->name, language_get_string(2718), sizeof(listItem->name));
memset(listItem->path, '\0', sizeof(listItem->path));
listItem->type = TYPE_UP;
_listItemsCount++;
}
else
{
//Get parent directory
int directoryLength = strlen(directory);
char separator = platform_get_path_separator();
for(i = directoryLength-2; i>=0; i--)
{
if(directory[i]==separator)
break;
}
}
if (includeNewItem) {
listItem = &_listItems[_listItemsCount];
safe_strncpy(listItem->name, language_get_string(2719), sizeof(listItem->name));
listItem->path[0] = '\0';
listItem->type = TYPE_NEW_FILE;
_listItemsCount++;
}
int sortStartIndex = _listItemsCount;
if (directory[0] != '\0'){
safe_strncpy(_parentDirectory, directory, sizeof(_parentDirectory));
_parentDirectory[i+1] = '\0';
if(_parentDirectory[0]=='\0' && platform_get_drives()==0)
w->disabled_widgets |= (1<<WIDX_UP);
else
w->disabled_widgets &= ~(1<<WIDX_UP);
w->disabled_widgets &= ~(1<<WIDX_NEW);
file_info fileInfo;
int fileEnumHandle;
const char *src;
char *dst;
char *last_dot_in_filename;
char subDir[MAX_PATH];
fileEnumHandle = platform_enumerate_directories_begin(directory);
while (platform_enumerate_directories_next(fileEnumHandle, subDir)){
if (listItemCapacity <= _listItemsCount) {
@ -690,7 +701,6 @@ static void window_loadsave_populate_list(int includeNewItem, bool browsable, co
platform_enumerate_files_end(fileEnumHandle);
window_loadsave_sort_list(sortStartIndex, _listItemsCount - 1);
sortStartIndex = _listItemsCount;
fileEnumHandle = platform_enumerate_files_begin(filter);
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
if (listItemCapacity <= _listItemsCount) {
@ -718,27 +728,7 @@ static void window_loadsave_populate_list(int includeNewItem, bool browsable, co
_listItemsCount++;
}
platform_enumerate_files_end(fileEnumHandle);
} else {
for (int x = 0; x < 32; x++){
if (listItemCapacity <= _listItemsCount) {
listItemCapacity *= 2;
_listItems = realloc(_listItems, listItemCapacity * sizeof(loadsave_list_item));
}
if (platform_get_drives() & (1 << (x))){
listItem = &_listItems[_listItemsCount];
memset(listItem->path, '\0', MAX_PATH);
listItem->path[0] = 'A' + x;
listItem->path[1] = ':';
listItem->path[2] = platform_get_path_separator();
strcpy(listItem->name, listItem->path);
listItem->type = TYPE_DIRECTORY;
_listItemsCount++;
}
}
}
window_loadsave_sort_list(sortStartIndex, _listItemsCount - 1);
}
static void window_loadsave_invoke_callback(int 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;