Rename global WorldTimestep var to more appropriate name
This commit is contained in:
parent
3bc2034c15
commit
af74a2f491
@ -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()) {
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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<Direction> const DirectionNames{
|
||||
{Direction::Left, "left"},
|
||||
|
@ -94,8 +94,8 @@ extern EnumMap<Rarity> 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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -733,7 +733,7 @@ void Plant::update(float dt, uint64_t) {
|
||||
m_windLevel += damageEffectPercentage * 20;
|
||||
}
|
||||
|
||||
m_netGroup.tickNetInterpolation(WorldTimestep);
|
||||
m_netGroup.tickNetInterpolation(GlobalTimestep);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<PacketPtr> const& packets) {
|
||||
}
|
||||
|
||||
} else if (auto entityUpdateSet = as<EntityUpdateSetPacket>(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<PacketPtr> const& packets) {
|
||||
|
||||
} else if (auto entityDestroy = as<EntityDestroyPacket>(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<PacketPtr> const& packets) {
|
||||
tryGiveMainPlayerItem(itemDatabase->item(giveItem->item));
|
||||
|
||||
} else if (auto stepUpdate = as<StepUpdatePacket>(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<EnvironmentUpdatePacket>(packet)) {
|
||||
|
@ -430,7 +430,7 @@ void WorldServer::handleIncomingPackets(ConnectionId clientId, List<PacketPtr> c
|
||||
}
|
||||
|
||||
} else if (auto entityUpdateSet = as<EntityUpdateSetPacket>(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<PacketPtr> c
|
||||
|
||||
} else if (auto entityDestroy = as<EntityDestroyPacket>(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) {
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user