History

support for multiple voxel servers in ping stats

ZappoMan committed 13 years ago

Commit 620fe121 parent 95e6fb12 files · +24 −9Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+23−8
@@ -2883,19 +2883,35 @@ void Application::displayStats() { · 2882 unmodified lines
28832883 drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
28842884
28852885 if (_testPing->isChecked()) {
2886− int pingAudio = 0, pingAvatar = 0, pingVoxel = 0;
2886+ int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
28872887
2888− NodeList *nodeList = NodeList::getInstance();
2889− Node *audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
2890− Node *avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
2891− Node *voxelServerNode = nodeList->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);
2888+ NodeList* nodeList = NodeList::getInstance();
2889+ Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
2890+ Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
28922891
28932892 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
28942893 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
2895− pingVoxel = voxelServerNode ? voxelServerNode->getPingMs() : 0;
2894+
2895+
2896+ // Now handle voxel servers, since there could be more than one, we average their ping times
2897+ unsigned long totalPingVoxel = 0;
2898+ int voxelServerCount = 0;
2899+ for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2900+ if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
2901+ totalPingVoxel += node->getPingMs();
2902+ voxelServerCount++;
2903+ if (pingVoxelMax < node->getPingMs()) {
2904+ pingVoxelMax = node->getPingMs();
2905+ }
2906+ }
2907+ }
2908+ if (voxelServerCount) {
2909+ pingVoxel = totalPingVoxel/voxelServerCount;
2910+ }
2911+
28962912
28972913 char pingStats[200];
2898− sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d ", pingAudio, pingAvatar, pingVoxel);
2914+ sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d avg %d max ", pingAudio, pingAvatar, pingVoxel, pingVoxelMax);
28992915 drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats);
29002916 }
29012917
@@ -3495,7 +3511,6 @@ void* Application::networkReceive(void* args) { · 593 unmodified lines
34953511 } // fall through to piggyback message
34963512
34973513 if (app->_renderVoxels->isChecked()) {
3498− //Node* voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);
34993514 Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
35003515 if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
35013516 voxelServer->lock();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t