mirror of https://github.com/OpenRCT2/OpenRCT2.git
commit
a5d85cd15f
|
@ -24,10 +24,10 @@
|
|||
#include "diagnostic.h"
|
||||
#include "rct2.h"
|
||||
|
||||
#define SafeFree(x) if ((x) != NULL) { free(x); (x) = NULL; }
|
||||
#define SafeFree(x) do { free(x); (x) = NULL; } while (0)
|
||||
|
||||
#define SafeDelete(x) if ((x) != nullptr) { delete (x); (x) = nullptr; }
|
||||
#define SafeDeleteArray(x) if ((x) != nullptr) { delete[] (x); (x) = nullptr; }
|
||||
#define SafeDelete(x) do { delete (x); (x) = nullptr; } while (0)
|
||||
#define SafeDeleteArray(x) do { delete[] (x); (x) = nullptr; } while (0)
|
||||
|
||||
#ifndef interface
|
||||
#define interface struct
|
||||
|
|
|
@ -176,7 +176,9 @@ int screenshot_dump_bmp()
|
|||
bytesWritten = SDL_RWwrite(fp, &header, sizeof(BitmapFileHeader), 1);
|
||||
if (bytesWritten != 1) {
|
||||
SDL_RWclose(fp);
|
||||
free(buffer);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Info header
|
||||
|
@ -193,7 +195,9 @@ int screenshot_dump_bmp()
|
|||
bytesWritten = SDL_RWwrite(fp, &info, sizeof(BitmapInfoHeader), 1);
|
||||
if (bytesWritten != 1) {
|
||||
SDL_RWclose(fp);
|
||||
free(buffer);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Palette
|
||||
|
@ -207,7 +211,9 @@ int screenshot_dump_bmp()
|
|||
bytesWritten = SDL_RWwrite(fp, buffer, sizeof(char), 246 * 4);
|
||||
if (bytesWritten != 246*4){
|
||||
SDL_RWclose(fp);
|
||||
free(buffer);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Image, save upside down
|
||||
|
@ -221,7 +227,9 @@ int screenshot_dump_bmp()
|
|||
bytesWritten = SDL_RWwrite(fp, buffer, sizeof(char), stride);
|
||||
if (bytesWritten != stride){
|
||||
SDL_RWclose(fp);
|
||||
free(buffer);
|
||||
SafeFree(buffer);
|
||||
log_error("failed to save screenshot");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -624,7 +624,7 @@ rct_window *window_create_auto_pos(int width, int height, rct_window_event_list
|
|||
// Clamp to inside the screen
|
||||
foundSpace:
|
||||
if (x < 0)
|
||||
x = x;
|
||||
x = 0;
|
||||
if (x + width > screenWidth)
|
||||
x = screenWidth - width;
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ void platform_draw()
|
|||
else
|
||||
if (pitch == (width * 2) + padding) {
|
||||
uint16 *dst = pixels;
|
||||
for (int y = height; y > 0; y++) {
|
||||
for (int y = height; y > 0; y--) {
|
||||
for (int x = width; x > 0; x--) { *dst++ = *(uint16 *)(&gPaletteHWMapped[*src++]); }
|
||||
dst = (uint16*)(((uint8 *)dst) + padding);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ void platform_draw()
|
|||
else
|
||||
if (pitch == width + padding) {
|
||||
uint8 *dst = pixels;
|
||||
for (int y = height; y > 0; y++) {
|
||||
for (int y = height; y > 0; y--) {
|
||||
for (int x = width; x > 0; x--) { *dst++ = *(uint8 *)(&gPaletteHWMapped[*src++]); }
|
||||
dst += padding;
|
||||
}
|
||||
|
|
|
@ -6333,7 +6333,7 @@ static int ride_get_track_length(rct_ride *ride)
|
|||
continue;
|
||||
|
||||
trackType = mapElement->properties.track.type;
|
||||
if (!RCT2_GLOBAL(0x0099BA64 + (trackType * 16), uint32) & 0x10)
|
||||
if (!(RCT2_GLOBAL(0x0099BA64 + (trackType * 16), uint32) & 0x10))
|
||||
continue;
|
||||
|
||||
if (mapElement->base_height != z)
|
||||
|
|
|
@ -579,11 +579,11 @@ static uint8 *title_script_load()
|
|||
sprintf(path, "%s%c%s", gExePath, platform_get_path_separator(), filePath);
|
||||
log_verbose("loading title script, %s", path);
|
||||
file = SDL_RWFromFile(path, "r");
|
||||
sint64 fileSize = SDL_RWsize(file);
|
||||
if (file == NULL) {
|
||||
log_error("unable to load title script");
|
||||
return NULL;
|
||||
}
|
||||
sint64 fileSize = SDL_RWsize(file);
|
||||
|
||||
uint8 *binaryScript = (uint8*)malloc(1024 * 8);
|
||||
if (binaryScript == NULL) {
|
||||
|
@ -624,7 +624,8 @@ static uint8 *title_script_load()
|
|||
*scriptPtr++ = atoi(part1) & 0xFF;
|
||||
} else {
|
||||
log_error("unknown token, %s", token);
|
||||
free(binaryScript);
|
||||
SafeFree(binaryScript);
|
||||
SDL_RWclose(file);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -985,6 +985,7 @@ void window_guest_overview_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
for (; i < PEEP_MAX_THOUGHTS; ++i){
|
||||
if (peep->thoughts[i].type == PEEP_THOUGHT_TYPE_NONE){
|
||||
w->list_information_type = 0;
|
||||
rct2_free(dpi_marquee);
|
||||
return;
|
||||
}
|
||||
if (peep->thoughts[i].var_2 == 1){ // If a fresh thought
|
||||
|
@ -993,6 +994,7 @@ void window_guest_overview_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
}
|
||||
if (i == PEEP_MAX_THOUGHTS){
|
||||
w->list_information_type = 0;
|
||||
rct2_free(dpi_marquee);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue