Merge pull request #9448 from ZehMatt/fix-9287

Fix marketing/money effect bugs
This commit is contained in:
Duncan 2019-06-20 19:18:03 +01:00 committed by GitHub
commit cc82975090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 2 deletions

View File

@ -36,6 +36,7 @@ enum
enum
{
CAMPAIGN_FIRST_WEEK_FLAG = (1 << 6),
CAMPAIGN_ACTIVE_FLAG = (1 << 7)
};

View File

@ -33,7 +33,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "43"
#define NETWORK_STREAM_VERSION "44"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -795,6 +795,8 @@ void S6Exporter::ExportMarketingCampaigns()
for (const auto& campaign : gMarketingCampaigns)
{
_s6.campaign_weeks_left[campaign.Type] = campaign.WeeksLeft | CAMPAIGN_ACTIVE_FLAG;
if ((campaign.Flags & MarketingCampaignFlags::FIRST_WEEK))
_s6.campaign_weeks_left[campaign.Type] |= CAMPAIGN_FIRST_WEEK_FLAG;
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
_s6.campaign_ride_index[campaign.Type] = campaign.RideId;

View File

@ -1072,7 +1072,11 @@ public:
{
MarketingCampaign campaign{};
campaign.Type = (uint8_t)i;
campaign.WeeksLeft = _s6.campaign_weeks_left[i] & ~CAMPAIGN_ACTIVE_FLAG;
campaign.WeeksLeft = _s6.campaign_weeks_left[i] & ~(CAMPAIGN_ACTIVE_FLAG | CAMPAIGN_FIRST_WEEK_FLAG);
if ((_s6.campaign_weeks_left[i] & CAMPAIGN_FIRST_WEEK_FLAG) != 0)
{
campaign.Flags |= MarketingCampaignFlags::FIRST_WEEK;
}
if (campaign.Type == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign.Type == ADVERTISING_CAMPAIGN_RIDE)
{
campaign.RideId = _s6.campaign_ride_index[i];

View File

@ -12,6 +12,7 @@
#include "../interface/Viewport.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../network/network.h"
#include "Map.h"
#include "Sprite.h"
@ -80,6 +81,14 @@ void rct_money_effect::Create(money32 value)
if (mapPosition.x == LOCATION_NULL)
{
// If game actions return no valid location of the action we can not use the screen
// coordinates as every client will have different ones.
if (network_get_mode() != NETWORK_MODE_NONE)
{
log_warning("Attempted to create money effect without a valid location in multiplayer");
return;
}
rct_window* mainWindow = window_get_main();
if (mainWindow == nullptr)
return;