Fix #6119: Advertising campaign for ride window not updated properly (#11335)

This commit is contained in:
Tulio Leao 2020-04-18 11:15:04 -03:00 committed by GitHub
parent 2ef77414d5
commit e2be89648e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 25 deletions

View File

@ -2,6 +2,7 @@
------------------------------------------------------------------------
- Feature: [#9029] Open doors with the tile inspector.
- Feature: [#11231] Change shortcut window list order to be more intuitive, and split it into logical sections.
- Fix: [#6119]: Advertising campaign for ride window not updated properly (original bug).
- Fix: [#11072] Land and water tools working out of bounds (original bug).
- Fix: [#11315] Ride that has never opened is shown as favorite ride of many guests.
- Improved: [#6530] Allow water and land height changes on park borders.

View File

@ -302,6 +302,12 @@ public:
window_new_ride_init_vars();
break;
case INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST:
{
WindowCampaignRefreshRides();
break;
}
case INTENT_ACTION_REFRESH_RIDE_LIST:
{
auto window = window_find_by_class(WC_RIDE_LIST);

View File

@ -155,31 +155,7 @@ rct_window* window_new_campaign_open(int16_t campaignType)
// Currently selected ride
w->campaign.ride_id = SELECTED_RIDE_UNDEFINED;
// Get all applicable rides
window_new_campaign_rides.clear();
for (const auto& ride : GetRideManager())
{
if (ride.status == RIDE_STATUS_OPEN)
{
if (!ride_type_has_flag(
ride.type,
RIDE_TYPE_FLAG_IS_SHOP | RIDE_TYPE_FLAG_SELLS_FOOD | RIDE_TYPE_FLAG_SELLS_DRINKS
| RIDE_TYPE_FLAG_IS_TOILET))
{
window_new_campaign_rides.push_back(ride.id);
}
}
}
// Take top 128 most valuable rides
if (window_new_campaign_rides.size() > DROPDOWN_ITEMS_MAX_SIZE)
{
qsort(window_new_campaign_rides.data(), window_new_campaign_rides.size(), sizeof(ride_id_t), ride_value_compare);
window_new_campaign_rides.resize(DROPDOWN_ITEMS_MAX_SIZE);
}
// Sort rides by name
qsort(window_new_campaign_rides.data(), window_new_campaign_rides.size(), sizeof(ride_id_t), ride_name_compare);
WindowCampaignRefreshRides();
return w;
}
@ -420,3 +396,38 @@ static void window_new_campaign_paint(rct_window* w, rct_drawpixelinfo* dpi)
money32 totalPrice = AdvertisingCampaignPricePerWeek[w->campaign.campaign_type] * w->campaign.no_weeks;
gfx_draw_string_left(dpi, STR_MARKETING_TOTAL_COST, &totalPrice, COLOUR_BLACK, x, y);
}
void WindowCampaignRefreshRides()
{
auto window = window_find_by_class(WC_NEW_CAMPAIGN);
if (window == nullptr)
{
return;
}
// Get all applicable rides
window_new_campaign_rides.clear();
for (const auto& ride : GetRideManager())
{
if (ride.status == RIDE_STATUS_OPEN)
{
if (!ride_type_has_flag(
ride.type,
RIDE_TYPE_FLAG_IS_SHOP | RIDE_TYPE_FLAG_SELLS_FOOD | RIDE_TYPE_FLAG_SELLS_DRINKS
| RIDE_TYPE_FLAG_IS_TOILET))
{
window_new_campaign_rides.push_back(ride.id);
}
}
}
// Take top 128 most valuable rides
if (window_new_campaign_rides.size() > DROPDOWN_ITEMS_MAX_SIZE)
{
qsort(window_new_campaign_rides.data(), window_new_campaign_rides.size(), sizeof(ride_id_t), ride_value_compare);
window_new_campaign_rides.resize(DROPDOWN_ITEMS_MAX_SIZE);
}
// Sort rides by name
qsort(window_new_campaign_rides.data(), window_new_campaign_rides.size(), sizeof(ride_id_t), ride_name_compare);
}

View File

@ -34,6 +34,7 @@ extern colour_t gWindowSceneryTertiaryColour;
extern bool gWindowSceneryEyedropperEnabled;
rct_window* window_about_open();
void WindowCampaignRefreshRides();
rct_window* window_changelog_open();
rct_window* window_cheats_open();
rct_window* window_clear_scenery_open();

View File

@ -259,6 +259,7 @@ private:
// Refresh windows that display the ride name
auto windowManager = OpenRCT2::GetContext()->GetUiContext()->GetWindowManager();
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST));
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_RIDE_LIST));
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST));

View File

@ -91,6 +91,7 @@ public:
// Refresh windows that display ride name
auto windowManager = OpenRCT2::GetContext()->GetUiContext()->GetWindowManager();
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST));
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_RIDE_LIST));
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST));

View File

@ -17,6 +17,8 @@
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
#include "../ride/Ride.h"
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
#include "../world/Park.h"
#include "../world/Sprite.h"
#include "GameAction.h"
@ -219,6 +221,9 @@ public:
Guard::Assert(false, "Invalid status passed: %u", _status);
break;
}
auto windowManager = OpenRCT2::GetContext()->GetUiContext()->GetWindowManager();
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST));
return res;
}
};

View File

@ -80,6 +80,7 @@ enum
{
INTENT_ACTION_MAP,
INTENT_ACTION_NEW_RIDE_OF_TYPE,
INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST,
INTENT_ACTION_REFRESH_NEW_RIDES,
INTENT_ACTION_REFRESH_RIDE_LIST,
INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION,