Commit MetaInfo

Révisionb24867c9a99ebe704d6d701c903e7243d0e6046f (tree)
l'heure2023-03-15 23:25:00
AuteurSean Baggaley <sean@csnx...>
CommiterSean Baggaley

Message de Log

The output of the dumptrafficmeasure CCMD is now sorted by the bandwidth used in ascending order. This can be changed to descending order by specifying "desc" as the first parameter (addresses 4090).

Change Summary

Modification

diff -r 42c405796de6 -r b24867c9a99e docs/zandronum-history.txt
--- a/docs/zandronum-history.txt Sun Feb 19 20:17:33 2023 +0000
+++ b/docs/zandronum-history.txt Wed Mar 15 14:25:00 2023 +0000
@@ -111,6 +111,7 @@
111111 ! - The GAMEMODE lump now accepts a wider range of gameplay-related CVars that aren't limited to flags. Strictly speaking, any CVars with the CVAR_GAMEPLAYSETTING bit, or any flags whose flagset has the CVAR_GAMEPLAYFLAGSET (previously named CVAR_GAMEMODELOCK) bit. [Kaminsky]
112112 ! - The "maplist" CCMD now also prints "current" or "used" alongside green or red text for map entries that are currently being played or used. This change is particularly useful for consoles or logfiles that strip color codes and couldn't show the colored text. [Kaminsky]
113113 ! - Zandronum is now marked as DPI-aware on Windows, which prevents issues caused by the operating system automatically upscaling the game window on high-DPI displays. [DrinkyBird]
114+! - The output of the dumptrafficmeasure CCMD is now sorted by the bandwidth used in ascending order. This can be changed to descending order by specifying "desc" as the first parameter. [DrinkyBird]
114115
115116
116117 3.1
diff -r 42c405796de6 -r b24867c9a99e src/network/nettraffic.cpp
--- a/src/network/nettraffic.cpp Sun Feb 19 20:17:33 2023 +0000
+++ b/src/network/nettraffic.cpp Wed Mar 15 14:25:00 2023 +0000
@@ -51,6 +51,8 @@
5151 #include "p_acs.h"
5252
5353 #include <map>
54+#include <vector>
55+#include <algorithm>
5456
5557 //*****************************************************************************
5658 // VARIABLES
@@ -109,14 +111,34 @@
109111 if ( NETWORK_GetState( ) != NETSTATE_SERVER )
110112 return;
111113
114+ // [SB] Sort ascending by default, so the actors and scripts using the most bandwidth
115+ // are more immediately visible when viewed in the console.
116+ const bool bSortDescending = argv.argc() > 1 && stricmp( argv[1], "desc" ) == 0;
117+
118+ const auto sortComparator = [=]( const auto &a, const auto &b )
119+ {
120+ return bSortDescending ? ( a.second > b.second ) : ( a.second < b.second );
121+ };
122+
112123 Printf ( "Network traffic (in bytes) caused by actor code pointers:\n" );
113124
114- for ( std::map<const char*, int, ltstr>::const_iterator it = g_actorTrafficMap.begin(); it != g_actorTrafficMap.end(); ++it )
115- Printf ( "%s %d\n", (*it).first, (*it).second );
125+ {
126+ std::vector<std::pair<const char*, int>> pairs( g_actorTrafficMap.cbegin(), g_actorTrafficMap.cend() );
127+ std::sort( pairs.begin(), pairs.end(), sortComparator );
128+
129+ for ( auto it = pairs.cbegin(); it != pairs.cend(); ++it )
130+ Printf ( "%s %d\n", (*it).first, (*it).second );
131+ }
116132
117133 Printf ( "\nNetwork traffic (in bytes) caused by ACS scripts:\n" );
118- for ( std::map<int, int>::const_iterator it = g_ACSScriptTrafficMap.begin(); it != g_ACSScriptTrafficMap.end(); ++it )
119- Printf ( "Script %s: %d\n", FBehavior::RepresentScript( (*it).first ).GetChars(), (*it).second );
134+
135+ {
136+ std::vector<std::pair<int, int>> pairs( g_ACSScriptTrafficMap.cbegin(), g_ACSScriptTrafficMap.cend() );
137+ std::sort( pairs.begin(), pairs.end(), sortComparator );
138+
139+ for ( auto it = pairs.cbegin(); it != pairs.cend(); ++it )
140+ Printf ( "Script %s: %d\n", FBehavior::RepresentScript( (*it).first ).GetChars(), (*it).second );
141+ }
120142 }
121143
122144 //*****************************************************************************
Afficher sur ancien navigateur de dépôt.