From 9cd5b415c1d44c8abb5bbdcc16ecae5c12b8be63 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 10 Mar 2018 11:04:31 +0200 Subject: [PATCH 1/3] Improved profilethinkers in various ways Added features: * Formatted table * Average time per one actor * Sorting column highlight * Rows limit * Usage help --- src/dthinker.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/src/dthinker.cpp b/src/dthinker.cpp index 7b0cfb824..39de2e9d6 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -41,6 +41,8 @@ #include "serializer.h" #include "d_player.h" #include "vm.h" +#include "c_dispatch.h" +#include "v_text.h" static int ThinkCount; @@ -462,7 +464,57 @@ void DThinker::DestroyThinkersInList (FThinkerList &list) // // //========================================================================== -CVAR(Int, profilethinkers, 0, 0) +static unsigned int profilethinkers, profilelimit; + +CCMD(profilethinkers) +{ + const int argc = argv.argc(); + + if (argc == 2 || argc == 3) + { + const char *str = argv[1]; + bool ascend = true; + + if (*str == '+') + { + ++str; + } + else if (*str == '-') + { + ascend = false; + ++str; + } + + int mode = 0; + + switch (*str) + { + case 't': mode = ascend ? 7 : 8; break; + case 'a': mode = ascend ? 5 : 6; break; + case '#': mode = ascend ? 3 : 4; break; + case 'c': mode = ascend ? 1 : 2; break; + default: mode = atoi(str); break; + } + + profilethinkers = mode; + profilelimit = argc == 3 ? atoi(argv[2]) : 0; + } + else + { + Printf( + "Usage: profilethinkers [+|-][t|a|#|c] [limit]\n" + " profilethinkers [1..8] [limit]\n\n" + "Sorting modes:\n" + TEXTCOLOR_YELLOW "c +c 1 " TEXTCOLOR_NORMAL "actor class, ascending\n" + TEXTCOLOR_YELLOW " -c 2 " TEXTCOLOR_NORMAL "actor class, descending\n" + TEXTCOLOR_YELLOW "# +# 3 " TEXTCOLOR_NORMAL "number of calls, ascending\n" + TEXTCOLOR_YELLOW " -# 4 " TEXTCOLOR_NORMAL "number of calls, descending\n" + TEXTCOLOR_YELLOW "a +a 5 " TEXTCOLOR_NORMAL "average time, ascending\n" + TEXTCOLOR_YELLOW " -a 6 " TEXTCOLOR_NORMAL "average time, descending\n" + TEXTCOLOR_YELLOW "t +t 7 " TEXTCOLOR_NORMAL "total time, ascending\n" + TEXTCOLOR_YELLOW " -t 8 " TEXTCOLOR_NORMAL "total time, descending\n"); + } +} struct ProfileInfo { @@ -556,19 +608,33 @@ void DThinker::RunThinkers () return left.numcalls < right.numcalls; case 4: // number of calls, descending return right.numcalls < left.numcalls; - case 5: // total time, ascending + case 5: // average time, ascending + return left.time / left.numcalls < right.time / right.numcalls; + case 6: // average time, descending + return right.time / right.numcalls < left.time / left.numcalls; + case 7: // total time, ascending return left.time < right.time; default: // total time, descending return right.time < left.time; } }); - for (const SortedProfileInfo& info : sorted) + Printf(TEXTCOLOR_YELLOW "Total, ms Averg, ms Calls Actor class\n"); + Printf(TEXTCOLOR_YELLOW "---------- ---------- ------ --------------------\n"); + + const unsigned count = MIN(profilelimit > 0 ? profilelimit : UINT_MAX, sorted.Size()); + + for (unsigned i = 0; i < count; ++i) { - Printf("%s, %dx, %fms\n", info.className, info.numcalls, info.time); + const SortedProfileInfo& info = sorted[i]; + Printf("%s%10.6f %s%10.6f %s%6d %s%s\n", + profilethinkers >= 7 ? TEXTCOLOR_YELLOW : TEXTCOLOR_WHITE, info.time, + profilethinkers == 5 || profilethinkers == 6 ? TEXTCOLOR_YELLOW : TEXTCOLOR_WHITE, info.time / info.numcalls, + profilethinkers == 3 || profilethinkers == 4 ? TEXTCOLOR_YELLOW : TEXTCOLOR_WHITE, info.numcalls, + profilethinkers == 1 || profilethinkers == 2 ? TEXTCOLOR_YELLOW : TEXTCOLOR_WHITE, info.className); } - profilethinkers = false; + profilethinkers = 0; } ThinkCycles.Unclock(); From 37fa3fa25e9690f802d23fbe46ab9add17562ed8 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 10 Mar 2018 10:36:43 -0500 Subject: [PATCH 2/3] - add variables 'am_unexploredsecretcolor' and 'am_ovunexploredsecretcolor' to mark undiscovered secrets differently in the automap --- src/am_map.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 452f82b78..c6e6ba19b 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -138,6 +138,7 @@ CVAR (Color, am_lockedcolor, 0x007800, CVAR_ARCHIVE); CVAR (Color, am_intralevelcolor, 0x0000ff, CVAR_ARCHIVE); CVAR (Color, am_interlevelcolor, 0xff0000, CVAR_ARCHIVE); CVAR (Color, am_secretsectorcolor, 0xff00ff, CVAR_ARCHIVE); +CVAR (Color, am_unexploredsecretcolor, 0xff00ff, CVAR_ARCHIVE); CVAR (Color, am_thingcolor_friend, 0xfcfcfc, CVAR_ARCHIVE); CVAR (Color, am_thingcolor_monster, 0xfcfcfc, CVAR_ARCHIVE); CVAR (Color, am_thingcolor_ncmonster, 0xfcfcfc, CVAR_ARCHIVE); @@ -158,6 +159,7 @@ CVAR (Color, am_ovunseencolor, 0x00226e, CVAR_ARCHIVE); CVAR (Color, am_ovtelecolor, 0xffff00, CVAR_ARCHIVE); CVAR (Color, am_ovinterlevelcolor, 0xffff00, CVAR_ARCHIVE); CVAR (Color, am_ovsecretsectorcolor,0x00ffff, CVAR_ARCHIVE); +CVAR (Color, am_ovunexploredsecretcolor,0x00ffff, CVAR_ARCHIVE); CVAR (Color, am_ovthingcolor, 0xe88800, CVAR_ARCHIVE); CVAR (Color, am_ovthingcolor_friend, 0xe88800, CVAR_ARCHIVE); CVAR (Color, am_ovthingcolor_monster, 0xe88800, CVAR_ARCHIVE); @@ -230,6 +232,7 @@ static const char *ColorNames[] = { "IntraTeleportColor", "InterTeleportColor", "SecretSectorColor", + "UnexploredSecretColor", "PortalColor", "AlmostBackgroundColor", NULL @@ -261,6 +264,7 @@ struct AMColorset IntraTeleportColor, InterTeleportColor, SecretSectorColor, + UnexploredSecretColor, PortalColor, AlmostBackgroundColor, AM_NUM_COLORS @@ -362,6 +366,7 @@ static FColorCVar *cv_standard[] = { &am_intralevelcolor, &am_interlevelcolor, &am_secretsectorcolor, + &am_unexploredsecretcolor, &am_portalcolor }; @@ -388,6 +393,7 @@ static FColorCVar *cv_overlay[] = { &am_ovtelecolor, &am_ovinterlevelcolor, &am_ovsecretsectorcolor, + &am_ovunexploredsecretcolor, &am_ovportalcolor }; @@ -430,6 +436,7 @@ static unsigned char DoomColors[]= { NOT_USED, // intrateleport NOT_USED, // interteleport NOT_USED, // secretsector + NOT_USED, // unexploredsecretsector 0x10,0x10,0x10, // almostbackground 0x40,0x40,0x40 // portal }; @@ -457,6 +464,7 @@ static unsigned char StrifeColors[]= { NOT_USED, // intrateleport NOT_USED, // interteleport NOT_USED, // secretsector + NOT_USED, // unexploredsecretsector 0x10,0x10,0x10, // almostbackground 0x40,0x40,0x40 // portal }; @@ -484,6 +492,7 @@ static unsigned char RavenColors[]= { NOT_USED, // intrateleport NOT_USED, // interteleport NOT_USED, // secretsector + NOT_USED, // unexploredsecretsector 0x10,0x10,0x10, // almostbackground 0x50,0x50,0x50 // portal }; @@ -2209,7 +2218,7 @@ void AM_drawSubsectors() // //============================================================================= -static bool AM_CheckSecret(line_t *line) +static int AM_CheckSecret(line_t *line) { if (AMColors.isValid(AMColors.SecretSectorColor)) { @@ -2217,20 +2226,20 @@ static bool AM_CheckSecret(line_t *line) { if (line->frontsector->wasSecret()) { - if (am_map_secrets!=0 && !line->frontsector->isSecret()) return true; - if (am_map_secrets==2 && !(line->flags & ML_SECRET)) return true; + if (am_map_secrets!=0 && !line->frontsector->isSecret()) return 1; + if (am_map_secrets==2 && !(line->flags & ML_SECRET)) return 2; } } if (line->backsector != NULL) { if (line->backsector->wasSecret()) { - if (am_map_secrets!=0 && !line->backsector->isSecret()) return true; - if (am_map_secrets==2 && !(line->flags & ML_SECRET)) return true; + if (am_map_secrets!=0 && !line->backsector->isSecret()) return 1; + if (am_map_secrets==2 && !(line->flags & ML_SECRET)) return 2; } } } - return false; + return 0; } @@ -2584,11 +2593,15 @@ void AM_drawWalls (bool allmap) { AM_drawMline(&l, AMColors.PortalColor); } - else if (AM_CheckSecret(&line)) + else if (AM_CheckSecret(&line) == 1) { // map secret sectors like Boom AM_drawMline(&l, AMColors.SecretSectorColor); } + else if (AM_CheckSecret(&line) == 2) + { + AM_drawMline(&l, AMColors.UnexploredSecretColor); + } else if (line.flags & ML_SECRET) { // secret door if (am_cheat != 0 && line.backsector != NULL) From 9600cfde3cf5556a47330d9239eeb7904f9ae75a Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 10 Mar 2018 10:55:24 -0500 Subject: [PATCH 3/3] - put unexplored secret color picker in the menu --- wadsrc/static/language.enu | 1 + wadsrc/static/menudef.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index eabe3b2f5..155ce839d 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1979,6 +1979,7 @@ MAPCOLORMNU_LOCKEDCOLOR = "Locked doors"; MAPCOLORMNU_INTRALEVELCOLOR = "Teleporter to the same map"; MAPCOLORMNU_INTERLEVELCOLOR = "Teleporter to a different map"; MAPCOLORMNU_SECRETSECTORCOLOR = "Secret sector"; +MAPCOLORMNU_UNEXPLOREDSECRETCOLOR = "Unexplored secret"; MAPCOLORMNU_SPECIALWALLCOLOR = "Special trigger lines"; MAPCOLORMNU_CHEATMODE = "Cheat Mode"; MAPCOLORMNU_TSWALLCOLOR = "Invisible 2-sided walls"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 09604328c..744e4d4c7 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1157,6 +1157,7 @@ OptionMenu MapColorMenu protected ColorPicker "$MAPCOLORMNU_INTRALEVELCOLOR", "am_intralevelcolor" ColorPicker "$MAPCOLORMNU_INTERLEVELCOLOR", "am_interlevelcolor" ColorPicker "$MAPCOLORMNU_SECRETSECTORCOLOR", "am_secretsectorcolor" + ColorPicker "$MAPCOLORMNU_UNEXPLOREDSECRETCOLOR", "am_unexploredsecretcolor" ColorPicker "$MAPCOLORMNU_SPECIALWALLCOLOR", "am_specialwallcolor" ColorPicker "$MAPCOLORMNU_PORTAL", "am_portalcolor" StaticText " "