From 9b64c576c42694f40b6aa4e1e534d2607a2c9776 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 16 Aug 2014 18:15:27 +0100 Subject: [PATCH] fixes #293, closes #301 (min/max) and fixes #304 (research window bug) --- src/rct2.h | 6 ++++++ src/window_research.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rct2.h b/src/rct2.h index dcdb81bcc0..643aec1c29 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -42,6 +42,12 @@ typedef unsigned long long uint64; #define ror32(x, shift) (((uint32)(x) >> (shift)) | ((uint32)(x) << (32 - (shift)))) #define rol64(x, shift) (((uint64)(x) << (shift)) | ((uint32)(x) >> (64 - (shift)))) #define ror64(x, shift) (((uint64)(x) >> (shift)) | ((uint32)(x) << (64 - (shift)))) +#ifndef min + #define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef max + #define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif #define sgn(x) ((x > 0) ? 1 : ((x < 0) ? -1 : 0)) #define clamp(l, x, h) (min(h, max(l, x))) diff --git a/src/window_research.c b/src/window_research.c index 364234a6b8..fd29a3b290 100644 --- a/src/window_research.c +++ b/src/window_research.c @@ -342,7 +342,7 @@ static void window_research_development_paint() if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { uint32 typeId = RCT2_GLOBAL(0x013580E0, uint32); if (typeId >= 0x10000) { - uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFFFF) * 4, uint8*); + uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, uint8*); if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000) stringId = RCT2_GLOBAL(rideEntry, uint16); else @@ -380,7 +380,7 @@ static void window_research_development_paint() uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32); if (typeId != 0xFFFFFFFF) { if (typeId >= 0x10000) { - uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFFFF) * 4, uint8*); + uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, uint8*); if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000) stringId = RCT2_GLOBAL(rideEntry, uint16); else