Reduced CPU load of the client
This commit is contained in:
@@ -137,11 +137,17 @@ void ClientApplication::Proc() {
|
|||||||
realTime = Clock::now();
|
realTime = Clock::now();
|
||||||
|
|
||||||
//simulate game time
|
//simulate game time
|
||||||
while (simTime < realTime) {
|
if (simTime < realTime) {
|
||||||
//call each user defined function
|
while (simTime < realTime) {
|
||||||
activeScene->RunFrame();
|
//call each user defined function
|
||||||
//~60 FPS
|
activeScene->RunFrame();
|
||||||
simTime += std::chrono::duration<int, std::milli>(16);
|
//~60 FPS
|
||||||
|
simTime += std::chrono::duration<int, std::milli>(16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//give the machine a break
|
||||||
|
SDL_Delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw the game to the screen
|
//draw the game to the screen
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ void ServerApplication::Proc() {
|
|||||||
std::cerr << "Client dropped: " << disconnected << std::endl;
|
std::cerr << "Client dropped: " << disconnected << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//give the computer a break
|
//give the machine a break
|
||||||
SDL_Delay(10);
|
SDL_Delay(10);
|
||||||
}
|
}
|
||||||
delete reinterpret_cast<char*>(packetBuffer);
|
delete reinterpret_cast<char*>(packetBuffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user