mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
bug fixes and more error reporting
This commit is contained in:
@@ -7,6 +7,9 @@ SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres)
|
|||||||
SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
|
SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
|
||||||
SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
|
SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config)
|
||||||
|
|
||||||
|
# potential flags to make code more similar to MSVC:
|
||||||
|
# -fshort-wchar -fshort-enums -mms-bitfields -fpack-struct=1
|
||||||
|
#
|
||||||
set(CMAKE_C_FLAGS "-masm=intel -std=gnu99" CACHE STRING "" FORCE)
|
set(CMAKE_C_FLAGS "-masm=intel -std=gnu99" CACHE STRING "" FORCE)
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc" CACHE STRING "" FORCE)
|
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc" CACHE STRING "" FORCE)
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
typedef signed char sint8;
|
typedef signed char sint8;
|
||||||
typedef signed short sint16;
|
typedef signed short sint16;
|
||||||
@@ -52,6 +53,11 @@ typedef unsigned long long uint64;
|
|||||||
#define RCT2_ERROR(format,...) fprintf(stderr, "ERROR %s:%s():%d: " format "\n", __FILE__, __func__, __LINE__, __VA_ARGS__);
|
#define RCT2_ERROR(format,...) fprintf(stderr, "ERROR %s:%s():%d: " format "\n", __FILE__, __func__, __LINE__, __VA_ARGS__);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
// use similar struct packing as MSVC for our structs
|
||||||
|
#pragma pack(1)
|
||||||
|
#endif
|
||||||
|
|
||||||
void rct2_finish();
|
void rct2_finish();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|||||||
@@ -81,9 +81,15 @@ int sawyercoding_read_chunk(HANDLE hFile, uint8 *buffer)
|
|||||||
|
|
||||||
// Read chunk header
|
// Read chunk header
|
||||||
ReadFile(hFile, &chunkHeader, sizeof(sawyercoding_chunk_header), &numBytesRead, NULL);
|
ReadFile(hFile, &chunkHeader, sizeof(sawyercoding_chunk_header), &numBytesRead, NULL);
|
||||||
|
if (sizeof(sawyercoding_chunk_header) != numBytesRead) {
|
||||||
|
RCT2_ERROR("read error %d != %d\n", sizeof(sawyercoding_chunk_header), numBytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
// Read chunk data
|
// Read chunk data
|
||||||
ReadFile(hFile, buffer, chunkHeader.length, &numBytesRead, NULL);
|
ReadFile(hFile, buffer, chunkHeader.length, &numBytesRead, NULL);
|
||||||
|
if (chunkHeader.length != numBytesRead) {
|
||||||
|
RCT2_ERROR("read error %d != %d\n", chunkHeader.length, numBytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
// Decode chunk data
|
// Decode chunk data
|
||||||
switch (chunkHeader.encoding) {
|
switch (chunkHeader.encoding) {
|
||||||
@@ -111,7 +117,7 @@ int sawyercoding_read_chunk(HANDLE hFile, uint8 *buffer)
|
|||||||
static int decode_chunk_rle(char *buffer, int length)
|
static int decode_chunk_rle(char *buffer, int length)
|
||||||
{
|
{
|
||||||
int i, j, count;
|
int i, j, count;
|
||||||
char *src, *dst, rleCodeByte;
|
unsigned char *src, *dst, rleCodeByte;
|
||||||
|
|
||||||
// Backup buffer
|
// Backup buffer
|
||||||
src = malloc(length);
|
src = malloc(length);
|
||||||
@@ -135,7 +141,7 @@ static int decode_chunk_rle(char *buffer, int length)
|
|||||||
free(src);
|
free(src);
|
||||||
|
|
||||||
// Return final size
|
// Return final size
|
||||||
return dst - buffer;
|
return (char*)dst - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +151,7 @@ static int decode_chunk_rle(char *buffer, int length)
|
|||||||
static int decode_chunk_repeat(char *buffer, int length)
|
static int decode_chunk_repeat(char *buffer, int length)
|
||||||
{
|
{
|
||||||
int i, j, count;
|
int i, j, count;
|
||||||
char *src, *dst, *copyOffset;
|
unsigned char *src, *dst, *copyOffset;
|
||||||
|
|
||||||
// Backup buffer
|
// Backup buffer
|
||||||
src = malloc(length);
|
src = malloc(length);
|
||||||
@@ -167,7 +173,7 @@ static int decode_chunk_repeat(char *buffer, int length)
|
|||||||
free(src);
|
free(src);
|
||||||
|
|
||||||
// Return final size
|
// Return final size
|
||||||
return dst - buffer;
|
return (char*)dst - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ static void window_title_exit_mouseup()
|
|||||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) != 0)
|
||||||
if (RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, int) != 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (widgetIndex == 0)
|
if (widgetIndex == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user