From af74a2f4918e39cd3a157350b9c8e00397c94ff8 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:38:40 +1000 Subject: [PATCH] Rename global WorldTimestep var to more appropriate name --- source/client/StarClientApplication.cpp | 8 ++++---- source/game/StarAmbient.cpp | 2 +- source/game/StarGameTimers.hpp | 4 ++-- source/game/StarGameTypes.cpp | 4 ++-- source/game/StarGameTypes.hpp | 4 ++-- source/game/StarItemDrop.cpp | 2 +- source/game/StarMonster.cpp | 2 +- source/game/StarMovementController.cpp | 2 +- source/game/StarMovementController.hpp | 2 +- source/game/StarNpc.cpp | 2 +- source/game/StarPlant.cpp | 2 +- source/game/StarPlantDrop.cpp | 2 +- source/game/StarPlayer.cpp | 4 ++-- source/game/StarProjectile.cpp | 2 +- source/game/StarVehicle.cpp | 4 ++-- source/game/StarWorldClient.cpp | 8 ++++---- source/game/StarWorldServer.cpp | 8 ++++---- source/game/StarWorldServerThread.cpp | 4 ++-- source/game/objects/StarPhysicsObject.cpp | 2 +- source/server/main.cpp | 4 ++-- source/windowing/StarPaneManager.cpp | 2 +- 21 files changed, 37 insertions(+), 37 deletions(-) diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index 9213d0e..995325e 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -185,14 +185,14 @@ void ClientApplication::applicationInit(ApplicationControllerPtr appController) bool borderless = configuration->get("borderless").toBool(); bool maximized = configuration->get("maximized").toBool(); - float updateRate = 1.0f / WorldTimestep; + float updateRate = 1.0f / GlobalTimestep; if (auto jUpdateRate = configuration->get("updateRate")) { updateRate = jUpdateRate.toFloat(); - WorldTimestep = 1.0f / updateRate; + GlobalTimestep = 1.0f / updateRate; } if (auto jServerUpdateRate = configuration->get("serverUpdateRate")) - ServerWorldTimestep = 1.0f / jServerUpdateRate.toFloat(); + ServerGlobalTimestep = 1.0f / jServerUpdateRate.toFloat(); appController->setTargetUpdateRate(updateRate); appController->setApplicationTitle(assets->json("/client.config:windowTitle").toString()); @@ -346,7 +346,7 @@ void ClientApplication::processInput(InputEvent const& event) { } void ClientApplication::update() { - float dt = WorldTimestep * GlobalTimescale; + float dt = GlobalTimestep * GlobalTimescale; if (m_state >= MainAppState::Title) { if (auto p2pNetworkingService = appController()->p2pNetworkingService()) { if (auto join = p2pNetworkingService->pullPendingJoin()) { diff --git a/source/game/StarAmbient.cpp b/source/game/StarAmbient.cpp index 6cb912d..7209ca8 100644 --- a/source/game/StarAmbient.cpp +++ b/source/game/StarAmbient.cpp @@ -105,7 +105,7 @@ AudioInstancePtr AmbientManager::updateAmbient(AmbientNoisesDescriptionPtr curre } if (m_volumeChanged) { if (m_delay > 0) - m_delay -= WorldTimestep; + m_delay -= GlobalTimestep; else { m_volumeChanged = false; if (m_currentTrack) { diff --git a/source/game/StarGameTimers.hpp b/source/game/StarGameTimers.hpp index 9dff1ae..15380e6 100644 --- a/source/game/StarGameTimers.hpp +++ b/source/game/StarGameTimers.hpp @@ -13,8 +13,8 @@ struct GameTimer { float time; float timer; - bool tick(float dt = WorldTimestep); // returns true if time is up - bool wrapTick(float dt = WorldTimestep); // auto resets + bool tick(float dt = GlobalTimestep); // returns true if time is up + bool wrapTick(float dt = GlobalTimestep); // auto resets void reset(); void setDone(); void invert(); diff --git a/source/game/StarGameTypes.cpp b/source/game/StarGameTypes.cpp index 584d3c3..d3171f0 100644 --- a/source/game/StarGameTypes.cpp +++ b/source/game/StarGameTypes.cpp @@ -3,8 +3,8 @@ namespace Star { float GlobalTimescale = 1.0f; -float WorldTimestep = 1.0f / 60.0f; -float ServerWorldTimestep = 1.0f / 60.0f; +float GlobalTimestep = 1.0f / 60.0f; +float ServerGlobalTimestep = 1.0f / 60.0f; EnumMap const DirectionNames{ {Direction::Left, "left"}, diff --git a/source/game/StarGameTypes.hpp b/source/game/StarGameTypes.hpp index c8ec287..ce24247 100644 --- a/source/game/StarGameTypes.hpp +++ b/source/game/StarGameTypes.hpp @@ -94,8 +94,8 @@ extern EnumMap const RarityNames; unsigned const TilePixels = 8; extern float GlobalTimescale; -extern float WorldTimestep; -extern float ServerWorldTimestep; +extern float GlobalTimestep; +extern float ServerGlobalTimestep; float const SystemWorldTimestep = 1.0f / 20.0f; size_t const WorldSectorSize = 32; diff --git a/source/game/StarItemDrop.cpp b/source/game/StarItemDrop.cpp index 15ca927..7940e63 100644 --- a/source/game/StarItemDrop.cpp +++ b/source/game/StarItemDrop.cpp @@ -250,7 +250,7 @@ void ItemDrop::update(float dt, uint64_t) { m_ageItemsTimer.setElapsedTime(0.0); } } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); Root::singleton().itemDatabase()->loadItem(m_itemDescriptor.get(), m_item); m_movementController.tickSlave(dt); } diff --git a/source/game/StarMonster.cpp b/source/game/StarMonster.cpp index 9d5bc7a..7e4e399 100644 --- a/source/game/StarMonster.cpp +++ b/source/game/StarMonster.cpp @@ -466,7 +466,7 @@ void Monster::update(float dt, uint64_t) { m_statusController->tickMaster(dt); updateStatus(dt); } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); m_statusController->tickSlave(dt); updateStatus(dt); diff --git a/source/game/StarMovementController.cpp b/source/game/StarMovementController.cpp index dd171c1..a9b626f 100644 --- a/source/game/StarMovementController.cpp +++ b/source/game/StarMovementController.cpp @@ -170,7 +170,7 @@ DataStream& operator<<(DataStream& ds, MovementParameters const& movementParamet MovementController::MovementController(MovementParameters const& parameters) { m_resting = false; - m_timeStep = WorldTimestep; + m_timeStep = GlobalTimestep; m_liquidPercentage = 0.0f; m_liquidId = EmptyLiquidId; diff --git a/source/game/StarMovementController.hpp b/source/game/StarMovementController.hpp index f5930cb..4f3ee02 100644 --- a/source/game/StarMovementController.hpp +++ b/source/game/StarMovementController.hpp @@ -184,7 +184,7 @@ public: // Stores dt value for Lua calls. void setTimestep(float dt); - // Integrates the ActorMovementController one WorldTimestep and applies all + // Integrates the ActorMovementController one GlobalTimestep and applies all // forces. void tickMaster(float dt); diff --git a/source/game/StarNpc.cpp b/source/game/StarNpc.cpp index e989147..9e97417 100644 --- a/source/game/StarNpc.cpp +++ b/source/game/StarNpc.cpp @@ -458,7 +458,7 @@ void Npc::update(float dt, uint64_t) { m_humanoid.setDance(m_dance); } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); m_movementController->tickSlave(dt); m_statusController->tickSlave(dt); diff --git a/source/game/StarPlant.cpp b/source/game/StarPlant.cpp index d0c6efe..f26c73a 100644 --- a/source/game/StarPlant.cpp +++ b/source/game/StarPlant.cpp @@ -733,7 +733,7 @@ void Plant::update(float dt, uint64_t) { m_windLevel += damageEffectPercentage * 20; } - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); } } diff --git a/source/game/StarPlantDrop.cpp b/source/game/StarPlantDrop.cpp index 2ca16a0..1c242b2 100644 --- a/source/game/StarPlantDrop.cpp +++ b/source/game/StarPlantDrop.cpp @@ -236,7 +236,7 @@ void PlantDrop::update(float dt, uint64_t) { } } } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); if (m_spawnedDropEffects && !m_spawnedDrops.get()) m_spawnedDropEffects = false; // false positive assumption over already having done the effect diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp index 188a6a8..5ee46c4 100644 --- a/source/game/StarPlayer.cpp +++ b/source/game/StarPlayer.cpp @@ -945,7 +945,7 @@ void Player::update(float dt, uint64_t) { m_statusController->resetResource("breath"); } - m_log->addPlayTime(WorldTimestep); + m_log->addPlayTime(GlobalTimestep); if (m_ageItemsTimer.wrapTick(dt)) { auto itemDatabase = Root::singleton().itemDatabase(); @@ -970,7 +970,7 @@ void Player::update(float dt, uint64_t) { m_interestingObjects = m_questManager->interestingObjects(); } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); m_movementController->tickSlave(dt); m_techController->tickSlave(dt); m_statusController->tickSlave(dt); diff --git a/source/game/StarProjectile.cpp b/source/game/StarProjectile.cpp index 234c053..7355135 100644 --- a/source/game/StarProjectile.cpp +++ b/source/game/StarProjectile.cpp @@ -336,7 +336,7 @@ void Projectile::update(float dt, uint64_t) { } } } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); m_movementController->tickSlave(dt); m_travelLine.min() = m_travelLine.max(); m_travelLine.max() = m_movementController->position(); diff --git a/source/game/StarVehicle.cpp b/source/game/StarVehicle.cpp index 89820b2..2b40417 100644 --- a/source/game/StarVehicle.cpp +++ b/source/game/StarVehicle.cpp @@ -273,7 +273,7 @@ void Vehicle::update(float dt, uint64_t) { m_scriptComponent.update(m_scriptComponent.updateDt(dt)); eraseWhere(m_aliveMasterConnections, [](auto& p) { - return p.second.tick(WorldTimestep); + return p.second.tick(GlobalTimestep); }); for (auto& loungePositionPair : m_loungePositions) { @@ -285,7 +285,7 @@ void Vehicle::update(float dt, uint64_t) { } } } else { - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); m_movementController.tickSlave(dt); diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index 34214ba..0b15afd 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -58,7 +58,7 @@ WorldClient::WorldClient(PlayerPtr mainPlayer) { return m_tileArray->tile({x, y}).collision; }); - m_modifiedTilePredictionTimeout = (int)round(m_clientConfig.getFloat("modifiedTilePredictionTimeout") / WorldTimestep); + m_modifiedTilePredictionTimeout = (int)round(m_clientConfig.getFloat("modifiedTilePredictionTimeout") / GlobalTimestep); m_latency = 0.0; @@ -756,7 +756,7 @@ void WorldClient::handleIncomingPackets(List const& packets) { } } else if (auto entityUpdateSet = as(packet)) { - float interpolationLeadTime = m_interpolationTracker.interpolationLeadSteps() * WorldTimestep; + float interpolationLeadTime = m_interpolationTracker.interpolationLeadSteps() * GlobalTimestep; m_entityMap->forAllEntities([&](EntityPtr const& entity) { EntityId entityId = entity->entityId(); if (connectionForEntity(entityId) == entityUpdateSet->forConnection) { @@ -767,7 +767,7 @@ void WorldClient::handleIncomingPackets(List const& packets) { } else if (auto entityDestroy = as(packet)) { if (auto entity = m_entityMap->entity(entityDestroy->entityId)) { - entity->readNetState(entityDestroy->finalNetState, m_interpolationTracker.interpolationLeadSteps() * WorldTimestep); + entity->readNetState(entityDestroy->finalNetState, m_interpolationTracker.interpolationLeadSteps() * GlobalTimestep); // Before destroying the entity, we should make sure that the entity is // using the absolute latest data, so we disable interpolation. @@ -874,7 +874,7 @@ void WorldClient::handleIncomingPackets(List const& packets) { tryGiveMainPlayerItem(itemDatabase->item(giveItem->item)); } else if (auto stepUpdate = as(packet)) { - m_currentServerStep = ((double)stepUpdate->remoteStep * (WorldTimestep / ServerWorldTimestep)); + m_currentServerStep = ((double)stepUpdate->remoteStep * (GlobalTimestep / ServerGlobalTimestep)); m_interpolationTracker.receiveStepUpdate(m_currentServerStep); } else if (auto environmentUpdatePacket = as(packet)) { diff --git a/source/game/StarWorldServer.cpp b/source/game/StarWorldServer.cpp index be00d1f..492ea81 100644 --- a/source/game/StarWorldServer.cpp +++ b/source/game/StarWorldServer.cpp @@ -430,7 +430,7 @@ void WorldServer::handleIncomingPackets(ConnectionId clientId, List c } } else if (auto entityUpdateSet = as(packet)) { - float interpolationLeadTime = clientInfo->interpolationTracker.interpolationLeadSteps() * WorldTimestep; + float interpolationLeadTime = clientInfo->interpolationTracker.interpolationLeadSteps() * GlobalTimestep; m_entityMap->forAllEntities([&](EntityPtr const& entity) { EntityId entityId = entity->entityId(); if (connectionForEntity(entityId) == clientId) { @@ -442,7 +442,7 @@ void WorldServer::handleIncomingPackets(ConnectionId clientId, List c } else if (auto entityDestroy = as(packet)) { if (auto entity = m_entityMap->entity(entityDestroy->entityId)) { - entity->readNetState(entityDestroy->finalNetState, clientInfo->interpolationTracker.interpolationLeadSteps() * WorldTimestep); + entity->readNetState(entityDestroy->finalNetState, clientInfo->interpolationTracker.interpolationLeadSteps() * GlobalTimestep); // Before destroying the entity, we should make sure that the entity is // using the absolute latest data, so we disable interpolation. entity->disableInterpolation(); @@ -636,10 +636,10 @@ void WorldServer::update(float dt) { m_fallingBlocksAgent->update(); if (auto delta = shouldRunThisStep("blockDamageUpdate")) - updateDamagedBlocks(*delta * WorldTimestep); + updateDamagedBlocks(*delta * GlobalTimestep); if (auto delta = shouldRunThisStep("worldStorageTick")) - m_worldStorage->tick(*delta * WorldTimestep); + m_worldStorage->tick(*delta * GlobalTimestep); if (auto delta = shouldRunThisStep("worldStorageGenerate")) { m_worldStorage->generateQueue(m_fidelityConfig.optUInt("worldStorageGenerationLevelLimit"), [this](WorldStorage::Sector a, WorldStorage::Sector b) { diff --git a/source/game/StarWorldServerThread.cpp b/source/game/StarWorldServerThread.cpp index 6928456..1b7d23a 100644 --- a/source/game/StarWorldServerThread.cpp +++ b/source/game/StarWorldServerThread.cpp @@ -207,7 +207,7 @@ void WorldServerThread::run() { double storageInterval = root.assets()->json("/universe_server.config:worldStorageInterval").toDouble() / 1000.0; Timer storageTimer = Timer::withTime(storageInterval); - TickRateApproacher tickApproacher(1.0 / ServerWorldTimestep, updateMeasureWindow); + TickRateApproacher tickApproacher(1.0 / ServerGlobalTimestep, updateMeasureWindow); double fidelityScore = 0.0; WorldServerFidelity automaticFidelity = WorldServerFidelity::Medium; @@ -267,7 +267,7 @@ void WorldServerThread::update(WorldServerFidelity fidelity) { } } - float dt = ServerWorldTimestep * GlobalTimescale; + float dt = ServerGlobalTimestep * GlobalTimescale; m_worldServer->setFidelity(fidelity); if (!m_pause || *m_pause == false) m_worldServer->update(dt); diff --git a/source/game/objects/StarPhysicsObject.cpp b/source/game/objects/StarPhysicsObject.cpp index 6b667a5..f327473 100644 --- a/source/game/objects/StarPhysicsObject.cpp +++ b/source/game/objects/StarPhysicsObject.cpp @@ -79,7 +79,7 @@ void PhysicsObject::uninit() { void PhysicsObject::update(float dt, uint64_t currentStep) { Object::update(dt, currentStep); if (isSlave()) - m_netGroup.tickNetInterpolation(WorldTimestep); + m_netGroup.tickNetInterpolation(GlobalTimestep); } RectF PhysicsObject::metaBoundBox() const { diff --git a/source/server/main.cpp b/source/server/main.cpp index ad16988..f4d4b91 100644 --- a/source/server/main.cpp +++ b/source/server/main.cpp @@ -47,10 +47,10 @@ int main(int argc, char** argv) { { Logger::info("Server Version {} ({}) Source ID: {} Protocol: {}", StarVersionString, StarArchitectureString, StarSourceIdentifierString, StarProtocolVersion); - float updateRate = 1.0f / WorldTimestep; + float updateRate = 1.0f / GlobalTimestep; if (auto jUpdateRate = configuration->get("updateRate")) { updateRate = jUpdateRate.toFloat(); - ServerWorldTimestep = WorldTimestep = 1.0f / updateRate; + ServerGlobalTimestep = GlobalTimestep = 1.0f / updateRate; Logger::info("Configured tickrate is {:4.2f}hz", updateRate); } diff --git a/source/windowing/StarPaneManager.cpp b/source/windowing/StarPaneManager.cpp index dcdace9..f44783c 100644 --- a/source/windowing/StarPaneManager.cpp +++ b/source/windowing/StarPaneManager.cpp @@ -270,7 +270,7 @@ void PaneManager::render() { } void PaneManager::update(float dt) { - m_tooltipShowTimer -= WorldTimestep; + m_tooltipShowTimer -= GlobalTimestep; if (m_tooltipShowTimer < 0 && !m_activeTooltip) { if (auto parentPane = getPaneAt(m_tooltipLastMousePos)) { if (auto tooltip = parentPane->createTooltip(m_tooltipLastMousePos)) {