From 2f8402e46154eaf371702bc96298bfeb2b75fa0e Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 21 Sep 2014 15:38:55 +0100 Subject: [PATCH] refactor peep easter egg names --- src/peep.c | 91 ++++++++++++++++++++++++++++++++++-------------------- src/peep.h | 32 ++++++++++++++++++- src/ride.c | 60 +++++++++++++++++------------------ 3 files changed, 118 insertions(+), 65 deletions(-) diff --git a/src/peep.c b/src/peep.c index d798790f79..623fff5273 100644 --- a/src/peep.c +++ b/src/peep.c @@ -32,6 +32,35 @@ static void peep_update(rct_peep *peep); +const char *gPeepEasterEggNames[] = { + "MICHAEL SCHUMACHER", + "JACQUES VILLENEUVE", + "DAMON HILL", + "MR BEAN", + "CHRIS SAWYER", + "KATIE BRAYSHAW", + "MELANIE WARN", + "SIMON FOSTER", + "JOHN WARDLEY", + "LISA STIRLING", + "DONALD MACRAE", + "KATHERINE MCGOWAN", + "FRANCES MCGOWAN", + "CORINA MASSOURA", + "CAROL YOUNG", + "MIA SHERIDAN", + "KATIE RODGER", + "EMMA GARRELL", + "JOANNE BARTON", + "FELICITY ANDERSON", + "KATIE SMITH", + "EILIDH BELL", + "NANCY STILLWAGON", + "ANDY HINE", + "ELISSA WHITE", + "DAVID ELLIS" +}; + int peep_get_staff_count() { uint16 spriteIndex; @@ -669,53 +698,49 @@ int get_face_sprite_offset(rct_peep *peep){ } /** -* Function split into large and small sprite -* rct2: 0x00698721 -*/ + * 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 -*/ + * 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)]; } /** -* -* rct2: 0x0069A5A0 -* tests if a peep's name matches a cheat code, normally returns using a register flag -* @param index (eax) -* @param ride (esi) -*/ -int peep_check_cheatcode(int index, rct_peep *peep) + * + * rct2: 0x0069A5A0 + * tests if a peep's name matches a cheat code, normally returns using a register flag + * @param index (eax) + * @param ride (esi) + */ +int peep_check_easteregg_name(int index, rct_peep *peep) { - char* str = RCT2_ADDRESS(RCT2_ADDRESS_EASTEREGG_NAMES, char*)[index]; - char* dst = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER; - format_string(dst, peep->name_string_idx, &peep->id); + char buffer[256]; - // strtoupper: - int i = 0; - while(dst[i]) { - if (dst[i] >= 0x61 && dst[i] <= 0x7A) { - dst[i] -= 0x20; - } - i++; - } + format_string(buffer, peep->name_string_idx, &peep->id); + return _stricmp(buffer, gPeepEasterEggNames[index]) == 0; +} - // check for match, characters are -1 to obfuscate the cheat codes - i = 0; - while(str[i] + 1) { - if (str[i] + 1 != dst[i]) { - return 0; - } - i++; - } +int peep_get_easteregg_name_id(rct_peep *peep) +{ + char buffer[256]; + int i; + + format_string(buffer, peep->name_string_idx, &peep->id); + + for (i = 0; i < countof(gPeepEasterEggNames); i++) + if (_stricmp(buffer, gPeepEasterEggNames[i]) == 0) + return i; + + return -1; - return 1; } int peep_is_mechanic(rct_peep *peep) diff --git a/src/peep.h b/src/peep.h index 78569e99be..858047cdfb 100644 --- a/src/peep.h +++ b/src/peep.h @@ -426,6 +426,35 @@ typedef struct { uint32 item_standard_flags; // 0xFC } rct_peep; +enum { + EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER, + EASTEREGG_PEEP_NAME_JACQUES_VILLENEUVE, + EASTEREGG_PEEP_NAME_DAMON_HILL, + EASTEREGG_PEEP_NAME_MR_BEAN, + EASTEREGG_PEEP_NAME_CHRIS_SAWYER, + EASTEREGG_PEEP_NAME_KATIE_BRAYSHAW, + EASTEREGG_PEEP_NAME_MELANIE_WARN, + EASTEREGG_PEEP_NAME_SIMON_FOSTER, + EASTEREGG_PEEP_NAME_JOHN_WARDLEY, + EASTEREGG_PEEP_NAME_LISA_STIRLING, + EASTEREGG_PEEP_NAME_DONALD_MACRAE, + EASTEREGG_PEEP_NAME_KATHERINE_MCGOWAN, + EASTEREGG_PEEP_NAME_FRANCES_MCGOWAN, + EASTEREGG_PEEP_NAME_CORINA_MASSOURA, + EASTEREGG_PEEP_NAME_CAROL_YOUNG, + EASTEREGG_PEEP_NAME_MIA_SHERIDAN, + EASTEREGG_PEEP_NAME_KATIE_RODGER, + EASTEREGG_PEEP_NAME_EMMA_GARRELL, + EASTEREGG_PEEP_NAME_JOANNE_BARTON, + EASTEREGG_PEEP_NAME_FELICITY_ANDERSON, + EASTEREGG_PEEP_NAME_KATIE_SMITH, + EASTEREGG_PEEP_NAME_EILIDH_BELL, + EASTEREGG_PEEP_NAME_NANCY_STILLWAGON, + EASTEREGG_PEEP_NAME_ANDY_HINE, + EASTEREGG_PEEP_NAME_ELISSA_WHITE, + EASTEREGG_PEEP_NAME_DAVID_ELLIS +}; + /** Helper macro until rides are stored in this module. */ #define GET_PEEP(sprite_index) &(g_sprite_list[sprite_index].peep) @@ -456,7 +485,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum 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); -int peep_check_cheatcode(int index, rct_peep *peep); +int peep_check_easteregg_name(int index, rct_peep *peep); +int peep_get_easteregg_name_id(rct_peep *peep); int peep_is_mechanic(rct_peep *peep); #endif diff --git a/src/ride.c b/src/ride.c index 2effab9c45..0e21718909 100644 --- a/src/ride.c +++ b/src/ride.c @@ -590,48 +590,46 @@ vehicle_colour ride_get_vehicle_colour(rct_ride *ride, int vehicleIndex) } /** -* -* rct2: 0x006AC988 -* set the speed of the gokart type vehicle at the start to a random value or alter if peep name is a cheat code -* @param ride (esi) -*/ + * + * rct2: 0x006AC988 + * set the speed of the go kart type vehicle at the start to a random value or alter if peep name is an easter egg + * @param ride (esi) + */ void ride_init_vehicle_speed(rct_ride *ride) { - int ecx = -1; - while (1) { - ecx++; - if (ecx >= ride->num_vehicles) { - break; - } - rct_vehicle *vehicle = &g_sprite_list[ride->vehicles[ecx]].vehicle; - vehicle->var_48 &= (1 << 6); - uint8 r = scenario_rand(); - r = 0xC; - r &= 0xF; - r -= 8; + rct_ride_type *rideEntry; + rct_vehicle *vehicle; + uint8 *unk; + int i; - int testaddr = (vehicle->var_31 * 0x65); - testaddr += (int)RCT2_ADDRESS(0x009ACFA4, rct_ride_type*)[vehicle->var_D6]; - uint8 test = ((uint8*)testaddr)[0x76]; - r += test; + for (i = 0; i < ride->num_vehicles; i++) { + vehicle = &g_sprite_list[ride->vehicles[i]].vehicle; + vehicle->var_48 &= ~(1 << 6); + + rideEntry = GET_RIDE_ENTRY(vehicle->var_D6); + unk = (uint8*)((int)rideEntry + (vehicle->var_31 * 0x65)); + + vehicle->speed = (scenario_rand() & 16) - 8 + RCT2_GLOBAL(unk + 0x76, uint8); - vehicle->speed = r; if (vehicle->var_B3) { rct_peep *peep = &g_sprite_list[vehicle->peep].peep; - if (peep_check_cheatcode(0, peep)) { // MICHAEL SCHUMACHER + + switch (peep_get_easteregg_name_id(peep)) { + case EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER: vehicle->speed += 35; - } - if (peep_check_cheatcode(1, peep)) { // JACQUES VILLENEUVE + break; + case EASTEREGG_PEEP_NAME_JACQUES_VILLENEUVE: vehicle->speed += 25; - } - if (peep_check_cheatcode(2, peep)) { // DAMON HILL + break; + case EASTEREGG_PEEP_NAME_DAMON_HILL: vehicle->speed += 55; - } - if (peep_check_cheatcode(4, peep)) { // CHRIS SAWYER + break; + case EASTEREGG_PEEP_NAME_CHRIS_SAWYER: vehicle->speed += 14; - } - if (peep_check_cheatcode(3, peep)) { // MR BEAN + break; + case EASTEREGG_PEEP_NAME_MR_BEAN: vehicle->speed = 9; + break; } } }