Port remaining wall stuff to struct methods

This commit is contained in:
Michael Steenbeek committed 2018-09-17 15:42:34 +02:00
1 parent 508276b081
commit 6062960390
14 files changed
+108 -59

No files matched your search

@@ -306,7 +306,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
return info->type;
case VIEWPORT_INTERACTION_ITEM_WALL:
sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
sceneryEntry = tileElement->AsWall()->GetEntry();
if (sceneryEntry->wall.scrolling_mode != 255)
{
set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
@@ -383,7 +383,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
return info->type;
case VIEWPORT_INTERACTION_ITEM_WALL:
sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
sceneryEntry = tileElement->AsWall()->GetEntry();
set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
set_map_tooltip_format_arg(2, rct_string_id, sceneryEntry->name);
return info->type;
@@ -540,10 +540,10 @@ void viewport_interaction_remove_park_entrance(rct_tile_element* tileElement, in
*/
static void viewport_interaction_remove_park_wall(rct_tile_element* tileElement, int32_t x, int32_t y)
{
rct_scenery_entry* sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
rct_scenery_entry* sceneryEntry = tileElement->AsWall()->GetEntry();
if (sceneryEntry->wall.scrolling_mode != 0xFF)
{
context_open_detail_window(WD_SIGN_SMALL, tileElement->properties.wall.banner_index);
context_open_detail_window(WD_SIGN_SMALL, tileElement->AsWall()->GetBannerIndex());
}
else
{
+5 -5
View File
@@ -410,10 +410,10 @@ rct_window* window_sign_small_open(rct_windownumber number)
{
if (tile_element->GetType() == TILE_ELEMENT_TYPE_WALL)
{
rct_scenery_entry* scenery_entry = get_wall_entry(tile_element->properties.wall.type);
rct_scenery_entry* scenery_entry = tile_element->AsWall()->GetEntry();
if (scenery_entry->wall.scrolling_mode != 0xFF)
{
if (tile_element->properties.wall.banner_index == w->number)
if (tile_element->AsWall()->GetBannerIndex() == w->number)
break;
}
}
@@ -425,7 +425,7 @@ rct_window* window_sign_small_open(rct_windownumber number)
w->list_information_type = tile_element->AsWall()->GetPrimaryColour();
w->var_492 = tile_element->AsWall()->GetSecondaryColour();
w->var_48C = tile_element->properties.wall.type;
w->var_48C = tile_element->AsWall()->GetEntryIndex();
view_x += 16;
view_y += 16;
@@ -468,10 +468,10 @@ static void window_sign_small_mouseup(rct_window* w, rct_widgetindex widgetIndex
{
if (tile_element->GetType() == TILE_ELEMENT_TYPE_WALL)
{
rct_scenery_entry* scenery_entry = get_wall_entry(tile_element->properties.wall.type);
rct_scenery_entry* scenery_entry = tile_element->AsWall()->GetEntry();
if (scenery_entry->wall.scrolling_mode != 0xFF)
{
if (tile_element->properties.wall.banner_index == w->number)
if (tile_element->AsWall()->GetBannerIndex() == w->number)
break;
}
}
+4 -4
View File
@@ -1623,7 +1623,7 @@ static void window_tile_inspector_invalidate(rct_window* w)
w->widgets[WIDX_WALL_DROPDOWN_SLOPE].text = WallSlopeStringIds[tileElement->AsWall()->GetSlope()];
w->widgets[WIDX_WALL_DROPDOWN_SLOPE_BUTTON].top = GBBT(propertiesAnchor, 1) + 4;
w->widgets[WIDX_WALL_DROPDOWN_SLOPE_BUTTON].bottom = GBBB(propertiesAnchor, 1) - 4;
const uint8_t wallType = tileElement->properties.wall.type;
const uint8_t wallType = tileElement->AsWall()->GetEntryIndex();
const rct_wall_scenery_entry wallEntry = get_wall_entry(wallType)->wall;
const bool canBeSloped = !(wallEntry.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE);
// Wall slope dropdown
@@ -1978,7 +1978,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
// Details
// Type
int16_t wallType = tileElement->properties.wall.type;
int16_t wallType = tileElement->AsWall()->GetEntryIndex();
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_WALL_TYPE, &wallType, COLOUR_DARK_GREEN, x, y);
// Banner info
@@ -1987,7 +1987,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
gfx_draw_string_left(
dpi, STR_TILE_INSPECTOR_ENTRY_BANNER_TEXT,
&gBanners[tileElement->properties.wall.banner_index].string_idx, COLOUR_DARK_GREEN, x, y + 11);
&gBanners[tileElement->AsWall()->GetBannerIndex()].string_idx, COLOUR_DARK_GREEN, x, y + 11);
}
else
{
@@ -2158,7 +2158,7 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo*
case TILE_ELEMENT_TYPE_WALL:
snprintf(
buffer, sizeof(buffer), "%s (%s)", language_get_string(STR_TILE_INSPECTOR_WALL),
language_get_string(get_wall_entry(tileElement->properties.wall.type)->name));
language_get_string(tileElement->AsWall()->GetEntry()->name));
typeName = buffer;
break;
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
+2 -2
View File
@@ -1001,7 +1001,7 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
}
case VIEWPORT_INTERACTION_ITEM_WALL:
{
rct_scenery_entry* scenery_entry = get_wall_entry(tile_element->properties.wall.type);
rct_scenery_entry* scenery_entry = tile_element->AsWall()->GetEntry();
// If can't repaint
if (!(scenery_entry->wall.flags & (WALL_SCENERY_HAS_PRIMARY_COLOUR | WALL_SCENERY_HAS_GLASS)))
@@ -1080,7 +1080,7 @@ static void scenery_eyedropper_tool_down(int16_t x, int16_t y, rct_widgetindex w
}
case VIEWPORT_INTERACTION_ITEM_WALL:
{
int32_t entryIndex = tileElement->properties.wall.type;
int32_t entryIndex = tileElement->AsWall()->GetEntryIndex();
rct_scenery_entry* sceneryEntry = get_wall_entry(entryIndex);
if (sceneryEntry != nullptr)
{
@@ -161,7 +161,7 @@ void setup_in_use_selection_flags()
Editor::SetSelectedObject(OBJECT_TYPE_PATHS, type, OBJECT_SELECTION_FLAG_SELECTED);
break;
case TILE_ELEMENT_TYPE_WALL:
type = iter.element->properties.wall.type;
type = iter.element->AsWall()->GetEntryIndex();
assert(type < object_entry_group_counts[OBJECT_TYPE_WALLS]);
Editor::SetSelectedObject(OBJECT_TYPE_WALLS, type, OBJECT_SELECTION_FLAG_SELECTED);
break;
@@ -158,7 +158,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_WALL;
rct_scenery_entry* sceneryEntry = get_wall_entry(tile_element->properties.wall.type);
rct_scenery_entry* sceneryEntry = tile_element->AsWall()->GetEntry();
if (sceneryEntry == nullptr)
{
return;
@@ -214,7 +214,8 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
LocationXYZ16 boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_;
uint8_t animationFrame = tile_element->AsWall()->GetAnimationFrame();
// Add the direction as well
animationFrame |= (tile_element->properties.wall.animation & WALL_ANIMATION_FLAG_DIRECTION_BACKWARD) >> 3;
if (tile_element->AsWall()->AnimationIsBackwards())
animationFrame |= (1 << 4);
uint32_t imageId;
switch (direction)
{
@@ -429,7 +430,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
uint16_t scrollingMode = sceneryEntry->wall.scrolling_mode + ((direction + 1) & 0x3);
uint8_t bannerIndex = tile_element->properties.wall.banner_index;
uint8_t bannerIndex = tile_element->AsWall()->GetBannerIndex();
rct_banner* banner = &gBanners[bannerIndex];
set_format_arg(0, rct_string_id, banner->string_idx);
+6 -6
View File
@@ -6299,7 +6299,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid
continue;
if (tileElement->GetDirection() != edge)
continue;
auto wallEntry = get_wall_entry(tileElement->properties.wall.type);
auto wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
continue;
if (peep->next_z + 4 <= tileElement->base_height)
@@ -6333,7 +6333,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid
continue;
if (tileElement->GetDirectionWithOffset(2) != edge)
continue;
auto wallEntry = get_wall_entry(tileElement->properties.wall.type);
auto wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
continue;
// TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A.
@@ -6411,7 +6411,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid
if (tileElement->GetType() == TILE_ELEMENT_TYPE_WALL)
{
auto wallEntry = get_wall_entry(tileElement->properties.wall.type);
auto wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
{
continue;
@@ -6445,7 +6445,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid
continue;
if (tileElement->GetDirectionWithOffset(2) != edge)
continue;
auto wallEntry = get_wall_entry(tileElement->properties.wall.type);
auto wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
continue;
if (peep->next_z + 6 <= tileElement->base_height)
@@ -6522,7 +6522,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid
if (tileElement->GetType() == TILE_ELEMENT_TYPE_WALL)
{
auto wallEntry = get_wall_entry(tileElement->properties.wall.type);
auto wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
{
continue;
@@ -6556,7 +6556,7 @@ static bool peep_find_ride_to_look_at(rct_peep* peep, uint8_t edge, uint8_t* rid
continue;
if (tileElement->GetDirectionWithOffset(2) != edge)
continue;
auto wallEntry = get_wall_entry(tileElement->properties.wall.type);
auto wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
continue;
if (peep->next_z + 8 <= tileElement->base_height)
+2 -2
View File
@@ -354,7 +354,7 @@ static void track_design_save_add_large_scenery(int32_t x, int32_t y, rct_tile_e
static void track_design_save_add_wall(int32_t x, int32_t y, rct_tile_element* tileElement)
{
int32_t entryType = tileElement->properties.wall.type;
int32_t entryType = tileElement->AsWall()->GetEntryIndex();
auto entry = object_entry_get_entry(OBJECT_TYPE_WALLS, entryType);
uint8_t flags = 0;
@@ -542,7 +542,7 @@ static void track_design_save_remove_large_scenery(int32_t x, int32_t y, rct_til
static void track_design_save_remove_wall(int32_t x, int32_t y, rct_tile_element* tileElement)
{
int32_t entryType = tileElement->properties.wall.type;
int32_t entryType = tileElement->AsWall()->GetEntryIndex();
auto entry = object_entry_get_entry(OBJECT_TYPE_WALLS, entryType);
uint8_t flags = 0;
+7 -6
View File
@@ -7397,7 +7397,7 @@ static void vehicle_update_additional_animation(rct_vehicle* vehicle)
*/
static void vehicle_play_scenery_door_open_sound(rct_vehicle* vehicle, rct_tile_element* tileElement)
{
rct_scenery_entry* wallEntry = get_wall_entry(tileElement->properties.wall.type);
rct_scenery_entry* wallEntry = tileElement->AsWall()->GetEntry();
int32_t doorSoundType = wall_entry_get_door_sound(wallEntry);
if (doorSoundType != 0)
{
@@ -7415,7 +7415,7 @@ static void vehicle_play_scenery_door_open_sound(rct_vehicle* vehicle, rct_tile_
*/
static void vehicle_play_scenery_door_close_sound(rct_vehicle* vehicle, rct_tile_element* tileElement)
{
rct_scenery_entry* wallEntry = get_wall_entry(tileElement->properties.wall.type);
rct_scenery_entry* wallEntry = tileElement->AsWall()->GetEntry();
int32_t doorSoundType = wall_entry_get_door_sound(wallEntry);
if (doorSoundType != 0)
{
@@ -7453,14 +7453,15 @@ static void vehicle_update_scenery_door(rct_vehicle* vehicle)
if (vehicle->next_vehicle_on_train != SPRITE_INDEX_NULL)
{
tileElement->properties.wall.animation &= ~(WALL_ANIMATION_FLAG_DIRECTION_BACKWARD);
// FIXME: Likely an implementation typo, should probably be true!
tileElement->AsWall()->SetAnimationIsBackwards(false);
tileElement->AsWall()->SetAnimationFrame(1);
map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z);
vehicle_play_scenery_door_open_sound(vehicle, tileElement);
}
else
{
tileElement->properties.wall.animation &= ~(WALL_ANIMATION_FLAG_DIRECTION_BACKWARD);
tileElement->AsWall()->SetAnimationIsBackwards(false);
tileElement->AsWall()->SetAnimationFrame(6);
vehicle_play_scenery_door_close_sound(vehicle, tileElement);
}
@@ -7533,14 +7534,14 @@ static void vehicle_update_handle_scenery_door(rct_vehicle* vehicle)
if (vehicle->next_vehicle_on_train != SPRITE_INDEX_NULL)
{
tileElement->properties.wall.animation |= WALL_ANIMATION_FLAG_DIRECTION_BACKWARD;
tileElement->AsWall()->SetAnimationIsBackwards(true);
tileElement->AsWall()->SetAnimationFrame(1);
map_animation_create(MAP_ANIMATION_TYPE_WALL_DOOR, x, y, z);
vehicle_play_scenery_door_open_sound(vehicle, tileElement);
}
else
{
tileElement->properties.wall.animation &= ~(WALL_ANIMATION_FLAG_DIRECTION_BACKWARD);
tileElement->AsWall()->SetAnimationIsBackwards(false);
tileElement->AsWall()->SetAnimationFrame(6);
vehicle_play_scenery_door_close_sound(vehicle, tileElement);
}
+3 -3
View File
@@ -3442,7 +3442,7 @@ void map_obstruction_set_error_text(rct_tile_element* tileElement)
}
break;
case TILE_ELEMENT_TYPE_WALL:
sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
sceneryEntry = tileElement->AsWall()->GetEntry();
errorStringId = STR_X_IN_THE_WAY;
set_format_arg(0, rct_string_id, sceneryEntry->name);
break;
@@ -4388,10 +4388,10 @@ void game_command_set_sign_style(
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue;
rct_scenery_entry* scenery_entry = get_wall_entry(tileElement->properties.wall.type);
rct_scenery_entry* scenery_entry = tileElement->AsWall()->GetEntry();
if (scenery_entry->wall.scrolling_mode == 0xFF)
continue;
if (tileElement->properties.wall.banner_index != bannerId)
if (tileElement->AsWall()->GetBannerIndex() != bannerId)
continue;
wall_found = true;
break;
+2 -2
View File
@@ -492,7 +492,7 @@ static bool map_animation_invalidate_wall_door(int32_t x, int32_t y, int32_t bas
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue;
sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
sceneryEntry = tileElement->AsWall()->GetEntry();
if (!(sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR))
continue;
@@ -552,7 +552,7 @@ static bool map_animation_invalidate_wall(int32_t x, int32_t y, int32_t baseZ)
if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL)
continue;
sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
sceneryEntry = tileElement->AsWall()->GetEntry();
if (!(sceneryEntry->wall.flags2 & WALL_SCENERY_2_ANIMATED) && sceneryEntry->wall.scrolling_mode == 255)
continue;
+3 -3
View File
@@ -78,11 +78,11 @@ BannerIndex tile_element_get_banner_index(rct_tile_element* tileElement)
return tileElement->AsLargeScenery()->GetBannerIndex();
case TILE_ELEMENT_TYPE_WALL:
sceneryEntry = get_wall_entry(tileElement->properties.wall.type);
sceneryEntry = tileElement->AsWall()->GetEntry();
if (sceneryEntry == nullptr || sceneryEntry->wall.scrolling_mode == 0xFF)
return BANNER_INDEX_NULL;
return tileElement->properties.wall.banner_index;
return tileElement->AsWall()->GetBannerIndex();
case TILE_ELEMENT_TYPE_BANNER:
return tileElement->properties.banner.index;
default:
@@ -95,7 +95,7 @@ void tile_element_set_banner_index(rct_tile_element* tileElement, BannerIndex ba
switch (tileElement->GetType())
{
case TILE_ELEMENT_TYPE_WALL:
tileElement->properties.wall.banner_index = bannerIndex;
tileElement->AsWall()->SetBannerIndex(bannerIndex);
break;
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
tileElement->AsLargeScenery()->SetBannerIndex(bannerIndex);
+12 -14
View File
@@ -64,19 +64,6 @@ struct rct_tile_element_entrance_properties
};
assert_struct_size(rct_tile_element_entrance_properties, 4);
struct rct_tile_element_wall_properties
{
uint8_t type; // 4
union
{
uint8_t colour_3; // 5
BannerIndex banner_index; // 5
};
uint8_t colour_1; // 6 0b_2221_1111 2 = colour_2 (uses flags for rest of colour2), 1 = colour_1
uint8_t animation; // 7 0b_dfff_ft00 d = direction, f = frame num, t = across track flag (not used)
};
assert_struct_size(rct_tile_element_wall_properties, 4);
struct rct_tile_element_banner_properties
{
BannerIndex index; // 4
@@ -91,7 +78,6 @@ union rct_tile_element_properties
rct_tile_element_path_properties path;
rct_tile_element_track_properties track;
rct_tile_element_entrance_properties entrance;
rct_tile_element_wall_properties wall;
rct_tile_element_banner_properties banner;
};
assert_struct_size(rct_tile_element_properties, 4);
@@ -309,6 +295,10 @@ struct WallElement : TileElementBase
uint8_t animation; // 7 0b_dfff_ft00 d = direction, f = frame num, t = across track flag (not used)
public:
uint8_t GetEntryIndex() const;
void SetEntryIndex(uint8_t newIndex);
rct_scenery_entry* GetEntry() const;
uint8_t GetSlope() const;
void SetSlope(uint8_t newslope);
@@ -322,6 +312,14 @@ public:
uint8_t GetAnimationFrame() const;
void SetAnimationFrame(uint8_t frameNum);
BannerIndex GetBannerIndex() const;
void SetBannerIndex(BannerIndex newIndex);
bool IsAcrossTrack() const;
void SetAcrossTrack(bool acrossTrack);
bool AnimationIsBackwards() const;
void SetAnimationIsBackwards(bool isBackwards);
int32_t GetRCT1WallType(int32_t edge) const;
colour_t GetRCT1WallColour() const;
};
+53 -4
View File
@@ -522,13 +522,13 @@ static money32 WallPlace(
if (wallAcrossTrack)
{
tileElement->properties.wall.animation |= WALL_ANIMATION_FLAG_ACROSS_TRACK;
tileElement->AsWall()->SetAcrossTrack(true);
}
tileElement->properties.wall.type = wallType;
tileElement->AsWall()->SetEntryIndex(wallType);
if (bannerIndex != 0xFF)
{
tileElement->properties.wall.banner_index = bannerIndex;
tileElement->AsWall()->SetBannerIndex(bannerIndex);
}
if (wallEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR)
@@ -584,7 +584,7 @@ static money32 WallSetColour(
if (flags & GAME_COMMAND_FLAG_APPLY)
{
rct_scenery_entry* scenery_entry = get_wall_entry(wallElement->properties.wall.type);
rct_scenery_entry* scenery_entry = wallElement->AsWall()->GetEntry();
wallElement->AsWall()->SetPrimaryColour(primaryColour);
wallElement->AsWall()->SetSecondaryColour(secondaryColour);
@@ -761,4 +761,53 @@ void WallElement::SetAnimationFrame(uint8_t frameNum)
{
animation &= WALL_ANIMATION_FLAG_ALL_FLAGS;
animation |= (frameNum & 0xF) << 3;
}
uint8_t WallElement::GetEntryIndex() const
{
return entryIndex;
}
rct_scenery_entry* WallElement::GetEntry() const
{
return get_wall_entry(entryIndex);
}
void WallElement::SetEntryIndex(uint8_t newIndex)
{
entryIndex = newIndex;
}
BannerIndex WallElement::GetBannerIndex() const
{
return banner_index;
}
void WallElement::SetBannerIndex(BannerIndex newIndex)
{
banner_index = newIndex;
}
bool WallElement::IsAcrossTrack() const
{
return (animation & WALL_ANIMATION_FLAG_ACROSS_TRACK) != 0;
}
void WallElement::SetAcrossTrack(bool acrossTrack)
{
animation &= ~WALL_ANIMATION_FLAG_ACROSS_TRACK;
if (acrossTrack)
animation |= WALL_ANIMATION_FLAG_ACROSS_TRACK;
}
bool WallElement::AnimationIsBackwards() const
{
return (animation & WALL_ANIMATION_FLAG_DIRECTION_BACKWARD) != 0;
}
void WallElement::SetAnimationIsBackwards(bool isBackwards)
{
animation &= ~WALL_ANIMATION_FLAG_DIRECTION_BACKWARD;
if (isBackwards)
animation |= WALL_ANIMATION_FLAG_DIRECTION_BACKWARD;
}