2014-04-08 01:41:35 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Copyright (c) 2014 Ted John
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* This file is part of OpenRCT2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2014-05-20 12:49:27 +02:00
|
|
|
#include <windows.h>
|
2014-04-08 01:41:35 +02:00
|
|
|
#include "addresses.h"
|
2014-05-11 01:35:45 +02:00
|
|
|
#include "finance.h"
|
2014-05-01 20:35:47 +02:00
|
|
|
#include "map.h"
|
2014-05-26 00:17:55 +02:00
|
|
|
#include "marketing.h"
|
2014-04-08 01:41:35 +02:00
|
|
|
#include "park.h"
|
|
|
|
#include "peep.h"
|
|
|
|
#include "ride.h"
|
2014-05-11 01:35:45 +02:00
|
|
|
#include "scenario.h"
|
2014-04-08 01:41:35 +02:00
|
|
|
#include "sprite.h"
|
2014-05-19 21:04:28 +02:00
|
|
|
#include "string_ids.h"
|
2014-05-01 20:35:47 +02:00
|
|
|
#include "window.h"
|
2014-04-08 01:41:35 +02:00
|
|
|
|
2014-04-16 03:05:49 +02:00
|
|
|
int park_is_open()
|
|
|
|
{
|
2014-05-03 13:39:36 +02:00
|
|
|
return (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_PARK_OPEN) != 0;
|
2014-04-16 03:05:49 +02:00
|
|
|
}
|
|
|
|
|
2014-04-09 18:06:47 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00667132
|
|
|
|
*/
|
|
|
|
void park_init()
|
|
|
|
{
|
2014-05-11 01:35:45 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x013CA740, uint8) = 0;
|
|
|
|
RCT2_GLOBAL(0x013573D4, uint16) = 777;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8) = 28;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_MECHANIC_COLOUR, uint8) = 28;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_SECURITY_COLOUR, uint8) = 28;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) = 0;
|
|
|
|
RCT2_GLOBAL(0x01357BC8, uint16) = 0;
|
|
|
|
RCT2_GLOBAL(0x01357846, uint16) = 0;
|
|
|
|
RCT2_GLOBAL(0x013573FE, uint16) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) = 0;
|
2014-05-25 14:59:31 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_GENERATION_PROBABILITY, uint16) = 0;
|
2014-05-11 01:35:45 +02:00
|
|
|
RCT2_GLOBAL(0x013580EE, uint16) = 0;
|
|
|
|
RCT2_GLOBAL(0x01357CF4, sint32) = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < 20; i++)
|
|
|
|
RCT2_ADDRESS(0x01358102, uint8)[i] = 0;
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x01358844, uint32) = 0xFFFFFFFF;
|
|
|
|
RCT2_GLOBAL(0x01358849, uint32) = 0xFFFFFFFE;
|
|
|
|
RCT2_GLOBAL(0x0135884E, uint32) = 0xFFFFFFFD;
|
|
|
|
finance_init();
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
RCT2_ADDRESS(0x01357404, uint32)[i] = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 56; i++)
|
|
|
|
RCT2_ADDRESS(0x01357BD0, sint32)[i] = -1;
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, money16) = MONEY(10, 00);
|
2014-05-11 01:35:45 +02:00
|
|
|
RCT2_GLOBAL(0x013573F2, sint16) = -1;
|
|
|
|
RCT2_GLOBAL(0x013573F8, sint16) = -1;
|
|
|
|
RCT2_GLOBAL(0x01357CF2, uint16) = 127;
|
2014-05-13 23:37:45 +02:00
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8) = 2;
|
2014-05-11 01:35:45 +02:00
|
|
|
|
|
|
|
RCT2_GLOBAL(0x013580F4, uint16) = 500;
|
|
|
|
RCT2_GLOBAL(0x013580E9, uint8) = 128;
|
|
|
|
RCT2_GLOBAL(0x013580F6, uint8) = 200;
|
|
|
|
RCT2_GLOBAL(0x013580F7, uint8) = 200;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) = 1;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8) = 4;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16) = 1000;
|
|
|
|
RCT2_GLOBAL(0x01358770, uint16) = 900;
|
|
|
|
RCT2_GLOBAL(0x01358772, uint16) = 400;
|
|
|
|
RCT2_GLOBAL(0x01358774, uint16) = 0;
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
2014-05-11 02:18:56 +02:00
|
|
|
park_reset_awards_and_history();
|
2014-05-11 01:35:45 +02:00
|
|
|
|
2014-05-12 02:45:45 +02:00
|
|
|
rct_s6_info *info = (rct_s6_info*)0x0141F570;
|
2014-05-11 01:35:45 +02:00
|
|
|
info->name[0] = '\0';
|
|
|
|
format_string(info->details, STR_NO_DETAILS_YET, NULL);
|
2014-04-09 18:06:47 +02:00
|
|
|
}
|
|
|
|
|
2014-05-11 02:18:56 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066729F
|
|
|
|
*/
|
|
|
|
void park_reset_awards_and_history()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Reset park rating and guests in park history
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8)[i] = 255;
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8)[i] = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset finance history
|
|
|
|
for (i = 0; i < 128; i++) {
|
2014-05-23 13:15:08 +02:00
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, money32)[i] = MONEY32_UNDEFINED;
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_WEEKLY_PROFIT_HISTORY, money32)[i] = MONEY32_UNDEFINED;
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_VALUE_HISTORY, money32)[i] = MONEY32_UNDEFINED;
|
2014-05-11 02:18:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reset awards
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_AWARD_LIST, rct_award)[i].time = 0;
|
|
|
|
}
|
|
|
|
|
2014-05-01 20:35:47 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066A348
|
|
|
|
*/
|
|
|
|
int park_calculate_size()
|
|
|
|
{
|
|
|
|
int tiles, x, y;
|
|
|
|
rct_map_element *mapElement;
|
|
|
|
|
|
|
|
tiles = 0;
|
|
|
|
for (y = 0; y < 256; y++) {
|
|
|
|
for (x = 0; x < 256; x++) {
|
|
|
|
mapElement = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[y * 256 + x];
|
|
|
|
while (mapElement->type & MAP_ELEMENT_TYPE_MASK) {
|
|
|
|
mapElement++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mapElement->properties.surface.ownership & 0x30)
|
|
|
|
tiles++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-05 21:59:59 +02:00
|
|
|
if (tiles != RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, sint16)) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_PARK_SIZE, sint16) = tiles;
|
2014-05-01 20:35:47 +02:00
|
|
|
window_invalidate_by_id(WC_PARK_INFORMATION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tiles;
|
|
|
|
}
|
|
|
|
|
2014-04-08 01:41:35 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00669EAA
|
|
|
|
*/
|
|
|
|
int calculate_park_rating()
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = 1150;
|
2014-05-03 13:39:36 +02:00
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x4000)
|
2014-04-08 01:41:35 +02:00
|
|
|
result = 1050;
|
|
|
|
|
|
|
|
// Guests
|
|
|
|
{
|
|
|
|
rct_peep* peep;
|
|
|
|
uint16 sprite_idx;
|
|
|
|
int num_happy_peeps;
|
|
|
|
short _bp;
|
|
|
|
|
|
|
|
// -150 to +3 based on a range of guests from 0 to 2000
|
|
|
|
result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13);
|
|
|
|
|
|
|
|
// Guests, happiness, ?
|
|
|
|
num_happy_peeps = 0;
|
|
|
|
_bp = 0;
|
|
|
|
for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) {
|
|
|
|
peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep);
|
|
|
|
if (peep->type != PEEP_TYPE_GUEST)
|
|
|
|
continue;
|
|
|
|
if (peep->var_2A != 0)
|
|
|
|
continue;
|
|
|
|
if (peep->happiness > 128)
|
|
|
|
num_happy_peeps++;
|
2014-05-03 17:04:14 +02:00
|
|
|
if (!(peep->flags & PEEP_FLAGS_LEAVING_PARK))
|
2014-04-08 01:41:35 +02:00
|
|
|
continue;
|
|
|
|
if (peep->var_C6 <= 89)
|
|
|
|
_bp++;
|
|
|
|
}
|
2014-05-06 22:54:42 +02:00
|
|
|
|
2014-04-08 01:41:35 +02:00
|
|
|
// Peep happiness -500 to +0
|
|
|
|
result -= 500;
|
2014-05-06 22:54:42 +02:00
|
|
|
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) > 0)
|
|
|
|
result += 2 * min(250, (num_happy_peeps * 300) / RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16));
|
2014-04-08 01:41:35 +02:00
|
|
|
|
|
|
|
// ?
|
|
|
|
_bp -= 25;
|
|
|
|
if (_bp >= 0)
|
|
|
|
result -= _bp * 7;
|
|
|
|
}
|
2014-05-06 22:54:42 +02:00
|
|
|
|
2014-04-08 01:41:35 +02:00
|
|
|
// Rides
|
|
|
|
{
|
|
|
|
int i;
|
2014-05-07 20:44:13 +02:00
|
|
|
short _ax, total_ride_intensity = 0, total_ride_excitement = 0, average_intensity, average_excitement;
|
|
|
|
int num_rides, num_exciting_rides = 0;
|
2014-04-08 01:41:35 +02:00
|
|
|
rct_ride* ride;
|
|
|
|
|
|
|
|
//
|
|
|
|
_ax = 0;
|
|
|
|
num_rides = 0;
|
|
|
|
for (i = 0; i < 255; i++) {
|
|
|
|
ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]);
|
|
|
|
|
|
|
|
if (ride->type == RIDE_TYPE_NULL)
|
|
|
|
continue;
|
|
|
|
_ax += 100 - ride->var_199;
|
2014-05-07 20:44:13 +02:00
|
|
|
|
|
|
|
if (ride->excitement != -1){
|
|
|
|
total_ride_excitement += ride->excitement / 8;
|
|
|
|
total_ride_intensity += ride->intensity / 8;
|
|
|
|
num_exciting_rides++;
|
|
|
|
}
|
2014-04-08 01:41:35 +02:00
|
|
|
num_rides++;
|
|
|
|
}
|
|
|
|
result -= 200;
|
|
|
|
if (num_rides > 0)
|
|
|
|
result += (_ax / num_rides) * 2;
|
|
|
|
|
2014-05-07 20:44:13 +02:00
|
|
|
result -= 100;
|
2014-04-08 01:41:35 +02:00
|
|
|
|
2014-05-07 20:44:13 +02:00
|
|
|
if (num_exciting_rides>0){
|
|
|
|
average_excitement = total_ride_excitement / num_exciting_rides;
|
|
|
|
average_intensity = total_ride_intensity / num_exciting_rides;
|
|
|
|
|
|
|
|
average_excitement -= 46;
|
|
|
|
if (average_excitement < 0){
|
|
|
|
average_excitement = -average_excitement;
|
|
|
|
}
|
|
|
|
|
|
|
|
average_intensity -= 65;
|
|
|
|
if (average_intensity < 0){
|
|
|
|
average_intensity = -average_intensity;
|
|
|
|
}
|
|
|
|
|
|
|
|
average_excitement = min(average_excitement / 2, 50);
|
|
|
|
average_intensity = min(average_intensity / 2, 50);
|
|
|
|
result += 100 - average_excitement - average_intensity;
|
2014-04-08 01:41:35 +02:00
|
|
|
}
|
2014-05-07 20:44:13 +02:00
|
|
|
|
|
|
|
total_ride_excitement = min(1000, total_ride_excitement);
|
|
|
|
total_ride_intensity = min(1000, total_ride_intensity);
|
|
|
|
result -= 200 - ((total_ride_excitement + total_ride_intensity) / 10);
|
2014-04-08 01:41:35 +02:00
|
|
|
}
|
2014-05-07 20:44:13 +02:00
|
|
|
|
2014-04-08 01:41:35 +02:00
|
|
|
// Litter
|
|
|
|
{
|
|
|
|
rct_litter* litter;
|
|
|
|
uint16 sprite_idx;
|
|
|
|
short num_litter;
|
|
|
|
|
|
|
|
num_litter = 0;
|
|
|
|
for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_LITTER, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = litter->next) {
|
|
|
|
litter = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].litter);
|
|
|
|
|
|
|
|
// Guessing this eliminates recently dropped litter
|
2014-05-07 20:46:30 +02:00
|
|
|
if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, uint32) >= 7680)
|
2014-04-08 01:41:35 +02:00
|
|
|
num_litter++;
|
|
|
|
}
|
|
|
|
result -= 600 - (4 * (150 - min(150, num_litter)));
|
|
|
|
}
|
2014-05-07 20:44:13 +02:00
|
|
|
|
2014-04-08 01:41:35 +02:00
|
|
|
result -= RCT2_GLOBAL(0x0135882E, sint16);
|
|
|
|
result = clamp(0, result, 999);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
money32 calculate_ride_value(rct_ride *ride)
|
|
|
|
{
|
|
|
|
if (ride->type == RIDE_TYPE_NULL)
|
|
|
|
return 0;
|
|
|
|
if (ride->reliability == 0xFFFF)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Reliability * (...)
|
|
|
|
return (ride->reliability * 10) * (
|
|
|
|
ride->var_124 + ride->var_126 + ride->var_128 + ride->var_12A +
|
|
|
|
ride->var_12C + ride->var_12E + ride->age + ride->running_cost +
|
|
|
|
ride->var_134 + ride->var_136 +
|
|
|
|
*((uint8*)(0x0097D21E + (ride->type * 8))) * 4
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-04-08 01:41:35 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066A3F6
|
|
|
|
*/
|
2014-05-23 13:15:08 +02:00
|
|
|
money32 calculate_park_value()
|
2014-04-08 01:41:35 +02:00
|
|
|
{
|
2014-05-23 13:15:08 +02:00
|
|
|
int i;
|
|
|
|
money32 result;
|
2014-04-08 01:41:35 +02:00
|
|
|
rct_ride* ride;
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
// Sum ride values
|
2014-04-08 01:41:35 +02:00
|
|
|
result = 0;
|
|
|
|
for (i = 0; i < 255; i++) {
|
|
|
|
ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]);
|
2014-05-23 13:15:08 +02:00
|
|
|
result += calculate_ride_value(ride);
|
2014-04-08 01:41:35 +02:00
|
|
|
}
|
|
|
|
|
2014-05-23 13:15:08 +02:00
|
|
|
// +7.00 per guest
|
|
|
|
result += RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) * MONEY(7, 00);
|
2014-04-08 01:41:35 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-23 13:15:08 +02:00
|
|
|
* Calculate the company value.
|
|
|
|
* Cash + Park Value - Loan
|
|
|
|
*
|
2014-04-08 01:41:35 +02:00
|
|
|
* rct2: 0x0066A498
|
|
|
|
*/
|
2014-05-23 13:15:08 +02:00
|
|
|
money32 calculate_company_value()
|
2014-04-08 01:41:35 +02:00
|
|
|
{
|
2014-05-23 13:15:08 +02:00
|
|
|
return
|
|
|
|
DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)) +
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) -
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
|
2014-04-21 11:27:48 +02:00
|
|
|
}
|
2014-05-06 23:04:09 +02:00
|
|
|
|
|
|
|
/**
|
2014-05-25 14:59:31 +02:00
|
|
|
*
|
|
|
|
* rct2: 0x00667104
|
|
|
|
*/
|
2014-05-23 13:15:08 +02:00
|
|
|
void reset_park_entrances()
|
|
|
|
{
|
2014-05-06 23:04:09 +02:00
|
|
|
RCT2_GLOBAL(0x013573D4, uint16) = 0;
|
|
|
|
|
|
|
|
for (short i = 0; i < 4; i++) {
|
|
|
|
RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] = 0x8000;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCT2_GLOBAL(0x013573F2, uint16) = 0xFFFF;
|
|
|
|
RCT2_GLOBAL(0x013573F8, uint16) = 0xFFFF;
|
|
|
|
}
|
2014-05-25 14:59:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0066730A
|
|
|
|
*/
|
|
|
|
static int park_calculate_guest_generation_probability()
|
|
|
|
{
|
|
|
|
int eax, ebx, ecx, edx, esi, edi, ebp;
|
|
|
|
RCT2_CALLFUNC_X(0x0066730A, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
|
|
|
return eax & 0xFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_random_peep_spawn(rct2_peep_spawn *spawn)
|
|
|
|
{
|
|
|
|
rct2_peep_spawn *peepSpawns = RCT2_ADDRESS(RCT2_ADDRESS_PEEP_SPAWNS, rct2_peep_spawn);
|
|
|
|
|
|
|
|
*spawn = peepSpawns[0];
|
|
|
|
if (peepSpawns[1].x != 0xFFFF)
|
|
|
|
if (scenario_rand() & 0x80000)
|
|
|
|
*spawn = peepSpawns[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static rct_peep *park_generate_new_guest()
|
|
|
|
{
|
|
|
|
rct_peep *peep;
|
|
|
|
rct2_peep_spawn spawn;
|
|
|
|
get_random_peep_spawn(&spawn);
|
|
|
|
|
|
|
|
if (spawn.x != 0xFFFF) {
|
|
|
|
spawn.z *= 16;
|
|
|
|
spawn.direction ^= 2;
|
|
|
|
peep = peep_generate(spawn.x, spawn.y, spawn.z);
|
|
|
|
if (peep != NULL) {
|
|
|
|
peep->var_1E = spawn.direction << 3;
|
|
|
|
|
|
|
|
// Get the centre point of the tile the peep is on
|
|
|
|
peep->var_32 = (peep->x & 0xFFE0) + 16;
|
|
|
|
peep->var_34 = (peep->y & 0xFFE0) + 16;
|
|
|
|
|
|
|
|
peep->var_36 = 5;
|
|
|
|
peep->var_76 = 0;
|
|
|
|
peep->var_78 = spawn.direction;
|
|
|
|
peep->var_37 = 0;
|
|
|
|
peep->state = PEEP_STATE_ENTERING_PARK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return peep;
|
|
|
|
}
|
|
|
|
|
|
|
|
static rct_peep *park_generate_new_guest_due_to_campaign(int campaign)
|
|
|
|
{
|
|
|
|
rct_peep *peep = park_generate_new_guest();
|
2014-05-26 00:17:55 +02:00
|
|
|
if (peep != NULL)
|
|
|
|
marketing_set_guest_campaign(peep, campaign);
|
2014-05-25 19:40:11 +02:00
|
|
|
return peep;
|
2014-05-25 14:59:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void park_generate_new_guests()
|
|
|
|
{
|
2014-05-26 00:17:55 +02:00
|
|
|
// Generate a new guest for some probability
|
|
|
|
if ((scenario_rand() & 0xFFFF) < RCT2_GLOBAL(0x013580EC, uint16)) {
|
|
|
|
int difficultGeneration = (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) != 0;
|
|
|
|
if (!difficultGeneration || RCT2_GLOBAL(0x0135883C, uint16) + 150 < RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16))
|
|
|
|
park_generate_new_guest();
|
|
|
|
}
|
2014-05-25 14:59:31 +02:00
|
|
|
|
|
|
|
// Extra guests generated by advertising campaigns
|
|
|
|
int campaign;
|
|
|
|
for (campaign = 0; campaign < ADVERTISING_CAMPAIGN_COUNT; campaign++) {
|
|
|
|
if (RCT2_ADDRESS(0x01358102, uint8)[campaign] != 0) {
|
|
|
|
// Random chance of guest generation
|
2014-05-26 00:17:55 +02:00
|
|
|
if ((scenario_rand() & 0xFFFF) < marketing_get_campaign_guest_generation_probability(campaign))
|
2014-05-25 14:59:31 +02:00
|
|
|
park_generate_new_guest_due_to_campaign(campaign);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006674F7
|
|
|
|
*/
|
|
|
|
void park_update()
|
|
|
|
{
|
|
|
|
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Every 5 seconds approximately
|
|
|
|
if (RCT2_GLOBAL(0x013628F4, uint8) % 512 == 0) {
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, uint16) = calculate_park_rating();
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, money32) = calculate_park_value();
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, money32) = calculate_company_value();
|
|
|
|
window_invalidate_by_id(WC_FINANCES, 0);
|
|
|
|
RCT2_GLOBAL(RCT2_ADDRESS_GUEST_GENERATION_PROBABILITY, uint16) = park_calculate_guest_generation_probability();
|
|
|
|
RCT2_GLOBAL(0x009A9804, uint16) |= 0x10;
|
|
|
|
window_invalidate_by_id(WC_PARK_INFORMATION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate new guests
|
|
|
|
park_generate_new_guests();
|
|
|
|
}
|