Add Counter for world updates per Second (#707)
* Add Counter for world updates per Second This work was just done for personal testing and is probably not up to the required code standards. Nonetheless, I have decided to send a PR as it is very useful information and a good starting point. * add MarkWorldUpdate method
This commit is contained in:
parent
d45678b3c8
commit
4ea1e50ae0
@ -99,6 +99,7 @@ namespace spades {
|
||||
};
|
||||
|
||||
FPSCounter fpsCounter;
|
||||
FPSCounter upsCounter;
|
||||
|
||||
std::unique_ptr<NetClient> net;
|
||||
std::string playerName;
|
||||
@ -265,16 +266,16 @@ namespace spades {
|
||||
/**
|
||||
* Retrieves the target player ID of the current camera mode (as returned by
|
||||
* `GetCameraMode`).
|
||||
*
|
||||
* Throws an exception if the current camera mode does not have a player in concern.
|
||||
*
|
||||
* Throws an exception if the current camera mode does not have a player in concern.
|
||||
*/
|
||||
int GetCameraTargetPlayerId();
|
||||
|
||||
/**
|
||||
* Retrieves the target player of the current camera mode (as returned by
|
||||
* `GetCameraMode`).
|
||||
*
|
||||
* Throws an exception if the current camera mode does not have a player in concern.
|
||||
*
|
||||
* Throws an exception if the current camera mode does not have a player in concern.
|
||||
*/
|
||||
Player &GetCameraTargetPlayer();
|
||||
|
||||
@ -413,6 +414,8 @@ namespace spades {
|
||||
World *GetWorld() const { return world.get(); }
|
||||
void AddLocalEntity(ILocalEntity *ent) { localEntities.emplace_back(ent); }
|
||||
|
||||
void MarkWorldUpdate();
|
||||
|
||||
IRenderer *GetRenderer() { return renderer; }
|
||||
SceneDefinition GetLastSceneDef() { return lastSceneDef; }
|
||||
IAudioDevice *GetAudioDevice() { return audioDevice; }
|
||||
|
@ -924,6 +924,16 @@ namespace spades {
|
||||
str += buf;
|
||||
}
|
||||
}
|
||||
{
|
||||
// Display world updates per second
|
||||
auto ups = upsCounter.GetFps();
|
||||
if (ups == 0.0)
|
||||
str += ", --.-- ups";
|
||||
else {
|
||||
sprintf(buf, ", %.02f ups", ups);
|
||||
str += buf;
|
||||
}
|
||||
}
|
||||
|
||||
if (net) {
|
||||
auto ping = net->GetPing();
|
||||
|
@ -336,5 +336,9 @@ namespace spades {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Client::MarkWorldUpdate() {
|
||||
upsCounter.MarkFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -818,6 +818,8 @@ namespace spades {
|
||||
if (protocolVersion == 4)
|
||||
bytesPerEntry++;
|
||||
|
||||
client->MarkWorldUpdate();
|
||||
|
||||
int entries = static_cast<int>(reader.GetData().size() / bytesPerEntry);
|
||||
for (int i = 0; i < entries; i++) {
|
||||
int idx = i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user