mirror of https://github.com/OpenRCT2/OpenRCT2.git
implement track_get_info
This commit is contained in:
parent
f246b97c69
commit
b7162b6979
44
src/track.h
44
src/track.h
|
@ -33,35 +33,43 @@ typedef struct {
|
|||
uint8 pad[2];
|
||||
} rct_trackdefinition;
|
||||
|
||||
#define TRACK_PREVIEW_IMAGE_SIZE (370 * 217)
|
||||
|
||||
/**
|
||||
* Track design structure.
|
||||
* size: 0x4E72B
|
||||
*/
|
||||
typedef struct {
|
||||
uint8 type; // 0x00
|
||||
uint8 type; // 0x00
|
||||
uint8 pad_01;
|
||||
money32 cost; // 0x02
|
||||
money32 cost; // 0x02
|
||||
uint8 var_06;
|
||||
uint8 var_07;
|
||||
uint8 pad_08[0x42];
|
||||
uint8 total_air_time; // 0x4A
|
||||
uint8 total_air_time; // 0x4A
|
||||
uint8 pad_4B[0x06];
|
||||
uint8 max_speed; // 0x51
|
||||
uint8 average_speed; // 0x52
|
||||
uint16 ride_length; // 0x53
|
||||
uint8 max_positive_vertical_g; // 0x55
|
||||
uint8 max_negitive_vertical_g; // 0x56
|
||||
uint8 max_lateral_g; // 0x57
|
||||
uint8 max_speed; // 0x51
|
||||
uint8 average_speed; // 0x52
|
||||
uint16 ride_length; // 0x53
|
||||
uint8 max_positive_vertical_g; // 0x55
|
||||
uint8 max_negitive_vertical_g; // 0x56
|
||||
uint8 max_lateral_g; // 0x57
|
||||
union {
|
||||
uint8 inversions; // 0x58
|
||||
uint8 holes; // 0x58
|
||||
uint8 inversions; // 0x58
|
||||
uint8 holes; // 0x58
|
||||
};
|
||||
uint8 drops; // 0x59
|
||||
uint8 highest_drop_height; // 0x5A
|
||||
uint8 excitement; // 0x5B
|
||||
uint8 intensity; // 0x5C
|
||||
uint8 nausea; // 0x5D
|
||||
uint8 drops; // 0x59
|
||||
uint8 highest_drop_height; // 0x5A
|
||||
uint8 excitement; // 0x5B
|
||||
uint8 intensity; // 0x5C
|
||||
uint8 nausea; // 0x5D
|
||||
uint8 pad_5E[0x0E];
|
||||
uint32 var_6C;
|
||||
uint8 pad_70[0x10];
|
||||
uint8 space_required_x; // 0x80
|
||||
uint8 space_required_y; // 0x81
|
||||
uint8 space_required_x; // 0x80
|
||||
uint8 space_required_y; // 0x81
|
||||
uint8 pad_82[0x21];
|
||||
uint8 preview[4][TRACK_PREVIEW_IMAGE_SIZE]; // 0xA3
|
||||
} rct_track_design;
|
||||
|
||||
enum {
|
||||
|
|
|
@ -96,16 +96,66 @@ static void* window_track_list_events[] = {
|
|||
static ride_list_item _window_track_list_item;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* I don't think preview is a necessary output argument. It can be obtained easily using the track design structure.
|
||||
* rct2: 0x006D1DEC
|
||||
*/
|
||||
static rct_track_design *track_get_info(int index, void** preview)
|
||||
static rct_track_design *track_get_info(int index, uint8** preview)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
eax = index;
|
||||
RCT2_CALLFUNC_X(0x006D1DEC, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
if (preview != NULL) *preview = (void*)esi;
|
||||
return (rct_track_design*)edi;
|
||||
rct_track_design *trackDesign;
|
||||
uint8 *trackDesignList = (uint8*)0x00F441EC;
|
||||
int i;
|
||||
|
||||
trackDesign = NULL;
|
||||
|
||||
// Check if track design has already been loaded
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (index == RCT2_ADDRESS(0x00F44109, uint32)[i]) {
|
||||
trackDesign = &RCT2_GLOBAL(0x00F44105, rct_track_design*)[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (trackDesign == NULL) {
|
||||
// Load track design
|
||||
i = RCT2_GLOBAL(0x00F44119, uint32);
|
||||
RCT2_GLOBAL(0x00F44119, uint32)++;
|
||||
if (RCT2_GLOBAL(0x00F44119, uint32) >= 4)
|
||||
RCT2_GLOBAL(0x00F44119, uint32) = 0;
|
||||
|
||||
RCT2_ADDRESS(0x00F44109, uint32)[i] = index;
|
||||
subsitute_path((char*)0x0141EF68, (char*)RCT2_ADDRESS_TRACKS_PATH, trackDesignList + (index * 128));
|
||||
if (!RCT2_CALLPROC_X(0x0067726A, 0, 0, 0, 0, 0, 0, 0)) {
|
||||
if (preview != NULL) *preview = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
trackDesign = &RCT2_GLOBAL(0x00F44105, rct_track_design*)[i];
|
||||
|
||||
memcpy(trackDesign, (void*)0x009D8178, 163);
|
||||
RCT2_CALLPROC_EBPSAFE(0x006D1EF0);
|
||||
|
||||
trackDesign->cost = RCT2_GLOBAL(0x00F4411D, money32);
|
||||
trackDesign->var_06 = RCT2_GLOBAL(0x00F44151, uint8) & 7;
|
||||
}
|
||||
|
||||
// Set preview to correct preview image based on rotation
|
||||
if (preview != NULL)
|
||||
*preview = trackDesign->preview[RCT2_GLOBAL(0x00F440AE, uint8)];
|
||||
|
||||
return trackDesign;
|
||||
}
|
||||
|
||||
void window_track_list_format_name(char *dst, const char *src, char colour)
|
||||
{
|
||||
if (colour != 0)
|
||||
*dst++ = colour;
|
||||
*dst++ = FORMAT_OPENQUOTES;
|
||||
while (*src != '.' && *src != 0) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
*dst++ = FORMAT_ENDQUOTES;
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,7 +210,6 @@ void window_track_list_open(ride_list_item item)
|
|||
static void window_track_list_select(rct_window *w, int index)
|
||||
{
|
||||
uint8 *trackDesignItem, *trackDesignList = (uint8*)0x00F441EC;
|
||||
char *src, *dst;
|
||||
rct_track_design *trackDesign;
|
||||
|
||||
w->track_list.var_480 = index;
|
||||
|
@ -180,18 +229,14 @@ static void window_track_list_select(rct_window *w, int index)
|
|||
|
||||
trackDesignItem = trackDesignList + (index * 128);;
|
||||
RCT2_GLOBAL(0x00F4403C, uint8*) = trackDesignItem;
|
||||
dst = (char*)0x009BC313;
|
||||
|
||||
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8))
|
||||
*dst++ = FORMAT_WHITE;
|
||||
*dst++ = FORMAT_OPENQUOTES;
|
||||
|
||||
while (*src != '.' && *src != 0) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
|
||||
*dst++ = FORMAT_ENDQUOTES;
|
||||
*dst = 0;
|
||||
window_track_list_format_name(
|
||||
(char*)0x009BC313,
|
||||
trackDesignItem,
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8 ?
|
||||
0 :
|
||||
FORMAT_WHITE
|
||||
);
|
||||
|
||||
subsitute_path((char*)0x0141EF68, (char*)RCT2_ADDRESS_TRACKS_PATH, trackDesignItem);
|
||||
|
||||
|
@ -414,14 +459,12 @@ static void window_track_list_paint()
|
|||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
rct_widget *widget;
|
||||
int trackIndex, x, y, colour, gForces, airTime;
|
||||
uint8 *trackDesignList = (uint8*)0x00F441EC;
|
||||
rct_track_design *trackDesign;
|
||||
fixed32_2dp rating;
|
||||
uint8 *image, *trackDesignList = (uint8*)0x00F441EC;
|
||||
uint16 holes, speed, drops, dropHeight, inversions;
|
||||
void *image;
|
||||
fixed32_2dp rating;
|
||||
int trackIndex, x, y, colour, gForces, airTime;
|
||||
rct_g1_element tmpElement, *subsituteElement, *g1Elements = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element);
|
||||
char *src, *dst;
|
||||
|
||||
window_paint_get_registers(w, dpi);
|
||||
|
||||
|
@ -443,7 +486,7 @@ static void window_track_list_paint()
|
|||
gfx_fill_rect(dpi, x, y, x + 369, y + 216, colour);
|
||||
|
||||
trackDesign = track_get_info(trackIndex, &image);
|
||||
if (image == (void*)0xFFFFFFFF)
|
||||
if (trackDesign == NULL)
|
||||
return;
|
||||
|
||||
subsituteElement = &g1Elements[0];
|
||||
|
@ -478,15 +521,7 @@ static void window_track_list_paint()
|
|||
}
|
||||
|
||||
// Track design name
|
||||
src = trackDesignList + (trackIndex * 128);
|
||||
dst = (char*)0x009BC677;
|
||||
*dst++ = FORMAT_WINDOW_COLOUR_1;
|
||||
*dst++ = FORMAT_OPENQUOTES;
|
||||
while (*src != '.' && *src != 0) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
*dst++ = FORMAT_ENDQUOTES;
|
||||
*dst = 0;
|
||||
window_track_list_format_name((char*)0x009BC677, trackDesignList + (trackIndex * 128), FORMAT_WINDOW_COLOUR_1);
|
||||
gfx_draw_string_centred_clipped(dpi, 3165, NULL, 0, x, y, 368);
|
||||
|
||||
// Information
|
||||
|
@ -607,9 +642,8 @@ static void window_track_list_scrollpaint()
|
|||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
rct_string_id stringId, stringId2;
|
||||
int i, j, x, y, colour;
|
||||
int i, x, y, colour;
|
||||
uint8 *trackDesignItem, *trackDesignList = (uint8*)0x00F441EC;
|
||||
char *trackName, *ch;
|
||||
|
||||
window_paint_get_registers(w, dpi);
|
||||
|
||||
|
@ -654,18 +688,8 @@ static void window_track_list_scrollpaint()
|
|||
stringId = 1191;
|
||||
}
|
||||
|
||||
// Get name of track
|
||||
trackName = ch = (char*)0x009BC678;
|
||||
*ch++ = FORMAT_OPENQUOTES;
|
||||
for (j = 0; j < 128; j++) {
|
||||
if (trackDesignItem[j] == '.')
|
||||
break;
|
||||
*ch++ = trackDesignItem[j];
|
||||
}
|
||||
*ch++ = FORMAT_ENDQUOTES;
|
||||
*ch = 0;
|
||||
|
||||
// Draw track name
|
||||
window_track_list_format_name((char*)0x009BC678, trackDesignItem, 0);
|
||||
stringId2 = 3165;
|
||||
gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue