Révision | b24867c9a99ebe704d6d701c903e7243d0e6046f (tree) |
---|---|
l'heure | 2023-03-15 23:25:00 |
Auteur | Sean Baggaley <sean@csnx...> |
Commiter | Sean Baggaley |
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).
@@ -111,6 +111,7 @@ | ||
111 | 111 | ! - 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] |
112 | 112 | ! - 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] |
113 | 113 | ! - 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] | |
114 | 115 | |
115 | 116 | |
116 | 117 | 3.1 |
@@ -51,6 +51,8 @@ | ||
51 | 51 | #include "p_acs.h" |
52 | 52 | |
53 | 53 | #include <map> |
54 | +#include <vector> | |
55 | +#include <algorithm> | |
54 | 56 | |
55 | 57 | //***************************************************************************** |
56 | 58 | // VARIABLES |
@@ -109,14 +111,34 @@ | ||
109 | 111 | if ( NETWORK_GetState( ) != NETSTATE_SERVER ) |
110 | 112 | return; |
111 | 113 | |
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 | + | |
112 | 123 | Printf ( "Network traffic (in bytes) caused by actor code pointers:\n" ); |
113 | 124 | |
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 | + } | |
116 | 132 | |
117 | 133 | 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 | + } | |
120 | 142 | } |
121 | 143 | |
122 | 144 | //***************************************************************************** |