mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Remove direct access to small scenery's colour_1 and _2 fields
This commit is contained in:
committed by
Michael Steenbeek
parent
db438a27b7
commit
2b540b9da1
@@ -117,10 +117,16 @@ void scenery_paint(uint8 direction, sint32 height, rct_map_element* mapElement)
|
||||
baseImageid += 4;
|
||||
}
|
||||
}
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR) {
|
||||
baseImageid |= ((mapElement->properties.scenery.colour_1 & 0x1F) << 19) | IMAGE_TYPE_REMAP;
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR) {
|
||||
baseImageid |= ((mapElement->properties.scenery.colour_2 & 0x1F) << 24) | IMAGE_TYPE_REMAP_2_PLUS;
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)
|
||||
{
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)
|
||||
{
|
||||
baseImageid |= SPRITE_ID_PALETTE_COLOUR_3(scenery_small_get_primary_colour(mapElement),
|
||||
scenery_small_get_secondary_colour(mapElement));
|
||||
}
|
||||
else
|
||||
{
|
||||
baseImageid |= SPRITE_ID_PALETTE_COLOUR_1(scenery_small_get_primary_colour(mapElement));
|
||||
}
|
||||
}
|
||||
if (dword_F64EB0 != 0) {
|
||||
@@ -134,7 +140,7 @@ void scenery_paint(uint8 direction, sint32 height, rct_map_element* mapElement)
|
||||
if (dword_F64EB0 == 0) {
|
||||
// Draw translucent overlay:
|
||||
// TODO: Name palette entries
|
||||
sint32 image_id = (baseImageid & 0x7FFFF) + (GlassPaletteIds[(mapElement->properties.scenery.colour_1 & 0x1F)] << 19) + 0x40000004;
|
||||
sint32 image_id = (baseImageid & 0x7FFFF) + (GlassPaletteIds[scenery_small_get_primary_colour(mapElement)] << 19) + 0x40000004;
|
||||
sub_98199C(image_id, x_offset, y_offset, boxlength.x, boxlength.y, boxlength.z - 1, height, boxoffset.x, boxoffset.y, boxoffset.z, rotation);
|
||||
}
|
||||
}
|
||||
@@ -235,10 +241,15 @@ void scenery_paint(uint8 direction, sint32 height, rct_map_element* mapElement)
|
||||
if (entry->small_scenery.flags & (SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED | SMALL_SCENERY_FLAG17)) {
|
||||
image_id += 4;
|
||||
}
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR) {
|
||||
image_id |= ((mapElement->properties.scenery.colour_1 & 0x1F) << 19) | IMAGE_TYPE_REMAP;
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)
|
||||
{
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR) {
|
||||
image_id |= ((mapElement->properties.scenery.colour_2 & 0x1F) << 24) | IMAGE_TYPE_REMAP_2_PLUS;
|
||||
image_id |= SPRITE_ID_PALETTE_COLOUR_3(scenery_small_get_primary_colour(mapElement),
|
||||
scenery_small_get_secondary_colour(mapElement));
|
||||
}
|
||||
else
|
||||
{
|
||||
image_id |= SPRITE_ID_PALETTE_COLOUR_1(scenery_small_get_primary_colour(mapElement));
|
||||
}
|
||||
}
|
||||
if (dword_F64EB0 != 0) {
|
||||
@@ -254,7 +265,7 @@ void scenery_paint(uint8 direction, sint32 height, rct_map_element* mapElement)
|
||||
}
|
||||
}
|
||||
// 6E0556: Draw supports:
|
||||
if (mapElement->properties.scenery.colour_1 & 0x20) {
|
||||
if (scenery_small_get_supports_needed(mapElement)) {
|
||||
if (!(entry->small_scenery.flags & SMALL_SCENERY_FLAG_NO_SUPPORTS)) {
|
||||
sint32 ax = 0;
|
||||
sint32 supportHeight = height;
|
||||
@@ -263,8 +274,9 @@ void scenery_paint(uint8 direction, sint32 height, rct_map_element* mapElement)
|
||||
ax = 49;
|
||||
}
|
||||
uint32 supportImageColourFlags = IMAGE_TYPE_REMAP;
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_PAINT_SUPPORTS) {
|
||||
supportImageColourFlags = ((mapElement->properties.scenery.colour_1 & 0x1F) << 19) | IMAGE_TYPE_REMAP;
|
||||
if (entry->small_scenery.flags & SMALL_SCENERY_FLAG_PAINT_SUPPORTS)
|
||||
{
|
||||
supportImageColourFlags = SPRITE_ID_PALETTE_COLOUR_1(scenery_small_get_primary_colour(mapElement));
|
||||
}
|
||||
if (dword_F64EB0 != 0) {
|
||||
supportImageColourFlags = dword_F64EB0;
|
||||
|
||||
@@ -2198,9 +2198,8 @@ private:
|
||||
{
|
||||
switch (map_element_get_type(mapElement)) {
|
||||
case MAP_ELEMENT_TYPE_SCENERY:
|
||||
colour = RCT1::GetColour(mapElement->properties.scenery.colour_1 & 0x1F);
|
||||
mapElement->properties.scenery.colour_1 &= 0xE0;
|
||||
mapElement->properties.scenery.colour_1 |= colour;
|
||||
colour = RCT1::GetColour(scenery_small_get_primary_colour(mapElement));
|
||||
scenery_small_set_primary_colour(mapElement, colour);
|
||||
|
||||
// Copied from [rct2: 0x006A2956]
|
||||
switch (mapElement->properties.scenery.type) {
|
||||
@@ -2209,7 +2208,7 @@ private:
|
||||
case 168: // TGE3 (Geometric Sculpture)
|
||||
case 170: // TGE4 (Geometric Sculpture)
|
||||
case 171: // TGE5 (Geometric Sculpture)
|
||||
mapElement->properties.scenery.colour_2 = COLOUR_WHITE;
|
||||
scenery_small_set_secondary_colour(mapElement, COLOUR_WHITE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -286,8 +286,8 @@ static void track_design_save_add_scenery(sint32 x, sint32 y, rct_map_element *m
|
||||
flags |= mapElement->type & 3;
|
||||
flags |= (mapElement->type & 0xC0) >> 4;
|
||||
|
||||
uint8 primaryColour = mapElement->properties.scenery.colour_1 & 0x1F;
|
||||
uint8 secondaryColour = mapElement->properties.scenery.colour_2 & 0x1F;
|
||||
uint8 primaryColour = scenery_small_get_primary_colour(mapElement);
|
||||
uint8 secondaryColour = scenery_small_get_secondary_colour(mapElement);
|
||||
|
||||
track_design_save_push_map_element(x, y, mapElement);
|
||||
track_design_save_push_map_element_desc(entry, x, y, mapElement->base_height, flags, primaryColour, secondaryColour);
|
||||
@@ -469,8 +469,8 @@ static void track_design_save_remove_scenery(sint32 x, sint32 y, rct_map_element
|
||||
flags |= mapElement->type & 3;
|
||||
flags |= (mapElement->type & 0xC0) >> 4;
|
||||
|
||||
uint8 primaryColour = mapElement->properties.scenery.colour_1 & 0x1F;
|
||||
uint8 secondaryColour = mapElement->properties.scenery.colour_2 & 0x1F;
|
||||
uint8 primaryColour = scenery_small_get_primary_colour(mapElement);
|
||||
uint8 secondaryColour = scenery_small_get_secondary_colour(mapElement);
|
||||
|
||||
track_design_save_pop_map_element(x, y, mapElement);
|
||||
track_design_save_pop_map_element_desc(entry, x, y, mapElement->base_height, flags, primaryColour, secondaryColour);
|
||||
|
||||
@@ -1045,8 +1045,8 @@ static void scenery_eyedropper_tool_down(sint16 x, sint16 y, rct_widgetindex wid
|
||||
sint32 sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_SMALL_SCENERY, entryIndex);
|
||||
if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) {
|
||||
gWindowSceneryRotation = map_element_get_direction_with_offset(mapElement, get_current_rotation());
|
||||
gWindowSceneryPrimaryColour = mapElement->properties.scenery.colour_1 & 0x1F;
|
||||
gWindowScenerySecondaryColour = mapElement->properties.scenery.colour_2 & 0x1F;
|
||||
gWindowSceneryPrimaryColour = scenery_small_get_primary_colour(mapElement);
|
||||
gWindowScenerySecondaryColour = scenery_small_get_secondary_colour(mapElement);
|
||||
gWindowSceneryEyedropperEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,10 +149,9 @@ static money32 SmallScenerySetColour(sint16 x, sint16 y, sint8 baseHeight, uint8
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
mapElement->properties.scenery.colour_1 &= 0xE0;
|
||||
mapElement->properties.scenery.colour_1 |= primaryColour;
|
||||
mapElement->properties.scenery.colour_2 &= 0xE0;
|
||||
mapElement->properties.scenery.colour_2 |= secondaryColour;
|
||||
scenery_small_set_primary_colour(mapElement, primaryColour);
|
||||
scenery_small_set_secondary_colour(mapElement, secondaryColour);
|
||||
|
||||
map_invalidate_tile_full(x, y);
|
||||
}
|
||||
|
||||
@@ -414,13 +413,13 @@ static money32 SmallSceneryPlace(sint16 x,
|
||||
newElement->type = type;
|
||||
newElement->properties.scenery.type = sceneryType;
|
||||
newElement->properties.scenery.age = 0;
|
||||
newElement->properties.scenery.colour_1 = primaryColour;
|
||||
newElement->properties.scenery.colour_2 = secondaryColour;
|
||||
scenery_small_set_primary_colour(newElement, primaryColour);
|
||||
scenery_small_set_secondary_colour(newElement, secondaryColour);
|
||||
newElement->clearance_height = newElement->base_height + ((sceneryEntry->small_scenery.height + 7) / 8);
|
||||
|
||||
if (supportsRequired)
|
||||
{
|
||||
newElement->properties.scenery.colour_1 |= 0x20;
|
||||
scenery_small_set_supports_needed(newElement);
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
|
||||
@@ -253,6 +253,11 @@ enum
|
||||
MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT = (1 << 7),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS = (1 << 5),
|
||||
};
|
||||
|
||||
#define MAP_ELEMENT_QUADRANT_MASK 0xC0
|
||||
#define MAP_ELEMENT_TYPE_MASK 0x3C
|
||||
#define MAP_ELEMENT_DIRECTION_MASK 0x03
|
||||
|
||||
@@ -257,7 +257,7 @@ static void mapgen_place_tree(sint32 type, sint32 x, sint32 y)
|
||||
mapElement->type = MAP_ELEMENT_TYPE_SCENERY | (util_rand() & 3);
|
||||
mapElement->properties.scenery.type = type;
|
||||
mapElement->properties.scenery.age = 0;
|
||||
mapElement->properties.scenery.colour_1 = COLOUR_YELLOW;
|
||||
scenery_small_set_primary_colour(mapElement, COLOUR_YELLOW);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -317,3 +317,38 @@ sint32 get_scenery_id_from_entry_index(uint8 objectType, sint32 entryIndex)
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
sint32 scenery_small_get_primary_colour(const rct_map_element *mapElement)
|
||||
{
|
||||
return (mapElement->properties.scenery.colour_1 & 0x1F);
|
||||
}
|
||||
|
||||
sint32 scenery_small_get_secondary_colour(const rct_map_element *mapElement)
|
||||
{
|
||||
return (mapElement->properties.scenery.colour_2 & 0x1F);
|
||||
}
|
||||
|
||||
void scenery_small_set_primary_colour(rct_map_element *mapElement, uint32 colour)
|
||||
{
|
||||
assert(colour <= 31);
|
||||
mapElement->properties.scenery.colour_1 &= ~0x1F;
|
||||
mapElement->properties.scenery.colour_1 |= colour;
|
||||
|
||||
}
|
||||
|
||||
void scenery_small_set_secondary_colour(rct_map_element *mapElement, uint32 colour)
|
||||
{
|
||||
assert(colour <= 31);
|
||||
mapElement->properties.scenery.colour_2 &= ~0x1F;
|
||||
mapElement->properties.scenery.colour_2 |= colour;
|
||||
}
|
||||
|
||||
bool scenery_small_get_supports_needed(const rct_map_element *mapElement)
|
||||
{
|
||||
return (bool)(mapElement->properties.scenery.colour_1 & MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS);
|
||||
}
|
||||
|
||||
void scenery_small_set_supports_needed(rct_map_element *mapElement)
|
||||
{
|
||||
mapElement->properties.scenery.colour_1 |= MAP_ELEM_SMALL_SCENERY_COLOUR_FLAG_NEEDS_SUPPORTS;
|
||||
}
|
||||
|
||||
@@ -295,4 +295,11 @@ rct_scenery_set_entry *get_scenery_group_entry(sint32 entryIndex);
|
||||
|
||||
sint32 get_scenery_id_from_entry_index(uint8 objectType, sint32 entryIndex);
|
||||
|
||||
sint32 scenery_small_get_primary_colour(const rct_map_element *mapElement);
|
||||
sint32 scenery_small_get_secondary_colour(const rct_map_element *mapElement);
|
||||
void scenery_small_set_primary_colour(rct_map_element *mapElement, uint32 colour);
|
||||
void scenery_small_set_secondary_colour(rct_map_element *mapElement, uint32 colour);
|
||||
bool scenery_small_get_supports_needed(const rct_map_element *mapElement);
|
||||
void scenery_small_set_supports_needed(rct_map_element *mapElement);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user