diff --git a/src/ride/ride.c b/src/ride/ride.c index 232a46dbfe..e21974c58f 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -883,7 +883,7 @@ static rct_window *ride_create_or_find_construction_window(int rideIndex) int ride_create_ride(ride_list_item listItem) { int eax, ebx, ecx, edx, esi, edi, ebp; - edx = *((uint16*)&listItem); + edx = listItem.ride_type_and_entry; eax = 0; ecx = 0; ebx = GAME_COMMAND_FLAG_APPLY; @@ -4355,7 +4355,7 @@ rct_vehicle *vehicle_create_car( vehicle->track_x = x; vehicle->track_y = y; vehicle->track_z = z; - vehicle->current_station = (mapElement->properties.track.sequence & 0x70) << 4; + vehicle->current_station = map_get_station(mapElement); z += RCT2_GLOBAL(0x0097D21A + (ride->type * 8), sint8); diff --git a/src/ride/ride.h b/src/ride/ride.h index 7fee5c3f31..2c817ec0b5 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -44,8 +44,13 @@ typedef struct { * Couples a ride type and subtype together. */ typedef struct { - uint8 type; - uint8 entry_index; + union { + struct { + uint8 type; + uint8 entry_index; + }; + uint16 ride_type_and_entry; + }; } ride_list_item; typedef struct { diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index 77f449b29d..14ff14767e 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -693,7 +693,7 @@ static void window_new_ride_scrollmousedown(rct_window *w, int scrollIndex, int return; RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, ride_list_item)[_window_new_ride_current_tab] = item; - w->new_ride.selected_ride_id = *((sint16*)&item); + w->new_ride.selected_ride_id = item.ride_type_and_entry; audio_play_sound_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); w->new_ride.selected_ride_countdown = 8; @@ -713,10 +713,10 @@ static void window_new_ride_scrollmouseover(rct_window *w, int scrollIndex, int item = window_new_ride_scroll_get_ride_list_item_at(w, x, y); - if (w->new_ride.highlighted_ride_id == *((sint16*)&item)) + if (w->new_ride.highlighted_ride_id == item.ride_type_and_entry) return; - w->new_ride.highlighted_ride_id = *((sint16*)&item); + w->new_ride.highlighted_ride_id = item.ride_type_and_entry; RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_RIDE_LIST_HIGHLIGHTED_ITEM, ride_list_item)[_window_new_ride_current_tab] = item; window_invalidate(w); } @@ -765,7 +765,7 @@ static void window_new_ride_paint(rct_window *w, rct_drawpixelinfo *dpi) window_new_ride_draw_tab_images(dpi, w); if (_window_new_ride_current_tab != WINDOW_NEW_RIDE_PAGE_RESEARCH) { - ride_list_item item = *((ride_list_item*)&w->new_ride.highlighted_ride_id); + ride_list_item item = { .ride_type_and_entry = w->new_ride.highlighted_ride_id }; if (item.type != 255 || item.entry_index != 255) window_new_ride_paint_ride_information(w, dpi, item, w->x + 3, w->y + w->height - 52, w->width - 6); } else { @@ -934,7 +934,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli */ static void window_new_ride_select(rct_window *w) { - ride_list_item item = *((ride_list_item*)&w->new_ride.selected_ride_id); + ride_list_item item = { .ride_type_and_entry = w->new_ride.selected_ride_id }; if (item.type == 255) return; diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 6349c391e5..f7c814f46d 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1151,7 +1151,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin // Also places it in lower but think thats for clobering *parameter_1 = (selected_scenery & 0xFF) << 8; - *parameter_2 = cl ^ (1 << 1) | (window_scenery_primary_colour << 8); + *parameter_2 = (cl ^ (1 << 1)) | (window_scenery_primary_colour << 8); *parameter_3 = rotation | (window_scenery_secondary_colour << 16); return; } diff --git a/src/world/map.c b/src/world/map.c index 1defd518f9..d62d770ca2 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -3943,7 +3943,7 @@ rct_map_element *map_element_insert(int x, int y, int z, int flags) newMapElement->base_height = z; newMapElement->flags = flags; newMapElement->clearance_height = z; - *((uint32*)&newMapElement->properties) = 0; + memset(&newMapElement->properties, 0, sizeof(newMapElement->properties)); newMapElement++; // Insert rest of map elements above insert height