mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-12 19:28:21 +00:00
Condense frame rates
This commit is contained in:
parent
e1cc25759e
commit
4775dbf27f
@ -138,7 +138,7 @@ int main(int argc, char** argv) {
|
|||||||
} else framesSinceLastSQLPing++;
|
} else framesSinceLastSQLPing++;
|
||||||
|
|
||||||
//Sleep our thread since auth can afford to.
|
//Sleep our thread since auth can afford to.
|
||||||
t += std::chrono::milliseconds(mediumFramerate); //Auth can run at a lower "fps"
|
t += std::chrono::milliseconds(mediumFrameDelta); //Auth can run at a lower "fps"
|
||||||
std::this_thread::sleep_until(t);
|
std::this_thread::sleep_until(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ int main(int argc, char** argv) {
|
|||||||
} else framesSinceLastSQLPing++;
|
} else framesSinceLastSQLPing++;
|
||||||
|
|
||||||
//Sleep our thread since auth can afford to.
|
//Sleep our thread since auth can afford to.
|
||||||
t += std::chrono::milliseconds(mediumFramerate); //Chat can run at a lower "fps"
|
t += std::chrono::milliseconds(mediumFrameDelta); //Chat can run at a lower "fps"
|
||||||
std::this_thread::sleep_until(t);
|
std::this_thread::sleep_until(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,15 +6,22 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "../thirdparty/raknet/Source/BitStream.h"
|
#include "BitStream.h"
|
||||||
|
|
||||||
#pragma warning (disable:4251) //Disables SQL warnings
|
#pragma warning (disable:4251) //Disables SQL warnings
|
||||||
|
|
||||||
typedef int RESTICKET;
|
typedef int RESTICKET;
|
||||||
|
|
||||||
const int highFrameRate = 16; //60fps
|
#define FRAMES_TO_MS(x) 1000 / x
|
||||||
const int mediumFramerate = 33; //30fps
|
|
||||||
const int lowFramerate = 66; //15fps
|
//=========== FRAME TIMINGS ===========
|
||||||
|
constexpr uint32_t highFramerate = 60;
|
||||||
|
constexpr uint32_t mediumFramerate = 30;
|
||||||
|
constexpr uint32_t lowFramerate = 15;
|
||||||
|
|
||||||
|
constexpr uint32_t highFrameDelta = FRAMES_TO_MS(highFramerate);
|
||||||
|
constexpr uint32_t mediumFrameDelta = FRAMES_TO_MS(mediumFramerate);
|
||||||
|
constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate);
|
||||||
|
|
||||||
//========== MACROS ===========
|
//========== MACROS ===========
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t += std::chrono::milliseconds(highFrameRate);
|
t += std::chrono::milliseconds(highFrameDelta);
|
||||||
std::this_thread::sleep_until(t);
|
std::this_thread::sleep_until(t);
|
||||||
}
|
}
|
||||||
return FinalizeShutdown(EXIT_SUCCESS);
|
return FinalizeShutdown(EXIT_SUCCESS);
|
||||||
@ -876,7 +876,7 @@ void ShutdownSequence(int signal) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
t += std::chrono::milliseconds(highFrameRate);
|
t += std::chrono::milliseconds(highFrameDelta);
|
||||||
std::this_thread::sleep_until(t);
|
std::this_thread::sleep_until(t);
|
||||||
|
|
||||||
ticks++;
|
ticks++;
|
||||||
|
@ -2,23 +2,18 @@
|
|||||||
|
|
||||||
#include "UserManager.h"
|
#include "UserManager.h"
|
||||||
|
|
||||||
//Times are 1 / fps, in ms
|
#define SOCIAL { lowFrameDelta }
|
||||||
#define HIGH 16 //60 fps
|
#define SOCIAL_HUB { mediumFrameDelta } //Added to compensate for the large playercounts in NS and NT
|
||||||
#define MEDIUM 33 //30 fps
|
#define BATTLE { highFrameDelta }
|
||||||
#define LOW 66 //15 fps
|
#define BATTLE_INSTANCE { mediumFrameDelta }
|
||||||
|
#define RACE { highFrameDelta }
|
||||||
#define SOCIAL { LOW }
|
#define PROPERTY { lowFrameDelta }
|
||||||
#define SOCIAL_HUB { MEDIUM } //Added to compensate for the large playercounts in NS and NT
|
|
||||||
#define BATTLE { HIGH }
|
|
||||||
#define BATTLE_INSTANCE { MEDIUM }
|
|
||||||
#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 };
|
PerformanceProfile PerformanceManager::m_InactiveProfile = { lowFrameDelta };
|
||||||
|
|
||||||
std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
||||||
// VE
|
// VE
|
||||||
@ -72,13 +67,6 @@ std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
|
|||||||
{ 2001, BATTLE_INSTANCE },
|
{ 2001, BATTLE_INSTANCE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
@ -8,18 +8,13 @@ struct PerformanceProfile {
|
|||||||
uint32_t serverFramerate;
|
uint32_t serverFramerate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PerformanceManager {
|
class PerformanceManager {
|
||||||
public:
|
public:
|
||||||
~PerformanceManager();
|
|
||||||
|
|
||||||
static void SelectProfile(LWOMAPID mapID);
|
static void SelectProfile(LWOMAPID mapID);
|
||||||
|
|
||||||
static uint32_t GetServerFramerate();
|
static uint32_t GetServerFramerate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PerformanceManager();
|
|
||||||
|
|
||||||
static PerformanceProfile m_CurrentProfile;
|
static PerformanceProfile m_CurrentProfile;
|
||||||
static PerformanceProfile m_DefaultProfile;
|
static PerformanceProfile m_DefaultProfile;
|
||||||
static PerformanceProfile m_InactiveProfile;
|
static PerformanceProfile m_InactiveProfile;
|
||||||
|
@ -232,7 +232,7 @@ int main(int argc, char** argv) {
|
|||||||
bool ready = false;
|
bool ready = false;
|
||||||
int framesSinceMasterStatus = 0;
|
int framesSinceMasterStatus = 0;
|
||||||
int framesSinceShutdownSequence = 0;
|
int framesSinceShutdownSequence = 0;
|
||||||
int currentFramerate = highFrameRate;
|
int currentFramerate = highFrameDelta;
|
||||||
|
|
||||||
int ghostingStepCount = 0;
|
int ghostingStepCount = 0;
|
||||||
auto ghostingLastTime = std::chrono::high_resolution_clock::now();
|
auto ghostingLastTime = std::chrono::high_resolution_clock::now();
|
||||||
@ -300,7 +300,7 @@ int main(int argc, char** argv) {
|
|||||||
const auto occupied = UserManager::Instance()->GetUserCount() != 0;
|
const auto occupied = UserManager::Instance()->GetUserCount() != 0;
|
||||||
|
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
currentFramerate = highFrameRate;
|
currentFramerate = highFrameDelta;
|
||||||
} else {
|
} else {
|
||||||
currentFramerate = PerformanceManager::GetServerFramerate();
|
currentFramerate = PerformanceManager::GetServerFramerate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user