mirror of
https://github.com/glest/glest-source.git
synced 2025-10-04 19:31:32 +02:00
- try to get threaded client working without lag
This commit is contained in:
@@ -1717,17 +1717,31 @@ void Game::update() {
|
|||||||
//updateLoops = 80;
|
//updateLoops = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
bool enableServerControlledAI = this->gameSettings.getEnableServerControlledAI();
|
||||||
|
bool isNetworkGame = this->gameSettings.isNetworkGame();
|
||||||
|
NetworkRole role = networkManager.getNetworkRole();
|
||||||
|
|
||||||
|
if(role == nrClient && updateLoops == 1) {
|
||||||
|
ClientInterface *clientInterface = dynamic_cast<ClientInterface *>(networkManager.getClientInterface());
|
||||||
|
if(clientInterface != NULL) {
|
||||||
|
uint64 lastNetworkFrameFromServer = clientInterface->getCachedLastPendingFrameCount();
|
||||||
|
if(lastNetworkFrameFromServer > 0 && lastNetworkFrameFromServer > world.getFrameCount() + gameSettings.getNetworkFramePeriod()) {
|
||||||
|
int frameDifference = lastNetworkFrameFromServer - world.getFrameCount();
|
||||||
|
|
||||||
|
printf("Client will speed up: %d frames lastNetworkFrameFromServer: %lld world.getFrameCount() = %d updateLoops = %d\n",frameDifference,(long long int)lastNetworkFrameFromServer,world.getFrameCount(),updateLoops);
|
||||||
|
|
||||||
|
updateLoops += frameDifference;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(showPerfStats) {
|
if(showPerfStats) {
|
||||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||||
perfList.push_back(perfBuf);
|
perfList.push_back(perfBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
|
||||||
bool enableServerControlledAI = this->gameSettings.getEnableServerControlledAI();
|
|
||||||
bool isNetworkGame = this->gameSettings.isNetworkGame();
|
|
||||||
NetworkRole role = networkManager.getNetworkRole();
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [before ReplaceDisconnectedNetworkPlayersWithAI]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld [before ReplaceDisconnectedNetworkPlayersWithAI]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(showPerfStats) {
|
if(showPerfStats) {
|
||||||
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
||||||
|
@@ -946,6 +946,14 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64 ClientInterface::getCachedLastPendingFrameCount() {
|
||||||
|
MutexSafeWrapper safeMutex(networkCommandListThreadAccessor,CODE_AT_LINE);
|
||||||
|
uint64 result = cachedLastPendingFrameCount;
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientInterface::simpleTask(BaseThread *callingThread) {
|
void ClientInterface::simpleTask(BaseThread *callingThread) {
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
||||||
|
@@ -90,6 +90,8 @@ public:
|
|||||||
bool getResumeInGameJoin() const { return resumeInGameJoin; }
|
bool getResumeInGameJoin() const { return resumeInGameJoin; }
|
||||||
void sendResumeGameMessage();
|
void sendResumeGameMessage();
|
||||||
|
|
||||||
|
uint64 getCachedLastPendingFrameCount();
|
||||||
|
|
||||||
//message processing
|
//message processing
|
||||||
virtual void update();
|
virtual void update();
|
||||||
virtual void updateLobby();
|
virtual void updateLobby();
|
||||||
|
Reference in New Issue
Block a user