Skip to content

Commit

Permalink
Improved Debug 'summary'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Aug 17, 2010
1 parent 8bb851c commit 013fcf3
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 27 deletions.
15 changes: 11 additions & 4 deletions doc.cpp
Expand Up @@ -7099,10 +7099,17 @@ void CMUSHclientDoc::ConnectionEstablished (void)
m_strLastCommandSent.Empty (); // no command sent yet
m_iNoteStyle = NORMAL; // back to default style

ZeroMemory (&m_bClient_IAC_DO, sizeof m_bClient_IAC_DO);
ZeroMemory (&m_bClient_IAC_DONT, sizeof m_bClient_IAC_DONT);
ZeroMemory (&m_bClient_IAC_WILL, sizeof m_bClient_IAC_WILL);
ZeroMemory (&m_bClient_IAC_WONT, sizeof m_bClient_IAC_WONT);

ZeroMemory (&m_bClient_sent_IAC_DO, sizeof m_bClient_sent_IAC_DO);
ZeroMemory (&m_bClient_sent_IAC_DONT, sizeof m_bClient_sent_IAC_DONT);
ZeroMemory (&m_bClient_sent_IAC_WILL, sizeof m_bClient_sent_IAC_WILL);
ZeroMemory (&m_bClient_sent_IAC_WONT, sizeof m_bClient_sent_IAC_WONT);

ZeroMemory (&m_bClient_got_IAC_DO, sizeof m_bClient_got_IAC_DO);
ZeroMemory (&m_bClient_got_IAC_DONT, sizeof m_bClient_got_IAC_DONT);
ZeroMemory (&m_bClient_got_IAC_WILL, sizeof m_bClient_got_IAC_WILL);
ZeroMemory (&m_bClient_got_IAC_WONT, sizeof m_bClient_got_IAC_WONT);

m_phase = NONE; // not in middle of telnet/mxp sequence yet
m_IAC_subnegotiation_data.erase ();
m_subnegotiation_type = 0;
Expand Down
13 changes: 9 additions & 4 deletions doc.h
Expand Up @@ -1003,10 +1003,15 @@ class CMUSHclientDoc : public CDocument

int m_subnegotiation_type; // what type of subnegotiation we are currently in (0 to 255)
string m_IAC_subnegotiation_data; // last string x from MUD: IAC SB c x IAC SE
bool m_bClient_IAC_DO [256]; // client sent IAC DO x
bool m_bClient_IAC_DONT [256]; // client sent IAC DONT x
bool m_bClient_IAC_WILL [256]; // client sent IAC WILL x
bool m_bClient_IAC_WONT [256]; // client sent IAC WONT x
bool m_bClient_sent_IAC_DO [256]; // client sent IAC DO x
bool m_bClient_sent_IAC_DONT [256]; // client sent IAC DONT x
bool m_bClient_sent_IAC_WILL [256]; // client sent IAC WILL x
bool m_bClient_sent_IAC_WONT [256]; // client sent IAC WONT x

bool m_bClient_got_IAC_DO [256]; // client got IAC DO x
bool m_bClient_got_IAC_DONT [256]; // client got IAC DONT x
bool m_bClient_got_IAC_WILL [256]; // client got IAC WILL x
bool m_bClient_got_IAC_WONT [256]; // client got IAC WONT x

// MSP (MUD Sound Protocol) stuff
bool m_bMSP; // true if using MSP
Expand Down
13 changes: 9 additions & 4 deletions doc_construct.cpp
Expand Up @@ -399,10 +399,15 @@ int i;
m_bPluginProcessesSetEntity = false;
m_bPluginProcessesError = false;

ZeroMemory (&m_bClient_IAC_DO, sizeof m_bClient_IAC_DO);
ZeroMemory (&m_bClient_IAC_DONT, sizeof m_bClient_IAC_DONT);
ZeroMemory (&m_bClient_IAC_WILL, sizeof m_bClient_IAC_WILL);
ZeroMemory (&m_bClient_IAC_WONT, sizeof m_bClient_IAC_WONT);
ZeroMemory (&m_bClient_sent_IAC_DO, sizeof m_bClient_sent_IAC_DO);
ZeroMemory (&m_bClient_sent_IAC_DONT, sizeof m_bClient_sent_IAC_DONT);
ZeroMemory (&m_bClient_sent_IAC_WILL, sizeof m_bClient_sent_IAC_WILL);
ZeroMemory (&m_bClient_sent_IAC_WONT, sizeof m_bClient_sent_IAC_WONT);

ZeroMemory (&m_bClient_got_IAC_DO, sizeof m_bClient_got_IAC_DO);
ZeroMemory (&m_bClient_got_IAC_DONT, sizeof m_bClient_got_IAC_DONT);
ZeroMemory (&m_bClient_got_IAC_WILL, sizeof m_bClient_got_IAC_WILL);
ZeroMemory (&m_bClient_got_IAC_WONT, sizeof m_bClient_got_IAC_WONT);

m_nCount_IAC_DO = 0;
m_nCount_IAC_DONT = 0;
Expand Down
28 changes: 16 additions & 12 deletions telnet_phases.cpp
Expand Up @@ -204,63 +204,63 @@ void CMUSHclientDoc::Send_IAC_DO (const unsigned char c)
// if we are already in a mode do not agree again - see RFC 854
// and forum subject 3061

if (m_bClient_IAC_DO [c])
if (m_bClient_sent_IAC_DO [c])
return;

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

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

} // end of CMUSHclientDoc::Send_IAC_DO

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

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

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

} // end of CMUSHclientDoc::Send_IAC_DONT

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

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

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

} // end of CMUSHclientDoc::Send_IAC_WILL

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

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

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

} // end of CMUSHclientDoc::Send_IAC_WONT

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

m_nCount_IAC_WILL++;
m_bClient_got_IAC_WILL [c] = true;

switch (c)
{
Expand Down Expand Up @@ -385,6 +386,7 @@ void CMUSHclientDoc::Phase_WONT (const unsigned char c)
m_phase = NONE;

m_nCount_IAC_WONT++;
m_bClient_got_IAC_WONT [c] = true;

switch (c)
{
Expand Down Expand Up @@ -418,6 +420,7 @@ void CMUSHclientDoc::Phase_DO (const unsigned char c)
m_phase = NONE;

m_nCount_IAC_DO++;
m_bClient_got_IAC_DO [c] = true;

switch (c)
{
Expand Down Expand Up @@ -473,6 +476,7 @@ void CMUSHclientDoc::Phase_DONT (const unsigned char c)
SendPacket (p, sizeof p);

m_nCount_IAC_DONT++;
m_bClient_got_IAC_DONT [c] = true;

switch (c)
{
Expand Down
105 changes: 102 additions & 3 deletions world_debug.cpp
Expand Up @@ -25,6 +25,7 @@ extern CString strKeypadNames [eKeypad_Max_Items];
extern tInfoTypeMapping InfoTypes [];

#define SHOW_TRUE(x) ((x) ? "yes" : "NO")
#define SHOW_TRUE_LC(x) ((x) ? "yes" : "no")

static char * sColourNames [8] =
{
Expand All @@ -38,6 +39,15 @@ static char * sColourNames [8] =
"White"
};

static char * sMxpModes [] =
{
"On command",
"On query",
"Yes - always",
"No - never"
};


// compare-less for colours
struct colour_less : binary_function<COLORREF, COLORREF, bool>
{
Expand Down Expand Up @@ -1371,20 +1381,30 @@ VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)

// telnet negotiation

Note (TFormat ("Telnet (IAC) received: DO: %ld, DONT: %ld, WILL: %ld, WONT: %ld, SB: %ld",
Tell (TFormat ("Telnet (IAC) received: DO: %ld, DONT: %ld, WILL: %ld, WONT: %ld, SB: %ld [",
m_nCount_IAC_DO,
m_nCount_IAC_DONT,
m_nCount_IAC_WILL,
m_nCount_IAC_WONT,
m_nCount_IAC_SB));

Hyperlink ("!!" DEBUG_PLUGIN_ID ":telnetlist()",
"List", "Click to list IAC items", "cyan", "", 0);
Note ("]");

ColourNote (SCRIPTERRORCONTEXTFORECOLOUR, "", "-- MXP --");

//MXP

Note (TFormat ("MXP active: %s, Pueblo mode: %s",
const char * sMode = "Unknown";

if (m_iUseMXP >= eOnCommandMXP && eOnCommandMXP <= eNoMXP)
sMode = sMxpModes [m_iUseMXP];

Note (TFormat ("MXP active: %s, Pueblo mode: %s, Activated: %s",
SHOW_TRUE (m_bMXP ),
SHOW_TRUE (m_bPuebloActive) ));
SHOW_TRUE (m_bPuebloActive),
sMode));

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

} // end of acceleratorlist

//-----------------------------------------------------------------------
// telnetlist
//-----------------------------------------------------------------------

else if (strAction == "telnetlist")
{

ColourNote (SCRIPTERRORCONTEXTFORECOLOUR, "", "------ Telnet negotiation List (numeric order) ------");
Note ("");

map<int,string> telnet_meanings;

// got these from Code_Chart.xml plugin

telnet_meanings [0x01] = "Echo"; // 1 Echo
telnet_meanings [0x03] = "Suppress Go-ahead (SGA)"; // 3 Suppress go ahead
telnet_meanings [0x05] = "Status"; // 5 Status
telnet_meanings [0x06] = "Timing Mark"; // 6 Timing mark
telnet_meanings [0x18] = "Termtype"; // 24 Terminal type
telnet_meanings [0x19] = "End of record (EOR)"; // 25 EOR
telnet_meanings [0x1F] = "Window Size (NAWS)"; // 31 Window size
telnet_meanings [0x20] = "Terminal Speed"; // 32 Terminal speed
telnet_meanings [0x21] = "RFC"; // 33 Remote flow control
telnet_meanings [0x22] = "Line Mode"; // 34 Line mode
telnet_meanings [0x24] = "EV"; // 36 Environment variables
telnet_meanings [0x2A] = "Charset"; // 42 Character set
telnet_meanings [0x55] = "MCCP1"; // 85 MUD Compression Protocol v1
telnet_meanings [0x56] = "MCCP2"; // 86 MUD Compression Protocol v2
telnet_meanings [0x5A] = "MSP"; // 90 (MUD Sound Protocol)
telnet_meanings [0x5B] = "MXP"; // 91 (MUD eXtension Protocol)
telnet_meanings [0x5D] = "ZMP"; // 93 (ZMP Protocol)
telnet_meanings [0x66] = "Aardwolf"; // 102 (Aardwolf telnet protocol)
telnet_meanings [0xC8] = "ATCP"; // 200 ATCP (Achaea Telnet Protocol)
telnet_meanings [0xC9] = "ATCP2/GMCP"; // 201 ATCP2/GMCP (Generic Mud Control Protocol)
telnet_meanings [0xFF] = "Extended Options"; // for future expansion


for (int i = 0; i < 256; i++)
{
if (m_bClient_sent_IAC_DO [i] ||
m_bClient_sent_IAC_DONT [i] ||
m_bClient_sent_IAC_WILL [i] ||
m_bClient_sent_IAC_WONT [i] ||
m_bClient_got_IAC_DO [i] ||
m_bClient_got_IAC_DONT [i] ||
m_bClient_got_IAC_WILL [i] ||
m_bClient_got_IAC_WONT [i])
{

string sMeaning = telnet_meanings [i];
CString strMeaning;
if (!sMeaning.empty ())
{
strMeaning = " (";
strMeaning += sMeaning.c_str ();
strMeaning += ")";
}

Note (CFormat ("%3i%s", i, (LPCTSTR) strMeaning));
ColourTell ("cyan", "", " Got: ");
Note (CFormat ("DO: %-3s, DONT: %-3s, WILL: %-3s, WONT: %-3s ",
SHOW_TRUE_LC (m_bClient_got_IAC_DO [i]),
SHOW_TRUE_LC (m_bClient_got_IAC_DONT [i]),
SHOW_TRUE_LC (m_bClient_got_IAC_WILL [i]),
SHOW_TRUE_LC (m_bClient_got_IAC_WONT [i])));

ColourTell ("cyan", "", " Sent: ");
Note (CFormat ("WILL: %-3s, WONT: %-3s, DO: %-3s, DONT: %-3s ",
SHOW_TRUE_LC (m_bClient_sent_IAC_WILL [i]),
SHOW_TRUE_LC (m_bClient_sent_IAC_WONT [i]),
SHOW_TRUE_LC (m_bClient_sent_IAC_DO [i]),
SHOW_TRUE_LC (m_bClient_sent_IAC_DONT [i])));

} // end of something true

} // end of loop

} // end of telnetlist

//-----------------------------------------------------------------------
// showtrigger
//-----------------------------------------------------------------------
Expand Down

0 comments on commit 013fcf3

Please sign in to comment.