Skip to content

Commit 013fcf3

Browse files
committed
Improved Debug 'summary'
1 parent 8bb851c commit 013fcf3

File tree

5 files changed

+147
-27
lines changed

5 files changed

+147
-27
lines changed

doc.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7099,10 +7099,17 @@ void CMUSHclientDoc::ConnectionEstablished (void)
70997099
m_strLastCommandSent.Empty (); // no command sent yet
71007100
m_iNoteStyle = NORMAL; // back to default style
71017101

7102-
ZeroMemory (&m_bClient_IAC_DO, sizeof m_bClient_IAC_DO);
7103-
ZeroMemory (&m_bClient_IAC_DONT, sizeof m_bClient_IAC_DONT);
7104-
ZeroMemory (&m_bClient_IAC_WILL, sizeof m_bClient_IAC_WILL);
7105-
ZeroMemory (&m_bClient_IAC_WONT, sizeof m_bClient_IAC_WONT);
7102+
7103+
ZeroMemory (&m_bClient_sent_IAC_DO, sizeof m_bClient_sent_IAC_DO);
7104+
ZeroMemory (&m_bClient_sent_IAC_DONT, sizeof m_bClient_sent_IAC_DONT);
7105+
ZeroMemory (&m_bClient_sent_IAC_WILL, sizeof m_bClient_sent_IAC_WILL);
7106+
ZeroMemory (&m_bClient_sent_IAC_WONT, sizeof m_bClient_sent_IAC_WONT);
7107+
7108+
ZeroMemory (&m_bClient_got_IAC_DO, sizeof m_bClient_got_IAC_DO);
7109+
ZeroMemory (&m_bClient_got_IAC_DONT, sizeof m_bClient_got_IAC_DONT);
7110+
ZeroMemory (&m_bClient_got_IAC_WILL, sizeof m_bClient_got_IAC_WILL);
7111+
ZeroMemory (&m_bClient_got_IAC_WONT, sizeof m_bClient_got_IAC_WONT);
7112+
71067113
m_phase = NONE; // not in middle of telnet/mxp sequence yet
71077114
m_IAC_subnegotiation_data.erase ();
71087115
m_subnegotiation_type = 0;

doc.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,15 @@ class CMUSHclientDoc : public CDocument
10031003

10041004
int m_subnegotiation_type; // what type of subnegotiation we are currently in (0 to 255)
10051005
string m_IAC_subnegotiation_data; // last string x from MUD: IAC SB c x IAC SE
1006-
bool m_bClient_IAC_DO [256]; // client sent IAC DO x
1007-
bool m_bClient_IAC_DONT [256]; // client sent IAC DONT x
1008-
bool m_bClient_IAC_WILL [256]; // client sent IAC WILL x
1009-
bool m_bClient_IAC_WONT [256]; // client sent IAC WONT x
1006+
bool m_bClient_sent_IAC_DO [256]; // client sent IAC DO x
1007+
bool m_bClient_sent_IAC_DONT [256]; // client sent IAC DONT x
1008+
bool m_bClient_sent_IAC_WILL [256]; // client sent IAC WILL x
1009+
bool m_bClient_sent_IAC_WONT [256]; // client sent IAC WONT x
1010+
1011+
bool m_bClient_got_IAC_DO [256]; // client got IAC DO x
1012+
bool m_bClient_got_IAC_DONT [256]; // client got IAC DONT x
1013+
bool m_bClient_got_IAC_WILL [256]; // client got IAC WILL x
1014+
bool m_bClient_got_IAC_WONT [256]; // client got IAC WONT x
10101015

10111016
// MSP (MUD Sound Protocol) stuff
10121017
bool m_bMSP; // true if using MSP

doc_construct.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,15 @@ int i;
399399
m_bPluginProcessesSetEntity = false;
400400
m_bPluginProcessesError = false;
401401

402-
ZeroMemory (&m_bClient_IAC_DO, sizeof m_bClient_IAC_DO);
403-
ZeroMemory (&m_bClient_IAC_DONT, sizeof m_bClient_IAC_DONT);
404-
ZeroMemory (&m_bClient_IAC_WILL, sizeof m_bClient_IAC_WILL);
405-
ZeroMemory (&m_bClient_IAC_WONT, sizeof m_bClient_IAC_WONT);
402+
ZeroMemory (&m_bClient_sent_IAC_DO, sizeof m_bClient_sent_IAC_DO);
403+
ZeroMemory (&m_bClient_sent_IAC_DONT, sizeof m_bClient_sent_IAC_DONT);
404+
ZeroMemory (&m_bClient_sent_IAC_WILL, sizeof m_bClient_sent_IAC_WILL);
405+
ZeroMemory (&m_bClient_sent_IAC_WONT, sizeof m_bClient_sent_IAC_WONT);
406+
407+
ZeroMemory (&m_bClient_got_IAC_DO, sizeof m_bClient_got_IAC_DO);
408+
ZeroMemory (&m_bClient_got_IAC_DONT, sizeof m_bClient_got_IAC_DONT);
409+
ZeroMemory (&m_bClient_got_IAC_WILL, sizeof m_bClient_got_IAC_WILL);
410+
ZeroMemory (&m_bClient_got_IAC_WONT, sizeof m_bClient_got_IAC_WONT);
406411

407412
m_nCount_IAC_DO = 0;
408413
m_nCount_IAC_DONT = 0;

telnet_phases.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,63 +204,63 @@ void CMUSHclientDoc::Send_IAC_DO (const unsigned char c)
204204
// if we are already in a mode do not agree again - see RFC 854
205205
// and forum subject 3061
206206

207-
if (m_bClient_IAC_DO [c])
207+
if (m_bClient_sent_IAC_DO [c])
208208
return;
209209

210210
unsigned char do_do_it [3] = { IAC, DO, c };
211211

212212
TRACE1 ("\nSending IAC DO <%d>\n", c);
213213
SendPacket (do_do_it, sizeof do_do_it);
214-
m_bClient_IAC_DO [c] = true;
215-
m_bClient_IAC_DONT [c] = false;
214+
m_bClient_sent_IAC_DO [c] = true;
215+
m_bClient_sent_IAC_DONT [c] = false;
216216

217217
} // end of CMUSHclientDoc::Send_IAC_DO
218218

219219
void CMUSHclientDoc::Send_IAC_DONT (const unsigned char c)
220220
{
221221
// if we are already in a mode do not agree again - see RFC 854
222222
// and forum subject 3061
223-
if (m_bClient_IAC_DONT [c])
223+
if (m_bClient_sent_IAC_DONT [c])
224224
return;
225225

226226
unsigned char dont_do_it [3] = { IAC, DONT, c };
227227

228228
TRACE1 ("\nSending IAC DONT <%d>\n", c);
229229
SendPacket (dont_do_it, sizeof dont_do_it);
230-
m_bClient_IAC_DONT [c] = true;
231-
m_bClient_IAC_DO [c] = false;
230+
m_bClient_sent_IAC_DONT [c] = true;
231+
m_bClient_sent_IAC_DO [c] = false;
232232

233233
} // end of CMUSHclientDoc::Send_IAC_DONT
234234

235235
void CMUSHclientDoc::Send_IAC_WILL (const unsigned char c)
236236
{
237237
// if we are already in a mode do not agree again - see RFC 854
238238
// and forum subject 3061
239-
if (m_bClient_IAC_WILL [c])
239+
if (m_bClient_sent_IAC_WILL [c])
240240
return;
241241

242242
unsigned char will_do_it [3] = { IAC, WILL, c };
243243

244244
TRACE1 ("\nSending IAC WILL <%d>\n", c);
245245
SendPacket (will_do_it, sizeof will_do_it);
246-
m_bClient_IAC_WILL [c] = true;
247-
m_bClient_IAC_WONT [c] = false;
246+
m_bClient_sent_IAC_WILL [c] = true;
247+
m_bClient_sent_IAC_WONT [c] = false;
248248

249249
} // end of CMUSHclientDoc::Send_IAC_WILL
250250

251251
void CMUSHclientDoc::Send_IAC_WONT (const unsigned char c)
252252
{
253253
// if we are already in a mode do not agree again - see RFC 854
254254
// and forum subject 3061
255-
if (m_bClient_IAC_WONT [c])
255+
if (m_bClient_sent_IAC_WONT [c])
256256
return;
257257

258258
unsigned char wont_do_it [3] = { IAC, WONT, c };
259259

260260
TRACE1 ("\nSending IAC WONT <%d>\n", c);
261261
SendPacket (wont_do_it, sizeof wont_do_it);
262-
m_bClient_IAC_WONT [c] = true;
263-
m_bClient_IAC_WILL [c] = false;
262+
m_bClient_sent_IAC_WONT [c] = true;
263+
m_bClient_sent_IAC_WILL [c] = false;
264264

265265
} // end of CMUSHclientDoc::Send_IAC_WONT
266266

@@ -280,6 +280,7 @@ void CMUSHclientDoc::Phase_WILL (const unsigned char c)
280280
m_phase = NONE; // back to normal text after this character
281281

282282
m_nCount_IAC_WILL++;
283+
m_bClient_got_IAC_WILL [c] = true;
283284

284285
switch (c)
285286
{
@@ -385,6 +386,7 @@ void CMUSHclientDoc::Phase_WONT (const unsigned char c)
385386
m_phase = NONE;
386387

387388
m_nCount_IAC_WONT++;
389+
m_bClient_got_IAC_WONT [c] = true;
388390

389391
switch (c)
390392
{
@@ -418,6 +420,7 @@ void CMUSHclientDoc::Phase_DO (const unsigned char c)
418420
m_phase = NONE;
419421

420422
m_nCount_IAC_DO++;
423+
m_bClient_got_IAC_DO [c] = true;
421424

422425
switch (c)
423426
{
@@ -473,6 +476,7 @@ void CMUSHclientDoc::Phase_DONT (const unsigned char c)
473476
SendPacket (p, sizeof p);
474477

475478
m_nCount_IAC_DONT++;
479+
m_bClient_got_IAC_DONT [c] = true;
476480

477481
switch (c)
478482
{

world_debug.cpp

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern CString strKeypadNames [eKeypad_Max_Items];
2525
extern tInfoTypeMapping InfoTypes [];
2626

2727
#define SHOW_TRUE(x) ((x) ? "yes" : "NO")
28+
#define SHOW_TRUE_LC(x) ((x) ? "yes" : "no")
2829

2930
static char * sColourNames [8] =
3031
{
@@ -38,6 +39,15 @@ static char * sColourNames [8] =
3839
"White"
3940
};
4041

42+
static char * sMxpModes [] =
43+
{
44+
"On command",
45+
"On query",
46+
"Yes - always",
47+
"No - never"
48+
};
49+
50+
4151
// compare-less for colours
4252
struct colour_less : binary_function<COLORREF, COLORREF, bool>
4353
{
@@ -1371,20 +1381,30 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
13711381

13721382
// telnet negotiation
13731383

1374-
Note (TFormat ("Telnet (IAC) received: DO: %ld, DONT: %ld, WILL: %ld, WONT: %ld, SB: %ld",
1384+
Tell (TFormat ("Telnet (IAC) received: DO: %ld, DONT: %ld, WILL: %ld, WONT: %ld, SB: %ld [",
13751385
m_nCount_IAC_DO,
13761386
m_nCount_IAC_DONT,
13771387
m_nCount_IAC_WILL,
13781388
m_nCount_IAC_WONT,
13791389
m_nCount_IAC_SB));
13801390

1391+
Hyperlink ("!!" DEBUG_PLUGIN_ID ":telnetlist()",
1392+
"List", "Click to list IAC items", "cyan", "", 0);
1393+
Note ("]");
1394+
13811395
ColourNote (SCRIPTERRORCONTEXTFORECOLOUR, "", "-- MXP --");
13821396

13831397
//MXP
13841398

1385-
Note (TFormat ("MXP active: %s, Pueblo mode: %s",
1399+
const char * sMode = "Unknown";
1400+
1401+
if (m_iUseMXP >= eOnCommandMXP && eOnCommandMXP <= eNoMXP)
1402+
sMode = sMxpModes [m_iUseMXP];
1403+
1404+
Note (TFormat ("MXP active: %s, Pueblo mode: %s, Activated: %s",
13861405
SHOW_TRUE (m_bMXP ),
1387-
SHOW_TRUE (m_bPuebloActive) ));
1406+
SHOW_TRUE (m_bPuebloActive),
1407+
sMode));
13881408

13891409
Note (TFormat ("MXP tags received: %I64d", m_iMXPtags));
13901410
Note (TFormat ("MXP entities received: %I64d", m_iMXPentities));
@@ -2045,6 +2065,85 @@ void CMUSHclientDoc::DebugHelper (const CString strAction, CString strArgument)
20452065

20462066
} // end of acceleratorlist
20472067

2068+
//-----------------------------------------------------------------------
2069+
// telnetlist
2070+
//-----------------------------------------------------------------------
2071+
2072+
else if (strAction == "telnetlist")
2073+
{
2074+
2075+
ColourNote (SCRIPTERRORCONTEXTFORECOLOUR, "", "------ Telnet negotiation List (numeric order) ------");
2076+
Note ("");
2077+
2078+
map<int,string> telnet_meanings;
2079+
2080+
// got these from Code_Chart.xml plugin
2081+
2082+
telnet_meanings [0x01] = "Echo"; // 1 Echo
2083+
telnet_meanings [0x03] = "Suppress Go-ahead (SGA)"; // 3 Suppress go ahead
2084+
telnet_meanings [0x05] = "Status"; // 5 Status
2085+
telnet_meanings [0x06] = "Timing Mark"; // 6 Timing mark
2086+
telnet_meanings [0x18] = "Termtype"; // 24 Terminal type
2087+
telnet_meanings [0x19] = "End of record (EOR)"; // 25 EOR
2088+
telnet_meanings [0x1F] = "Window Size (NAWS)"; // 31 Window size
2089+
telnet_meanings [0x20] = "Terminal Speed"; // 32 Terminal speed
2090+
telnet_meanings [0x21] = "RFC"; // 33 Remote flow control
2091+
telnet_meanings [0x22] = "Line Mode"; // 34 Line mode
2092+
telnet_meanings [0x24] = "EV"; // 36 Environment variables
2093+
telnet_meanings [0x2A] = "Charset"; // 42 Character set
2094+
telnet_meanings [0x55] = "MCCP1"; // 85 MUD Compression Protocol v1
2095+
telnet_meanings [0x56] = "MCCP2"; // 86 MUD Compression Protocol v2
2096+
telnet_meanings [0x5A] = "MSP"; // 90 (MUD Sound Protocol)
2097+
telnet_meanings [0x5B] = "MXP"; // 91 (MUD eXtension Protocol)
2098+
telnet_meanings [0x5D] = "ZMP"; // 93 (ZMP Protocol)
2099+
telnet_meanings [0x66] = "Aardwolf"; // 102 (Aardwolf telnet protocol)
2100+
telnet_meanings [0xC8] = "ATCP"; // 200 ATCP (Achaea Telnet Protocol)
2101+
telnet_meanings [0xC9] = "ATCP2/GMCP"; // 201 ATCP2/GMCP (Generic Mud Control Protocol)
2102+
telnet_meanings [0xFF] = "Extended Options"; // for future expansion
2103+
2104+
2105+
for (int i = 0; i < 256; i++)
2106+
{
2107+
if (m_bClient_sent_IAC_DO [i] ||
2108+
m_bClient_sent_IAC_DONT [i] ||
2109+
m_bClient_sent_IAC_WILL [i] ||
2110+
m_bClient_sent_IAC_WONT [i] ||
2111+
m_bClient_got_IAC_DO [i] ||
2112+
m_bClient_got_IAC_DONT [i] ||
2113+
m_bClient_got_IAC_WILL [i] ||
2114+
m_bClient_got_IAC_WONT [i])
2115+
{
2116+
2117+
string sMeaning = telnet_meanings [i];
2118+
CString strMeaning;
2119+
if (!sMeaning.empty ())
2120+
{
2121+
strMeaning = " (";
2122+
strMeaning += sMeaning.c_str ();
2123+
strMeaning += ")";
2124+
}
2125+
2126+
Note (CFormat ("%3i%s", i, (LPCTSTR) strMeaning));
2127+
ColourTell ("cyan", "", " Got: ");
2128+
Note (CFormat ("DO: %-3s, DONT: %-3s, WILL: %-3s, WONT: %-3s ",
2129+
SHOW_TRUE_LC (m_bClient_got_IAC_DO [i]),
2130+
SHOW_TRUE_LC (m_bClient_got_IAC_DONT [i]),
2131+
SHOW_TRUE_LC (m_bClient_got_IAC_WILL [i]),
2132+
SHOW_TRUE_LC (m_bClient_got_IAC_WONT [i])));
2133+
2134+
ColourTell ("cyan", "", " Sent: ");
2135+
Note (CFormat ("WILL: %-3s, WONT: %-3s, DO: %-3s, DONT: %-3s ",
2136+
SHOW_TRUE_LC (m_bClient_sent_IAC_WILL [i]),
2137+
SHOW_TRUE_LC (m_bClient_sent_IAC_WONT [i]),
2138+
SHOW_TRUE_LC (m_bClient_sent_IAC_DO [i]),
2139+
SHOW_TRUE_LC (m_bClient_sent_IAC_DONT [i])));
2140+
2141+
} // end of something true
2142+
2143+
} // end of loop
2144+
2145+
} // end of telnetlist
2146+
20482147
//-----------------------------------------------------------------------
20492148
// showtrigger
20502149
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)