mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +00:00
Rehook dPhysics to main framerate
Should fix bug causing double enter and exit events
This commit is contained in:
parent
cabd220a66
commit
d5a18af0e8
@ -2,21 +2,23 @@
|
|||||||
|
|
||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
|
|
||||||
#define HIGH 16
|
//Times are 1 / fps, in ms
|
||||||
#define MEDIUM 33
|
#define HIGH 16 //60 fps
|
||||||
#define LOW 66
|
#define MEDIUM 33 //30 fps
|
||||||
|
#define LOW 66 //15 fps
|
||||||
|
|
||||||
#define SOCIAL { MEDIUM, LOW }
|
#define SOCIAL { LOW }
|
||||||
#define BATTLE { HIGH, MEDIUM }
|
#define SOCIAL_HUB { MEDIUM } //Added to compensate for the large playercounts in NS and NT
|
||||||
#define BATTLE_INSTANCE { MEDIUM, LOW }
|
#define BATTLE { HIGH }
|
||||||
#define RACE { MEDIUM, LOW }
|
#define BATTLE_INSTANCE { MEDIUM }
|
||||||
#define PROPERTY { LOW, LOW }
|
#define RACE { HIGH }
|
||||||
|
#define PROPERTY { LOW }
|
||||||
|
|
||||||
PerformanceProfile PerformanceManager::m_CurrentProfile = SOCIAL;
|
PerformanceProfile PerformanceManager::m_CurrentProfile = SOCIAL;
|
||||||
|
|
||||||
PerformanceProfile PerformanceManager::m_DefaultProfile = SOCIAL;
|
PerformanceProfile PerformanceManager::m_DefaultProfile = SOCIAL;
|
||||||
|
|
||||||
PerformanceProfile PerformanceManager::m_InactiveProfile = { LOW, LOW };
|
PerformanceProfile PerformanceManager::m_InactiveProfile = { LOW };
|
||||||
|
|
||||||
std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
||||||
// VE
|
// VE
|
||||||
@ -30,7 +32,7 @@ std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
|||||||
{ 1151, PROPERTY },
|
{ 1151, PROPERTY },
|
||||||
|
|
||||||
// NS
|
// NS
|
||||||
{ 1200, SOCIAL },
|
{ 1200, SOCIAL_HUB },
|
||||||
{ 1201, SOCIAL },
|
{ 1201, SOCIAL },
|
||||||
{ 1203, RACE },
|
{ 1203, RACE },
|
||||||
{ 1204, BATTLE_INSTANCE },
|
{ 1204, BATTLE_INSTANCE },
|
||||||
@ -63,7 +65,7 @@ std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
|||||||
{ 1800, BATTLE },
|
{ 1800, BATTLE },
|
||||||
|
|
||||||
// NT
|
// NT
|
||||||
{ 1900, SOCIAL },
|
{ 1900, SOCIAL_HUB },
|
||||||
|
|
||||||
// NJ
|
// NJ
|
||||||
{ 2000, BATTLE },
|
{ 2000, BATTLE },
|
||||||
@ -71,20 +73,16 @@ std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PerformanceManager::PerformanceManager()
|
PerformanceManager::PerformanceManager() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceManager::~PerformanceManager()
|
PerformanceManager::~PerformanceManager() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerformanceManager::SelectProfile(LWOMAPID mapID)
|
void PerformanceManager::SelectProfile(LWOMAPID mapID) {
|
||||||
{
|
|
||||||
const auto pair = m_Profiles.find(mapID);
|
const auto pair = m_Profiles.find(mapID);
|
||||||
|
|
||||||
if (pair == m_Profiles.end())
|
if (pair == m_Profiles.end()) {
|
||||||
{
|
|
||||||
m_CurrentProfile = m_DefaultProfile;
|
m_CurrentProfile = m_DefaultProfile;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -93,32 +91,10 @@ void PerformanceManager::SelectProfile(LWOMAPID mapID)
|
|||||||
m_CurrentProfile = pair->second;
|
m_CurrentProfile = pair->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PerformanceManager::GetServerFramerate()
|
uint32_t PerformanceManager::GetServerFramerate() {
|
||||||
{
|
if (UserManager::Instance()->GetUserCount() == 0) {
|
||||||
if (UserManager::Instance()->GetUserCount() == 0)
|
|
||||||
{
|
|
||||||
return m_InactiveProfile.serverFramerate;
|
return m_InactiveProfile.serverFramerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_CurrentProfile.serverFramerate;
|
return m_CurrentProfile.serverFramerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PerformanceManager::GetPhysicsFramerate()
|
|
||||||
{
|
|
||||||
if (UserManager::Instance()->GetUserCount() == 0)
|
|
||||||
{
|
|
||||||
return m_InactiveProfile.physicsFramerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_CurrentProfile.physicsFramerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t PerformanceManager::GetPhysicsStepRate()
|
|
||||||
{
|
|
||||||
if (UserManager::Instance()->GetUserCount() == 0)
|
|
||||||
{
|
|
||||||
return 10; // Row physics at a really low framerate if the server is empty
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_CurrentProfile.physicsFramerate / m_CurrentProfile.serverFramerate;
|
|
||||||
}
|
|
||||||
|
@ -4,23 +4,18 @@
|
|||||||
|
|
||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
|
|
||||||
struct PerformanceProfile
|
struct PerformanceProfile {
|
||||||
{
|
|
||||||
uint32_t serverFramerate;
|
uint32_t serverFramerate;
|
||||||
uint32_t physicsFramerate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PerformanceManager
|
class PerformanceManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
~PerformanceManager();
|
~PerformanceManager();
|
||||||
|
|
||||||
static void SelectProfile(LWOMAPID mapID);
|
static void SelectProfile(LWOMAPID mapID);
|
||||||
|
|
||||||
static uint32_t GetServerFramerate();
|
static uint32_t GetServerFramerate();
|
||||||
static uint32_t GetPhysicsFramerate();
|
|
||||||
static uint32_t GetPhysicsStepRate();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PerformanceManager();
|
PerformanceManager();
|
||||||
|
@ -223,9 +223,7 @@ int main(int argc, char** argv) {
|
|||||||
int framesSinceMasterStatus = 0;
|
int framesSinceMasterStatus = 0;
|
||||||
int framesSinceShutdownSequence = 0;
|
int framesSinceShutdownSequence = 0;
|
||||||
int currentFramerate = highFrameRate;
|
int currentFramerate = highFrameRate;
|
||||||
int physicsFramerate = highFrameRate;
|
|
||||||
int physicsStepRate = 0;
|
|
||||||
int physicsStepCount = 0;
|
|
||||||
int ghostingStepCount = 0;
|
int ghostingStepCount = 0;
|
||||||
auto ghostingLastTime = std::chrono::high_resolution_clock::now();
|
auto ghostingLastTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
@ -301,9 +299,6 @@ int main(int argc, char** argv) {
|
|||||||
currentFramerate = PerformanceManager::GetServerFramerate();
|
currentFramerate = PerformanceManager::GetServerFramerate();
|
||||||
}
|
}
|
||||||
|
|
||||||
physicsFramerate = PerformanceManager::GetPhysicsFramerate();
|
|
||||||
physicsStepRate = PerformanceManager::GetPhysicsStepRate();
|
|
||||||
|
|
||||||
//Warning if we ran slow
|
//Warning if we ran slow
|
||||||
if (deltaTime > currentFramerate) {
|
if (deltaTime > currentFramerate) {
|
||||||
Game::logger->Log("WorldServer", "We're running behind, dT: %f > %f (framerate)\n", deltaTime, currentFramerate);
|
Game::logger->Log("WorldServer", "We're running behind, dT: %f > %f (framerate)\n", deltaTime, currentFramerate);
|
||||||
@ -338,10 +333,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if (zoneID != 0 && deltaTime > 0.0f) {
|
if (zoneID != 0 && deltaTime > 0.0f) {
|
||||||
Metrics::StartMeasurement(MetricVariable::Physics);
|
Metrics::StartMeasurement(MetricVariable::Physics);
|
||||||
if (physicsStepCount++ >= physicsStepRate) {
|
|
||||||
dpWorld::Instance().StepWorld(deltaTime);
|
dpWorld::Instance().StepWorld(deltaTime);
|
||||||
physicsStepCount = 0;
|
|
||||||
}
|
|
||||||
Metrics::EndMeasurement(MetricVariable::Physics);
|
Metrics::EndMeasurement(MetricVariable::Physics);
|
||||||
|
|
||||||
Metrics::StartMeasurement(MetricVariable::UpdateEntities);
|
Metrics::StartMeasurement(MetricVariable::UpdateEntities);
|
||||||
|
Loading…
Reference in New Issue
Block a user