1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 08:14:38 +01:00

Merge pull request #430 from duncanspumpkin/window_peep_events

Window peep events
This commit is contained in:
Ted John
2014-09-15 21:36:15 +01:00
14 changed files with 1548 additions and 192 deletions

View File

@@ -440,7 +440,7 @@ static void RCT2_CALLPROC_EBPSAFE(int address)
#endif
}
static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, int _esi, int _edi, int _ebp)
static int RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, int _esi, int _edi, int _ebp)
{
#ifdef _MSC_VER
__asm {
@@ -453,6 +453,7 @@ static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx,
mov edi, _edi
mov ebp, _ebp
call [esp]
lahf
add esp, 4
}
#else
@@ -469,6 +470,7 @@ static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx,
mov edi, %[_edi] \n\
mov ebp, %[_ebp] \n\
call [esp] \n\
lahf \n\
add esp, 4 \n\
pop ebp \n\
pop ebx \n\

View File

@@ -925,7 +925,7 @@ static uint32 game_do_command_table[58] = {
0x006A67C0,
0x00663CCD, // 20
0x006B53E9,
0x00698D6C,
0x00698D6C, // text input
0x0068C542,
0x0068C6D1,
0x0068BC01,

View File

@@ -1819,7 +1819,7 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i
int half_width = gfx_get_string_width(buffer) / 2;
gfx_draw_string(dpi, buffer, 0xFE, x - half_width, line_y);
buffer += strlen(buffer) + 1;
buffer += get_string_length(buffer) + 1;
line_y += line_height;
}
@@ -1874,7 +1874,7 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int
for (int line = 0; line <= num_lines; ++line) {
gfx_draw_string(dpi, buffer, 0xFE, x, line_y);
buffer += strlen(buffer) + 1;
buffer += get_string_length(buffer) + 1;
line_y += line_height;
}

View File

@@ -195,6 +195,7 @@ typedef struct {
void map_init();
void map_update_tile_pointers();
rct_map_element *map_get_surface_element_at(int x, int y);
int map_element_height(int x, int y);
void sub_68B089();
int map_coord_is_connected(uint16 coordinate, uint8 height, uint8 face_direction);

View File

@@ -26,6 +26,7 @@
#include "rct2.h"
#include "ride.h"
#include "sprite.h"
#include "sprites.h"
#include "window.h"
static void peep_update(rct_peep *peep);
@@ -586,4 +587,98 @@ void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, ui
*/
int peep_can_be_picked_up(rct_peep* peep){
return RCT2_ADDRESS(0x982004, uint8)[peep->state] & 1;
}
}
enum{
PEEP_FACE_OFFSET_ANGRY = 0,
PEEP_FACE_OFFSET_VERY_VERY_SICK,
PEEP_FACE_OFFSET_VERY_SICK,
PEEP_FACE_OFFSET_SICK,
PEEP_FACE_OFFSET_VERY_TIRED,
PEEP_FACE_OFFSET_TIRED,
PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY,
PEEP_FACE_OFFSET_VERY_UNHAPPY,
PEEP_FACE_OFFSET_UNHAPPY,
PEEP_FACE_OFFSET_NORMAL,
PEEP_FACE_OFFSET_HAPPY,
PEEP_FACE_OFFSET_VERY_HAPPY,
PEEP_FACE_OFFSET_VERY_VERY_HAPPY,
};
const int face_sprite_small[] = {
SPR_PEEP_SMALL_FACE_ANGRY,
SPR_PEEP_SMALL_FACE_VERY_VERY_SICK,
SPR_PEEP_SMALL_FACE_VERY_SICK,
SPR_PEEP_SMALL_FACE_SICK,
SPR_PEEP_SMALL_FACE_VERY_TIRED,
SPR_PEEP_SMALL_FACE_TIRED,
SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY,
SPR_PEEP_SMALL_FACE_VERY_UNHAPPY,
SPR_PEEP_SMALL_FACE_UNHAPPY,
SPR_PEEP_SMALL_FACE_NORMAL,
SPR_PEEP_SMALL_FACE_HAPPY,
SPR_PEEP_SMALL_FACE_VERY_HAPPY,
SPR_PEEP_SMALL_FACE_VERY_VERY_HAPPY,
};
const int face_sprite_large[] = {
SPR_PEEP_LARGE_FACE_ANGRY,
SPR_PEEP_LARGE_FACE_VERY_VERY_SICK,
SPR_PEEP_LARGE_FACE_VERY_SICK,
SPR_PEEP_LARGE_FACE_SICK,
SPR_PEEP_LARGE_FACE_VERY_TIRED,
SPR_PEEP_LARGE_FACE_TIRED,
SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY,
SPR_PEEP_LARGE_FACE_VERY_UNHAPPY,
SPR_PEEP_LARGE_FACE_UNHAPPY,
SPR_PEEP_LARGE_FACE_NORMAL,
SPR_PEEP_LARGE_FACE_HAPPY,
SPR_PEEP_LARGE_FACE_VERY_HAPPY,
SPR_PEEP_LARGE_FACE_VERY_VERY_HAPPY,
};
int get_face_sprite_offset(rct_peep *peep){
// ANGRY
if (peep->var_F3) return PEEP_FACE_OFFSET_ANGRY;
// VERY_VERY_SICK
if (peep->nausea > 200) return PEEP_FACE_OFFSET_VERY_VERY_SICK;
// VERY_SICK
if (peep->nausea > 170) return PEEP_FACE_OFFSET_VERY_SICK;
// SICK
if (peep->nausea > 140) return PEEP_FACE_OFFSET_SICK;
// VERY_TIRED
if (peep->energy < 46) return PEEP_FACE_OFFSET_VERY_TIRED;
// TIRED
if (peep->energy < 70) return PEEP_FACE_OFFSET_TIRED;
int offset = PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY;
//There are 7 different happiness based faces
for (int i = 37; peep->happiness >= i; i += 37)
{
offset++;
}
return offset;
}
/**
* Function split into large and small sprite
* rct2: 0x00698721
*/
int get_peep_face_sprite_small(rct_peep *peep){
return face_sprite_small[get_face_sprite_offset(peep)];
}
/**
* Function split into large and small sprite
* rct2: 0x00698721
*/
int get_peep_face_sprite_large(rct_peep *peep){
return face_sprite_large[get_face_sprite_offset(peep)];
}

View File

@@ -296,10 +296,10 @@ enum PEEP_ITEM {
};
typedef struct {
uint8 type;
uint8 item;
uint8 var_2;
uint8 var_3;
uint8 type; //0
uint8 item; //1
uint8 var_2; //2
uint8 var_3; //3
} rct_peep_thought;
typedef struct {
@@ -332,7 +332,7 @@ typedef struct {
uint8 pad_2C;
uint8 sprite_type; // 0x2D
uint8 type; // 0x2E
uint8 staff_type; // 0x2F
uint8 staff_type; // 0x2F Also used for no_of_rides
uint8 tshirt_colour; // 0x30
uint8 trousers_colour; // 0x31
uint16 var_32;
@@ -342,7 +342,7 @@ typedef struct {
uint8 energy; // 0x38
uint8 energy_growth_rate; // 0x39
uint8 happiness; // 0x3A
uint8 happiness_growth_rate; // 0x3B
sint8 happiness_growth_rate; // 0x3B
uint8 nausea; // 0x3C
uint8 nausea_growth_rate; // 0x3D
uint8 hunger; // 0x3E
@@ -351,7 +351,7 @@ typedef struct {
uint8 pad_41[0x2];
uint8 intensity; // 0x43
uint8 nausea_tolerance; // 0x44
uint8 var_45;
uint8 var_45; // Some sort of flags?
money16 paid_on_drink; // 0x46
uint8 pad_48[0x10];
uint32 item_extra_flags; // 0x58
@@ -376,12 +376,14 @@ typedef struct {
uint8 pad_77;
uint8 var_78;
uint8 pad_79[0x03];
uint8 rides_been_on[32]; // 0x7C
uint8 rides_been_on[32]; // 0x7C
// 255 bit bitmap of every ride the peep has been on see
// window_peep_rides_update for how to use.
uint32 id; // 0x9C
money32 cash_in_pocket; // 0xA0
money32 cash_spent; // 0xA4
uint8 var_A8; // 0xA8
sint32 time_in_park; // 0xA9
sint32 time_in_park; // 0xA8
uint8 var_AC; // 0xAC
uint8 var_AD; // creation/hire time?
uint16 var_AE;
rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0
@@ -404,8 +406,8 @@ typedef struct {
uint8 no_of_drinks; // 0xED
uint8 no_of_souvenirs; // 0xEE
uint8 pad_EF;
uint8 var_F0;
uint8 var_F1;
uint8 var_F0; //voucher_type
uint8 var_F1; //voucher_type arguments i.e. ride_id
uint8 pad_F2;
uint8 var_F3;
uint8 pad_F4[0x02];
@@ -445,5 +447,8 @@ 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);
int get_peep_face_sprite_small(rct_peep *peep);
int get_peep_face_sprite_large(rct_peep *peep);
#endif

View File

@@ -491,6 +491,7 @@ const bool rideUnknownData2[0x60] = {
true, // 59 LIM Launched Roller Coaster
};
/* Data at 0x0097E3B8 */
const uint8 rideUnknownData3[0x60] = {
10, // 00 Spiral Roller coaster
10, // 01 Stand Up Coaster

View File

@@ -1508,7 +1508,7 @@ void format_string_code(unsigned char format_code, char **dest, char **args)
}
format_integer(dest, value % 60);
strcpy(*dest, value % 60 == 1 ? "sec:" : "secs:");
strcpy(*dest, value % 60 == 1 ? "sec" : "secs");
*dest += strlen(*dest);
break;
case FORMAT_REALTIME:
@@ -1523,7 +1523,7 @@ void format_string_code(unsigned char format_code, char **dest, char **args)
}
format_integer(dest, value % 60);
strcpy(*dest, value % 60 == 1 ? "min:" : "mins:");
strcpy(*dest, value % 60 == 1 ? "min" : "mins");
*dest += strlen(*dest);
break;
case FORMAT_LENGTH:
@@ -1691,4 +1691,59 @@ void reset_saved_strings() {
for (int i = 0; i < 1024; i++) {
RCT2_ADDRESS(0x135A8F4, uint8)[i * 32] = 0;
}
}
/**
* Return the length of the string in buffer.
* note you can't use strlen as there can be inline sprites!
*
* buffer (esi)
*/
int get_string_length(char* buffer)
{
// Length of string
int length = 0;
for (uint8* curr_char = (uint8*)buffer; *curr_char != (uint8)0; curr_char++) {
length++;
if (*curr_char >= 0x20) {
continue;
}
switch (*curr_char) {
case FORMAT_MOVE_X:
case FORMAT_ADJUST_PALETTE:
case 3:
case 4:
curr_char++;
length++;
break;
case FORMAT_NEWLINE:
case FORMAT_NEWLINE_SMALLER:
case FORMAT_TINYFONT:
case FORMAT_BIGFONT:
case FORMAT_MEDIUMFONT:
case FORMAT_SMALLFONT:
case FORMAT_OUTLINE:
case FORMAT_OUTLINE_OFF:
case FORMAT_WINDOW_COLOUR_1:
case FORMAT_WINDOW_COLOUR_2:
case FORMAT_WINDOW_COLOUR_3:
case 0x10:
continue;
case FORMAT_INLINE_SPRITE:
length += 4;
curr_char += 4;
break;
default:
if (*curr_char <= 0x16) { //case 0x11? FORMAT_NEW_LINE_X_Y
length += 2;
curr_char += 2;
continue;
}
length += 4;
curr_char += 4;//never happens?
break;
}
}
return length;
}

View File

@@ -30,6 +30,7 @@ void error_string_quit(int error, rct_string_id format);
char format_get_code(const char *token);
const char *format_get_token(char code);
int get_string_length(char* buffer);
enum {
// Font format codes

View File

@@ -234,7 +234,12 @@ typedef enum {
WE_RESIZE = 2,
WE_MOUSE_DOWN = 3,
WE_DROPDOWN = 4,
WE_UNKNOWN_05 = 5,
WE_UNKNOWN_05 = 5,
// Unknown 05: Used to update tabs that are not being animated
// see window_peep. When the overview tab is not highlighted the
// items being carried such as hats/balloons still need to be shown
// and removed. Probably called after anything that affects items
// being carried.
WE_UPDATE = 6,
WE_UNKNOWN_07 = 7,
WE_UNKNOWN_08 = 8,
@@ -491,6 +496,12 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct
__asm mov dropdownIndex, ax \
__asm mov widgetIndex, dx \
__asm mov w, esi
#define window_text_input_get_registers(w, widgetIndex, _cl, text) \
__asm mov widgetIndex, dx \
__asm mov _cl, cl \
__asm mov w, esi \
__asm mov text, edi
#define window_scrollmouse_get_registers(w, x, y) \
__asm mov x, cx \
@@ -519,6 +530,12 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct
__asm__ ( "mov %["#widgetIndex"], dx " : [widgetIndex] "+m" (widgetIndex) ); \
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) );
#define window_text_input_get_registers(w, widgetIndex, _cl, text) \
__asm__ ( "mov %[_cl], cl " : [_cl] "+m" (_cl) ); \
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \
__asm__ ( "mov %[w], esi " : [w] "+m" (w) ); \
__asm__ ( "mov %[text], edi " : [text] "+m" (text) );
#define window_scrollmouse_get_registers(w, x, y) \
__asm__ ( "mov %["#x"], cx " : [x] "+m" (x) ); \
__asm__ ( "mov %["#y"], dx " : [y] "+m" (y) ); \

View File

@@ -132,8 +132,7 @@ static uint8 _window_guest_list_groups_guest_faces[240 * 58];
static int window_guest_list_is_peep_in_filter(rct_peep* peep);
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);
/**
@@ -626,7 +625,7 @@ static void window_guest_list_scrollpaint()
switch (_window_guest_list_selected_view) {
case VIEW_ACTIONS:
// Guest face
gfx_draw_sprite(dpi, get_guest_face_sprite_small(peep), 118, y, 0);
gfx_draw_sprite(dpi, get_peep_face_sprite_small(peep), 118, y, 0);
// Tracking icon
if (peep->flags & PEEP_FLAGS_TRACKING)
@@ -802,7 +801,7 @@ static void window_guest_list_find_groups()
RCT2_ADDRESS(0x00F1AF26, uint8)[groupIndex] = groupIndex;
faceIndex = groupIndex * 56;
_window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep) - 5486;
_window_guest_list_groups_guest_faces[faceIndex++] = get_peep_face_sprite_small(peep) - 5486;
// Find more peeps that belong to same group
FOR_ALL_GUESTS(spriteIndex2, peep2) {
@@ -822,7 +821,7 @@ static void window_guest_list_find_groups()
// Add face sprite, cap at 56 though
if (_window_guest_list_groups_num_guests[groupIndex] >= 56)
continue;
_window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep2) - 5486;
_window_guest_list_groups_guest_faces[faceIndex++] = get_peep_face_sprite_small(peep2) - 5486;
}
if (RCT2_GLOBAL(0x00F1EDF6, uint16) == 0) {
@@ -872,75 +871,4 @@ static void window_guest_list_find_groups()
nextPeep:
;
}
}
/**
* Function split into large and small sprite
* rct2: 0x00698721
*/
static int get_guest_face_sprite_small(rct_peep *peep)
{
int sprite;
sprite = SPR_PEEP_SMALL_FACE_ANGRY;
if (peep->var_F3) return sprite;
sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_SICK;
if (peep->nausea > 200) return sprite;
sprite--; //VERY_SICK
if (peep->nausea > 170) return sprite;
sprite--; //SICK
if (peep->nausea > 140) return sprite;
sprite = SPR_PEEP_SMALL_FACE_VERY_TIRED;
if (peep->energy < 46) return sprite;
sprite--; //TIRED
if (peep->energy < 70) return sprite;
sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY;
//There are 7 different happiness based faces
for (int i = 37; peep->happiness >= i; i += 37)
{
sprite++;
}
return sprite;
}
/**
* Function split into large and small sprite
* rct2: 0x00698721
*/
static int get_guest_face_sprite_large(rct_peep* peep){
int sprite;
sprite = SPR_PEEP_LARGE_FACE_ANGRY;
if (peep->var_F3) return sprite;
sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_SICK;
if (peep->nausea > 200) return sprite;
sprite = SPR_PEEP_LARGE_FACE_VERY_SICK;
if (peep->nausea > 170) return sprite;
sprite = SPR_PEEP_LARGE_FACE_SICK;
if (peep->nausea > 140) return sprite;
sprite = SPR_PEEP_LARGE_FACE_VERY_TIRED;
if (peep->energy < 46) return sprite;
sprite--; //TIRED
if (peep->energy < 70) return sprite;
sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY;
//There are 7 different happiness based faces
for (int i = 37; peep->happiness >= i; i += 37)
{
sprite++;
}
return sprite;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -333,7 +333,7 @@ void window_staff_peep_disable_widgets(rct_window* w)
}
/**
* Same as window_peep_close.
* Same as window_peep_overview_close.
* rct2: 0x006BDFF8
*/
void window_staff_peep_overview_close()

View File

@@ -223,6 +223,7 @@ static void window_scenarioselect_scrollgetsize()
}
/* rct2: 0x6780FE */
static void window_scenarioselect_scrollmousedown()
{
int i;
@@ -249,6 +250,7 @@ static void window_scenarioselect_scrollmousedown()
}
}
/* rct2: 0x678162 */
static void window_scenarioselect_scrollmouseover()
{
int i;