From 33a88fbdbd0b886b9e03c0f958e79c8529b778cb Mon Sep 17 00:00:00 2001 From: chaitanyathengdi Date: Sat, 25 Jul 2020 11:49:51 +0530 Subject: [PATCH] Fix #10946: On-ride photo profit assumes every guest buys one (#12285) * Use stored values of customers to adjust income from on-ride photos Use stored values of photos sold and total customers to calculate ratio and use that to predict income per hour for rides that include on-ride-photo sections. * Get rid of float * Fix formatting * Fix formatting - again * Review changes * Fix formatting * Use new method of checking on-ride photo * Use constants * Add a changelog and contributors entry --- contributors.md | 1 + distribution/changelog.txt | 1 + src/openrct2/ride/Ride.cpp | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/contributors.md b/contributors.md index 30a9a3cfff..f70cbf8ba3 100644 --- a/contributors.md +++ b/contributors.md @@ -147,6 +147,7 @@ The following people are not part of the development team, but have been contrib * Michael Coates (outerwear) * Reid Baris (Rdbaris) * Deanna Baris (dbaris) +* Chaitanya Thengdi (chaitanyathengdi) ## Toolchain * (Balletie) - macOS diff --git a/distribution/changelog.txt b/distribution/changelog.txt index cd5b8128f1..e641405cad 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -48,6 +48,7 @@ - Fix: [#12123] Long server descriptions are not cut off properly. - Fix: [#12211] Map Generator shows incorrect map sizes (e.g. "150 x 0"). - Fix: [#12221] Map Generation tool doesn't place any trees. +- Fix: [#12285] On-ride photo profit assumes every guest buys one. - Fix: [#12312] Softlock when loading save file via command line fails. - Fix: RCT1 scenarios have more items in the object list than are present in the park or the research list. - Improved: [#6530] Allow water and land height changes on park borders. diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index b4bd34ee61..a0238c7384 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -396,8 +396,24 @@ money32 Ride::CalculateIncomePerHour() const if (currentShopItem != SHOP_ITEM_NONE) { - priceMinusCost += price[1]; - priceMinusCost -= ShopItems[currentShopItem].Cost; + const money16 shopItemProfit = price[1] - ShopItems[currentShopItem].Cost; + + if (ShopItems[currentShopItem].IsPhoto()) + { + const int32_t rideTicketsSold = total_customers - no_secondary_items_sold; + + // Use the ratio between photo sold and total admissions to approximate the photo income(as not every guest will buy + // one). + // TODO: use data from the last 5 minutes instead of all-time values for a more accurate calculation + if (rideTicketsSold > 0) + { + priceMinusCost += ((no_secondary_items_sold * shopItemProfit) / rideTicketsSold); + } + } + else + { + priceMinusCost += shopItemProfit; + } if (entry->shop_item[0] != SHOP_ITEM_NONE) priceMinusCost /= 2;