You've already forked OpenRCT2-Unity
mirror of
https://github.com/izzy2lost/OpenRCT2-Unity.git
synced 2026-03-10 12:38:22 -07:00
refactor some of the track design place code
This commit is contained in:
@@ -252,8 +252,6 @@
|
||||
#define RCT2_ADDRESS_TRACK_DESIGN_INDEX_CACHE 0x00F44109
|
||||
#define RCT2_ADDRESS_TRACK_DESIGN_NEXT_INDEX_CACHE 0x00F44119
|
||||
|
||||
#define RCT2_ADDRESS_TRACK_DESIGN_COST 0x00F4411D
|
||||
|
||||
#define RCT2_ADDRESS_TRACK_DESIGN_SCENERY_TOGGLE 0x00F44152
|
||||
|
||||
#define RCT2_ADDRESS_ABOVE_GROUND_FLAGS 0x00F441D4
|
||||
@@ -603,6 +601,7 @@
|
||||
|
||||
#define RCT2_ADDRESS_CONSTRUCT_PATH_VALID_DIRECTIONS 0x00F3EF9E
|
||||
#define RCT2_ADDRESS_TRACK_PREVIEW_ROTATION 0x00F440AE
|
||||
#define RCT2_ADDRESS_TRACK_DESIGN_COST 0x00F4411D
|
||||
|
||||
#define RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT 0x0140E9A4
|
||||
|
||||
|
||||
435
src/ride/track.c
435
src/ride/track.c
File diff suppressed because it is too large
Load Diff
@@ -573,6 +573,20 @@ enum {
|
||||
TRACK_ELEMENT_LOCATION_IS_UNDERGROUND = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
TDPF_PLACE_SCENERY = 1 << 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
PTD_OPERATION_DRAW_OUTLINES,
|
||||
PTD_OPERATION_1,
|
||||
PTD_OPERATION_2,
|
||||
PTD_OPERATION_GET_PLACE_Z,
|
||||
PTD_OPERATION_4,
|
||||
PTD_OPERATION_GET_COST,
|
||||
PTD_OPERATION_CLEAR_OUTLINES
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
rct_xy_element last;
|
||||
rct_xy_element current;
|
||||
@@ -594,6 +608,8 @@ extern const rct_trackdefinition *gTrackDefinitions;
|
||||
extern rct_map_element **gTrackSavedMapElements;
|
||||
|
||||
extern rct_track_td6 *gActiveTrackDesign;
|
||||
extern money32 gTrackDesignCost;
|
||||
extern uint8 gTrackDesignPlaceFlags;
|
||||
|
||||
void track_load_list(ride_list_item item);
|
||||
int sub_67726A(const char *path);
|
||||
|
||||
@@ -413,7 +413,7 @@ static void window_track_list_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
// Load in a new preview image, calculate cost variable, calculate var_06
|
||||
draw_track_preview(td6, (uint8**)_loadedTrackDesignPreview);
|
||||
|
||||
td6->cost = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_COST, money32);
|
||||
td6->cost = gTrackDesignCost;
|
||||
td6->track_flags = RCT2_GLOBAL(0x00F44151, uint8) & 7;
|
||||
|
||||
_loadedTrackDesignIndex = trackIndex;
|
||||
|
||||
@@ -307,7 +307,7 @@ static void window_track_place_clear_provisional()
|
||||
if (_window_track_place_last_was_valid) {
|
||||
sub_6D01B3(
|
||||
gActiveTrackDesign,
|
||||
6,
|
||||
PTD_OPERATION_CLEAR_OUTLINES,
|
||||
RCT2_GLOBAL(0x00F440EB, uint8),
|
||||
_window_track_place_last_valid_x,
|
||||
_window_track_place_last_valid_y,
|
||||
@@ -342,7 +342,7 @@ static int window_track_place_get_base_z(int x, int y)
|
||||
if (mapElement->properties.surface.terrain & 0x1F)
|
||||
z = max(z, (mapElement->properties.surface.terrain & 0x1F) << 4);
|
||||
|
||||
return z + sub_6D01B3(gActiveTrackDesign, 3, 0, x, y, z);
|
||||
return z + sub_6D01B3(gActiveTrackDesign, PTD_OPERATION_GET_PLACE_Z, 0, x, y, z);
|
||||
}
|
||||
|
||||
static void window_track_place_attempt_placement(int x, int y, int z, int bl, money32 *cost, uint8 *rideIndex)
|
||||
@@ -475,7 +475,7 @@ static void window_track_place_toolupdate(rct_window* w, int widgetIndex, int x,
|
||||
|
||||
// Check if tool map position has changed since last update
|
||||
if (mapX == _window_track_place_last_x && mapY == _window_track_place_last_y) {
|
||||
sub_6D01B3(gActiveTrackDesign, 0, 0, mapX, mapY, 0);
|
||||
sub_6D01B3(gActiveTrackDesign, PTD_OPERATION_DRAW_OUTLINES, 0, mapX, mapY, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ static void window_track_place_toolupdate(rct_window* w, int widgetIndex, int x,
|
||||
widget_invalidate(w, WIDX_PRICE);
|
||||
}
|
||||
|
||||
sub_6D01B3(gActiveTrackDesign, 0, 0, mapX, mapY, mapZ);
|
||||
sub_6D01B3(gActiveTrackDesign, PTD_OPERATION_DRAW_OUTLINES, 0, mapX, mapY, mapZ);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5494,3 +5494,25 @@ rct_map_element *map_get_track_element_at_with_direction_from_ride(int x, int y,
|
||||
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void map_offset_with_rotation(sint16 *x, sint16 *y, sint16 offsetX, sint16 offsetY, uint8 rotation)
|
||||
{
|
||||
switch (rotation & 3) {
|
||||
case MAP_ELEMENT_DIRECTION_WEST:
|
||||
*x += offsetX;
|
||||
*y += offsetY;
|
||||
break;
|
||||
case MAP_ELEMENT_DIRECTION_NORTH:
|
||||
*x += offsetY;
|
||||
*y -= offsetX;
|
||||
break;
|
||||
case MAP_ELEMENT_DIRECTION_EAST:
|
||||
*x -= offsetX;
|
||||
*y -= offsetY;
|
||||
break;
|
||||
case MAP_ELEMENT_DIRECTION_SOUTH:
|
||||
*x -= offsetY;
|
||||
*y += offsetX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,6 +425,8 @@ bool map_large_scenery_get_origin(
|
||||
int *outX, int *outY, int *outZ, rct_map_element** outElement
|
||||
);
|
||||
|
||||
void map_offset_with_rotation(sint16 *x, sint16 *y, sint16 offsetX, sint16 offsetY, uint8 rotation);
|
||||
|
||||
rct_map_element *map_get_track_element_at(int x, int y, int z);
|
||||
rct_map_element *map_get_track_element_at_of_type(int x, int y, int z, int trackType);
|
||||
rct_map_element *map_get_track_element_at_of_type_seq(int x, int y, int z, int trackType, int sequence);
|
||||
|
||||
Reference in New Issue
Block a user