mirror of https://github.com/OpenRCT2/OpenRCT2.git
fixes for issues in vehcile-update
This commit is contained in:
parent
7f68149516
commit
0903dda369
|
@ -91,7 +91,7 @@ const uint8 byte_9A3A18[] = {
|
||||||
|
|
||||||
const rct_vehicle_info *vehicle_get_move_info(int cd, int typeAndDirection, int offset)
|
const rct_vehicle_info *vehicle_get_move_info(int cd, int typeAndDirection, int offset)
|
||||||
{
|
{
|
||||||
const rct_vehicle_info **infoListList = RCT2_ADDRESS(0x008B8F30, rct_vehicle_info**)[cd];
|
const rct_vehicle_info **infoListList = RCT2_ADDRESS(0x008B8F30, const rct_vehicle_info**)[cd];
|
||||||
const rct_vehicle_info *infoList = infoListList[typeAndDirection];
|
const rct_vehicle_info *infoList = infoListList[typeAndDirection];
|
||||||
return &infoList[offset];
|
return &infoList[offset];
|
||||||
}
|
}
|
||||||
|
@ -1853,6 +1853,7 @@ static bool try_add_synchronised_station(int x, int y, int z)
|
||||||
sv->vehicle_id = spriteIndex;
|
sv->vehicle_id = spriteIndex;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3919,7 +3920,9 @@ static void vehicle_update_doing_circus_show(rct_vehicle *vehicle)
|
||||||
static rct_map_element* vehicle_check_collision(sint16 x, sint16 y, sint16 z) {
|
static rct_map_element* vehicle_check_collision(sint16 x, sint16 y, sint16 z) {
|
||||||
rct_map_element* mapElement = map_get_first_element_at(x / 32, y / 32);
|
rct_map_element* mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||||
if (mapElement == NULL)
|
if (mapElement == NULL)
|
||||||
return 1; //Can't return null as that implies no collision.
|
// Can't return null as that implies no collision,
|
||||||
|
// but should still cause a crash when dereferenced.
|
||||||
|
return (rct_map_element *) -1;
|
||||||
|
|
||||||
uint8 bl;
|
uint8 bl;
|
||||||
if ((x & 0x1F) >= 16) {
|
if ((x & 0x1F) >= 16) {
|
||||||
|
@ -5376,6 +5379,9 @@ static void loc_6DB1B0(rct_vehicle *vehicle, rct_map_element *mapElement)
|
||||||
} while (!track_element_is_block_start(trackBeginEnd.begin_element));
|
} while (!track_element_is_block_start(trackBeginEnd.begin_element));
|
||||||
|
|
||||||
mapElement = map_get_track_element_at(x, y, z >> 3);
|
mapElement = map_get_track_element_at(x, y, z >> 3);
|
||||||
|
if (mapElement == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mapElement->flags &= ~(1 << 5);
|
mapElement->flags &= ~(1 << 5);
|
||||||
map_invalidate_element(x, y, mapElement);
|
map_invalidate_element(x, y, mapElement);
|
||||||
|
|
||||||
|
@ -6138,7 +6144,7 @@ static void sub_6D63D4(rct_vehicle *vehicle)
|
||||||
*
|
*
|
||||||
* rct2: 0x006DEDB1
|
* rct2: 0x006DEDB1
|
||||||
*/
|
*/
|
||||||
static vehicle_play_scenery_door_open_sound(rct_vehicle *vehicle, rct_map_element *mapElement)
|
static void vehicle_play_scenery_door_open_sound(rct_vehicle *vehicle, rct_map_element *mapElement)
|
||||||
{
|
{
|
||||||
rct_scenery_entry *wallEntry = g_wallSceneryEntries[mapElement->properties.fence.type];
|
rct_scenery_entry *wallEntry = g_wallSceneryEntries[mapElement->properties.fence.type];
|
||||||
int doorSoundType = (wallEntry->wall.flags2 >> 1) & 3;
|
int doorSoundType = (wallEntry->wall.flags2 >> 1) & 3;
|
||||||
|
@ -6154,7 +6160,7 @@ static vehicle_play_scenery_door_open_sound(rct_vehicle *vehicle, rct_map_elemen
|
||||||
*
|
*
|
||||||
* rct2: 0x006DED7A
|
* rct2: 0x006DED7A
|
||||||
*/
|
*/
|
||||||
static vehicle_play_scenery_door_close_sound(rct_vehicle *vehicle, rct_map_element *mapElement)
|
static void vehicle_play_scenery_door_close_sound(rct_vehicle *vehicle, rct_map_element *mapElement)
|
||||||
{
|
{
|
||||||
rct_scenery_entry *wallEntry = g_wallSceneryEntries[mapElement->properties.fence.type];
|
rct_scenery_entry *wallEntry = g_wallSceneryEntries[mapElement->properties.fence.type];
|
||||||
int doorSoundType = (wallEntry->wall.flags2 >> 1) & 3;
|
int doorSoundType = (wallEntry->wall.flags2 >> 1) & 3;
|
||||||
|
@ -6173,11 +6179,11 @@ static vehicle_play_scenery_door_close_sound(rct_vehicle *vehicle, rct_map_eleme
|
||||||
static void vehicle_update_scenery_door(rct_vehicle *vehicle)
|
static void vehicle_update_scenery_door(rct_vehicle *vehicle)
|
||||||
{
|
{
|
||||||
int trackType = vehicle->track_type >> 2;
|
int trackType = vehicle->track_type >> 2;
|
||||||
rct_preview_track *trackBlock = TrackBlocks[trackType];
|
const rct_preview_track *trackBlock = TrackBlocks[trackType];
|
||||||
while ((trackBlock + 1)->index != 255) {
|
while ((trackBlock + 1)->index != 255) {
|
||||||
trackBlock++;
|
trackBlock++;
|
||||||
}
|
}
|
||||||
rct_track_coordinates *trackCoordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates *trackCoordinates = &TrackCoordinates[trackType];
|
||||||
int x = floor2(vehicle->x, 32);
|
int x = floor2(vehicle->x, 32);
|
||||||
int y = floor2(vehicle->y, 32);
|
int y = floor2(vehicle->y, 32);
|
||||||
int z = (vehicle->track_z - trackBlock->z + trackCoordinates->z_end) >> 3;
|
int z = (vehicle->track_z - trackBlock->z + trackCoordinates->z_end) >> 3;
|
||||||
|
@ -6258,8 +6264,8 @@ static void vehicle_trigger_on_ride_photo(rct_vehicle *vehicle, rct_map_element
|
||||||
static void sub_6DEDE8(rct_vehicle *vehicle)
|
static void sub_6DEDE8(rct_vehicle *vehicle)
|
||||||
{
|
{
|
||||||
int trackType = vehicle->track_type >> 2;
|
int trackType = vehicle->track_type >> 2;
|
||||||
rct_preview_track *trackBlock = TrackBlocks[trackType];
|
const rct_preview_track *trackBlock = TrackBlocks[trackType];
|
||||||
rct_track_coordinates *trackCoordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates *trackCoordinates = &TrackCoordinates[trackType];
|
||||||
int x = vehicle->track_x;
|
int x = vehicle->track_x;
|
||||||
int y = vehicle->track_y;
|
int y = vehicle->track_y;
|
||||||
int z = (vehicle->track_z - trackBlock->z + trackCoordinates->z_begin) >> 3;
|
int z = (vehicle->track_z - trackBlock->z + trackCoordinates->z_begin) >> 3;
|
||||||
|
@ -6362,7 +6368,7 @@ static void sub_6DB807(rct_vehicle *vehicle)
|
||||||
static bool sub_6DD078(rct_vehicle *vehicle, uint16* otherVehicleIndex)
|
static bool sub_6DD078(rct_vehicle *vehicle, uint16* otherVehicleIndex)
|
||||||
{
|
{
|
||||||
registers regs = { 0 };
|
registers regs = { 0 };
|
||||||
regs.esi = vehicle;
|
regs.esi = (int)vehicle;
|
||||||
if (otherVehicleIndex != NULL) {
|
if (otherVehicleIndex != NULL) {
|
||||||
regs.bp = *otherVehicleIndex;
|
regs.bp = *otherVehicleIndex;
|
||||||
}
|
}
|
||||||
|
@ -6793,7 +6799,7 @@ loc_6DB8A5:
|
||||||
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
||||||
if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0) {
|
if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0) {
|
||||||
regs.bp = vehicle->prev_vehicle_on_ride;
|
regs.bp = vehicle->prev_vehicle_on_ride;
|
||||||
if (sub_6DD078(vehicle, ®s.bp)) {
|
if (sub_6DD078(vehicle, (uint16 *)®s.bp)) {
|
||||||
goto loc_6DB967;
|
goto loc_6DB967;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7002,6 +7008,7 @@ loc_6DBC3B:
|
||||||
// There are two bytes before the move info list
|
// There are two bytes before the move info list
|
||||||
uint16 trackTotalProgress = *((uint16*)((int)moveInfo - 2));
|
uint16 trackTotalProgress = *((uint16*)((int)moveInfo - 2));
|
||||||
*progress = trackTotalProgress - 1;
|
*progress = trackTotalProgress - 1;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7031,7 +7038,7 @@ loc_6DBA33:;
|
||||||
|
|
||||||
regs.ax = vehicle->track_progress - 1;
|
regs.ax = vehicle->track_progress - 1;
|
||||||
if (regs.ax == -1) {
|
if (regs.ax == -1) {
|
||||||
if (!vehicle_update_track_motion_backwards_get_new_track(vehicle, trackType, ride, rideEntry, ®s.ax)) {
|
if (!vehicle_update_track_motion_backwards_get_new_track(vehicle, trackType, ride, rideEntry, (uint16 *)®s.ax)) {
|
||||||
goto loc_6DBE5E;
|
goto loc_6DBE5E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7071,7 +7078,7 @@ loc_6DBD42:
|
||||||
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
||||||
if (RCT2_GLOBAL(0x00F64E08, sint32) < 0) {
|
if (RCT2_GLOBAL(0x00F64E08, sint32) < 0) {
|
||||||
regs.bp = vehicle->next_vehicle_on_ride;
|
regs.bp = vehicle->next_vehicle_on_ride;
|
||||||
if (sub_6DD078(vehicle, ®s.bp)) {
|
if (sub_6DD078(vehicle, (uint16 *)®s.bp)) {
|
||||||
goto loc_6DBE7F;
|
goto loc_6DBE7F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7721,7 +7728,7 @@ loc_6DC8A1:
|
||||||
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
||||||
if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0) {
|
if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0) {
|
||||||
regs.bp = vehicle->var_44;
|
regs.bp = vehicle->var_44;
|
||||||
sub_6DD078(vehicle, ®s.bp);
|
sub_6DD078(vehicle, (uint16 *)®s.bp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto loc_6DC99A;
|
goto loc_6DC99A;
|
||||||
|
@ -7861,7 +7868,7 @@ loc_6DCC2C:
|
||||||
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
if (vehicle == RCT2_GLOBAL(0x00F64E00, rct_vehicle*)) {
|
||||||
if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0) {
|
if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0) {
|
||||||
regs.bp = vehicle->var_44;
|
regs.bp = vehicle->var_44;
|
||||||
if (sub_6DD078(vehicle, ®s.bp)) {
|
if (sub_6DD078(vehicle, (uint16 *)®s.bp)) {
|
||||||
goto loc_6DCD6B;
|
goto loc_6DCD6B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7888,7 +7895,7 @@ loc_6DCD6B:
|
||||||
RCT2_GLOBAL(0x00F64E0C, sint32) -= regs.eax;
|
RCT2_GLOBAL(0x00F64E0C, sint32) -= regs.eax;
|
||||||
vehicle->remaining_distance -= regs.eax;
|
vehicle->remaining_distance -= regs.eax;
|
||||||
rct_vehicle *vEBP = GET_VEHICLE(regs.bp);
|
rct_vehicle *vEBP = GET_VEHICLE(regs.bp);
|
||||||
rct_vehicle *vEDI = RCT2_GLOBAL(0x00F64E04, uint32);
|
rct_vehicle *vEDI = RCT2_GLOBAL(0x00F64E04, rct_vehicle *);
|
||||||
regs.eax = abs(vEDI->velocity - vEBP->velocity);
|
regs.eax = abs(vEDI->velocity - vEBP->velocity);
|
||||||
if (regs.eax > 0xE0000) {
|
if (regs.eax > 0xE0000) {
|
||||||
if (!(vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_6)) {
|
if (!(vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_6)) {
|
||||||
|
|
Loading…
Reference in New Issue