diff --git a/CMakeLists.txt b/CMakeLists.txt index 20a9c6416a..3664d6f6a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,10 @@ else (DISABLE_NETWORK) endif (WIN32) endif (DISABLE_NETWORK) +set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 0–3.") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") + # include lib include_directories("lib/") # add source files @@ -57,8 +61,8 @@ file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" "lib/cu if (UNIX) # force 32bit build for now and set necessary flags to compile code as is - set(CMAKE_C_FLAGS "-m32 -std=gnu99") - set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -std=gnu99") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -std=gnu++11") set(CMAKE_SHARED_LINKER_FLAGS "-m32") set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif (UNIX) diff --git a/src/audio/audio.c b/src/audio/audio.c index ac90544cc4..02f67c061e 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -108,7 +108,7 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) } sint16 rx; sint16 ry; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: rx = y - x; ry = ((y + x) / 2) - z; diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index e232fa908e..fa692f1787 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -199,14 +199,6 @@ bool Source_Sample::Convert(AudioFormat format) return false; } -Source_SampleStream::Source_SampleStream() -{ - length = 0; - rw = NULL; - buffer = 0; - buffersize = 0; -} - Source_SampleStream::~Source_SampleStream() { Unload(); @@ -349,18 +341,9 @@ void Source_SampleStream::Unload() Channel::Channel() { - resampler = 0; SetRate(1); SetVolume(SDL_MIX_MAXVOLUME); - oldvolume = 0; - oldvolume_l = 0; - oldvolume_r = 0; SetPan(0.5f); - done = true; - stopping = false; - source = 0; - deletesourceondone = false; - group = MIXER_GROUP_NONE; } Channel::~Channel() diff --git a/src/audio/mixer.h b/src/audio/mixer.h index 0e6faf3218..3fe66b4816 100644 --- a/src/audio/mixer.h +++ b/src/audio/mixer.h @@ -105,7 +105,7 @@ protected: class Source_SampleStream : public Source { public: - Source_SampleStream(); + Source_SampleStream() = default; ~Source_SampleStream(); bool LoadWAV(SDL_RWops* rw); @@ -113,10 +113,10 @@ private: Uint32 FindChunk(SDL_RWops* rw, Uint32 wanted_id); void Unload(); - SDL_RWops* rw; - Uint64 databegin; - uint8* buffer; - unsigned long buffersize; + SDL_RWops* rw = nullptr; + Uint64 databegin = 0; + uint8* buffer = nullptr; + unsigned long buffersize = 0; protected: unsigned long Read(unsigned long offset, const uint8** data, unsigned long length); @@ -139,21 +139,21 @@ public: friend class Mixer; private: - int loop; - unsigned long offset; - double rate; - int volume; - float volume_l, volume_r; - float oldvolume_l, oldvolume_r; - float pan; - bool done; - bool deleteondone; - bool deletesourceondone; - bool stopping; - int oldvolume; - int group; - SpeexResamplerState* resampler; - Source* source; + int loop = 0; + unsigned long offset = 0; + double rate = 0; + int volume = 1; + float volume_l = 0.f, volume_r = 0.f; + float oldvolume_l = 0.f, oldvolume_r = 0.f; + float pan = 0; + bool done = true; + bool deleteondone = false; + bool deletesourceondone = false; + bool stopping = false; + int oldvolume = 0; + int group = MIXER_GROUP_NONE; + SpeexResamplerState* resampler = nullptr; + Source* source = nullptr; }; class Mixer diff --git a/src/diagnostic.h b/src/diagnostic.h index 556ff98324..00c03bd154 100644 --- a/src/diagnostic.h +++ b/src/diagnostic.h @@ -30,6 +30,49 @@ enum { DIAGNOSTIC_LEVEL_COUNT }; +/* + * Compile-time debug levels. + * + * When compiling, just add -DDEBUG={0,1,2,3} (where 0 means disabled) + * Regardless of DEBUG value, a set of defines will be created: + * - DEBUG_LEVEL_1 + * - DEBUG_LEVEL_2 + * - DEBUG_LEVEL_3 + * which you would use like so: + * + * #if DEBUG_LEVEL_1 + * (... some debug code ...) + * #if DEBUG_LEVEL_2 + * (... more debug code ...) + * #endif // DEBUG_LEVEL_2 + * #endif // DEBUG_LEVEL_1 + * + * The defines will be either 0 or 1 so compiler will complain about undefined + * macro if you forget to include the file, which would not happen if we were + * only checking whether the define is present or not. + */ + +#if defined(DEBUG) + #if DEBUG > 0 + #define DEBUG_LEVEL_1 1 + #if DEBUG > 1 + #define DEBUG_LEVEL_2 1 + #if DEBUG > 2 + #define DEBUG_LEVEL_3 1 + #else + #define DEBUG_LEVEL_3 0 + #endif // DEBUG > 2 + #else + #define DEBUG_LEVEL_3 0 + #define DEBUG_LEVEL_2 0 + #endif // DEBUG > 1 + #endif // DEBUG > 0 +#else + #define DEBUG_LEVEL_3 0 + #define DEBUG_LEVEL_2 0 + #define DEBUG_LEVEL_1 0 +#endif // defined(DEBUG) + extern int _log_levels[DIAGNOSTIC_LEVEL_COUNT]; void diagnostic_log(int diagnosticLevel, const char *format, ...); diff --git a/src/drawing/sprite.c b/src/drawing/sprite.c index 9f47d9b533..aaa09f1cd2 100644 --- a/src/drawing/sprite.c +++ b/src/drawing/sprite.c @@ -136,6 +136,7 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui uint32 source_line_width = source_image->width * zoom_amount; //Requires use of palette? if (image_type & IMAGE_TYPE_USE_PALETTE){ + assert(palette_pointer != NULL); //Mix with another image?? and colour adjusted if (unknown_pointer!= NULL){ //Not tested. I can't actually work out when this code runs. @@ -182,6 +183,7 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui //Mix with background. It only uses source pointer for //telling if it needs to be drawn not for colour. if (image_type & IMAGE_TYPE_MIX_BACKGROUND){//Not tested + assert(palette_pointer != NULL); for (; height > 0; height -= zoom_amount){ uint8* next_source_pointer = source_pointer + source_line_width; uint8* next_dest_pointer = dest_pointer + dest_line_width; diff --git a/src/input.c b/src/input.c index 947138e16b..cee459a73f 100644 --- a/src/input.c +++ b/src/input.c @@ -428,6 +428,7 @@ static void input_viewport_drag_continue() dx = newDragX - _dragX; dy = newDragY - _dragY; w = window_find_by_number(_dragWindowClass, _dragWindowNumber); + assert(w != NULL); viewport = w->viewport; RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_DRAG_START, sint16) += RCT2_GLOBAL(RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE, sint16); diff --git a/src/interface/screenshot.c b/src/interface/screenshot.c index 9ac0c16546..79c1ae2ccf 100644 --- a/src/interface/screenshot.c +++ b/src/interface/screenshot.c @@ -357,7 +357,7 @@ bool screenshot_write_png(rct_drawpixelinfo *dpi, const char *path) void screenshot_giant() { - int originalRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + int originalRotation = get_current_rotation(); int originalZoom = 0; rct_window *mainWindow = window_get_main(); diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 20d5a872f8..f10ba0d4d0 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -140,7 +140,7 @@ void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_view .z = z }; - rct_xy16 coord_2d = coordinate_3d_to_2d(&coord_3d, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + rct_xy16 coord_2d = coordinate_3d_to_2d(&coord_3d, get_current_rotation()); // If the start location was invalid // propagate the invalid location to the output. @@ -259,7 +259,7 @@ void sub_689174(sint16* x, sint16* y, sint16 *z) if (pos.x > max && pos.y > max) { int x_corr[] = { -1, 1, 1, -1 }; int y_corr[] = { -1, -1, 1, 1 }; - uint32 rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + uint32 rotation = get_current_rotation(); pos.x += x_corr[rotation] * height; pos.y += y_corr[rotation] * height; } @@ -816,7 +816,7 @@ void sub_688485(){ /* rct2: 0x006874B0, 0x00687618, 0x0068778C, 0x00687902, 0x0098199C */ int sub_98199C(sint8 al, sint8 ah, int image_id, sint8 cl, int height, sint16 length_y, sint16 length_x, uint32 rotation){ - RCT2_CALLPROC_X(RCT2_ADDRESS(0x98199C, uint32_t)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)], + RCT2_CALLPROC_X(RCT2_ADDRESS(0x98199C, uint32_t)[get_current_rotation()], al | (ah << 8), image_id, cl, @@ -858,7 +858,7 @@ int sub_98197C(sint8 al, sint8 ah, int image_id, sint8 cl, int height, sint16 le }; switch (rotation) { - case 0: + case 0: rotate_map_coordinates(&coord_3d.x, &coord_3d.y, 0); break; case 1: @@ -1008,7 +1008,7 @@ void viewport_vehicle_paint_setup(rct_vehicle *vehicle, int imageDirection) RCT2_GLOBAL(0x9DEA52, uint16) = 0; RCT2_GLOBAL(0x9DEA54, uint16) = 0; RCT2_GLOBAL(0x9DEA56, uint16) = z + 2; - sub_98197C(0, 0, ebx, 0, z, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 0, ebx, 0, z, 1, 1, get_current_rotation()); return; } @@ -1087,7 +1087,7 @@ void viewport_litter_paint_setup(rct_litter *litter, int imageDirection) RCT2_GLOBAL(0x9DEA54, uint16) = 0xFFFC; RCT2_GLOBAL(0x9DEA56, uint16) = litter->z + 2; - sub_98197C(0, 0xFF, image_id, 0, litter->z, 4, 4, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 0xFF, image_id, 0, litter->z, 4, 4, get_current_rotation()); } @@ -1125,7 +1125,7 @@ void sprite_paint_setup(uint16 eax, uint16 ecx){ if (dpi->x + dpi->width <= spr->unknown.sprite_left)continue; if (spr->unknown.sprite_right <= dpi->x)continue; - int image_direction = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + int image_direction = get_current_rotation(); image_direction <<= 3; image_direction += spr->unknown.sprite_direction; image_direction &= 0x1F; @@ -1230,7 +1230,7 @@ void viewport_ride_entrance_exit_paint_setup(uint8 direction, int height, rct_ma sint16 lengthY = (direction & 1) ? 28 : 2; sint16 lengthX = (direction & 1) ? 2 : 28; - sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, get_current_rotation()); if (transparant_image_id){ if (is_exit){ @@ -1252,7 +1252,7 @@ void viewport_ride_entrance_exit_paint_setup(uint8 direction, int height, rct_ma RCT2_GLOBAL(0x009DEA54, uint16) = (direction & 1) ? 2 : 28; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, get_current_rotation()); if (transparant_image_id){ transparant_image_id += 4; @@ -1367,7 +1367,7 @@ void viewport_park_entrance_paint_setup(uint8 direction, int height, rct_map_ele RCT2_GLOBAL(0x009DEA54, uint16) = 2; RCT2_GLOBAL(0x009DEA56, sint16) = height; - sub_98197C(0, 0, image_id, 0, height, 0x1C, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0, image_id, 0, height, 0x1C, 32, get_current_rotation()); entrance = (rct_entrance_type*)object_entry_groups[OBJECT_TYPE_PARK_ENTRANCE].chunks[0]; image_id = (entrance->image_id + direction * 3) | ghost_id; @@ -1376,7 +1376,7 @@ void viewport_park_entrance_paint_setup(uint8 direction, int height, rct_map_ele RCT2_GLOBAL(0x009DEA54, uint16) = 2; RCT2_GLOBAL(0x009DEA56, sint16) = height + 32; - sub_98197C(0, 0x2F, image_id, 0, height, 0x1C, 0x1C, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x2F, image_id, 0, height, 0x1C, 0x1C, get_current_rotation()); if ((direction + 1) & (1 << 1)) break; @@ -1423,7 +1423,7 @@ void viewport_park_entrance_paint_setup(uint8 direction, int height, rct_map_ele RCT2_GLOBAL(0x009DEA54, uint16) = 3; RCT2_GLOBAL(0x009DEA56, sint16) = height; - sub_98197C(0, 0x4F, image_id, 0, height, di, 0x1A, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x4F, image_id, 0, height, di, 0x1A, get_current_rotation()); break; } @@ -1491,7 +1491,7 @@ void viewport_track_paint_setup(uint8 direction, int height, rct_map_element *ma RCT2_GLOBAL(0x009DEA52, uint16) = 1000; RCT2_GLOBAL(0x009DEA54, uint16) = 1000; RCT2_GLOBAL(0x009DEA56, uint16) = 2047; - sub_98197C(16, 0, ebx, 16, height + ax + 3, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(16, 0, ebx, 16, height + ax + 3, 1, 1, get_current_rotation()); } } @@ -1571,7 +1571,7 @@ void viewport_entrance_paint_setup(uint8 direction, int height, rct_map_element* RCT2_GLOBAL(0x009DEA56, sint16) = z; RCT2_GLOBAL(0x009DEA56, uint16) += 64; - sub_98197C(16, 0, image_id, 16, height, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(16, 0, image_id, 16, height, 1, 1, get_current_rotation()); } } @@ -1620,11 +1620,11 @@ void viewport_banner_paint_setup(uint8 direction, int height, rct_map_element* m 0x20000000; } - sub_98197C(0, 0x15, image_id, 0, height, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x15, image_id, 0, height, 1, 1, get_current_rotation()); RCT2_GLOBAL(0x9DEA52, uint32) = RCT2_ADDRESS(0x98D888, uint32)[direction * 2]; image_id++; - sub_98197C(0, 0x15, image_id, 0, height, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x15, image_id, 0, height, 1, 1, get_current_rotation()); // Opposite direction direction ^= 2; @@ -1678,7 +1678,7 @@ static void sub_68B3FB(int x, int y) rct_map_element* map_element = map_get_first_element_at(x >> 5, y >> 5); int dx = 0; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) { + switch (get_current_rotation()) { case 0: dx = x + y; break; @@ -1702,7 +1702,7 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DE56A, uint16) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) && RCT2_GLOBAL(0x9DE56E, uint16) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16)){ uint8 arrowRotation = - (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + (get_current_rotation() + (RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) & 3)) & 3; uint32 imageId = @@ -1719,7 +1719,7 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DEA54, uint16) = 0; RCT2_GLOBAL(0x9DEA56, uint16) = arrowZ + 18; - sub_98197C(0, 0xFF, imageId, 0, arrowZ, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 0xFF, imageId, 0, arrowZ, 32, 32, get_current_rotation()); } int bx = dx + 52; @@ -1753,7 +1753,7 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DE56C, sint16) = y; RCT2_GLOBAL(0x9DE57C, uint16) = 0; do { - int direction = (map_element->type + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) & MAP_ELEMENT_DIRECTION_MASK; + int direction = (map_element->type + get_current_rotation()) & MAP_ELEMENT_DIRECTION_MASK; int height = map_element->base_height * 8; uint32_t dword_9DE574 = RCT2_GLOBAL(0x9DE574, uint32_t); @@ -1806,7 +1806,7 @@ static void viewport_blank_tiles_paint_setup(int x, int y) rct_drawpixelinfo *dpi = RCT2_GLOBAL(0x0140E9A8, rct_drawpixelinfo*); int dx; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) { + switch (get_current_rotation()) { case 0: dx = x + y; break; @@ -1835,14 +1835,14 @@ static void viewport_blank_tiles_paint_setup(int x, int y) RCT2_GLOBAL(0x9DE56C, sint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_NONE; RCT2_CALLPROC_X( - (int)RCT2_ADDRESS(0x98196C, uint32_t*)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)], + (int)RCT2_ADDRESS(0x98196C, uint32_t*)[get_current_rotation()], 0xFF00, 3123, y & 0xFF00, 16, 32, 32, - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t) + get_current_rotation() ); } @@ -1925,7 +1925,7 @@ void viewport_paint_setup() uint16 num_vertical_quadrants = (dpi->height + 2128) >> 5; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)){ + switch (get_current_rotation()){ case 0: mapTile.x = mapTile.y - half_x; mapTile.y = mapTile.y + half_x; @@ -2074,7 +2074,7 @@ void sub_688217_helper(uint16 ax, uint8 flag) if (!(ps_next->var_1B & (1 << 1))) continue; int yes = 0; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: if (my_some_y >= ps_next->some_x && my_other_y >= ps_next->attached_y && my_other_x >= ps_next->attached_x && !(my_some_x < ps_next->some_y && my_attached_y < ps_next->other_y && my_attached_x < ps_next->other_x)) @@ -2339,7 +2339,7 @@ rct_xy16 screen_coord_to_viewport_coord(rct_viewport *viewport, uint16 x, uint16 rct_xy16 viewport_coord_to_map_coord(int x, int y, int z) { rct_xy16 ret; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: ret.x = -x / 2 + y + z; ret.y = x / 2 + y + z; @@ -2854,3 +2854,23 @@ void screen_get_map_xy_side_with_z(sint16 screenX, sint16 screenY, sint16 z, sin *mapX = floor2(*mapX, 32); *mapY = floor2(*mapY, 32); } + +/** + * Get current viewport rotation. + * + * If an invalid rotation is detected and DEBUG_LEVEL_1 is enabled, an error + * will be reported. + * + * @returns rotation in range 0-3 (inclusive) + */ +int get_current_rotation() +{ + int rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + int rotation_masked = rotation & 3; +#if DEBUG_LEVEL_1 + if (rotation != rotation_masked) { + log_error("Found wrong rotation %d! Will return %d instead.", rotation, rotation_masked); + } +#endif // DEBUG_LEVEL_1 + return rotation_masked; +} diff --git a/src/interface/viewport.h b/src/interface/viewport.h index d416a96494..16b585f82e 100644 --- a/src/interface/viewport.h +++ b/src/interface/viewport.h @@ -144,4 +144,6 @@ void screen_get_map_xy_quadrant_with_z(sint16 screenX, sint16 screenY, sint16 z, void screen_get_map_xy_side(sint16 screenX, sint16 screenY, sint16 *mapX, sint16 *mapY, uint8 *side); void screen_get_map_xy_side_with_z(sint16 screenX, sint16 screenY, sint16 z, sint16 *mapX, sint16 *mapY, uint8 *side); +int get_current_rotation(); + #endif diff --git a/src/interface/window.c b/src/interface/window.c index e40ca34f86..90865813d7 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1301,7 +1301,7 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z) } } - rct_xy16 map_coordinate = coordinate_3d_to_2d(&location_3d, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)); + rct_xy16 map_coordinate = coordinate_3d_to_2d(&location_3d, get_current_rotation()); int i = 0; if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)) { @@ -1389,7 +1389,7 @@ void window_rotate_camera(rct_window *w, int direction) z = map_element_height(x, y); } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + direction) % 4; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = (get_current_rotation() + direction) % 4; int new_x, new_y; center_2d_coordinates(x, y, z, &new_x, &new_y, viewport); diff --git a/src/management/research.c b/src/management/research.c index d8e3f0d116..5873493565 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -295,7 +295,9 @@ void sub_684AC3(){ ebp = inner_research; } } while ((inner_research++)->entryIndex != RESEARCHED_ITEMS_END); + assert(edx != NULL); edx->entryIndex = research->entryIndex; + assert(ebp != NULL); ebp->entryIndex = (research + 1)->entryIndex; uint8 cat = edx->category; diff --git a/src/rct1.c b/src/rct1.c index b151ee507a..90fe58171d 100644 --- a/src/rct1.c +++ b/src/rct1.c @@ -1528,152 +1528,157 @@ static const RCT1DefaultObjectsGroup RCT1DefaultObjects[10] = { }; // Keep these in the same order as gVehicleHierarchies -char *SpiralRCObjectOrder[] = { "SPDRCR "}; -char *StandupRCObjectOrder[] = { "TOGST "}; -char *SuspendedSWRCObjectOrder[] = { "ARRSW1 ", "VEKVAMP ", "ARRSW2 "}; -char *InvertedRCObjectOrder[] = { "NEMT "}; -char *JuniorCoasterObjectOrder[] = { "ZLDB ", "ZLOG "}; -char *MiniatureRailwayObjectOrder[] = { "NRL ", "NRL2 ", "AML1 ", "TRAM1 "}; -char *MonorailObjectOrder[] = { "MONO1 ", "MONO2 ", "MONO3 "}; -char *MiniSuspendedRCObjectOrder[] = { "BATFL ", "SKYTR "}; -char *BoatRideObjectOrder[] = { "RBOAT ", "BBOAT ", "CBOAT ", "SWANS ", "TRIKE ","JSKI "}; -char *WoodenWMObjectOrder[] = { "WMOUSE ", "WMMINE "}; -char *SteeplechaseObjectOrder[] = { "STEEP1 ", "STEEP2 ", "SBOX "}; -char *CarRideObjectOrder[] = { "SPCAR ", "RCR ", "TRUCK1 ", "VCR ", "CTCAR "}; -char *LaunchedFFObjectOrder[] = { "SSC1 "}; -char *BobsleighRCObjectOrder[] = { "BOB1 ", "INTBOB "}; -char *ObservationTowerObjectOrder[] = { "OBS1 ", "OBS2 "}; -char *LoopingRCObjectOrder[] = { "SCHT1 "}; -char *DinghySlideObjectOrder[] = { "DING1 "}; -char *MineTrainRCObjectOrder[] = { "AMT1 "}; -char *ChairliftObjectOrder[] = { "CLIFT1 ", "CLIFT2 "}; -char *CorkscrewRCObjectOrder[] = { "ARRT1 ", "ARRT2 "}; -char *GoKartsObjectOrder[] = { "KART1 "}; -char *LogFlumeObjectOrder[] = { "LFB1 "}; -char *RiverRapidsObjectOrder[] = { "RAPBOAT "}; -char *ReverseFreefallRCObjectOrder[]= { "REVF1 "}; -char *LiftObjectOrder[] = { "LIFT1 "}; -char *VerticalDropRCObjectOrder[] = { "BMVD "}; -char *GhostTrainObjectOrder[] = { "GTC ", "HMCAR "}; -char *TwisterRCObjectOrder[] = { "BMSD ", "BMSU ", "BMFL ", "BMRB ", "GOLTR "}; -char *WoodenRCObjectOrder[] = { "PTCT1 ", "MFT ", "PTCT2 "}; -char *SideFrictionRCObjectOrder[] = { "SFRIC1 "}; -char *SteelWildMouseObjectOrder[] = { "SMC1 ", "SMC2 ", "WMSPIN "}; -char *MultiDimensionRCObjectOrder[] = { "ARRX "}; -char *FlyingRCObjectOrder[] = { "BMAIR "}; -char *VirginiaReelRCObjectOrder[] = { "VREEL "}; -char *SplashBoatsObjectOrder[] = { "SPBOAT "}; -char *MiniHelicoptersObjectOrder[] = { "HELICAR "}; -char *LayDownRCObjectOrder[] = { "VEKST "}; -char *SuspendedMonorailObjectOrder[]= { "SMONO "}; -char *ReverserRCObjectOrder[] = { "REVCAR "}; -char *HeartlineTwisterObjectOrder[] = { "UTCAR ", "UTCARR "}; -char *GigaRCObjectOrder[] = { "INTST "}; -char *RotoDropObjectOrder[] = { "GDROP1 "}; -char *MonorailCyclesObjectOrder[] = { "MONBK "}; -char *CompactInvertedRCObjectOrder[]= { "SLCT ", "SLCFO ", "VEKDV "}; -char *WaterRCObjectOrder[] = { "CSTBOAT "}; -char *AirPoweredRCObjectOrder[] = { "THCAR "}; -char *InvertedHairpinRCObjectOrder[]= { "IVMC1 "}; -char *SubmarineRideObjectOrder[] = { "SUBMAR "}; -char *RiverRaftsObjectOrder[] = { "RFTBOAT "}; -char *InvertedImpulseRCObjectOrder[]= { "INTINV "}; -char *MiniRCObjectOrder[] = { "WCATC ", "RCKC ", "JSTAR1 "}; -char *MineRideRCObjectOrder[] = { "PMT1 "}; -char *LIMLaunchedRCObjectOrder[] = { "PREMT1 "}; +const char *SpiralRCObjectOrder[] = { "SPDRCR "}; +const char *StandupRCObjectOrder[] = { "TOGST "}; +const char *SuspendedSWRCObjectOrder[] = { "ARRSW1 ", "VEKVAMP ", "ARRSW2 "}; +const char *InvertedRCObjectOrder[] = { "NEMT "}; +const char *JuniorCoasterObjectOrder[] = { "ZLDB ", "ZLOG "}; +const char *MiniatureRailwayObjectOrder[] = { "NRL ", "NRL2 ", "AML1 ", "TRAM1 "}; +const char *MonorailObjectOrder[] = { "MONO1 ", "MONO2 ", "MONO3 "}; +const char *MiniSuspendedRCObjectOrder[] = { "BATFL ", "SKYTR "}; +const char *BoatRideObjectOrder[] = { "RBOAT ", "BBOAT ", "CBOAT ", "SWANS ", "TRIKE ","JSKI "}; +const char *WoodenWMObjectOrder[] = { "WMOUSE ", "WMMINE "}; +const char *SteeplechaseObjectOrder[] = { "STEEP1 ", "STEEP2 ", "SBOX "}; +const char *CarRideObjectOrder[] = { "SPCAR ", "RCR ", "TRUCK1 ", "VCR ", "CTCAR "}; +const char *LaunchedFFObjectOrder[] = { "SSC1 "}; +const char *BobsleighRCObjectOrder[] = { "BOB1 ", "INTBOB "}; +const char *ObservationTowerObjectOrder[] = { "OBS1 ", "OBS2 "}; +const char *LoopingRCObjectOrder[] = { "SCHT1 "}; +const char *DinghySlideObjectOrder[] = { "DING1 "}; +const char *MineTrainRCObjectOrder[] = { "AMT1 "}; +const char *ChairliftObjectOrder[] = { "CLIFT1 ", "CLIFT2 "}; +const char *CorkscrewRCObjectOrder[] = { "ARRT1 ", "ARRT2 "}; +const char *GoKartsObjectOrder[] = { "KART1 "}; +const char *LogFlumeObjectOrder[] = { "LFB1 "}; +const char *RiverRapidsObjectOrder[] = { "RAPBOAT "}; +const char *ReverseFreefallRCObjectOrder[] = { "REVF1 "}; +const char *LiftObjectOrder[] = { "LIFT1 "}; +const char *VerticalDropRCObjectOrder[] = { "BMVD "}; +const char *GhostTrainObjectOrder[] = { "GTC ", "HMCAR "}; +const char *TwisterRCObjectOrder[] = { "BMSD ", "BMSU ", "BMFL ", "BMRB ", "GOLTR "}; +const char *WoodenRCObjectOrder[] = { "PTCT1 ", "MFT ", "PTCT2 "}; +const char *SideFrictionRCObjectOrder[] = { "SFRIC1 "}; +const char *SteelWildMouseObjectOrder[] = { "SMC1 ", "SMC2 ", "WMSPIN "}; +const char *MultiDimensionRCObjectOrder[] = { "ARRX "}; +const char *FlyingRCObjectOrder[] = { "BMAIR "}; +const char *VirginiaReelRCObjectOrder[] = { "VREEL "}; +const char *SplashBoatsObjectOrder[] = { "SPBOAT "}; +const char *MiniHelicoptersObjectOrder[] = { "HELICAR "}; +const char *LayDownRCObjectOrder[] = { "VEKST "}; +const char *SuspendedMonorailObjectOrder[] = { "SMONO "}; +const char *ReverserRCObjectOrder[] = { "REVCAR "}; +const char *HeartlineTwisterObjectOrder[] = { "UTCAR ", "UTCARR "}; +const char *GigaRCObjectOrder[] = { "INTST "}; +const char *RotoDropObjectOrder[] = { "GDROP1 "}; +const char *MonorailCyclesObjectOrder[] = { "MONBK "}; +const char *CompactInvertedRCObjectOrder[] = { "SLCT ", "SLCFO ", "VEKDV "}; +const char *WaterRCObjectOrder[] = { "CSTBOAT "}; +const char *AirPoweredRCObjectOrder[] = { "THCAR "}; +const char *InvertedHairpinRCObjectOrder[] = { "IVMC1 "}; +const char *SubmarineRideObjectOrder[] = { "SUBMAR "}; +const char *RiverRaftsObjectOrder[] = { "RFTBOAT "}; +const char *InvertedImpulseRCObjectOrder[] = { "INTINV "}; +const char *MiniRCObjectOrder[] = { "WCATC ", "RCKC ", "JSTAR1 "}; +const char *MineRideRCObjectOrder[] = { "PMT1 "}; +const char *LIMLaunchedRCObjectOrder[] = { "PREMT1 "}; -char **gVehicleHierarchies[0x60] = { - SpiralRCObjectOrder, // 0 Spiral Roller coaster - StandupRCObjectOrder, // 1 Stand Up Coaster - SuspendedSWRCObjectOrder, // 2 Suspended Swinging - InvertedRCObjectOrder, // 3 Inverted - JuniorCoasterObjectOrder, // 4 Junior RC / Steel Mini Coaster - MiniatureRailwayObjectOrder, // 5 Mini Railroad - MonorailObjectOrder, // 6 Monorail - MiniSuspendedRCObjectOrder, // 7 Mini Suspended Coaster - BoatRideObjectOrder, // 8 Boat ride - WoodenWMObjectOrder, // 9 Wooden Wild Mine/Mouse - SteeplechaseObjectOrder, // a Steeplechase/Motorbike/Soap Box Derby - CarRideObjectOrder, // b Car Ride - LaunchedFFObjectOrder, // c Launched Freefall - BobsleighRCObjectOrder, // d Bobsleigh Coaster - ObservationTowerObjectOrder, // e Observation Tower - LoopingRCObjectOrder, // f Looping Roller Coaster - DinghySlideObjectOrder, // 10 Dinghy Slide - MineTrainRCObjectOrder, // 11 Mine Train Coaster - ChairliftObjectOrder, // 12 Chairlift - CorkscrewRCObjectOrder, // 13 Corkscrew Roller Coaster - NULL, // 14 Maze, N/A - NULL, // 15 Spiral Slide, N/A - GoKartsObjectOrder, // 16 Go Karts - LogFlumeObjectOrder, // 17 Log Flume - RiverRapidsObjectOrder, // 18 River Rapids - NULL, // 19 Dodgems, N/A - NULL, // 1a Pirate Ship, N/A - NULL, // 1b Swinging Inverter Ship, N/A - NULL, // 1c Food Stall, N/A - NULL, // 1d (none), N/A - NULL, // 1e Drink Stall, N/A - NULL, // 1f (none), N/A - NULL, // 20 Shop (all types), N/A - NULL, // 21 Merry Go Round, N/A - NULL, // 22 Balloon Stall (maybe), N/A - NULL, // 23 Information Kiosk, N/A - NULL, // 24 Bathroom, N/A - NULL, // 25 Ferris Wheel, N/A - NULL, // 26 Motion Simulator, N/A - NULL, // 27 3D Cinema, N/A - NULL, // 28 Top Spin, N/A - NULL, // 29 Space Rings, N/A - ReverseFreefallRCObjectOrder, // 2a Reverse Freefall Coaster - LiftObjectOrder, // 2b Lift - VerticalDropRCObjectOrder, // 2c Vertical Drop Roller Coaster - NULL, // 2d ATM, N/A - NULL, // 2e Twist, N/A - NULL, // 2f Haunted House, N/A - NULL, // 30 First Aid, N/A - NULL, // 31 Circus Show, N/A - GhostTrainObjectOrder, // 32 Ghost Train - TwisterRCObjectOrder, // 33 Twister Roller Coaster - WoodenRCObjectOrder, // 34 Wooden Roller Coaster - SideFrictionRCObjectOrder, // 35 Side-Friction Roller Coaster - SteelWildMouseObjectOrder, // 36 Steel Wild Mouse - MultiDimensionRCObjectOrder, // 37 Multi Dimension Coaster - NULL, // 38 (none), N/A - FlyingRCObjectOrder, // 39 Flying Roller Coaster - NULL, // 3a (none), N/A - VirginiaReelRCObjectOrder, // 3b Virginia Reel - SplashBoatsObjectOrder, // 3c Splash Boats - MiniHelicoptersObjectOrder, // 3d Mini Helicopters - LayDownRCObjectOrder, // 3e Lay-down Roller Coaster - SuspendedMonorailObjectOrder, // 3f Suspended Monorail - NULL, // 40 (none), N/A - ReverserRCObjectOrder, // 41 Reverser Roller Coaster - HeartlineTwisterObjectOrder, // 42 Heartline Twister Roller Coaster - NULL, // 43 Mini Golf, N/A - GigaRCObjectOrder, // 44 Giga Coaster - RotoDropObjectOrder, // 45 Roto-Drop - NULL, // 46 Flying Saucers, N/A - NULL, // 47 Crooked House, N/A - MonorailCyclesObjectOrder, // 48 Monorail Cycles - CompactInvertedRCObjectOrder, // 49 Compact Inverted Coaster - WaterRCObjectOrder, // 4a Water Coaster - AirPoweredRCObjectOrder, // 4b Air Powered Vertical Coaster - InvertedHairpinRCObjectOrder, // 4c Inverted Hairpin Coaster - NULL, // 4d Magic Carpet, N/A - SubmarineRideObjectOrder, // 4e Submarine Ride - RiverRaftsObjectOrder, // 4f River Rafts - NULL, // 50 (none), N/A - NULL, // 51 Enterprise, N/A - NULL, // 52 (none), N/A - NULL, // 53 (none), N/A - NULL, // 54 (none), N/A - NULL, // 55 (none), N/A - InvertedImpulseRCObjectOrder, // 56 Inverted Impulse Coaster - MiniRCObjectOrder, // 57 Mini Roller Coaster - MineRideRCObjectOrder, // 58 Mine Ride - NULL, // 59 Unknown Ride - LIMLaunchedRCObjectOrder, // 60 LIM Launched Roller Coaster +typedef struct { + const char **entries; + int count; +} RCT1VehicleHierarchiesGroup; + +RCT1VehicleHierarchiesGroup gVehicleHierarchies[0x60] = { + { SpiralRCObjectOrder, countof(SpiralRCObjectOrder) }, // 0 Spiral Roller coaster + { StandupRCObjectOrder, countof(StandupRCObjectOrder) }, // 1 Stand Up Coaster + { SuspendedSWRCObjectOrder, countof(SuspendedSWRCObjectOrder) }, // 2 Suspended Swinging + { InvertedRCObjectOrder, countof(InvertedRCObjectOrder) }, // 3 Inverted + { JuniorCoasterObjectOrder, countof(JuniorCoasterObjectOrder) }, // 4 Junior RC / Steel Mini Coaster + { MiniatureRailwayObjectOrder, countof(MiniatureRailwayObjectOrder) }, // 5 Mini Railroad + { MonorailObjectOrder, countof(MonorailObjectOrder) }, // 6 Monorail + { MiniSuspendedRCObjectOrder, countof(MiniSuspendedRCObjectOrder) }, // 7 Mini Suspended Coaster + { BoatRideObjectOrder, countof(BoatRideObjectOrder) }, // 8 Boat ride + { WoodenWMObjectOrder, countof(WoodenWMObjectOrder) }, // 9 Wooden Wild Mine/Mouse + { SteeplechaseObjectOrder, countof(SteeplechaseObjectOrder) }, // a Steeplechase/Motorbike/Soap Box Derby + { CarRideObjectOrder, countof(CarRideObjectOrder) }, // b Car Ride + { LaunchedFFObjectOrder, countof(LaunchedFFObjectOrder) }, // c Launched Freefall + { BobsleighRCObjectOrder, countof(BobsleighRCObjectOrder) }, // d Bobsleigh Coaster + { ObservationTowerObjectOrder, countof(ObservationTowerObjectOrder) }, // e Observation Tower + { LoopingRCObjectOrder, countof(LoopingRCObjectOrder) }, // f Looping Roller Coaster + { DinghySlideObjectOrder, countof(DinghySlideObjectOrder) }, // 10 Dinghy Slide + { MineTrainRCObjectOrder, countof(MineTrainRCObjectOrder) }, // 11 Mine Train Coaster + { ChairliftObjectOrder, countof(ChairliftObjectOrder) }, // 12 Chairlift + { CorkscrewRCObjectOrder, countof(CorkscrewRCObjectOrder) }, // 13 Corkscrew Roller Coaster + { NULL, 0 }, // 14 Maze, N/A + { NULL, 0 }, // 15 Spiral Slide, N/A + { GoKartsObjectOrder, countof(GoKartsObjectOrder) }, // 16 Go Karts + { LogFlumeObjectOrder, countof(LogFlumeObjectOrder) }, // 17 Log Flume + { RiverRapidsObjectOrder, countof(RiverRapidsObjectOrder) }, // 18 River Rapids + { NULL, 0 }, // 19 Dodgems, N/A + { NULL, 0 }, // 1a Pirate Ship, N/A + { NULL, 0 }, // 1b Swinging Inverter Ship, N/A + { NULL, 0 }, // 1c Food Stall, N/A + { NULL, 0 }, // 1d (none), N/A + { NULL, 0 }, // 1e Drink Stall, N/A + { NULL, 0 }, // 1f (none), N/A + { NULL, 0 }, // 20 Shop (all types), N/A + { NULL, 0 }, // 21 Merry Go Round, N/A + { NULL, 0 }, // 22 Balloon Stall (maybe), N/A + { NULL, 0 }, // 23 Information Kiosk, N/A + { NULL, 0 }, // 24 Bathroom, N/A + { NULL, 0 }, // 25 Ferris Wheel, N/A + { NULL, 0 }, // 26 Motion Simulator, N/A + { NULL, 0 }, // 27 3D Cinema, N/A + { NULL, 0 }, // 28 Top Spin, N/A + { NULL, 0 }, // 29 Space Rings, N/A + { ReverseFreefallRCObjectOrder, countof(ReverseFreefallRCObjectOrder) }, // 2a Reverse Freefall Coaster + { LiftObjectOrder, countof(LiftObjectOrder) }, // 2b Lift + { VerticalDropRCObjectOrder, countof(VerticalDropRCObjectOrder) }, // 2c Vertical Drop Roller Coaster + { NULL, 0 }, // 2d ATM, N/A + { NULL, 0 }, // 2e Twist, N/A + { NULL, 0 }, // 2f Haunted House, N/A + { NULL, 0 }, // 30 First Aid, N/A + { NULL, 0 }, // 31 Circus Show, N/A + { GhostTrainObjectOrder, countof(GhostTrainObjectOrder) }, // 32 Ghost Train + { TwisterRCObjectOrder, countof(TwisterRCObjectOrder) }, // 33 Twister Roller Coaster + { WoodenRCObjectOrder, countof(WoodenRCObjectOrder) }, // 34 Wooden Roller Coaster + { SideFrictionRCObjectOrder, countof(SideFrictionRCObjectOrder) }, // 35 Side-Friction Roller Coaster + { SteelWildMouseObjectOrder, countof(SteelWildMouseObjectOrder) }, // 36 Steel Wild Mouse + { MultiDimensionRCObjectOrder, countof(MultiDimensionRCObjectOrder) }, // 37 Multi Dimension Coaster + { NULL, 0 }, // 38 (none), N/A + { FlyingRCObjectOrder, countof(FlyingRCObjectOrder) }, // 39 Flying Roller Coaster + { NULL, 0 }, // 3a (none), N/A + { VirginiaReelRCObjectOrder, countof(VirginiaReelRCObjectOrder) }, // 3b Virginia Reel + { SplashBoatsObjectOrder, countof(SplashBoatsObjectOrder) }, // 3c Splash Boats + { MiniHelicoptersObjectOrder, countof(MiniHelicoptersObjectOrder) }, // 3d Mini Helicopters + { LayDownRCObjectOrder, countof(LayDownRCObjectOrder) }, // 3e Lay-down Roller Coaster + { SuspendedMonorailObjectOrder, countof(SuspendedMonorailObjectOrder) }, // 3f Suspended Monorail + { NULL, 0 }, // 40 (none), N/A + { ReverserRCObjectOrder, countof(ReverserRCObjectOrder) }, // 41 Reverser Roller Coaster + { HeartlineTwisterObjectOrder, countof(HeartlineTwisterObjectOrder) }, // 42 Heartline Twister Roller Coaster + { NULL, 0 }, // 43 Mini Golf, N/A + { GigaRCObjectOrder, countof(GigaRCObjectOrder) }, // 44 Giga Coaster + { RotoDropObjectOrder, countof(RotoDropObjectOrder) }, // 45 Roto-Drop + { NULL, 0 }, // 46 Flying Saucers, N/A + { NULL, 0 }, // 47 Crooked House, N/A + { MonorailCyclesObjectOrder, countof(MonorailCyclesObjectOrder) }, // 48 Monorail Cycles + { CompactInvertedRCObjectOrder, countof(CompactInvertedRCObjectOrder) }, // 49 Compact Inverted Coaster + { WaterRCObjectOrder, countof(WaterRCObjectOrder) }, // 4a Water Coaster + { AirPoweredRCObjectOrder, countof(AirPoweredRCObjectOrder) }, // 4b Air Powered Vertical Coaster + { InvertedHairpinRCObjectOrder, countof(InvertedHairpinRCObjectOrder) }, // 4c Inverted Hairpin Coaster + { NULL, 0 }, // 4d Magic Carpet, N/A + { SubmarineRideObjectOrder, countof(SubmarineRideObjectOrder) }, // 4e Submarine Ride + { RiverRaftsObjectOrder, countof(RiverRaftsObjectOrder) }, // 4f River Rafts + { NULL, 0 }, // 50 (none), N/A + { NULL, 0 }, // 51 Enterprise, N/A + { NULL, 0 }, // 52 (none), N/A + { NULL, 0 }, // 53 (none), N/A + { NULL, 0 }, // 54 (none), N/A + { NULL, 0 }, // 55 (none), N/A + { InvertedImpulseRCObjectOrder, countof(InvertedImpulseRCObjectOrder) }, // 56 Inverted Impulse Coaster + { MiniRCObjectOrder, countof(MiniRCObjectOrder) }, // 57 Mini Roller Coaster + { MineRideRCObjectOrder, countof(MineRideRCObjectOrder) }, // 58 Mine Ride + { NULL, 0 }, // 59 Unknown Ride + { LIMLaunchedRCObjectOrder, countof(LIMLaunchedRCObjectOrder) }, // 60 LIM Launched Roller Coaster }; const uint8 gRideCategories[0x60] = { @@ -1774,7 +1779,7 @@ const uint8 gRideCategories[0x60] = { It determines which picture is shown on the new ride tab and which train type is selected by default.*/ bool vehicleIsHigherInHierarchy(int track_type, char *currentVehicleName, char *comparedVehicleName) { - if(currentVehicleName==NULL || comparedVehicleName==NULL || gVehicleHierarchies[track_type]==NULL) { + if(currentVehicleName==NULL || comparedVehicleName==NULL || gVehicleHierarchies[track_type].entries==NULL) { return false; } @@ -1784,14 +1789,14 @@ bool vehicleIsHigherInHierarchy(int track_type, char *currentVehicleName, char * currentVehicleHierarchy=255; comparedVehicleHierarchy=255; - for(int i=0;istation_heights[i]; mapElement = ride_get_station_start_track_element(ride, i); - int rotation = ((mapElement->type & 3) << 2) | RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + int rotation = ((mapElement->type & 3) << 2) | get_current_rotation(); x *= 32; y *= 32; x += RCT2_GLOBAL(0x0098DDB8 + (rotation * 4), sint16); @@ -3231,7 +3231,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint RCT2_GLOBAL(0x009AF47C, uint16) = sampleRate; sint16 v11; sint16 v12; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: v11 = y - x; v12 = ((y + x) / 2) - z; diff --git a/src/ride/track.c b/src/ride/track.c index 290bb7ae46..8d12c0a5f2 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -716,7 +716,7 @@ int backup_map(){ *(uint16*)(backup_info + 4) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16); *(uint16*)(backup_info + 6) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, uint16); *(uint16*)(backup_info + 8) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16); - *(uint32*)(backup_info + 10) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + *(uint32*)(backup_info + 10) = get_current_rotation(); return 1; } diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 5f6f0c2f2a..5d6920f3ec 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -182,7 +182,7 @@ void top_spin_paint_tile_0(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; @@ -265,7 +265,7 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction // Left back bottom support image_id += 572; - sub_98197C(al, 90, image_id, cl, height, lengthY, lengthX, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(al, 90, image_id, cl, height, lengthY, lengthX, get_current_rotation()); image_id = RCT2_GLOBAL(0x00F441A0, uint32); if (image_id == 0x20000000) { @@ -290,10 +290,10 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C( al, 90, - image_id, - cl, - height, - lengthY, + image_id, + cl, + height, + lengthY, lengthX, 0); @@ -352,18 +352,18 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C( (sint8)seatCoords.x, - 90, - image_id, + 90, + image_id, (sint8)seatCoords.y, - seatCoords.z, - lengthY, + seatCoords.z, + lengthY, lengthX, 0); rct_drawpixelinfo* dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); if (dpi->zoom_level < 2 && vehicle != NULL && vehicle->num_peeps != 0) { - image_id = - (vehicle->peep_tshirt_colours[0] << 19) | + image_id = + (vehicle->peep_tshirt_colours[0] << 19) | (vehicle->peep_tshirt_colours[1] << 24); image_id += seatImageId; image_id += 0xA0000000; @@ -403,7 +403,7 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C((sint8)seatCoords.x, 90, image_id, (sint8)seatCoords.y, seatCoords.z, lengthY, lengthX, 0); } - } + } image_id = RCT2_GLOBAL(0x00F441A0, uint32); if (image_id == 0x20000000) { @@ -420,12 +420,12 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction image_id += 476; sub_98199C( - al, + al, 90, - image_id, - cl, - height, - lengthY, + image_id, + cl, + height, + lengthY, lengthX, 0); @@ -445,10 +445,10 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C( al, 90, - image_id, - cl, - height, - lengthY, + image_id, + cl, + height, + lengthY, lengthX, 0); @@ -466,12 +466,12 @@ void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + uint16 entranceLoc = + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -487,8 +487,8 @@ void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction } entranceLoc = - ((x / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -499,9 +499,9 @@ void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction sub_98199C(0, 7, image_id, 0, height, 32, 1, 0); } - + top_spin_paint_vehicle(32, 32, rideIndex, direction, height, mapElement); - + RCT2_GLOBAL(0x141E9B4, uint16) = height + 2; RCT2_GLOBAL(0x141E9B6, uint16) = 32; RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; @@ -532,12 +532,12 @@ void top_spin_paint_tile_2(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -579,12 +579,12 @@ void top_spin_paint_tile_4(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -626,12 +626,12 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -647,8 +647,8 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction } entranceLoc = - ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | - (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | + (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -657,7 +657,7 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 30; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 1, 32, get_current_rotation()); } top_spin_paint_vehicle(32, -32, rideIndex, direction, height, mapElement); @@ -692,15 +692,15 @@ void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | - (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | + (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); @@ -708,7 +708,7 @@ void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 30; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 1, 32, get_current_rotation()); } top_spin_paint_vehicle(0, -32, rideIndex, direction, height, mapElement); @@ -740,12 +740,12 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -761,8 +761,8 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction } entranceLoc = - ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | - (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | + (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -771,7 +771,7 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA54, uint16) = 2; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 32, 1, get_current_rotation()); } top_spin_paint_vehicle(-32, 32, rideIndex, direction, height, mapElement); @@ -806,15 +806,15 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | - (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | + (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -823,12 +823,12 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 29; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(0, 7, image_id, 0, height, 28, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 28, 1, get_current_rotation()); } entranceLoc = - ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | - (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | + (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -837,7 +837,7 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 29; RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(0, 7, image_id, 0, height, 1, 28, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 1, 28, get_current_rotation()); } top_spin_paint_vehicle(-32, -32, rideIndex, direction, height, mapElement); @@ -872,15 +872,15 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | - (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | + (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -889,7 +889,7 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 32, 1, get_current_rotation()); } top_spin_paint_vehicle(-32, 0, rideIndex, direction, height, mapElement); @@ -910,7 +910,7 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction } } -/* rct2: 0x007667BC +/* rct2: 0x007667BC */ void top_spin_paint_setup_rot_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { switch (trackSequence) @@ -1052,4 +1052,4 @@ void top_spin_paint_setup_rot_3(uint8 rideIndex, uint8 trackSequence, uint8 dire break; } return; -} \ No newline at end of file +} diff --git a/src/scenario.c b/src/scenario.c index d250db71cd..597c0d452e 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -991,7 +991,7 @@ int scenario_save(SDL_RWops* rw, int flags) viewX = viewport->view_width / 2 + viewport->view_x; viewY = viewport->view_height / 2 + viewport->view_y; viewZoom = viewport->zoom; - viewRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + viewRotation = get_current_rotation(); } else { viewX = 0; viewY = 0; @@ -1064,7 +1064,7 @@ int scenario_save_network(SDL_RWops* rw) viewX = viewport->view_width / 2 + viewport->view_x; viewY = viewport->view_height / 2 + viewport->view_y; viewZoom = viewport->zoom; - viewRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + viewRotation = get_current_rotation(); } else { viewX = 0; viewY = 0; diff --git a/src/windows/footpath.c b/src/windows/footpath.c index adcd719edb..51309bc1ac 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -537,7 +537,7 @@ static void window_footpath_paint(rct_window *w, rct_drawpixelinfo *dpi) if (!(w->disabled_widgets & (1 << WIDX_CONSTRUCT))) { // Get construction image - image = (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) % 4; + image = (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) + get_current_rotation()) % 4; if (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_SLOPE, uint8) == 2) image += 4; else if (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_SLOPE, uint8) == 6) @@ -618,7 +618,7 @@ static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget static void window_footpath_mousedown_direction(int direction) { footpath_provisional_update(); - RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) = (direction - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) & 3; + RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) = (direction - get_current_rotation()) & 3; _window_footpath_cost = MONEY32_UNDEFINED; window_footpath_set_enabled_and_pressed_widgets(); } @@ -1012,7 +1012,7 @@ static void window_footpath_set_enabled_and_pressed_widgets() pressedWidgets = w->pressed_widgets & 0xFFFF887F; disabledWidgets = 0; - currentRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + currentRotation = get_current_rotation(); if (RCT2_GLOBAL(RCT2_ADDRESS_PATH_CONSTRUCTION_MODE, uint8) >= PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL) { // Set pressed directional widget direction = (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) + currentRotation) & 3; diff --git a/src/windows/guest.c b/src/windows/guest.c index f460e0329d..f0e18f6739 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -732,7 +732,7 @@ void window_guest_viewport_init(rct_window* w){ focus.sprite.type |= VIEWPORT_FOCUS_TYPE_SPRITE | VIEWPORT_FOCUS_TYPE_COORDINATE; focus.sprite.pad_486 &= 0xFFFF; } - focus.coordinate.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + focus.coordinate.rotation = get_current_rotation(); } uint16 viewport_flags; diff --git a/src/windows/map.c b/src/windows/map.c index 13b7f1bf63..22179e1b98 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -224,7 +224,7 @@ void window_map_open() window_init_scroll_widgets(w); - w->map.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint16); + w->map.rotation = get_current_rotation(); window_map_init_map(); RCT2_GLOBAL(0x00F64F05, uint8) = 0; @@ -394,8 +394,8 @@ static void window_map_mousedown(int widgetIndex, rct_window *w, rct_widget *wid */ static void window_map_update(rct_window *w) { - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) != w->map.rotation) { - w->map.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + if (get_current_rotation() != w->map.rotation) { + w->map.rotation = get_current_rotation(); window_map_init_map(); window_map_center_on_view_point(); } @@ -885,7 +885,7 @@ static void window_map_center_on_view_point() if (w_map == NULL) return; - rct_xy16 offset = MiniMapOffsets[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) & 3]; + rct_xy16 offset = MiniMapOffsets[get_current_rotation()]; // calculate center view point of viewport and transform it to minimap coordinates @@ -975,7 +975,7 @@ static void window_map_transform_to_map_coords(sint16 *left, sint16 *top) sint16 x = *left, y = *top; sint16 temp; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 3: temp = x; x = y; @@ -1097,7 +1097,7 @@ static void window_map_paint_hud_rectangle(rct_drawpixelinfo *dpi) if (viewport == NULL) return; - rct_xy16 offset = MiniMapOffsets[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) & 3]; + rct_xy16 offset = MiniMapOffsets[get_current_rotation()]; sint16 left = (viewport->view_x >> 5) + offset.x; sint16 right = ((viewport->view_x + viewport->view_width) >> 5) + offset.x; sint16 top = (viewport->view_y >> 4) + offset.y; @@ -1176,7 +1176,7 @@ void sub_666EEF(int x, int y, sint16 *mapX, sint16 *mapY, sint16 *mapZ, int *dir } } } - *direction = (window_scenery_rotation - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) & 3; + *direction = (window_scenery_rotation - get_current_rotation()) & 3; } /** @@ -1604,7 +1604,7 @@ static void map_window_set_pixels(rct_window *w) int x, y, dx, dy; destination = (uint16*)((RCT2_GLOBAL(0x00F1AD6C, uint32) * 511) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_IMAGE_DATA, uint32) + 255); - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) { + switch (get_current_rotation()) { case 0: x = RCT2_GLOBAL(0x00F1AD6C, uint32) * 32; y = 0; @@ -1665,7 +1665,7 @@ static void map_window_screen_to_map(int screenX, int screenY, int *mapX, int *m screenY = ((screenY + 8) ) / 2; x = (screenY - screenX) * 32; y = (screenX + screenY) * 32; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) & 3) { + switch (get_current_rotation()) { case 0: *mapX = x; *mapY = y; diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index 5dc90c56f6..f815181b43 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -225,7 +225,7 @@ static void window_maze_construction_mouseup(rct_window *w, int widgetIndex) case WIDX_MAZE_DIRECTION_SE: case WIDX_MAZE_DIRECTION_SW: window_maze_construction_construct( - ((widgetIndex - WIDX_MAZE_DIRECTION_NW) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) & 3 + ((widgetIndex - WIDX_MAZE_DIRECTION_NW) - get_current_rotation()) & 3 ); break; } diff --git a/src/windows/park.c b/src/windows/park.c index 8f761e9f31..6b32b71bed 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1064,7 +1064,7 @@ static void window_park_init_viewport(rct_window *w) x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] + 16; y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i] + 16; z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[i] + 32; - r = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + r = get_current_rotation(); xy = 0x40000000 | (y << 16) | x; zr = (z << 16) | (r << 8); diff --git a/src/windows/ride.c b/src/windows/ride.c index e3dadfd032..4032b18685 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -1488,7 +1488,7 @@ static void window_ride_init_viewport(rct_window *w) focus.sprite.sprite_id = -1; focus.coordinate.zoom = 0; - focus.coordinate.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + focus.coordinate.rotation = get_current_rotation(); if (eax >= 0 && eax < ride->num_vehicles && ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK){ diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 7ebe6f8527..d81b6e7c0f 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -2152,7 +2152,7 @@ static void window_ride_construction_draw_track_piece( z -= bx; int start_x = x; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) { + switch (get_current_rotation()) { case 0: x = y - x; y = (y + start_x) / 2 - z; diff --git a/src/windows/staff.c b/src/windows/staff.c index d47741ee1c..9d4f41b29a 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -1188,7 +1188,7 @@ void window_staff_viewport_init(rct_window* w){ } else{ focus.type |= VIEWPORT_FOCUS_TYPE_SPRITE | VIEWPORT_FOCUS_TYPE_COORDINATE; - focus.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + focus.rotation = get_current_rotation(); } uint16 viewport_flags; diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 3eb2511f76..154019aabe 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1117,7 +1117,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin rotation = scenario_rand() & 0xFF; } - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; // Also places it in lower but think thats for clobering @@ -1195,7 +1195,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin rotation = scenario_rand() & 0xFF; } - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; // Also places it in lower but think thats for clobering @@ -1344,7 +1344,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin *grid_y &= 0xFFE0; uint8 rotation = window_scenery_rotation; - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; *parameter_1 = (rotation << 8); @@ -1371,7 +1371,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin } uint8 rotation = window_scenery_rotation; - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; sint16 z = map_element->base_height; diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 9d73faee30..12eddb7ee8 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -150,7 +150,7 @@ static void window_track_place_draw_mini_preview() if (track->type != RIDE_TYPE_MAZE) { #pragma region Track - rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + get_current_rotation(); trackElement = RCT2_ADDRESS(0x009D821B, rct_track_element); while (trackElement->type != 255) { @@ -249,7 +249,7 @@ static void window_track_place_draw_mini_preview() } else { #pragma region Maze - rotation = (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) & 3; + rotation = (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + get_current_rotation()) & 3; mazeElement = RCT2_ADDRESS(0x009D821B, rct_maze_element); while (mazeElement->all != 0) { x = mazeElement->x * 32; @@ -393,7 +393,7 @@ void window_track_place_open() show_gridlines(); _window_track_place_last_cost = MONEY32_UNDEFINED; _window_track_place_last_x = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = (-RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) + 2) & 3; + RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = (-get_current_rotation() + 2) & 3; window_track_place_draw_mini_preview(); } diff --git a/src/windows/viewport.c b/src/windows/viewport.c index 166759a19a..9a09015bb0 100644 --- a/src/windows/viewport.c +++ b/src/windows/viewport.c @@ -119,7 +119,7 @@ void window_viewport_open() (1 << WIDX_LOCATE); w->number = _viewportNumber++; - rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32); + rotation = get_current_rotation(); // Create viewport viewport_create(w, w->x, w->y, w->width, w->height, 0, 128 * 32, 128 * 32, 0, 1, -1); @@ -245,4 +245,4 @@ static void window_viewport_paint(rct_window *w, rct_drawpixelinfo *dpi) // Draw viewport if (w->viewport != NULL) window_draw_viewport(dpi, w); -} \ No newline at end of file +} diff --git a/src/world/map.c b/src/world/map.c index fbc12b811a..81919c5ff4 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -3539,28 +3539,28 @@ void map_get_bounding_box(int ax, int ay, int bx, int by, int *left, int *top, i int x, y; x = ax; y = ay; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); *left = x; *right = x; *top = y; *bottom = y; x = bx; y = ay; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; if (y < *top) *top = y; x = bx; y = by; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; if (y < *top) *top = y; x = ax; y = by; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; @@ -4431,7 +4431,7 @@ void map_invalidate_tile_under_zoom(int x, int y, int z0, int z1, int maxZoom) x += 16; y += 16; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); x1 = x - 32; y1 = y - 32 - z1; diff --git a/src/world/map_animation.c b/src/world/map_animation.c index b68a6a9e52..0ce1832451 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -22,6 +22,7 @@ #include "../ride/ride.h" #include "../ride/ride_data.h" #include "../ride/track.h" +#include "../interface/viewport.h" #include "map_animation.h" #include "map.h" #include "scenery.h" @@ -150,7 +151,7 @@ static bool map_animation_invalidate_queue_banner(int x, int y, int baseZ) if (!(mapElement->properties.path.type & PATH_FLAG_QUEUE_BANNER)) continue; - int direction = ((mapElement->type >> 6) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) & 3; + int direction = ((mapElement->type >> 6) + get_current_rotation()) & 3; if (direction == MAP_ELEMENT_DIRECTION_NORTH || direction == MAP_ELEMENT_DIRECTION_EAST) { baseZ = mapElement->base_height * 8; map_invalidate_tile_zoom1(x, y, baseZ + 16, baseZ + 30); @@ -542,4 +543,4 @@ static const map_animation_invalidate_event_handler _animatedObjectEventHandlers map_animation_invalidate_large_scenery, map_animation_invalidate_wall_unknown, map_animation_invalidate_wall -}; \ No newline at end of file +}; diff --git a/src/world/money_effect.c b/src/world/money_effect.c index 132d6293a3..b33565531f 100644 --- a/src/world/money_effect.c +++ b/src/world/money_effect.c @@ -96,8 +96,8 @@ void money_effect_update(rct_money_effect *moneyEffect) return; moneyEffect->move_delay = 0; - int x = moneyEffect->x + _moneyEffectMoveOffset[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)].x; - int y = moneyEffect->y + _moneyEffectMoveOffset[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)].y; + int x = moneyEffect->x + _moneyEffectMoveOffset[get_current_rotation()].x; + int y = moneyEffect->y + _moneyEffectMoveOffset[get_current_rotation()].y; int z = moneyEffect->z; sprite_move(x, y, z, (rct_sprite*)moneyEffect); diff --git a/src/world/sprite.c b/src/world/sprite.c index 51098ca2b4..3be296848e 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -451,7 +451,7 @@ void sprite_move(sint16 x, sint16 y, sint16 z, rct_sprite* sprite){ return; } sint16 new_x = x, new_y = y, start_x = x; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)){ + switch (get_current_rotation()){ case 0: new_x = new_y - new_x; new_y = (new_y + start_x) / 2 - z;