Fix #4071: Guests paid when free entry park flag

Make most usages of park entrance fee use a common function which does the necessary checks.
This commit is contained in:
Ted John 2016-07-13 19:48:42 +01:00
parent c09780967b
commit 04340021f6
7 changed files with 35 additions and 25 deletions

View File

@ -162,7 +162,7 @@ static int award_is_deserved_best_value(int awardType, int activeAwardTypes)
return 0;
if (gTotalRideValue < MONEY(10, 00))
return 0;
if (gParkEntranceFee + MONEY(0, 10) >= gTotalRideValue / 2)
if (park_get_entrance_fee() + MONEY(0, 10) >= gTotalRideValue / 2)
return 0;
return 1;
}
@ -210,9 +210,11 @@ static int award_is_deserved_worse_value(int awardType, int activeAwardTypes)
return 0;
if (gParkFlags & PARK_FLAGS_NO_MONEY)
return 0;
if (gParkEntranceFee == MONEY(0, 00))
money32 parkEntranceFee = park_get_entrance_fee();
if (parkEntranceFee == MONEY(0, 00))
return 0;
if (gTotalRideValue >= gParkEntranceFee)
if (gTotalRideValue >= parkEntranceFee)
return 0;
return 1;
}

View File

@ -48,11 +48,11 @@ int marketing_get_campaign_guest_generation_probability(int campaign)
// Lower probability of guest generation if price was already low
switch (campaign) {
case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE:
if (gParkEntranceFee < 4)
if (park_get_entrance_fee() < 4)
probability /= 8;
break;
case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE:
if (gParkEntranceFee < 6)
if (park_get_entrance_fee() < 6)
probability /= 8;
break;
case ADVERTISING_CAMPAIGN_RIDE_FREE:

View File

@ -7052,8 +7052,8 @@ static int peep_interact_with_entrance(rct_peep* peep, sint16 x, sint16 y, rct_m
return peep_return_to_center_of_tile(peep);
}
money16 entranceFee = gParkEntranceFee;
if (entranceFee != 0 && !(gParkFlags & PARK_FLAGS_NO_MONEY)){
money16 entranceFee = park_get_entrance_fee();
if (entranceFee != 0) {
if (peep->item_standard_flags & PEEP_ITEM_VOUCHER){
if (peep->voucher_type == VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE){
entranceFee /= 2;

View File

@ -374,17 +374,15 @@ void scenario_entrance_fee_too_high_check()
{
uint16 x = 0, y = 0;
money16 totalRideValue = gTotalRideValue;
money16 park_entrance_fee = gParkEntranceFee;
money16 max_fee = totalRideValue + (totalRideValue / 2);
uint32 game_flags = gParkFlags, packed_xy;
if ((game_flags & PARK_FLAGS_PARK_OPEN) && !(game_flags & PARK_FLAGS_NO_MONEY) && park_entrance_fee > max_fee) {
if ((gParkFlags & PARK_FLAGS_PARK_OPEN) && park_get_entrance_fee() > max_fee) {
for (int i = 0; gParkEntranceX[i] != SPRITE_LOCATION_NULL; i++) {
x = gParkEntranceX[i] + 16;
y = gParkEntranceY[i] + 16;
}
packed_xy = (y << 16) | x;
uint32 packed_xy = (y << 16) | x;
if (gConfigNotifications.park_warnings) {
news_item_add_to_queue(NEWS_ITEM_BLANK, STR_ENTRANCE_FEE_TOO_HI, packed_xy);
}

View File

@ -1455,8 +1455,9 @@ static void window_park_price_invalidate(rct_window *w)
window_park_prepare_window_title_text();
// If the entry price is locked at free, disable the widget, unless the unlock_all_prices cheat is active.
if ((gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY)
&& (!gCheatsUnlockAllPrices)) {
if ((gParkFlags & PARK_FLAGS_NO_MONEY) ||
((gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY) && !gCheatsUnlockAllPrices)
) {
window_park_price_widgets[WIDX_PRICE].type = WWT_12;
window_park_price_widgets[WIDX_INCREASE_PRICE].type = WWT_EMPTY;
window_park_price_widgets[WIDX_DECREASE_PRICE].type = WWT_EMPTY;
@ -1466,8 +1467,9 @@ static void window_park_price_invalidate(rct_window *w)
window_park_price_widgets[WIDX_DECREASE_PRICE].type = WWT_DROPDOWN_BUTTON;
}
set_format_arg(6, uint32, gParkEntranceFee);
window_park_price_widgets[WIDX_PRICE].image = gParkEntranceFee == 0 ? STR_FREE : 1429;
money16 parkEntranceFee = park_get_entrance_fee();
set_format_arg(6, uint32, parkEntranceFee);
window_park_price_widgets[WIDX_PRICE].image = parkEntranceFee == 0 ? STR_FREE : 1429;
window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_7);
window_park_anchor_border_widgets(w);

View File

@ -440,17 +440,14 @@ static int park_calculate_guest_generation_probability()
if (numGuests > 7000)
probability /= 4;
// Check if money is enabled
if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) {
// Penalty for overpriced entrance fee relative to total ride value
money16 entranceFee = gParkEntranceFee;
if (entranceFee > totalRideValue) {
probability /= 4;
// Penalty for overpriced entrance fee relative to total ride value
money16 entranceFee = park_get_entrance_fee();
if (entranceFee > totalRideValue) {
probability /= 4;
// Extra penalty for very overpriced entrance fee
if (entranceFee / 2 > totalRideValue)
probability /= 4;
}
// Extra penalty for very overpriced entrance fee
if (entranceFee / 2 > totalRideValue)
probability /= 4;
}
// Reward or penalties for park awards
@ -1179,3 +1176,12 @@ money32 park_place_ghost_entrance(int x, int y, int z, int direction)
}
return result;
}
money16 park_get_entrance_fee()
{
if (gParkFlags & PARK_FLAGS_NO_MONEY) return 0;
if (!gCheatsUnlockAllPrices) {
if (gParkFlags & PARK_FLAGS_PARK_FREE_ENTRY) return 0;
}
return gParkEntranceFee;
}

View File

@ -113,4 +113,6 @@ void map_invalidate_tile(int x, int y, int z0, int z1);
void park_remove_ghost_entrance();
money32 park_place_ghost_entrance(int x, int y, int z, int direction);
money16 park_get_entrance_fee();
#endif