integrate ride construction variables

- _currentTrackPrice
- _numCurrentPossibleRideConfigurations
- _numCurrentPossibleSpecialTrackPieces
- _currentTrackCurve
- _currentTrackEndX
- _currentTrackEndY
- _rideConstructionState
- _currentRideIndex
- _currentTrackBeginX
- _currentTrackBeginY
- _currentTrackBeginZ
- _currentTrackPieceDirection
- _currentTrackPieceType
- _currentTrackSelectionFlags
- _rideConstructionArrowPulseTime
- _currentTrackSlopeEnd
- _currentTrackBankEnd
- _currentTrackLiftHill
- _currentTrackCovered
- _previousTrackBankEnd
- _previousTrackSlopeEnd
- _previousTrackPieceX
- _previousTrackPieceY
- _previousTrackPieceZ
- _currentSeatRotationAngle
This commit is contained in:
Ted John committed 2016-04-15 20:56:48 +01:00
1 parent 681961eaec
commit 7b248f0079
7 files changed
+96 -63

No files matched your search

+31
View File
@@ -137,6 +137,37 @@ int gRideRemoveTrackPieceCallbackZ;
int gRideRemoveTrackPieceCallbackDirection;
int gRideRemoveTrackPieceCallbackType;
money32 _currentTrackPrice;
uint16 _numCurrentPossibleRideConfigurations;
uint16 _numCurrentPossibleSpecialTrackPieces;
uint16 _currentTrackCurve;
uint16 _currentTrackEndX;
uint16 _currentTrackEndY;
uint8 _rideConstructionState;
uint8 _currentRideIndex;
uint16 _currentTrackBeginX;
uint16 _currentTrackBeginY;
uint16 _currentTrackBeginZ;
uint8 _currentTrackPieceDirection;
uint8 _currentTrackPieceType;
uint8 _currentTrackSelectionFlags;
sint8 _rideConstructionArrowPulseTime;
uint8 _currentTrackSlopeEnd;
uint8 _currentTrackBankEnd;
uint8 _currentTrackLiftHill;
uint8 _currentTrackCovered;
uint8 _previousTrackBankEnd;
uint8 _previousTrackSlopeEnd;
uint16 _previousTrackPieceX;
uint16 _previousTrackPieceY;
uint16 _previousTrackPieceZ;
uint8 _currentSeatRotationAngle;
// Static function declarations
rct_peep *find_closest_mechanic(int x, int y, int forInspection);
static void ride_breakdown_status_update(int rideIndex);
+25 -31
View File
@@ -886,42 +886,36 @@ rct_ride_measurement *get_ride_measurement(int index);
extern const uint8 gRideClassifications[255];
extern money32 _currentTrackPrice;
// Macros for very commonly used varaibles, eventually will be changed to locals or globals
#define _enabledRidePieces RCT2_GLOBAL(0x00F44048, uint64)
#define _enabledRidePiecesA RCT2_GLOBAL(0x00F44048, uint32)
#define _enabledRidePiecesB RCT2_GLOBAL(0x00F4404C, uint32)
extern uint16 _numCurrentPossibleRideConfigurations;
extern uint16 _numCurrentPossibleSpecialTrackPieces;
#define _currentTrackPrice RCT2_GLOBAL(0x00F44070, money32)
extern uint16 _currentTrackCurve;
extern uint16 _currentTrackEndX;
extern uint16 _currentTrackEndY;
extern uint8 _rideConstructionState;
extern uint8 _currentRideIndex;
extern uint16 _currentTrackBeginX;
extern uint16 _currentTrackBeginY;
extern uint16 _currentTrackBeginZ;
extern uint8 _currentTrackPieceDirection;
extern uint8 _currentTrackPieceType;
extern uint8 _currentTrackSelectionFlags;
extern sint8 _rideConstructionArrowPulseTime;
extern uint8 _currentTrackSlopeEnd;
extern uint8 _currentTrackBankEnd;
extern uint8 _currentTrackLiftHill;
extern uint8 _currentTrackCovered;
#define _numCurrentPossibleRideConfigurations RCT2_GLOBAL(0x00F44078, uint16)
#define _numCurrentPossibleSpecialTrackPieces RCT2_GLOBAL(0x00F4407A, uint16)
extern uint8 _previousTrackBankEnd;
extern uint8 _previousTrackSlopeEnd;
#define _currentTrackCurve RCT2_GLOBAL(0x00F440A0, uint16)
#define _currentTrackEndX RCT2_GLOBAL(0x00F440A2, uint16)
#define _currentTrackEndY RCT2_GLOBAL(0x00F440A4, uint16)
#define _rideConstructionState RCT2_GLOBAL(0x00F440A6, uint8)
#define _currentRideIndex RCT2_GLOBAL(0x00F440A7, uint8)
#define _currentTrackBeginX RCT2_GLOBAL(0x00F440A8, uint16)
#define _currentTrackBeginY RCT2_GLOBAL(0x00F440AA, uint16)
#define _currentTrackBeginZ RCT2_GLOBAL(0x00F440AC, uint16)
#define _currentTrackPieceDirection RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8)
#define _currentTrackPieceType RCT2_GLOBAL(0x00F440AF, uint8)
#define _currentTrackSelectionFlags RCT2_GLOBAL(0x00F440B0, uint8)
#define _rideConstructionArrowPulseTime RCT2_GLOBAL(0x00F440B1, sint8)
#define _currentTrackSlopeEnd RCT2_GLOBAL(0x00F440B2, uint8)
#define _currentTrackBankEnd RCT2_GLOBAL(0x00F440B3, uint8)
#define _currentTrackLiftHill RCT2_GLOBAL(0x00F440B4, uint8)
#define _currentTrackCovered RCT2_GLOBAL(0x00F440B5, uint8)
extern uint16 _previousTrackPieceX;
extern uint16 _previousTrackPieceY;
extern uint16 _previousTrackPieceZ;
#define _previousTrackBankEnd RCT2_GLOBAL(0x00F440B6, uint8)
#define _previousTrackSlopeEnd RCT2_GLOBAL(0x00F440B7, uint8)
#define _previousTrackPieceX RCT2_GLOBAL(0x00F440B9, uint16)
#define _previousTrackPieceY RCT2_GLOBAL(0x00F440BB, uint16)
#define _previousTrackPieceZ RCT2_GLOBAL(0x00F440BD, uint16)
#define _currentSeatRotationAngle RCT2_GLOBAL(0x00F440CF, uint8)
extern uint8 _currentSeatRotationAngle;
extern bool gGotoStartPlacementMode;
extern int gRideRemoveTrackPieceCallbackX;
+14 -14
View File
@@ -1033,7 +1033,7 @@ int track_place_scenery(rct_track_scenery* scenery_start, uint8 rideIndex, int o
for (rct_track_scenery* scenery = scenery_start; (scenery->scenery_object.flags & 0xFF) != 0xFF; scenery++){
uint8 rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
uint8 rotation = _currentTrackPieceDirection;
rct_xy8 tile = { .x = originX / 32, .y = originY / 32 };
switch (rotation & 3){
@@ -1113,7 +1113,7 @@ int track_place_scenery(rct_track_scenery* scenery_start, uint8 rideIndex, int o
rotation &= 3;
//bh
uint8 quadrant = (scenery->flags >> 2) + RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
uint8 quadrant = (scenery->flags >> 2) + _currentTrackPieceDirection;
quadrant &= 3;
uint8 bh = rotation | (quadrant << 6) | MAP_ELEMENT_TYPE_SCENERY;
@@ -1223,7 +1223,7 @@ int track_place_scenery(rct_track_scenery* scenery_start, uint8 rideIndex, int o
rotation += scenery->flags;
rotation &= 3;
z = scenery->z * 8 + originZ;
uint8 quadrant = ((scenery->flags >> 2) + RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8)) & 3;
uint8 quadrant = ((scenery->flags >> 2) + _currentTrackPieceDirection) & 3;
bl = 0x81;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 5)bl = 0xA9;
@@ -1386,14 +1386,14 @@ int track_place_maze(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8** trac
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, sint16) = y;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, sint16) = map_element_height(x, y) & 0xFFFF;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = _currentTrackPieceDirection;
}
RCT2_GLOBAL(0x00F440D5, uint32) = 0;
rct_maze_element* maze = (rct_maze_element*)(*track_elements);
for (; maze->all != 0; maze++){
uint8 rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
uint8 rotation = _currentTrackPieceDirection;
rct_xy16 mapCoord = { .x = maze->x * 32, .y = maze->y * 32 };
switch (rotation & 3){
@@ -1571,11 +1571,11 @@ int track_place_ride(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8** trac
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, sint16) = y;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, sint16) = map_element_height(x, y) & 0xFFFF;
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = _currentTrackPieceDirection;
}
RCT2_GLOBAL(0x00F440D5, uint32) = 0;
uint8 rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
uint8 rotation = _currentTrackPieceDirection;
rct_track_element* track = (rct_track_element*)(*track_elements);
for (; track->type != 0xFF; track++){
@@ -1791,7 +1791,7 @@ int track_place_ride(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8** trac
*track_elements = (uint8*)track + 1;
rct_track_entrance* entrance = (rct_track_entrance*)(*track_elements);
for (; entrance->z != -1; entrance++){
rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
rotation = _currentTrackPieceDirection;
x = entrance->x;
y = entrance->y;
@@ -2044,12 +2044,12 @@ int sub_6D2189(int* cost, uint8* ride_id){
}
RCT2_GLOBAL(0x009D8150, uint8) |= 1;
uint8 backup_rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
uint8 backup_rotation = _currentTrackPieceDirection;
uint32 backup_park_flags = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32);
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_FORBID_HIGH_CONSTRUCTION;
int map_size = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16) << 4;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = 0;
_currentTrackPieceDirection = 0;
int z = sub_6D01B3(3, 0, map_size, map_size, 16);
if (RCT2_GLOBAL(0xF4414E, uint8) & 4){
@@ -2072,14 +2072,14 @@ int sub_6D2189(int* cost, uint8* ride_id){
RCT2_GLOBAL(0xF44151, uint8) |= 4;
}
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = backup_rotation;
_currentTrackPieceDirection = backup_rotation;
RCT2_GLOBAL(0x009D8150, uint8) &= ~1;
*cost = edi;
return 1;
}
else{
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = backup_rotation;
_currentTrackPieceDirection = backup_rotation;
user_string_free(ride->name);
ride->type = RIDE_TYPE_NULL;
RCT2_GLOBAL(0x009D8150, uint8) &= ~1;
@@ -2284,7 +2284,7 @@ rct_track_design *track_get_info(int index, uint8** preview)
// Set preview to correct preview image based on rotation
if (preview != NULL)
*preview = trackDesign->preview[RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8)];
*preview = trackDesign->preview[_currentTrackPieceDirection];
return trackDesign;
}
@@ -3176,7 +3176,7 @@ rct_track_design *temp_track_get_info(char* path, uint8** preview)
// Set preview to correct preview image based on rotation
if (preview != NULL)
*preview = trackDesign->preview[RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8)];
*preview = trackDesign->preview[_currentTrackPieceDirection];
return trackDesign;
}
+3 -3
View File
@@ -120,7 +120,7 @@ void window_install_track_open(const char* path)
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_CACHE, void*) = mem;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_SCENERY_TOGGLE, uint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = 2;
_currentTrackPieceDirection = 2;
reset_track_list_cache();
x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 201;
@@ -227,8 +227,8 @@ static void window_install_track_mouseup(rct_window *w, int widgetIndex)
window_close(w);
break;
case WIDX_ROTATE:
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8)++;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) %= 4;
_currentTrackPieceDirection++;
_currentTrackPieceDirection %= 4;
window_invalidate(w);
break;
case WIDX_TOGGLE_SCENERY:
+17 -9
View File
@@ -447,6 +447,14 @@ rct_string_id RideConfigurationStringIds[] = {
#pragma endregion
union {
uint64 ab;
struct {
uint32 a;
uint32 b;
};
} _enabledRidePieces;
static bool _trackPlaceCtrlState;
static int _trackPlaceCtrlZ;
static bool _trackPlaceShiftState;
@@ -493,7 +501,7 @@ uint8 *_currentPossibleRideConfigurations = (uint8*)0x00F4407C;
static bool is_track_enabled(int trackFlagIndex)
{
return _enabledRidePieces & (1ULL << trackFlagIndex);
return _enabledRidePieces.ab & (1ULL << trackFlagIndex);
}
static int ride_get_alternative_type(rct_ride *ride)
@@ -560,7 +568,7 @@ rct_window *window_ride_construction_open()
_previousTrackBankEnd = 0;
_previousTrackSlopeEnd = 0;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = 0;
_currentTrackPieceDirection = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_PLACE;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
@@ -2430,7 +2438,7 @@ static bool sub_6CA2DF_get_track_element(uint8 *trackElement) {
return false;
}
bool startsDiagonal = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) & (1 << 2);
bool startsDiagonal = _currentTrackPieceDirection & (1 << 2);
if (curve == TRACK_CURVE_LEFT_LARGE || curve == TRACK_CURVE_RIGHT_LARGE) {
if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_BACK) {
startsDiagonal = !startsDiagonal;
@@ -2525,7 +2533,7 @@ static bool sub_6CA2DF(int *_trackType, int *_trackDirection, int *_rideIndex, i
rct_ride *ride = get_ride(rideIndex);
if (_enabledRidePiecesB & (1 << 8)) {
if (_enabledRidePieces.b & (1 << 8)) {
switch (trackType) {
case TRACK_ELEM_FLAT_TO_60_DEG_UP:
trackType = TRACK_ELEM_FLAT_TO_60_DEG_UP_LONG_BASE;
@@ -2565,7 +2573,7 @@ static bool sub_6CA2DF(int *_trackType, int *_trackDirection, int *_rideIndex, i
z = _currentTrackBeginZ;
if (_rideConstructionState == 2) {
z -= trackCoordinates->z_end;
trackDirection = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) ^ 0x02;
trackDirection = _currentTrackPieceDirection ^ 0x02;
trackDirection -= trackCoordinates->rotation_end;
trackDirection += trackCoordinates->rotation_begin;
trackDirection &= 0x03;
@@ -2597,12 +2605,12 @@ static bool sub_6CA2DF(int *_trackType, int *_trackDirection, int *_rideIndex, i
}
} else {
z -= trackCoordinates->z_begin;
trackDirection = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
trackDirection = _currentTrackPieceDirection;
}
bool do_loc_6CAF26 = false;
if (!(_enabledRidePiecesA & (1 << 5))) {
if (!(_enabledRidePieces.a & (1 << 5))) {
if (RCT2_ADDRESS(0x0099423C, uint16)[trackType] & 0x2000) {
do_loc_6CAF26 = true;
}
@@ -2654,8 +2662,8 @@ static void window_ride_construction_update_enabled_track_pieces()
return;
int rideType = _currentTrackCovered & 2 ? RCT2_ADDRESS(0x0097D4F5, uint8)[ride->type * 8] : ride->type;
_enabledRidePiecesA = rideEntry->enabledTrackPiecesA & RCT2_ADDRESS(0x01357444, uint32)[rideType];
_enabledRidePiecesB = rideEntry->enabledTrackPiecesB & RCT2_ADDRESS(0x01357644, uint32)[rideType];
_enabledRidePieces.a = rideEntry->enabledTrackPiecesA & RCT2_ADDRESS(0x01357444, uint32)[rideType];
_enabledRidePieces.b = rideEntry->enabledTrackPiecesB & RCT2_ADDRESS(0x01357644, uint32)[rideType];
}
/**
+3 -3
View File
@@ -144,7 +144,7 @@ void window_track_list_open(ride_list_item item)
w->track_list.var_484 = 0;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_SCENERY_TOGGLE, uint8) = 0;
window_push_others_right(w);
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = 2;
_currentTrackPieceDirection = 2;
}
/**
@@ -253,8 +253,8 @@ static void window_track_list_mouseup(rct_window *w, int widgetIndex)
}
break;
case WIDX_ROTATE:
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8)++;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) %= 4;
_currentTrackPieceDirection++;
_currentTrackPieceDirection %= 4;
window_invalidate(w);
break;
case WIDX_TOGGLE_SCENERY:
+3 -3
View File
@@ -151,7 +151,7 @@ static void window_track_place_draw_mini_preview()
if (track->type != RIDE_TYPE_MAZE) {
#pragma region Track
rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + get_current_rotation();
rotation = _currentTrackPieceDirection + get_current_rotation();
trackElement = RCT2_ADDRESS(0x009D821B, rct_track_element);
while (trackElement->type != 255) {
@@ -250,7 +250,7 @@ static void window_track_place_draw_mini_preview()
} else {
#pragma region Maze
rotation = (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + get_current_rotation()) & 3;
rotation = (_currentTrackPieceDirection + get_current_rotation()) & 3;
mazeElement = RCT2_ADDRESS(0x009D821B, rct_maze_element);
while (mazeElement->all != 0) {
x = mazeElement->x * 32;
@@ -395,7 +395,7 @@ void window_track_place_open()
show_gridlines();
_window_track_place_last_cost = MONEY32_UNDEFINED;
_window_track_place_last_x = 0xFFFF;
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = (2 - get_current_rotation()) & 3;
_currentTrackPieceDirection = (2 - get_current_rotation()) & 3;
window_track_place_draw_mini_preview();
}