Skip to content

Commit 889dabd

Browse files
committed
Added Debug function option: summary
1 parent 67ac194 commit 889dabd

File tree

5 files changed

+327
-10
lines changed

5 files changed

+327
-10
lines changed

doc.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ UINT AFXAPI AfxGetFileTitle(LPCTSTR lpszPathName, LPTSTR lpszTitle, UINT nMax);
4848
#endif
4949
#endif
5050

51-
/* These macros are the standard way of turning unquoted text into C strings.
52-
They allow macros like PCRE_MAJOR to be defined without quotes, which is
53-
convenient for user programs that want to test its value. */
54-
55-
#define STRING(a) # a
56-
#define XSTRING(s) STRING(s)
57-
58-
5951
#ifdef _DEBUG
6052
//#define new DEBUG_NEW
6153
#undef THIS_FILE

globalregistryoptions.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static tGlobalConfigurationAlphaOption AlphaGlobalOptionsTable [] = {
8888
{ GLB_ALPHA_OPT (m_strNotepadQuoteString ), "NotepadQuoteString", "> " },
8989
{ GLB_ALPHA_OPT (m_strPluginList ), "PluginList", "" },
9090
{ GLB_ALPHA_OPT (m_strPluginsDirectory ), "PluginsDirectory", ".\\worlds\\plugins\\" },
91-
{ GLB_ALPHA_OPT (m_strDefaultStateFilesDirectory), "StateFilesDirectory", ".\\worlds\\plugins\\state\\" },
91+
{ GLB_ALPHA_OPT (m_strDefaultStateFilesDirectory), "StateFilesDirectory", ".\\worlds\\plugins\\state\\" }, // however see below
9292
{ GLB_ALPHA_OPT (m_strPrinterFont ), "PrinterFont", "Courier" },
9393
{ GLB_ALPHA_OPT (m_strTrayIconFileName ), "TrayIconFileName", "" },
9494
{ GLB_ALPHA_OPT (m_strWordDelimiters ), "WordDelimiters", ".,()[]\"\'" },
@@ -136,6 +136,10 @@ int CMUSHclientApp::PopulateDatabase (void)
136136
strcmp (AlphaGlobalOptionsTable [i].pName, "FixedPitchFont") == 0)
137137
AlphaGlobalOptionsTable [i].sDefault = (LPCTSTR) m_strFixedPitchFont;
138138

139+
// For Willfa, see below
140+
if (strcmp (AlphaGlobalOptionsTable [i].pName, "StateFilesDirectory") == 0)
141+
AlphaGlobalOptionsTable [i].sDefault = (LPCTSTR) (App.m_strPluginsDirectory + "state\\");
142+
139143
CString strValue = GetProfileString ("Global prefs",
140144
AlphaGlobalOptionsTable [i].pName,
141145
AlphaGlobalOptionsTable [i].sDefault);
@@ -160,6 +164,13 @@ void CMUSHclientApp::LoadGlobalsFromDatabase (void)
160164
int i;
161165
string db_value;
162166

167+
// for Willfa - make state directory default to plugins directory (whatever that is now) with state\ at the end
168+
for (i = 0; AlphaGlobalOptionsTable [i].pName; i++)
169+
{
170+
if (strcmp (AlphaGlobalOptionsTable [i].pName, "StateFilesDirectory") == 0)
171+
AlphaGlobalOptionsTable [i].sDefault = (LPCTSTR) (App.m_strPluginsDirectory + "state\\");
172+
}
173+
163174
for (i = 0; GlobalOptionsTable [i].pName; i++)
164175
{
165176
const char * p = (const char *) this + GlobalOptionsTable [i].iOffset;

resource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@
15621562
#ifdef APSTUDIO_INVOKED
15631563
#ifndef APSTUDIO_READONLY_SYMBOLS
15641564
#define _APS_3D_CONTROLS 1
1565-
#define _APS_NEXT_RESOURCE_VALUE 359
1565+
#define _APS_NEXT_RESOURCE_VALUE 360
15661566
#define _APS_NEXT_COMMAND_VALUE 33054
15671567
#define _APS_NEXT_CONTROL_VALUE 2897
15681568
#define _APS_NEXT_SYMED_VALUE 312

stdafx.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,3 +919,10 @@ void ChangeToStartupDirectory ();
919919
#define SCRIPTERRORFORECOLOUR "orangered" // "darkorange"
920920
#define SCRIPTERRORBACKCOLOUR "black"
921921
#define SCRIPTERRORCONTEXTFORECOLOUR "burlywood"
922+
923+
/* These macros are the standard way of turning unquoted text into C strings.
924+
They allow macros like PCRE_MAJOR to be defined without quotes, which is
925+
convenient for user programs that want to test its value. */
926+
927+
#define STRING(a) # a
928+
#define XSTRING(s) STRING(s)

world_debug.cpp

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "sendvw.h"
66
#include "Color.h"
77

8+
#include "png/png.h" // for version
9+
810
// my debugging
911

1012
// memory state tracking
@@ -841,6 +843,310 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
841843
Note (TFormat ("%i info item%s.", PLURAL (iCount)));
842844

843845
} // end of info
846+
//-----------------------------------------------------------------------
847+
// summary
848+
//-----------------------------------------------------------------------
849+
else if (strcmp (Command, "summary") == 0)
850+
{
851+
852+
Note ("");
853+
Note ("-------------- MUSHclient summary --------------");
854+
Note ("");
855+
Note (TFormat ("MUSHclient version: %s", MUSHCLIENT_VERSION));
856+
// show compilation date
857+
Note (TFormat ("Compiled: %s.", __DATE__));
858+
859+
OSVERSIONINFO ver;
860+
// see which OS we are using
861+
memset(&ver, 0, sizeof(ver));
862+
ver.dwOSVersionInfoSize = sizeof(ver);
863+
::GetVersionEx (&ver);
864+
865+
// work out operating system
866+
867+
char * sVersion = "unknown";
868+
869+
if (ver.dwPlatformId == 1) // Windows 95-style versions
870+
{
871+
switch (ver.dwMinorVersion)
872+
{
873+
case 0: sVersion = "Windows 95"; break;
874+
case 10: sVersion = "Windows 98"; break;
875+
case 90: sVersion = "Windows ME"; break;
876+
} // end of switch on dwMinorVersion
877+
} // end of dwPlatformId == 1
878+
else if (ver.dwPlatformId == 2) // Windows NT versions
879+
{
880+
switch (ver.dwMajorVersion)
881+
{
882+
case 3: sVersion = "Windows NT 3.51"; break;
883+
case 4: sVersion = "Windows NT"; break;
884+
case 5:
885+
switch (ver.dwMinorVersion)
886+
{
887+
case 0: sVersion = "Windows 2000"; break;
888+
case 1: sVersion = "Windows XP"; break;
889+
case 2: sVersion = "Windows Server 2003"; break;
890+
} // end of switch on dwMinorVersion
891+
break; // end case 5 of dwMinorVersion
892+
893+
case 6:
894+
switch (ver.dwMinorVersion)
895+
{
896+
case 0: sVersion = "Windows Vista"; break;
897+
case 1: sVersion = "Windows 7"; break;
898+
} // end of switch on dwMinorVersion
899+
break; // end case 6 of dwMinorVersion
900+
901+
} // end of switch on dwMajorVersion
902+
} // end of dwPlatformId == 2
903+
904+
905+
Note (TFormat ("Operating system: %s", sVersion));
906+
907+
908+
// show included library versions
909+
Note (TFormat ("Using: %s, PCRE %s, PNG %s, SQLite3 %s, Zlib %s",
910+
LUA_RELEASE,
911+
XSTRING(PCRE_MAJOR.PCRE_MINOR),
912+
PNG_LIBPNG_VER_STRING,
913+
SQLITE_VERSION,
914+
ZLIB_VERSION));
915+
916+
917+
// scripting info
918+
919+
Note (TFormat ("Script language: %s, enabled: %s",
920+
(LPCTSTR) m_strLanguage,
921+
(m_bEnableScripts ? "yes" : "no")));
922+
Note (TFormat ("Scripting active: %s",
923+
(GetScriptEngine () ? "yes" : "no")));
924+
if (!m_strScriptFilename.IsEmpty ())
925+
Note (TFormat ("Script file: %s",
926+
(LPCTSTR) m_strScriptFilename
927+
));
928+
929+
930+
// count triggers, aliases, timers
931+
932+
933+
POSITION pos;
934+
CString strName;
935+
CTrigger * pTrigger;
936+
CAlias * pAlias;
937+
CTimer * pTimer;
938+
CPlugin * pPlugin;
939+
940+
__int64 nTotalMatches = 0;
941+
__int64 nTotalMatchAttempts = 0;
942+
long nTotal = 0;
943+
long nEnabled = 0;
944+
long nRegexp = 0;
945+
LONGLONG iTimeTaken = 0;
946+
double elapsed_time;
947+
948+
949+
// count number of triggers matched
950+
for (pos = m_TriggerMap.GetStartPosition(); pos; )
951+
{
952+
m_TriggerMap.GetNextAssoc (pos, strName, pTrigger);
953+
nTotal++;
954+
955+
if (pTrigger->regexp)
956+
{
957+
iTimeTaken += pTrigger->regexp->iTimeTaken;
958+
nTotalMatchAttempts += pTrigger->regexp->m_iMatchAttempts;
959+
}
960+
961+
nTotalMatches += pTrigger->nMatched;
962+
963+
if (pTrigger->bRegexp)
964+
nRegexp++;
965+
966+
if (pTrigger->bEnabled)
967+
nEnabled++;
968+
}
969+
970+
// time taken to execute triggers
971+
if (App.m_iCounterFrequency > 0)
972+
{
973+
elapsed_time = ((double) iTimeTaken) /
974+
((double) App.m_iCounterFrequency);
975+
}
976+
else
977+
elapsed_time = 0;
978+
979+
Note (TFormat ("** Triggers: %ld in world file, triggers enabled: %s.",
980+
nTotal,
981+
(m_enable_triggers ? "yes" : "no")));
982+
Note (TFormat (" %ld enabled, %ld regexp, %I64d attempts, %I64d matched, %1.6f seconds.",
983+
nEnabled, nRegexp, nTotalMatchAttempts, nTotalMatches, elapsed_time));
984+
985+
986+
nTotalMatches = 0;
987+
nTotalMatchAttempts = 0;
988+
nTotal = 0;
989+
nEnabled = 0;
990+
nRegexp = 0;
991+
iTimeTaken = 0;
992+
elapsed_time;
993+
994+
// count number of aliases matched
995+
for (pos = m_AliasMap.GetStartPosition(); pos; )
996+
{
997+
m_AliasMap.GetNextAssoc (pos, strName, pAlias);
998+
nTotal++;
999+
1000+
if (pAlias->regexp)
1001+
{
1002+
iTimeTaken += pAlias->regexp->iTimeTaken;
1003+
nTotalMatchAttempts += pAlias->regexp->m_iMatchAttempts;
1004+
}
1005+
1006+
nTotalMatches += pAlias->nMatched;
1007+
if (pAlias->bRegexp)
1008+
nRegexp++;
1009+
1010+
if (pAlias->bEnabled)
1011+
nEnabled++;
1012+
}
1013+
1014+
// time taken to execute aliases
1015+
if (App.m_iCounterFrequency > 0)
1016+
{
1017+
elapsed_time = ((double) iTimeTaken) /
1018+
((double) App.m_iCounterFrequency);
1019+
}
1020+
else
1021+
elapsed_time = 0;
1022+
1023+
Note (TFormat ("** Aliases: %ld in world file, aliases enabled: %s.",
1024+
nTotal,
1025+
(m_enable_aliases ? "yes" : "no")));
1026+
Note (TFormat (" %ld enabled, %ld regexp, %I64d attempts, %I64d matched, %1.6f seconds.",
1027+
nEnabled, nRegexp, nTotalMatchAttempts, nTotalMatches, elapsed_time));
1028+
1029+
nTotalMatches = 0;
1030+
nTotal = 0;
1031+
nEnabled = 0;
1032+
1033+
// count number of timers fired
1034+
for (pos = m_TimerMap.GetStartPosition(); pos; )
1035+
{
1036+
m_TimerMap.GetNextAssoc (pos, strName, pTimer);
1037+
nTotal++;
1038+
1039+
nTotalMatches += pTimer->nMatched;
1040+
1041+
if (pTimer->bEnabled)
1042+
nEnabled++;
1043+
}
1044+
1045+
1046+
Note (TFormat ("** Timers: %ld in world file, timers enabled: %s.",
1047+
nTotal,
1048+
(m_bEnableTimers ? "yes" : "no")));
1049+
Note (TFormat (" %ld enabled, %I64d fired.",
1050+
nEnabled, nTotalMatches));
1051+
1052+
// time taken to do MCCP
1053+
if (App.m_iCounterFrequency > 0)
1054+
{
1055+
elapsed_time = ((double) m_iCompressionTimeTaken) /
1056+
((double) App.m_iCounterFrequency);
1057+
}
1058+
else
1059+
elapsed_time = 0;
1060+
1061+
1062+
nTotal = 0;
1063+
1064+
for (pos = GetVariableMap ().GetStartPosition(); pos; nTotal++)
1065+
{
1066+
CString strVariableName;
1067+
CVariable * variable_item;
1068+
1069+
GetVariableMap ().GetNextAssoc (pos, strVariableName, variable_item);
1070+
}
1071+
1072+
Note (TFormat ("** Variables: %ld.", nTotal));
1073+
1074+
if (m_bCompress)
1075+
Note (TFormat ("MCCP active, took %1.6f seconds to decompress", elapsed_time));
1076+
else
1077+
Note (Translate ("MCCP not active."));
1078+
1079+
1080+
// count and display plugins
1081+
1082+
nTotal = 0;
1083+
nEnabled = 0;
1084+
1085+
for (pos = m_PluginList.GetHeadPosition (); pos; iCount++)
1086+
{
1087+
pPlugin = m_PluginList.GetNext (pos);
1088+
nTotal++;
1089+
Note (TFormat ("Plugin: %s, '%s', enabled: %s",
1090+
(LPCTSTR) pPlugin->m_strID,
1091+
(LPCTSTR) pPlugin->m_strName,
1092+
(pPlugin->m_bEnabled ? "yes" : "no")));
1093+
1094+
if (pPlugin->m_bEnabled)
1095+
nEnabled++;
1096+
1097+
}
1098+
1099+
Note (TFormat ("** Plugins: %ld loaded, %ld enabled.", nTotal, nEnabled));
1100+
1101+
// show bytes sent/received
1102+
1103+
__int64 nInK = m_nBytesIn / (__int64) 1024;
1104+
__int64 nOutK = m_nBytesOut / (__int64) 1024;
1105+
Note (TFormat ("Received: %I64d bytes (%I64d Kb)", m_nBytesIn, nInK));
1106+
Note (TFormat ("Sent: %I64d bytes (%I64d Kb)", m_nBytesOut, nOutK));
1107+
1108+
Note (TFormat ("Output buffer: %i of %ld lines.",
1109+
m_LineList.GetCount (),
1110+
m_maxlines));
1111+
1112+
Note (TFormat ("Total lines received: %ld", m_total_lines));
1113+
1114+
//MXP
1115+
1116+
Note (TFormat ("MXP active: %s, Pueblo mode: %s",
1117+
(m_bMXP ? "yes" : "no"),
1118+
(m_bPuebloActive ? "yes" : "no") ));
1119+
1120+
Note (TFormat ("MXP tags received: %I64d", m_iMXPtags));
1121+
Note (TFormat ("MXP entities received: %I64d", m_iMXPentities));
1122+
Note (TFormat ("MXP errors: %I64d", m_iMXPerrors));
1123+
1124+
1125+
// commands typed
1126+
1127+
nTotal = 0;
1128+
1129+
for(pos = GetFirstViewPosition(); pos != NULL; )
1130+
{
1131+
CView* pView = GetNextView(pos);
1132+
1133+
if (pView->IsKindOf(RUNTIME_CLASS(CSendView)))
1134+
{
1135+
CSendView* pmyView = (CSendView*)pView;
1136+
1137+
for (POSITION pos = pmyView->m_msgList.GetHeadPosition(); pos; nTotal++)
1138+
pmyView->m_msgList.GetNext (pos);
1139+
1140+
} // end of being a CSendView
1141+
} // end of loop through views
1142+
1143+
Note (TFormat ("** Commands in command history: %ld", nTotal));
1144+
1145+
Note ("");
1146+
Note ("-------------- End summary --------------");
1147+
1148+
} // end of summary
1149+
8441150
#ifdef PANE
8451151
//-----------------------------------------------------------------------
8461152
// panes
@@ -924,6 +1230,7 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
9241230
Note ("plugins");
9251231
Note ("server_elements");
9261232
Note ("server_entities");
1233+
Note ("summary");
9271234
Note ("triggers");
9281235
Note ("variables");
9291236
} // end of invalid/none entered

0 commit comments

Comments
 (0)