Merge pull request #3498 from marijnvdwerf/paint-setup/wall

Paint walls/fences
This commit is contained in:
Ted John 2016-05-18 22:04:44 +01:00
commit 16dbed03b5
13 changed files with 393 additions and 18 deletions

View File

@ -760,6 +760,7 @@ enum {
STR_OFF = 1775,
STR_ON = 1776,
STR_RIDE_MUSIC = 1777,
STR_SCROLLING_SIGN_TEXT = 1778,
STR_UNIFORM_COLOUR_TIP = 1790,
STR_UNIFORM_COLOUR = 1791,

View File

@ -1116,7 +1116,7 @@ static void object_type_wall_paint(void *objectEntry, rct_drawpixelinfo *dpi, si
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2){
imageId = sceneryEntry->image + 0x44500006;
gfx_draw_sprite(&clipDPI, imageId, x, y, 0);
} else if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5){
} else if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR){
imageId++;
gfx_draw_sprite(&clipDPI, imageId, x, y, 0);
}

View File

@ -53,7 +53,7 @@ void banner_paint(uint8 direction, int height, rct_map_element* map_element)
if (map_element->flags & MAP_ELEMENT_FLAG_GHOST)//if being placed
{
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_NONE;
image_id |= RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour];
image_id |= construction_markers[gConfigGeneral.construction_marker_colour];
}
else{
image_id |=

View File

@ -60,7 +60,7 @@ void ride_entrance_exit_paint(uint8 direction, int height, rct_map_element* map_
if (map_element->flags & MAP_ELEMENT_FLAG_GHOST){
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE;
image_id = RCT2_ADDRESS(0x993CC4, uint32_t)[gConfigGeneral.construction_marker_colour];
image_id = construction_markers[gConfigGeneral.construction_marker_colour];
RCT2_GLOBAL(0x009E32BC, uint32) = image_id;
if (transparant_image_id)
transparant_image_id = image_id;
@ -168,7 +168,7 @@ void park_entrance_paint(uint8 direction, int height, rct_map_element* map_eleme
uint32 image_id, ghost_id = 0;
if (map_element->flags & MAP_ELEMENT_FLAG_GHOST){
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE;
ghost_id = RCT2_ADDRESS(0x993CC4, uint32)[gConfigGeneral.construction_marker_colour];
ghost_id = construction_markers[gConfigGeneral.construction_marker_colour];
RCT2_GLOBAL(0x009E32BC, uint32) = ghost_id;
}

View File

@ -14,14 +14,374 @@
*****************************************************************************/
#pragma endregion
#include "map_element.h"
#include "../../common.h"
#include "../../addresses.h"
#include "../../world/map.h"
#include "../../drawing/drawing.h"
#include "../../world/scenery.h"
#include "../../game.h"
#include "../../ride/track.h"
#include "../../config.h"
#include "../../localisation/localisation.h"
#include "../../interface/colour.h"
#include "../../interface/viewport.h"
#include "../paint.h"
extern bool TempForScrollText;
const uint8 byte_9A406C[] = {
2, 2, 22, 26, 30, 34, 34, 34, 34, 34, 30, 26, 22, 2, 6, 2,
2, 2, 6, 10, 14, 18, 18, 18, 18, 18, 14, 10, 6, 2, 22, 2
};
void fence_paint(uint8 direction, int height, rct_map_element* mapElement) {
TempForScrollText = true;
RCT2_CALLPROC_X(0x6E44B0, 0, 0, direction, height, (int)mapElement, 0, 0);
TempForScrollText = false;
const uint8 byte_9A408C[] = {
0, 0, 4, 8, 12, 16, 16, 16, 16, 16, 12, 8, 4, 0, 20, 0,
0, 0, 20, 24, 28, 32, 32, 32, 32, 32, 28, 24, 20, 0, 4, 0
};
const uint8 byte_9A40AC[] = {
2, 2, 6, 10, 14, 18, 18, 18, 18, 18, 14, 10, 6, 2, 22, 2,
2, 2, 22, 26, 30, 34, 34, 34, 34, 34, 30, 26, 22, 2, 6, 2
};
const uint8 byte_9A40CC[] = {
0, 0, 20, 24, 28, 32, 32, 32, 32, 32, 28, 24, 20, 0, 4, 0,
0, 0, 4, 8, 12, 16, 16, 16, 16, 16, 12, 8, 4, 0, 20, 0
};
void fence_paint_door(uint32 imageId,
rct_scenery_entry * sceneryEntry,
uint32 imageColourFlags, uint32 tertiaryColour, uint32 dword_141F710,
rct_xyz8 offset,
rct_xyz16 boundsR1, rct_xyz16 boundsR1_,
rct_xyz16 boundsR2, rct_xyz16 boundsR2_,
rct_xyz16 boundsL1, rct_xyz16 boundsL1_)
{
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) {
imageId |= imageColourFlags;
}
if (dword_141F710 != 0) {
imageId = (imageId & 0x7FFFF) | dword_141F710;
}
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) {
paint_struct * ps;
ps = sub_98197C(imageId, offset.x, offset.y, boundsR1.x, boundsR1.y, (sint8) boundsR1.z, offset.z, boundsR1_.x, boundsR1_.y, boundsR1_.z, get_current_rotation());
if (ps != NULL) {
ps->tertiary_colour = tertiaryColour;
}
ps = sub_98197C(imageId + 1, offset.x, offset.y, boundsR2.x, boundsR2.y, (sint8) boundsR2.z, offset.z, boundsR2_.x, boundsR2_.y, boundsR2_.z, get_current_rotation());
if (ps != NULL) {
ps->tertiary_colour = tertiaryColour;
}
} else {
paint_struct * ps;
ps = sub_98197C(imageId, offset.x, offset.y, boundsL1.x, boundsL1.y, (sint8) boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation());
if (ps != NULL) {
ps->tertiary_colour = tertiaryColour;
}
ps = sub_98199C(imageId + 1, offset.x, offset.y, boundsL1.x, boundsL1.y, (sint8) boundsL1.z, offset.z, boundsL1_.x, boundsL1_.y, boundsL1_.z, get_current_rotation());
if (ps != NULL) {
ps->tertiary_colour = tertiaryColour;
}
}
}
void fence_paint_wall(uint32 frameNum, const rct_scenery_entry * sceneryEntry, uint32 dword_141F710, uint32 imageColourFlags, uint32 dword_141F718, uint32 tertiaryColour, uint32 imageOffset, rct_xyz16 offset, rct_xyz16 bounds, rct_xyz16 boundsOffset)
{
uint32 baseImageId = sceneryEntry->image + imageOffset + frameNum;
uint32 imageId = baseImageId;
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) {
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) {
imageId |= imageColourFlags;
}
if (dword_141F710 != 0) {
imageId = (imageId & 0x7FFFF) | dword_141F710;
}
sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation());
if (dword_141F710 == 0) {
imageId = baseImageId + dword_141F718;
sub_98199C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation());
}
} else {
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG1) {
imageId |= imageColourFlags;
}
if (dword_141F710 != 0) {
imageId = (imageId & 0x7FFFF) | dword_141F710;
}
paint_struct * paint = sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation());
if (paint != NULL) {
paint->tertiary_colour = tertiaryColour;
}
}
}
/**
* rct2: 0x006E44B0
* @param direction (cl)
* @param height (dx)
* @param map_element (esi)
*/
void fence_paint(uint8 direction, int height, rct_map_element * map_element)
{
rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *);
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_WALL;
rct_scenery_entry * sceneryEntry = gWallSceneryEntries[map_element->properties.fence.type];
uint32 frameNum = 0;
if (sceneryEntry->wall.flags2 & WALL_SCENERY_2_FLAG_5) {
frameNum = (gCurrentTicks & 7) * 2;
}
int primaryColour = map_element->properties.fence.item[1] & 0x1F;
uint32 imageColourFlags = primaryColour << 19 | 0x20000000;
uint32 dword_141F718 = imageColourFlags + 0x23800006;
if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) {
uint8 secondaryColour = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags & 0x60) >> 2);
imageColourFlags |= secondaryColour << 24 | 0x80000000;
}
uint32 tertiaryColour = 0;
if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) {
tertiaryColour = map_element->properties.fence.item[0];
imageColourFlags &= 0x0DFFFFFFF;
}
int clearanceHeight = ceil2(map_element->clearance_height * 8 + 15, 16);
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height;
RCT2_GLOBAL(0x141E9DA, uint8) = 0x20;
}
uint32 dword_141F710 = 0;
if (RCT2_GLOBAL(0x9DEA6F, uint8) & 1) {
if (!track_design_save_contains_map_element(map_element)) {
dword_141F710 = 0x21700000;
}
}
if (map_element->flags & MAP_ELEMENT_FLAG_GHOST) {
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_NONE;
dword_141F710 = construction_markers[gConfigGeneral.construction_marker_colour];
}
// save map_element
uint8 ah = sceneryEntry->wall.height * 8 - 2;
if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR) {
rct_xyz8 offset;
rct_xyz16 boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_;
uint8 animationFrame = (map_element->properties.fence.item[2] >> 3) & 0x1F;
uint32 imageId;
switch (direction) {
case 0:
imageId = sceneryEntry->image + byte_9A406C[animationFrame];
boundsR1 = (rct_xyz16) {1, 3, ah - 5};
boundsR1_ = (rct_xyz16) {1, 1, height + 1};
boundsR2 = (rct_xyz16) {1, 28, 3};
boundsR2_ = (rct_xyz16) {1, 1, height + ah - 9};
boundsL1 = (rct_xyz16) {1, 28, ah};
boundsL1_ = (rct_xyz16) {1, 1, height + 1};
offset = (rct_xyz8) {0, 0, height};
fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_);
break;
case 1:
imageId = sceneryEntry->image + byte_9A408C[animationFrame];
boundsR1 = (rct_xyz16) {3, 3, ah - 5};
boundsR1_ = (rct_xyz16) {1, 30, height + 1};
boundsR2 = (rct_xyz16) {29, 3, 2};
boundsR2_ = (rct_xyz16) {1, 30, height + ah - 8};
boundsL1 = (rct_xyz16) {29, 1, ah};
boundsL1_ = (rct_xyz16) {2, 30, height + 1};
offset = (rct_xyz8) {1, 31, height};
fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_);
break;
case 2:
imageId = sceneryEntry->image + byte_9A40AC[animationFrame];
boundsR1 = (rct_xyz16) {3, 3, ah - 5};
boundsR1_ = (rct_xyz16) {30, 1, height + 1};
boundsR2 = (rct_xyz16) {3, 29, 2};
boundsR2_ = (rct_xyz16) {30, 1, height + ah - 8};
boundsL1 = (rct_xyz16) {1, 29, ah};
boundsL1_ = (rct_xyz16) {30, 2, height + 1};
offset = (rct_xyz8) {31, 0, height};
fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_);
break;
case 3:
imageId = sceneryEntry->image + byte_9A40CC[animationFrame];
boundsR1 = (rct_xyz16) {3, 1, ah - 5};
boundsR1_ = (rct_xyz16) {1, 1, height + 1};
boundsR2 = (rct_xyz16) {28, 1, 3};
boundsR2_ = (rct_xyz16) {1, 1, height + ah - 9};
boundsL1 = (rct_xyz16) {28, 1, ah};
boundsL1_ = (rct_xyz16) {1, 1, height + 1};
offset = (rct_xyz8) {2, 1, height};
fence_paint_door(imageId, sceneryEntry, imageColourFlags, tertiaryColour, dword_141F710, offset, boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_);
break;
}
return;
}
uint32 imageOffset;
rct_xyz16 offset, bounds, boundsOffset;
switch (direction) {
case 0:
if (map_element->type & 0x80) {
imageOffset = 3;
} else if (map_element->type & 0x40) {
imageOffset = 5;
} else {
imageOffset = 1;
}
offset = (rct_xyz16){0, 0, height};
bounds = (rct_xyz16){1, 28, ah};
boundsOffset = (rct_xyz16){1, 1, height + 1};
break;
case 1:
if (map_element->type & 0x80) {
imageOffset = 2;
} else if (map_element->type & 0x40) {
imageOffset = 4;
} else {
imageOffset = 0;
}
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) {
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) {
imageOffset += 12;
}
} else {
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) {
imageOffset += 6;
}
}
offset = (rct_xyz16){1, 31, height};
bounds = (rct_xyz16){29, 1, ah};
boundsOffset = (rct_xyz16){2, 30, height + 1};
break;
case 2:
if (map_element->type & 0x80) {
imageOffset = 5;
} else if (map_element->type & 0x40) {
imageOffset = 3;
} else {
imageOffset = 1;
}
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG4) {
imageOffset += 6;
}
offset = (rct_xyz16){31, 0, height};
bounds = (rct_xyz16){1, 29, ah};
boundsOffset = (rct_xyz16){30, 2, height + 1};
break;
case 3:
if (map_element->type & 0x80) {
imageOffset = 4;
} else if (map_element->type & 0x40) {
imageOffset = 2;
} else {
imageOffset = 0;
}
offset = (rct_xyz16){2, 1, height};
bounds = (rct_xyz16){28, 1, ah};
boundsOffset = (rct_xyz16){1, 1, height + 1};
break;
}
fence_paint_wall(frameNum, sceneryEntry, dword_141F710, imageColourFlags, dword_141F718, tertiaryColour, imageOffset, offset, bounds, boundsOffset);
if (sceneryEntry->wall.var_0D == 0xFF) {
return;
}
if (direction != 0 && direction != 3) {
return;
}
set_format_arg(0, uint32, 0);
set_format_arg(4, uint32, 0);
uint8 al_2 = map_element->properties.fence.item[1] >> 5 | (map_element->flags & 0x60) >> 2;
if (dword_141F710 != 0) {
al_2 = COLOUR_GREY;
}
if (direction == 0) {
al_2 |= 0x80;
}
set_format_arg(7, uint8, al_2);
uint16 scrollingMode = sceneryEntry->wall.var_0D + ((direction + 1) & 0x3);
uint8 bannerIndex = map_element->properties.fence.item[0];
rct_banner * banner = &gBanners[bannerIndex];
set_format_arg(0, rct_string_id, banner->string_idx);
if (banner->flags & BANNER_FLAG_2) {
rct_ride * ride = get_ride(banner->colour);
set_format_arg(0, rct_string_id, ride->name);
set_format_arg(2, uint32, ride->name_arguments);
}
utf8 signString[MAX_PATH];
rct_string_id stringId = STR_SCROLLING_SIGN_TEXT;
if (gConfigGeneral.upper_case_banners) {
format_string_to_upper(signString, stringId, gCommonFormatArgs);
} else {
format_string(signString, stringId, gCommonFormatArgs);
}
gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY;
uint16 string_width = gfx_get_string_width(signString);
uint16 scroll = (gCurrentTicks / 2) % string_width;
sub_98199C(scrolling_text_setup(stringId, scroll, scrollingMode), 0, 0, 1, 1, 13, height + 8, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation());
}

View File

@ -23,6 +23,11 @@
#include "sprite/sprite.h"
#include "../addresses.h"
const uint32 construction_markers[] = {
COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_USE_PALETTE << 28, // White
2 << 19 | 0b110000 << 19 | IMAGE_TYPE_MIX_BACKGROUND << 28, // Translucent
};
/**
*
* rct2: 0x0068615B

View File

@ -19,6 +19,8 @@
#include "../common.h"
#include "../world/map.h"
#include "../interface/colour.h"
#include "../drawing/drawing.h"
typedef struct attached_paint_struct attached_paint_struct;
@ -43,9 +45,9 @@ typedef struct paint_struct paint_struct;
struct paint_struct {
uint32 image_id; // 0x00
union {
uint32 tertiary_colour;
uint32 tertiary_colour; // 0x04
// If masked image_id is masked_id
uint32 colour_image_id;
uint32 colour_image_id; // 0x04
};
uint16 bound_box_x; // 0x08
uint16 bound_box_y; // 0x0A
@ -85,6 +87,9 @@ enum PAINT_STRUCT_FLAGS {
PAINT_STRUCT_FLAG_IS_MASKED = (1 << 0)
};
/** rct2: 0x00993CC4 */
extern const uint32 construction_markers[];
void painter_setup();
paint_struct * sub_98196C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, sint16 z_offset, uint32 rotation);

View File

@ -209,6 +209,7 @@ void track_design_draw_preview(rct_track_td6 *td6, uint8 *pixels);
///////////////////////////////////////////////////////////////////////////////
void track_design_save_init();
void track_design_save_reset_scenery();
bool track_design_save_contains_map_element(rct_map_element *mapElement);
void track_design_save_select_nearby_scenery(int rideIndex);
void track_design_save_toggle_map_element(int interactionType, int x, int y, rct_map_element *mapElement);
bool track_design_save(uint8 rideIndex);

View File

@ -44,7 +44,6 @@ static uint8 _trackSaveDirection;
static bool track_design_save_should_select_scenery_around(int rideIndex, rct_map_element *mapElement);
static void track_design_save_select_nearby_scenery_for_tile(int rideIndex, int cx, int cy);
static bool track_design_save_contains_map_element(rct_map_element *mapElement);
static bool track_design_save_add_map_element(int interactionType, int x, int y, rct_map_element *mapElement);
static void track_design_save_remove_map_element(int interactionType, int x, int y, rct_map_element *mapElement);
static bool track_design_save_copy_scenery_to_td6(rct_track_td6 *td6);
@ -210,7 +209,7 @@ bool track_design_save(uint8 rideIndex)
return true;
}
static bool track_design_save_contains_map_element(rct_map_element *mapElement)
bool track_design_save_contains_map_element(rct_map_element *mapElement)
{
for (size_t i = 0; i < _trackSavedMapElementsCount; i++) {
if (_trackSavedMapElements[i] == mapElement) {

View File

@ -238,7 +238,7 @@ void track_paint(uint8 direction, int height, rct_map_element *mapElement)
RCT2_GLOBAL(0x00F441A4, uint32) = 0x21600000;
}
if (mapElement->flags & MAP_ELEMENT_FLAG_GHOST) {
uint32 ghost_id = RCT2_ADDRESS(0x00993CC4, uint32)[gConfigGeneral.construction_marker_colour];
uint32 ghost_id = construction_markers[gConfigGeneral.construction_marker_colour];
RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = 0;
RCT2_GLOBAL(0x00F44198, uint32) = ghost_id;
RCT2_GLOBAL(0x00F4419C, uint32) = ghost_id;

View File

@ -1169,7 +1169,7 @@ void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrol
gfx_draw_sprite(&clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32,
tertiaryColour);
if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5){
if (sceneryEntry->wall.flags & WALL_SCENERY_IS_DOOR){
gfx_draw_sprite(&clipdpi, imageId + 1, 0x2F, (sceneryEntry->wall.height * 2) + 0x32,
tertiaryColour);
}

View File

@ -3130,7 +3130,7 @@ static bool map_place_fence_check_obstruction_with_track(rct_scenery_entry *wall
}
}
if (!(wall->wall.flags & WALL_SCENERY_FLAG5)) {
if (!(wall->wall.flags & WALL_SCENERY_IS_DOOR)) {
return false;
}

View File

@ -97,12 +97,16 @@ typedef enum {
WALL_SCENERY_FLAG2 = (1 << 1), // 0x2
WALL_SCENERY_FLAG3 = (1 << 2), // 0x4
WALL_SCENERY_FLAG4 = (1 << 3), // 0x8 // Probably indicates translucency
WALL_SCENERY_FLAG5 = (1 << 4), // 0x10
WALL_SCENERY_IS_DOOR = (1 << 4), // 0x10
WALL_SCENERY_FLAG6 = (1 << 5), // 0x20
WALL_SCENERY_HAS_SECONDARY_COLOUR = (1 << 6), // 0x40
WALL_SCENERY_HAS_TERNARY_COLOUR = (1 << 7), // 0x80
} WALL_SCENERY_FLAGS;
typedef enum {
WALL_SCENERY_2_FLAG_5 = (1 << 4), // 0x10
} WALL_SCENERY_2_FLAGS;
typedef struct rct_path_bit_scenery_entry {
uint16 var_06;
uint8 pad_08;