Merge branch 'master' into ride-window

This commit is contained in:
IntelOrca 2014-08-31 15:41:39 +01:00
commit 8e0f1884b9
4 changed files with 94 additions and 3 deletions

View File

@ -23,9 +23,6 @@
#include "date.h"
#include "map.h"
#define GET_MAP_ELEMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element)[x]))
#define TILE_MAP_ELEMENT_POINTER(x) (RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[x])
static void tiles_init();
void map_element_set_terrain(rct_map_element *element, int terrain)

View File

@ -199,5 +199,7 @@ int map_element_height(int x, int y);
void sub_68B089();
int map_coord_is_connected(uint16 coordinate, uint8 height, uint8 face_direction);
#define GET_MAP_ELEMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element)[x]))
#define TILE_MAP_ELEMENT_POINTER(x) (RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[x])
#endif

View File

@ -344,3 +344,91 @@ void ride_check_all_reachable()
}
}
/**
*
* rct2: 0x006CAF80
* ax result x
* bx result y
* dl ride index
* esi result map element
*/
rct_map_element *sub_6CAF80(int rideIndex, int *outX, int *outY)
{
rct_map_element *resultMapElement, *mapElement;
int foundSpecialTrackPiece;
resultMapElement = (rct_map_element*)-1;
foundSpecialTrackPiece = 0;
uint16 x, y;
for (x = 0; x < 256; x++) {
for (y = 0; y < 256; y++) {
// Iterate through map elements on tile
int tileIndex = (y << 8) | x;
mapElement = TILE_MAP_ELEMENT_POINTER(tileIndex);
do {
if ((mapElement->type & MAP_ELEMENT_TYPE_MASK) != MAP_ELEMENT_TYPE_TRACK)
continue;
if (rideIndex != mapElement->properties.track.ride_index)
continue;
// Found a track piece for target ride
// Check if its a ???
int specialTrackPiece = (
(mapElement->properties.track.type != 2 && mapElement->properties.track.type != 3) &&
(RCT2_ADDRESS(0x0099BA64, uint8)[mapElement->properties.track.type * 16] & 0x10)
);
// Set result tile to this track piece if first found track or a ???
if (resultMapElement == (rct_map_element*)-1 || specialTrackPiece) {
resultMapElement = mapElement;
if (outX != NULL) *outX = x * 32;
if (outY != NULL) *outY = y * 32;
}
if (specialTrackPiece) {
foundSpecialTrackPiece = 1;
return resultMapElement;
}
} while (!(mapElement->flags & MAP_ELEMENT_FLAG_LAST_TILE) && mapElement++);
}
}
return resultMapElement;
}
/**
*
* rct2: 0x006CB02F
* ax result x
* bx result y
* esi input / output map element
*/
rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *outX, int *outY)
{
int eax, ebx, ecx, edx, esi, edi, ebp;
esi = (int)startTrackElement;
eax = *outX;
ebx = 0;
ecx = *outY;
edx = 0;
edi = 0;
ebp = 0;
RCT2_CALLFUNC_X(0x006CB02F, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
if (outX != NULL) *outX = eax & 0xFFFF;
if (outY != NULL) *outY = ecx & 0xFFFF;
return (rct_map_element*)esi;
}
/**
*
* rct2: 0x006CC056
*/
int ride_try_construct(rct_map_element *trackMapElement)
{
// Success stored in carry flag which can't be accessed after call using is macro
RCT2_CALLPROC_X(0x006CC056, 0, 0, 0, (int)trackMapElement, 0, 0, 0);
return 1;
}

View File

@ -21,6 +21,7 @@
#ifndef _RIDE_H_
#define _RIDE_H_
#include "map.h"
#include "rct2.h"
#include "string_ids.h"
@ -382,5 +383,8 @@ void ride_init_all();
void reset_all_ride_build_dates();
void ride_update_favourited_stat();
void ride_check_all_reachable();
rct_map_element *sub_6CAF80(int rideIndex, int *outX, int *outY);
rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *outX, int *outY);
int ride_try_construct(rct_map_element *trackMapElement);
#endif