mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 21:43:06 +01:00
Deciphered flags and z param of get_map_coordinates_from_pos
This commit is contained in:
@@ -70,9 +70,9 @@ struct paint_struct{
|
||||
uint8 sprite_type; //0x28
|
||||
uint8 var_29;
|
||||
uint16 pad_2A;
|
||||
uint16 map_x;
|
||||
uint16 map_y;
|
||||
rct_map_element *mapElement;
|
||||
uint16 map_x; // 0x2C
|
||||
uint16 map_y; // 0x2E
|
||||
rct_map_element *mapElement; // 0x30
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1609,10 +1609,10 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, int left, in
|
||||
* viewport: edi
|
||||
*/
|
||||
void sub_688972(int screenX, int screenY, sint16 *x, sint16 *y, rct_viewport **viewport) {
|
||||
int my_x, my_y, z;
|
||||
int my_x, my_y, z, interactionType;
|
||||
rct_viewport *myViewport;
|
||||
get_map_coordinates_from_pos(screenX, screenY, 0xFFFE, &my_x, &my_y, &z, NULL, &myViewport);
|
||||
if (z == 0) {
|
||||
get_map_coordinates_from_pos(screenX, screenY, VIEWPORT_INTERACTION_MASK_TERRAIN, &my_x, &my_y, &interactionType, NULL, &myViewport);
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) {
|
||||
*x = 0x8000;
|
||||
return;
|
||||
}
|
||||
@@ -1877,10 +1877,13 @@ void sub_688697(paint_struct *ps)
|
||||
{
|
||||
if (RCT2_GLOBAL(0x0141F569, uint8) == 0) return;
|
||||
|
||||
if (ps->sprite_type == 0 || ps->sprite_type == 11 || ps->sprite_type > 12) return;
|
||||
if (ps->sprite_type == VIEWPORT_INTERACTION_ITEM_NONE
|
||||
|| ps->sprite_type == 11 // 11 as a type seems to not exist, maybe part of the typo mentioned later on.
|
||||
|| ps->sprite_type > VIEWPORT_INTERACTION_ITEM_BANNER) return;
|
||||
|
||||
uint16 mask;
|
||||
if (ps->sprite_type == 12)
|
||||
if (ps->sprite_type == VIEWPORT_INTERACTION_ITEM_BANNER)
|
||||
// I think CS made a typo here. Let's replicate the original behaviour.
|
||||
mask = 1 << 9;
|
||||
else
|
||||
mask = 1 << (ps->sprite_type - 1);
|
||||
@@ -1951,7 +1954,7 @@ void sub_68862C()
|
||||
* mapElement: edx
|
||||
* viewport: edi
|
||||
*/
|
||||
void get_map_coordinates_from_pos(int screenX, int screenY, int flags, int *x, int *y, int *z, rct_map_element **mapElement, rct_viewport **viewport)
|
||||
void get_map_coordinates_from_pos(int screenX, int screenY, int flags, int *x, int *y, int *interactionType, rct_map_element **mapElement, rct_viewport **viewport)
|
||||
{
|
||||
RCT2_GLOBAL(0x9AC154, uint16_t) = flags & 0xFFFF;
|
||||
RCT2_GLOBAL(0x9AC148, uint8_t) = 0;
|
||||
@@ -1989,7 +1992,7 @@ void get_map_coordinates_from_pos(int screenX, int screenY, int flags, int *x, i
|
||||
}
|
||||
if (viewport != NULL) *viewport = myviewport;
|
||||
}
|
||||
if (z != NULL) *z = RCT2_GLOBAL(0x9AC148, uint8_t);
|
||||
if (interactionType != NULL) *interactionType = RCT2_GLOBAL(0x9AC148, uint8_t);
|
||||
if (x != NULL) *x = (int)RCT2_GLOBAL(0x9AC14C, int16_t);
|
||||
if (y != NULL) *y = (int)RCT2_GLOBAL(0x9AC14E, int16_t);
|
||||
if (mapElement != NULL) *mapElement = RCT2_GLOBAL(0x9AC150, rct_map_element*);
|
||||
|
||||
@@ -46,10 +46,11 @@ enum {
|
||||
|
||||
enum {
|
||||
VIEWPORT_INTERACTION_ITEM_NONE,
|
||||
|
||||
VIEWPORT_INTERACTION_ITEM_SPRITE = 2,
|
||||
VIEWPORT_INTERACTION_ITEM_TERRAIN,
|
||||
VIEWPORT_INTERACTION_ITEM_SPRITE,
|
||||
VIEWPORT_INTERACTION_ITEM_RIDE,
|
||||
VIEWPORT_INTERACTION_ITEM_SCENERY = 5,
|
||||
VIEWPORT_INTERACTION_ITEM_WATER,
|
||||
VIEWPORT_INTERACTION_ITEM_SCENERY,
|
||||
VIEWPORT_INTERACTION_ITEM_FOOTPATH,
|
||||
VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM,
|
||||
VIEWPORT_INTERACTION_ITEM_PARK,
|
||||
@@ -59,6 +60,21 @@ enum {
|
||||
|
||||
};
|
||||
|
||||
enum {
|
||||
VIEWPORT_INTERACTION_MASK_NONE = 0,
|
||||
VIEWPORT_INTERACTION_MASK_TERRAIN = ~(1 << (VIEWPORT_INTERACTION_ITEM_TERRAIN - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_SPRITE = ~(1 << (VIEWPORT_INTERACTION_ITEM_SPRITE - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_RIDE = ~(1 << (VIEWPORT_INTERACTION_ITEM_RIDE - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_WATER = ~(1 << (VIEWPORT_INTERACTION_ITEM_WATER - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_SCENERY = ~(1 << (VIEWPORT_INTERACTION_ITEM_SCENERY - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_FOOTPATH = ~(1 << (VIEWPORT_INTERACTION_ITEM_FOOTPATH - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM = ~(1 << (VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_PARK = ~(1 << (VIEWPORT_INTERACTION_ITEM_PARK - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_WALL = ~(1 << (VIEWPORT_INTERACTION_ITEM_WALL - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_LARGE_SCENERY = ~(1 << (VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY - 1)),
|
||||
VIEWPORT_INTERACTION_MASK_BANNER = ~(1 << (VIEWPORT_INTERACTION_ITEM_BANNER - 1)),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
int x;
|
||||
@@ -97,7 +113,7 @@ void show_construction_rights();
|
||||
void hide_construction_rights();
|
||||
void viewport_set_visibility(uint8 mode);
|
||||
|
||||
void get_map_coordinates_from_pos(int screenX, int screenY, int flags, int *x, int *y, int *z, rct_map_element **mapElement, rct_viewport **viewport);
|
||||
void get_map_coordinates_from_pos(int screenX, int screenY, int flags, int *x, int *y, int *interactionType, rct_map_element **mapElement, rct_viewport **viewport);
|
||||
|
||||
int viewport_interaction_get_item_left(int x, int y, viewport_interaction_info *info);
|
||||
int viewport_interaction_left_over(int x, int y);
|
||||
|
||||
@@ -58,7 +58,7 @@ int viewport_interaction_get_item_left(int x, int y, viewport_interaction_info *
|
||||
if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) && s6Info->var_000 != 6)
|
||||
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
||||
|
||||
get_map_coordinates_from_pos(x, y, 0xFF79, &info->x, &info->y, &info->type, &info->mapElement, NULL);
|
||||
get_map_coordinates_from_pos(x, y, VIEWPORT_INTERACTION_MASK_SPRITE & VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_PARK, &info->x, &info->y, &info->type, &info->mapElement, NULL);
|
||||
mapElement = info->mapElement;
|
||||
sprite = (rct_sprite*)mapElement;
|
||||
|
||||
@@ -178,7 +178,7 @@ int viewport_interaction_get_item_right(int x, int y, viewport_interaction_info
|
||||
if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) && s6Info->var_000 != 6)
|
||||
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
|
||||
|
||||
get_map_coordinates_from_pos(x, y, 9, &info->x, &info->y, &info->type, &info->mapElement, NULL);
|
||||
get_map_coordinates_from_pos(x, y, ~(VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER), &info->x, &info->y, &info->type, &info->mapElement, NULL);
|
||||
mapElement = info->mapElement;
|
||||
sprite = (rct_sprite*)mapElement;
|
||||
|
||||
@@ -565,21 +565,20 @@ static rct_peep *viewport_interaction_get_closest_peep(int x, int y, int maxDist
|
||||
*/
|
||||
void sub_68A15E(int screenX, int screenY, short *x, short *y, int *direction, rct_map_element **mapElement)
|
||||
{
|
||||
int my_x, my_y, z;
|
||||
int my_x, my_y, z, interactionType;
|
||||
rct_map_element *myMapElement;
|
||||
rct_viewport *viewport;
|
||||
get_map_coordinates_from_pos(screenX, screenY, 0xFFF6, &my_x, &my_y, &z, &myMapElement, &viewport);
|
||||
get_map_coordinates_from_pos(screenX, screenY, VIEWPORT_INTERACTION_MASK_SPRITE & VIEWPORT_INTERACTION_MASK_WATER, &my_x, &my_y, &interactionType, &myMapElement, &viewport);
|
||||
|
||||
if (z == 0) {
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) {
|
||||
*x = 0x8000;
|
||||
return;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(0x00F1AD3E, uint8) = z;
|
||||
RCT2_GLOBAL(0x00F1AD3E, uint8) = interactionType;
|
||||
RCT2_GLOBAL(0x00F1AD30, rct_map_element*) = myMapElement;
|
||||
|
||||
if (z == 4) {
|
||||
// myMapElement appears to be water
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_WATER) {
|
||||
z = myMapElement->properties.surface.terrain;
|
||||
z = (z & MAP_ELEMENT_WATER_HEIGHT_MASK) << 4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user