mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge #8900 branch 'zehmatt/mp-peep-flags-ga' into game_actions
This commit is contained in:
commit
329514a49c
|
@ -1,9 +1,10 @@
|
|||
0.2.2+ (in development)
|
||||
------------------------------------------------------------------------
|
||||
- Change: [#8688] Move common actions from debug menu into cheats menu.
|
||||
- Fix: [#5579] Network desync immediately after connecting.
|
||||
- Fix: [#7884] Unfinished preserved rides can be demolished with quick demolish.
|
||||
- Fix: [#8873] Potential crash when placing footpaths.
|
||||
- Change: [#8688] Move common actions from debug menu into cheats menu.
|
||||
- Fix: [#8900] Peep tracking is not synchronized.
|
||||
|
||||
0.2.2 (2019-03-13)
|
||||
------------------------------------------------------------------------
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/actions/GuestSetFlagsAction.hpp>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/localisation/Localisation.h>
|
||||
#include <openrct2/management/Marketing.h>
|
||||
|
@ -636,7 +637,12 @@ void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex)
|
|||
window_scroll_to_viewport(w);
|
||||
break;
|
||||
case WIDX_TRACK:
|
||||
get_sprite(w->number)->peep.peep_flags ^= PEEP_FLAGS_TRACKING;
|
||||
{
|
||||
uint32_t flags = peep->peep_flags ^ PEEP_FLAGS_TRACKING;
|
||||
|
||||
auto guestSetFlagsAction = GuestSetFlagsAction(w->number, flags);
|
||||
GameActions::Execute(&guestSetFlagsAction);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ enum GAME_COMMAND
|
|||
GAME_COMMAND_SET_STAFF_COSTUME, // GA
|
||||
GAME_COMMAND_PLACE_FOOTPATH_SCENERY, // GA
|
||||
GAME_COMMAND_REMOVE_FOOTPATH_SCENERY, // GA
|
||||
GAME_COMMAND_GUEST_SET_FLAGS, // GA
|
||||
GAME_COMMAND_COUNT,
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "FootpathSceneryPlaceAction.hpp"
|
||||
#include "FootpathSceneryRemoveAction.hpp"
|
||||
#include "GameAction.h"
|
||||
#include "GuestSetFlagsAction.hpp"
|
||||
#include "GuestSetNameAction.hpp"
|
||||
#include "LandLowerAction.hpp"
|
||||
#include "LandRaiseAction.hpp"
|
||||
|
@ -113,5 +114,6 @@ namespace GameActions
|
|||
Register<WaterSetHeightAction>();
|
||||
Register<WaterLowerAction>();
|
||||
Register<WaterRaiseAction>();
|
||||
Register<GuestSetFlagsAction>();
|
||||
}
|
||||
} // namespace GameActions
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(GuestSetFlagsAction, GAME_COMMAND_GUEST_SET_FLAGS, GameActionResult)
|
||||
{
|
||||
private:
|
||||
uint16_t _peepId = SPRITE_INDEX_NULL;
|
||||
uint32_t _newFlags = 0;
|
||||
|
||||
public:
|
||||
GuestSetFlagsAction()
|
||||
{
|
||||
}
|
||||
|
||||
GuestSetFlagsAction(uint16_t peepId, uint32_t flags)
|
||||
: _peepId(peepId)
|
||||
, _newFlags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t GetActionFlags() const override
|
||||
{
|
||||
return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED;
|
||||
}
|
||||
|
||||
void Serialise(DataSerialiser & stream) override
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_peepId) << DS_TAG(_newFlags);
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Query() const override
|
||||
{
|
||||
Peep* peep = GET_PEEP(_peepId);
|
||||
if (peep == nullptr)
|
||||
{
|
||||
log_error("Used invalid sprite index for peep: %u", (uint32_t)_peepId);
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_THIS);
|
||||
}
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Execute() const override
|
||||
{
|
||||
Peep* peep = GET_PEEP(_peepId);
|
||||
if (peep == nullptr)
|
||||
{
|
||||
log_error("Used invalid sprite index for peep: %u", (uint32_t)_peepId);
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_THIS);
|
||||
}
|
||||
|
||||
peep->peep_flags = _newFlags;
|
||||
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
};
|
|
@ -171,6 +171,7 @@ const std::array<NetworkAction, NETWORK_PERMISSION_COUNT> NetworkActions::Action
|
|||
GAME_COMMAND_SET_GUEST_NAME,
|
||||
GAME_COMMAND_PICKUP_GUEST,
|
||||
GAME_COMMAND_BALLOON_PRESS,
|
||||
GAME_COMMAND_GUEST_SET_FLAGS,
|
||||
},
|
||||
},
|
||||
NetworkAction{
|
||||
|
|
|
@ -24,6 +24,7 @@ void twitch_update()
|
|||
# include "../Context.h"
|
||||
# include "../Game.h"
|
||||
# include "../OpenRCT2.h"
|
||||
# include "../actions/GuestSetFlagsAction.hpp"
|
||||
# include "../config/Config.h"
|
||||
# include "../core/Json.hpp"
|
||||
# include "../core/String.hpp"
|
||||
|
@ -442,30 +443,41 @@ namespace Twitch
|
|||
if (member == nullptr)
|
||||
{
|
||||
// Member no longer peep name worthy
|
||||
peep->peep_flags &= ~(PEEP_FLAGS_TRACKING | PEEP_FLAGS_TWITCH);
|
||||
uint32_t flags = peep->peep_flags & ~(PEEP_FLAGS_TRACKING | PEEP_FLAGS_TWITCH);
|
||||
|
||||
auto guestSetFlagsAction = GuestSetFlagsAction(peep->sprite_index, flags);
|
||||
GameActions::Execute(&guestSetFlagsAction);
|
||||
|
||||
// TODO set peep name back to number / real name
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t flags = peep->peep_flags;
|
||||
if (member->ShouldTrack)
|
||||
{
|
||||
peep->peep_flags |= (PEEP_FLAGS_TRACKING);
|
||||
flags |= (PEEP_FLAGS_TRACKING);
|
||||
}
|
||||
else if (!member->ShouldTrack)
|
||||
{
|
||||
peep->peep_flags &= ~(PEEP_FLAGS_TRACKING);
|
||||
flags &= ~(PEEP_FLAGS_TRACKING);
|
||||
}
|
||||
if (flags != peep->peep_flags)
|
||||
{
|
||||
auto guestSetFlagsAction = GuestSetFlagsAction(peep->sprite_index, flags);
|
||||
GameActions::Execute(&guestSetFlagsAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (member != nullptr && !(peep->peep_flags & PEEP_FLAGS_LEAVING_PARK))
|
||||
{
|
||||
// Peep with same name already exists but not twitch
|
||||
peep->peep_flags |= PEEP_FLAGS_TWITCH;
|
||||
uint32_t flags = peep->peep_flags | PEEP_FLAGS_TWITCH;
|
||||
if (member->ShouldTrack)
|
||||
{
|
||||
peep->peep_flags |= PEEP_FLAGS_TRACKING;
|
||||
flags |= PEEP_FLAGS_TRACKING;
|
||||
}
|
||||
auto guestSetFlagsAction = GuestSetFlagsAction(peep->sprite_index, flags);
|
||||
GameActions::Execute(&guestSetFlagsAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -498,11 +510,15 @@ namespace Twitch
|
|||
if (newStringId != 0)
|
||||
{
|
||||
peep->name_string_idx = newStringId;
|
||||
peep->peep_flags |= PEEP_FLAGS_TWITCH;
|
||||
|
||||
uint32_t flags = peep->peep_flags | PEEP_FLAGS_TWITCH;
|
||||
if (member->ShouldTrack)
|
||||
{
|
||||
peep->peep_flags |= PEEP_FLAGS_TRACKING;
|
||||
flags |= PEEP_FLAGS_TRACKING;
|
||||
}
|
||||
|
||||
auto guestSetFlagsAction = GuestSetFlagsAction(peep->sprite_index, flags);
|
||||
GameActions::Execute(&guestSetFlagsAction);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue