Merge pull request #3208 from janisozaur/develop

Various fixes
This commit is contained in:
Ted John 2016-04-01 10:29:56 +01:00
commit a1bdf3868b
4 changed files with 12 additions and 8 deletions

View File

@ -958,15 +958,14 @@ int win1252_to_utf8(utf8string dst, const char *src, size_t maxBufferLength)
if (srcLength > bufferCount) {
bufferCount = srcLength + 4;
heapBuffer = malloc(bufferCount * sizeof(utf16));
assert(heapBuffer != NULL);
intermediateBuffer = heapBuffer;
}
}
MultiByteToWideChar(CP_ACP, 0, src, -1, intermediateBuffer, bufferCount);
int result = WideCharToMultiByte(CP_UTF8, 0, intermediateBuffer, -1, dst, maxBufferLength, NULL, NULL);
if (heapBuffer != NULL) {
free(heapBuffer);
}
free(heapBuffer);
#else
//log_warning("converting %s of size %d", src, srcLength);
char *buffer_conv = strndup(src, srcLength);

View File

@ -195,10 +195,10 @@ bool platform_directory_delete(const utf8 *path)
wchar_t *wPath = utf8_to_widechar(path);
wcsncpy(pszFrom, wPath, MAX_PATH);
free(wPath);
// Needs to be double-null terminated for some weird reason
pszFrom[wcslen(wPath) + 1] = 0;
free(wPath);
SHFILEOPSTRUCTW fileop;
fileop.hwnd = NULL; // no status display
@ -370,8 +370,10 @@ int platform_enumerate_directories_begin(const utf8 *directory)
wchar_t *wDirectory = utf8_to_widechar(directory);
if (wcslen(wDirectory) + 3 >= MAX_PATH)
if (wcslen(wDirectory) + 3 >= MAX_PATH) {
free(wDirectory);
return INVALID_HANDLE;
}
for (i = 0; i < countof(_enumerateFileInfoList); i++) {
enumFileInfo = &_enumerateFileInfoList[i];
@ -634,7 +636,7 @@ bool platform_open_common_file_dialog(utf8 *outFilename, file_dialog_desc *desc)
openFileName.lpstrFilter = wcFilter;
// Open dialog
BOOL result;
BOOL result = false;
DWORD commonFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
if (desc->type == FD_OPEN) {
openFileName.Flags = commonFlags | OFN_NONETWORKBUTTON | OFN_FILEMUSTEXIST;

View File

@ -1695,9 +1695,12 @@ int ride_modify(rct_xy_element *input)
mapElement = *input;
rideIndex = mapElement.element->properties.track.ride_index;
ride = get_ride(rideIndex);
if (ride == NULL) {
return 0;
}
rideType = get_ride_entry_by_ride(ride);
if ((ride == NULL) || (rideType == NULL) || !ride_check_if_construction_allowed(ride))
if ((rideType == NULL) || !ride_check_if_construction_allowed(ride))
return 0;
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) {

View File

@ -277,7 +277,7 @@ static void duck_update_fly_away(rct_duck *duck)
return;
}
int z = z = min(duck->z + 2, 496);
int z = min(duck->z + 2, 496);
sprite_move(x, y, z, (rct_sprite*)duck);
duck_invalidate(duck);
}