Added more to window_peep overview paint

Moved get_arguments_from_thought to peep.c and added to peep.h
Fixed possible crash in viewport_update_position
Fixed compile error
This commit is contained in:
Duncan Frost 2014-08-25 19:31:53 +01:00
parent edd1651b4d
commit dffd689ee6
6 changed files with 106 additions and 54 deletions

View File

@ -542,6 +542,44 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum
}
/**
* rct2: 0x00698342
* thought.item (eax)
* thought.type (ebx)
* argument_1 (esi & ebx)
* argument_2 (esi+2)
*/
void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2){
int esi = 0x9AC86C;
if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 1){
rct_ride* ride = &g_ride_list[thought.item];
esi = (int)(&(ride->var_04A));
}
else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 2){
if (thought.item < 0x20){
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_START;
}
else{
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_START;
}
}
else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 4){
if (thought.item < 0x20){
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_SINGULAR_START;
}
else
{
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_SINGULAR_START;
}
}
else{
esi = 0x9AC864; //No thought?
}
*argument_1 = ((thought.type + STR_THOUGHT_START) & 0xFFFF) | (*((uint16*)esi) << 16);
*argument_2 = *((uint32*)(esi + 2)); //Always 0 apart from on rides?
}
/**
* rct2: 0x00698827
* returns 1 on pickup (CF not set)

View File

@ -444,5 +444,6 @@ void peep_update_crowd_noise();
void peep_applause();
rct_peep *peep_generate(int x, int y, int z);
void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2);
void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2);
#endif

View File

@ -280,7 +280,7 @@ void viewport_update_position(rct_window *window)
if (window->viewport_target_sprite != -1){
rct_sprite* sprite = &g_sprite_list[window->viewport_target_sprite];
int height = map_element_height(sprite->unknown.x, sprite->unknown.y) - 16;
int height = map_element_height(0xFFFF & sprite->unknown.x, 0xFFFF & sprite->unknown.y) - 16;
int underground = sprite->unknown.z < height;
RCT2_CALLPROC_X(0x6E7A15, sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, underground, (int)window, (int)viewport, 0);

View File

@ -203,7 +203,7 @@ typedef struct rct_window {
sint16 page; // 0x48A
sint16 var_48C;
sint16 frame_no; // 0x48E updated every tic for motion in windows sprites
uint16 list_information_type; // 0x490 0 for none
uint16 list_information_type; // 0x490 0 for none, Used as current position of marquee in window_peep
sint16 var_492;
uint32 var_494;
uint8 var_498[0x14];

View File

@ -135,7 +135,7 @@ static void window_guest_list_find_groups();
static int get_guest_face_sprite_small(rct_peep *peep);
static int get_guest_face_sprite_large(rct_peep *peep);
static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2);
void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2);
/**
*
* rct2: 0x006992E3
@ -730,44 +730,6 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep)
return 1;
}
/**
* rct2: 0x00698342
* thought.item (eax)
* thought.type (ebx)
* argument_1 (esi & ebx)
* argument_2 (esi+2)
*/
void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2){
int esi = 0x9AC86C;
if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 1){
rct_ride* ride = &g_ride_list[thought.item];
esi = (int)(&(ride->var_04A));
}
else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 2){
if (thought.item < 0x20){
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_START;
}
else{
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_START;
}
}
else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 4){
if (thought.item < 0x20){
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM_SINGULAR_START;
}
else
{
RCT2_GLOBAL(0x9AC86C, uint16) = thought.item + STR_ITEM2_SINGULAR_START;
}
}
else{
esi = 0x9AC864; //No thought?
}
*argument_1 = ((thought.type + STR_THOUGHT_START) & 0xFFFF) | (*((uint16*)esi) << 16);
*argument_2 = *((uint32*)(esi+2)); //Always 0 apart from on rides?
}
/**
* rct2:0x0069B7EA
* Calculates a hash value (arguments) for comparing peep actions/thoughts

View File

@ -85,18 +85,18 @@ rct_widget window_peep_overview_widgets[] = {
};
rct_widget window_peep_stats_widgets[] = {
{WWT_FRAME, 0, 0,191,0,156,-1,-1},
{WWT_CAPTION, 0, 1,190,1,14,865,829},
{WWT_CLOSEBOX, 0, 179,189,2,13,824,828},
{WWT_RESIZE, 1, 0,191,43,156,-1,-1},
{WWT_TAB, 1, 3,33,17,43,0x2000144E,1938},
{WWT_TAB, 1, 34,64,17,43,0x2000144E,1940},
{WWT_TAB, 1, 65,95,17,43,0x2000144E,1941},
{WWT_TAB, 1, 96,126,17,43,0x2000144E,1942},
{WWT_TAB, 1, 127,157,17,43,0x2000144E,1943},
{WWT_TAB, 1, 158,188,17,43,0x2000144E,1944},
{WWT_FRAME, 0, 0, 191, 0, 156, -1, STR_NONE},
{WWT_CAPTION, 0, 1, 190, 1, 14, 865, STR_WINDOW_TITLE_TIP},
{WWT_CLOSEBOX, 0, 179, 189, 2, 13, 824, STR_CLOSE_WINDOW_TIP},
{WWT_RESIZE, 1, 0, 191, 43, 156, -1, STR_NONE},
{WWT_TAB, 1, 3, 33, 17, 43, 0x2000144E, 1938},
{WWT_TAB, 1, 34, 64, 17, 43, 0x2000144E, 1940},
{WWT_TAB, 1, 65, 95, 17, 43, 0x2000144E, 1941},
{WWT_TAB, 1, 96, 126, 17, 43, 0x2000144E, 1942},
{WWT_TAB, 1, 127, 157, 17, 43, 0x2000144E, 1943},
{WWT_TAB, 1, 158, 188, 17, 43, 0x2000144E, 1944},
{WIDGETS_END},
}
};
//0x981D0C
rct_widget *window_peep_page_widgets[] = {
@ -693,8 +693,8 @@ void window_peep_overview_paint(){
//rct_widget *labelWidget;
window_paint_get_registers(w, dpi);
RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0);
return;
//RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0);
//return;
window_draw_widgets(w, dpi);
//6983dd
@ -703,7 +703,58 @@ void window_peep_overview_paint(){
//69861f
//69869b
//698661
// Draw the viewport no sound sprite
if (w->viewport){
window_draw_viewport(dpi, w);
rct_viewport* viewport = w->viewport;
if (viewport->flags & VIEWPORT_FLAG_SOUND_ON){
gfx_draw_sprite(dpi, SPR_HEARING_VIEWPORT, w->x + 2, w->y + 2, 0);
}
}
// Draw the centered label
uint32 argument1, argument2;
rct_peep* peep = GET_PEEP(w->number);
get_arguments_from_action(peep, &argument1, &argument2);
RCT2_GLOBAL(0x13CE952, uint32) = argument1;
RCT2_GLOBAL(0x13CE952 + 4, uint32) = argument2;
rct_widget* widget = &w->widgets[WIDX_ACTION_LBL];
int x = (widget->left + widget->right) / 2 + w->x;
int y = w->y + widget->top - 1;
int width = widget->right - widget->left;
gfx_draw_string_centred_clipped(dpi, 1191, (void*)0x13CE952, 0, x, y, width);
// Draw the marquee thought
widget = &w->widgets[WIDX_MARQUEE];
width = widget->right - widget->left - 3;
int left = widget->left + 2 + w->x;
int top = widget->top + w->y;
int height = widget->bottom - widget->top;
rct_drawpixelinfo* dpi_marquee = clip_drawpixelinfo(dpi, left, width, top, height);
if (!dpi_marquee)return;
int i = 0;
for (; i < PEEP_MAX_THOUGHTS; ++i){
if (peep->thoughts[i].type == PEEP_THOUGHT_TYPE_NONE){
w->list_information_type = 0;
return;
}
if (peep->thoughts[i].var_2 == 1){ // If a fresh thought
break;
}
}
if (i == PEEP_MAX_THOUGHTS){
w->list_information_type = 0;
return;
}
get_arguments_from_thought(peep->thoughts[i], &argument1, &argument2);
RCT2_GLOBAL(0x13CE952, uint32) = argument1;
RCT2_GLOBAL(0x13CE952 + 4, uint32) = argument2;
RCT2_GLOBAL(0x13CE952 + 8, uint16) = 0;
x = widget->right - widget->left - w->list_information_type;
gfx_draw_string_left(dpi_marquee, 1193, (void*)0x13CE952, 0, x, 0);
}