1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Lock game actions and commands to replay commands if replay is active.

This commit is contained in:
Matt
2018-12-06 08:48:00 +01:00
parent 6e8216d7c7
commit bf8108c2d6
2 changed files with 31 additions and 2 deletions

View File

@@ -388,6 +388,18 @@ int32_t game_do_command_p(
flags = *ebx;
auto* replayManager = GetContext()->GetReplayManager();
if (replayManager != nullptr && replayManager->IsReplaying())
{
// We only accept replay commands as long the replay is active.
if ((flags & GAME_COMMAND_FLAG_REPLAY) == 0)
{
// TODO: Introduce proper error.
gGameCommandErrorText = STR_CHEAT_BUILD_IN_PAUSE_MODE;
return MONEY32_UNDEFINED;
}
}
if (gGameCommandNestLevel == 0)
{
gGameCommandErrorText = STR_NONE;
@@ -473,7 +485,6 @@ int32_t game_do_command_p(
// Second call to actually perform the operation
new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp);
auto* replayManager = GetContext()->GetReplayManager();
if (replayManager != nullptr && replayManager->IsRecording() && (flags & GAME_COMMAND_FLAG_APPLY)
&& (flags & GAME_COMMAND_FLAG_GHOST) == 0 && (flags & GAME_COMMAND_FLAG_5) == 0)
{
@@ -544,7 +555,9 @@ int32_t game_do_command_p(
// Show error window
if (gGameCommandNestLevel == 0 && (flags & GAME_COMMAND_FLAG_APPLY) && gUnk141F568 == gUnk13CA740
&& !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
{
context_show_error(gGameCommandErrorTitle, gGameCommandErrorText);
}
return MONEY32_UNDEFINED;
}

View File

@@ -200,6 +200,23 @@ namespace GameActions
uint16_t actionFlags = action->GetActionFlags();
uint32_t flags = action->GetFlags();
auto* replayManager = OpenRCT2::GetContext()->GetReplayManager();
if (replayManager != nullptr && replayManager->IsReplaying())
{
// We only accept replay commands as long the replay is active.
if ((flags & GAME_COMMAND_FLAG_REPLAY) == 0)
{
// TODO: Introduce proper error.
GameActionResult::Ptr result = std::make_unique<GameActionResult>();
result->Error = GA_ERROR::GAME_PAUSED;
result->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
result->ErrorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
return result;
}
}
GameActionResult::Ptr result = Query(action);
if (result->Error == GA_ERROR::OK)
{
@@ -265,7 +282,6 @@ namespace GameActions
}
else if (network_get_mode() == NETWORK_MODE_NONE)
{
auto* replayManager = OpenRCT2::GetContext()->GetReplayManager();
if (replayManager != nullptr && replayManager->IsRecording())
{
replayManager->AddGameAction(gCurrentTicks, action);