mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Merge pull request #20322 from ZehMatt/fix-gameactions
Revert #20286 and change game actions to be always queued
This commit is contained in:
@@ -109,8 +109,6 @@ void GameState::Tick()
|
||||
{
|
||||
PROFILED_FUNCTION();
|
||||
|
||||
gInUpdateCode = true;
|
||||
|
||||
// Normal game play will update only once every GAME_UPDATE_TIME_MS
|
||||
uint32_t numUpdates = 1;
|
||||
|
||||
@@ -250,7 +248,6 @@ void GameState::Tick()
|
||||
}
|
||||
|
||||
gDoSingleUpdate = false;
|
||||
gInUpdateCode = false;
|
||||
}
|
||||
|
||||
void GameState::UpdateLogic(LogicTimings* timings)
|
||||
@@ -266,6 +263,8 @@ void GameState::UpdateLogic(LogicTimings* timings)
|
||||
}
|
||||
};
|
||||
|
||||
gInUpdateCode = true;
|
||||
|
||||
gScreenAge++;
|
||||
if (gScreenAge == 0)
|
||||
gScreenAge--;
|
||||
@@ -290,6 +289,7 @@ void GameState::UpdateLogic(LogicTimings* timings)
|
||||
// Don't run past the server, this condition can happen during map changes.
|
||||
if (NetworkGetServerTick() == gCurrentTicks)
|
||||
{
|
||||
gInUpdateCode = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,6 +397,8 @@ void GameState::UpdateLogic(LogicTimings* timings)
|
||||
{
|
||||
timings->CurrentIdx = (timings->CurrentIdx + 1) % LOGIC_UPDATE_MEASUREMENTS_COUNT;
|
||||
}
|
||||
|
||||
gInUpdateCode = false;
|
||||
}
|
||||
|
||||
void GameState::CreateStateSnapshot()
|
||||
|
||||
@@ -334,10 +334,11 @@ namespace GameActions
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (NetworkGetMode() == NETWORK_MODE_SERVER)
|
||||
else if (NetworkGetMode() == NETWORK_MODE_SERVER || !gInUpdateCode)
|
||||
{
|
||||
// If player is the server it would execute right away as where clients execute the commands
|
||||
// at the beginning of the frame, so we have to put them into the queue.
|
||||
// This is also the case when its executed from the UI update.
|
||||
if (!(actionFlags & GameActions::Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED))
|
||||
{
|
||||
LOG_VERBOSE("[%s] GameAction::Execute %s (Queue)", GetRealm(), action->GetName());
|
||||
|
||||
@@ -35,14 +35,6 @@ struct EntitySpriteData
|
||||
ScreenRect SpriteRect;
|
||||
};
|
||||
|
||||
namespace EntityRenderFlags
|
||||
{
|
||||
// Disables tweening for this tick, this is helpful when entities are teleported
|
||||
// and should not be tweened.
|
||||
constexpr uint32_t kInvalidateTweening = (1U << 0);
|
||||
|
||||
} // namespace EntityRenderFlags
|
||||
|
||||
struct EntityBase
|
||||
{
|
||||
EntityType Type;
|
||||
@@ -50,8 +42,6 @@ struct EntityBase
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
// Rendering specific flags, this should not be stored in the save file.
|
||||
uint32_t RenderFlags;
|
||||
EntitySpriteData SpriteData;
|
||||
// Used as direction or rotation depending on the entity.
|
||||
uint8_t Orientation;
|
||||
|
||||
@@ -273,7 +273,6 @@ static void EntityReset(EntityBase* entity)
|
||||
|
||||
entity->Id = entityIndex;
|
||||
entity->Type = EntityType::Null;
|
||||
entity->RenderFlags = 0;
|
||||
}
|
||||
|
||||
static constexpr uint16_t MAX_MISC_SPRITES = 300;
|
||||
@@ -473,13 +472,6 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation)
|
||||
EntitySetCoordinates(loc, this);
|
||||
Invalidate(); // Invalidate new position.
|
||||
}
|
||||
|
||||
if (!gInUpdateCode)
|
||||
{
|
||||
// Make sure we don't tween when the position was modified outside of the
|
||||
// update loop.
|
||||
RenderFlags |= EntityRenderFlags::kInvalidateTweening;
|
||||
}
|
||||
}
|
||||
|
||||
void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity)
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
void EntityTweener::AddEntity(EntityBase* entity)
|
||||
{
|
||||
entity->RenderFlags &= ~EntityRenderFlags::kInvalidateTweening;
|
||||
|
||||
Entities.push_back(entity);
|
||||
PrePos.emplace_back(entity->GetLocation());
|
||||
}
|
||||
@@ -92,9 +90,6 @@ void EntityTweener::Tween(float alpha)
|
||||
if (ent == nullptr)
|
||||
continue;
|
||||
|
||||
if (ent->RenderFlags & EntityRenderFlags::kInvalidateTweening)
|
||||
continue;
|
||||
|
||||
auto& posA = PrePos[i];
|
||||
auto& posB = PostPos[i];
|
||||
|
||||
@@ -118,9 +113,6 @@ void EntityTweener::Restore()
|
||||
if (ent == nullptr)
|
||||
continue;
|
||||
|
||||
if (ent->RenderFlags & EntityRenderFlags::kInvalidateTweening)
|
||||
continue;
|
||||
|
||||
EntitySetCoordinates(PostPos[i], ent);
|
||||
ent->Invalidate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user