/
world_debug.cpp
2566 lines (2003 loc) · 82.2 KB
/
world_debug.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// world_debug.cpp
// Implementation for script command: Debug ("something")
#include "stdafx.h"
#include "MUSHclient.h"
#include "doc.h"
#include "mxp\mxp.h"
#include "sendvw.h"
#include "Color.h"
#include "childfrm.h"
#include "MUSHview.h"
#include "TextDocument.h"
#include "png/png.h" // for version
// my debugging
// memory state tracking
#ifdef _DEBUG
extern CMemoryState oldMemState, newMemState, diffMemState;
#endif
extern tConfigurationNumericOption OptionsTable [];
extern tConfigurationAlphaOption AlphaOptionsTable [];
extern tCommandIDMapping CommandIDs [];
extern CString strMacroDescriptions [MACRO_COUNT];
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] =
{
"Black",
"Red",
"Green",
"Yellow",
"Blue",
"Magenta",
"Cyan",
"White"
};
static char * sMxpModes [] =
{
"On command",
"On query",
"Yes - always",
"No - never"
};
// compare-less for colours
struct colour_less : binary_function<COLORREF, COLORREF, bool>
{
bool operator() (const COLORREF & c1, const COLORREF & c2) const
{
CColor clr1, clr2;
clr1.SetColor (c1);
clr2.SetColor (c2);
// compare hue
float hue1 = clr1.GetHue ();
float hue2 = clr2.GetHue ();
if (hue1 < hue2)
return true;
else if (hue1 > hue2)
return false;
// hue the same, compare saturation
float saturation1 = clr1.GetSaturation ();
float saturation2 = clr2.GetSaturation ();
if (saturation1 < saturation2)
return true;
else if (saturation1 > saturation2)
return false;
// saturation the same - compare luminance
float luminance1 = clr1.GetLuminance ();
float luminance2 = clr2.GetLuminance ();
if (luminance1 < luminance2)
return true;
return false;
} // end of operator()
}; // end of colour_less
static void ShowOneColour (CMUSHclientDoc * pDoc,
CString strColourName,
const COLORREF iColour)
{
int iRed = GetRValue (iColour);
int iGreen = GetGValue (iColour);
int iBlue = GetBValue (iColour);
CString strName = CFormat ("%-24s ", (LPCTSTR) strColourName);
CString strTextColour = "black";
// if colour is dark, use white, otherwise use black
if (((GetRValue (iColour) & 0xFF) +
(GetGValue (iColour) & 0xFF) +
(GetBValue (iColour) & 0xFF) ) < (128 * 3))
strTextColour = "white";
pDoc->ColourTell (strTextColour, ColourToName (iColour), strName);
strName = CFormat (" R=%3i G=%3i B=%3i ", // RGB
iRed,
iGreen,
iBlue);
strName += CFormat ("#%02X%02X%02X ", // MXP
iRed,
iGreen,
iBlue);
strName += CFormat ("&h%02X%02X%02X ", // VB
iBlue,
iGreen,
iRed);
strName += CFormat ("0x%02X%02X%02X ", // Jscript
iBlue,
iGreen,
iRed);
strName += CFormat ("%08ld", iColour); // Lua
pDoc->Note (strName);
} // end of ShowOneColour
static void ShowAnsiColour (CMUSHclientDoc * pDoc,
CString strColourName,
const COLORREF iColour)
{
int iRed = GetRValue (iColour);
int iGreen = GetGValue (iColour);
int iBlue = GetBValue (iColour);
CString strName = CFormat ("%-24s ", (LPCTSTR) strColourName);
CString strTextColour = "black";
// if colour is dark, use white, otherwise use black
if (((iRed & 0xFF) + (iGreen & 0xFF) + (iBlue & 0xFF) ) < (128 * 3))
strTextColour = "white";
pDoc->ColourTell (strTextColour, ColourToName (iColour), strName);
pDoc->ColourTell (ColourToName (iColour), ColourToName (pDoc->m_normalcolour [0]), strName);
pDoc->ColourTell (ColourToName (pDoc->m_normalcolour [7]), ColourToName (iColour), strName);
pDoc->Note ("");
} // end of ShowAnsiColour
VARIANT CMUSHclientDoc::Debug(LPCTSTR Command)
{
VARIANT vaResult;
VariantInit(&vaResult);
int iCount = 0;
#ifdef _DEBUG
//-----------------------------------------------------------------------
// memdiff
//-----------------------------------------------------------------------
if (strcmp (Command, "memdiff") == 0)
{
newMemState.Checkpoint();
if (diffMemState.Difference(oldMemState, newMemState))
{
TRACE("Memory leaked.\n");
diffMemState.DumpStatistics();
// oldMemState.DumpAllObjectsSince ();
}
else
TRACE("No memory leak.\n");
}
//-----------------------------------------------------------------------
// memchk
//-----------------------------------------------------------------------
if (strcmp (Command, "memchk") == 0)
{
TRACE("Memory checkpoint taken.\n");
oldMemState.Checkpoint();
}
else
#endif
//-----------------------------------------------------------------------
// colours
//-----------------------------------------------------------------------
if (strcmp (Command, "colours") == 0 || strcmp (Command, "colors") == 0)
{
multimap<COLORREF, string, colour_less> mColours;
for (POSITION pos = App.m_ColoursMap.GetStartPosition(); pos; iCount++)
{
CColours * pColour;
CString strColourName;
App.m_ColoursMap.GetNextAssoc (pos, strColourName, pColour);
mColours.insert (make_pair (pColour->iColour, strColourName));
}
for (multimap<COLORREF, string, colour_less>::const_iterator it = mColours.begin ();
it != mColours.end ();
it++)
ShowOneColour (this, it->second.c_str (), it->first);
Note (TFormat ("%i colour%s.", PLURAL (iCount)));
} // end of colours
//-----------------------------------------------------------------------
// colours256
//-----------------------------------------------------------------------
else if (strcmp (Command, "colours256") == 0 || strcmp (Command, "colors256") == 0)
{
for (int i = 0; i < 256; i++)
{
CString strName;
// see if we can find colour name in list
for (POSITION pos = App.m_ColoursMap.GetStartPosition(); pos; )
{
CColours * pColour;
CString strColourName;
App.m_ColoursMap.GetNextAssoc (pos, strColourName, pColour);
// note - colour might match more than one name
if (pColour->iColour == xterm_256_colours [i])
{
if (!strName.IsEmpty ())
strName += ", ";
else
strName = " (";
strName += strColourName;
}
} // end of loop
if (!strName.IsEmpty ())
strName += ")";
ShowOneColour (this, CFormat ("%i%s", i, (LPCTSTR) strName), xterm_256_colours [i]);
} // end of loop
} // end of colours256
//-----------------------------------------------------------------------
// ansi
//-----------------------------------------------------------------------
else if (strcmp (Command, "ansi") == 0)
{
int i;
Note (TFormat ("%-24s %-24s %-24s", " Name", " On normal background", " Under normal text"));
Note ("------------------------ ------------------------ ------------------------ ");
for (i = 0; i < 8; i++)
{
CString strName = TFormat (" Normal #%i (%s)", i + 1, sColourNames [i]);
ShowAnsiColour (this, strName, m_normalcolour [i]);
} // end for loop
for (i = 0; i < 8; i++)
{
CString strName = TFormat (" Bold #%i (%s)", i + 1, sColourNames [i]);
ShowAnsiColour (this, strName, m_boldcolour [i]);
} // end for loop
} // end of ansi
//-----------------------------------------------------------------------
// custom_colour
//-----------------------------------------------------------------------
else if (strcmp (Command, "custom_colours") == 0 || strcmp (Command, "custom_colors") == 0)
{
int i;
for (i = 0; i < MAX_CUSTOM; i++)
{
CString strName = TFormat (" Custom #%2i (%s)", i + 1, m_strCustomColourName [i]);
ColourNote ( ColourToName (m_customtext [i]), ColourToName (m_customback [i]), strName);
} // end for loop
} // end of custom_colour
//-----------------------------------------------------------------------
// entities
//-----------------------------------------------------------------------
else if (strcmp (Command, "entities") == 0)
{
for (POSITION pos = App.m_EntityMap.GetStartPosition(); pos; iCount++)
{
CString strEntityName;
CString strEntityValue;
App.m_EntityMap.GetNextAssoc (pos, strEntityName, strEntityValue);
CString strName = CFormat ("%-10s = %s",
(LPCTSTR) strEntityName,
(LPCTSTR) strEntityValue);
Note (strName);
}
Note (TFormat ("%i entit%s.", PLURALIE (iCount)));
} // end of entities
//-----------------------------------------------------------------------
// server_entities
//-----------------------------------------------------------------------
else if (strcmp (Command, "server_entities") == 0)
{
for (POSITION pos = m_CustomEntityMap.GetStartPosition(); pos; iCount++)
{
CString strEntityName;
CString strEntityValue;
m_CustomEntityMap.GetNextAssoc (pos, strEntityName, strEntityValue);
CString strName = CFormat ("%-10s = %s",
(LPCTSTR) strEntityName,
(LPCTSTR) strEntityValue);
Note (strName);
}
Note (TFormat ("%i server entit%s.", PLURALIE (iCount)));
} // end of server_entities
//-----------------------------------------------------------------------
// elements
//-----------------------------------------------------------------------
else if (strcmp (Command, "elements") == 0)
{
for (POSITION pos = App.m_ElementMap.GetStartPosition(); pos; iCount++)
{
CAtomicElement * pElement;
CString strElementName;
App.m_ElementMap.GetNextAssoc (pos, strElementName, pElement);
CString strName = CFormat ("%-25s %3i", (LPCTSTR) strElementName,
pElement->iAction);
if (pElement->iFlags & TAG_OPEN)
strName += " open";
if (pElement->iFlags & TAG_COMMAND)
strName += " empty";
if (pElement->iFlags & TAG_NO_RESET)
strName += " no_reset";
if (pElement->iFlags & TAG_NOT_IMP)
strName += " not_imp";
if (!pElement->strArgs.IsEmpty ())
strName += CFormat (" (%s)", (LPCTSTR) pElement->strArgs);
Note (strName);
}
Note (TFormat ("%i element%s.", PLURAL (iCount)));
} // end of elements
//-----------------------------------------------------------------------
// server_elements
//-----------------------------------------------------------------------
else if (strcmp (Command, "server_elements") == 0)
{
for (POSITION pos = m_CustomElementMap.GetStartPosition(); pos; iCount++)
{
CElement * pElement;
CString strElementName;
m_CustomElementMap.GetNextAssoc (pos, strElementName, pElement);
CString strName = CFormat ("%s", (LPCTSTR) strElementName);
if (pElement->bOpen)
strName += " open";
if (pElement->bCommand)
strName += " empty";
if (pElement->iTag)
strName += CFormat (" tag=%i", pElement->iTag);
if (!pElement->strFlag.IsEmpty ())
strName += CFormat (" flag=%s", (LPCTSTR) pElement->strFlag);
Note (strName);
// list the attributes
if (!pElement->AttributeList.IsEmpty ())
{
Note (" Attributes:");
for (POSITION attpos = pElement->AttributeList.GetHeadPosition (); attpos; )
{
CArgument * pArgument = pElement->AttributeList.GetNext (attpos);
if (pArgument->strName.IsEmpty ())
Note (CFormat (" %s=''",
(LPCTSTR) pArgument->strValue));
else
Note (CFormat (" %s='%s'",
(LPCTSTR) pArgument->strName,
(LPCTSTR) pArgument->strValue));
} // end of looping through each attribute
} // end of having attributes
for (POSITION elementpos = pElement->ElementItemList.GetHeadPosition (); elementpos; )
{
CElementItem * pItem = pElement->ElementItemList.GetNext (elementpos);
CString strName = CFormat (" <%s", (LPCTSTR) pItem->pAtomicElement->strName);
for (POSITION attpos = pElement->AttributeList.GetHeadPosition (); attpos; )
{
CArgument * pArgument = pElement->AttributeList.GetNext (attpos);
// empty ones we will put there by position
if (pArgument->strName.IsEmpty ())
strName += CFormat (" %s",
(LPCTSTR) pArgument->strValue);
else
strName += CFormat (" %s='%s'",
(LPCTSTR) pArgument->strName,
(LPCTSTR) pArgument->strValue);
} // end of looping through each attribute
strName += ">";
Note (strName);
} // end of looping through each atomic element
Note (""); // blank line between each one
}
Note (TFormat ("%i server element%s.", PLURAL (iCount)));
} // end of server_elements
//-----------------------------------------------------------------------
// actions
//-----------------------------------------------------------------------
else if (strcmp (Command, "actions") == 0)
{
for (POSITION pos = m_ActionList.GetHeadPosition(); pos; iCount++)
{
CAction * pAction = m_ActionList.GetNext (pos);
Note (CFormat ("Item %i, Count: %i", iCount + 1, pAction->GetReferenceCount ()));
Note (CFormat ("Send: %s", (LPCTSTR) pAction->m_strAction));
if (!pAction->m_strHint.IsEmpty ())
Note (CFormat ("Hint: %s", (LPCTSTR) pAction->m_strHint));
if (!pAction->m_strVariable.IsEmpty ())
Note (CFormat ("Var : %s", (LPCTSTR) pAction->m_strVariable));
Note (""); // blank line
}
Note (TFormat ("%i action%s.", PLURAL (iCount)));
} // end of actions
//-----------------------------------------------------------------------
// commands
//-----------------------------------------------------------------------
else if (strcmp (Command, "commands") == 0)
{
int iViewNumber = 0;
for(POSITION pos = GetFirstViewPosition(); pos != NULL; )
{
CView* pView = GetNextView(pos);
if (pView->IsKindOf(RUNTIME_CLASS(CSendView)))
{
CSendView* pmyView = (CSendView*)pView;
// show a message if we are showing multiple non-empty views
if (!pmyView->m_msgList.IsEmpty ())
if (++iViewNumber > 1)
{
Note ("");
Note (TFormat ("--- Command Window %i ---", iViewNumber));
Note ("");
}
for (POSITION pos = pmyView->m_msgList.GetHeadPosition(); pos; iCount++)
Note (pmyView->m_msgList.GetNext (pos));
} // end of being a CSendView
} // end of loop through views
Note (TFormat ("%i command%s.", PLURAL (iCount)));
} // end of commands
//-----------------------------------------------------------------------
// aliases
//-----------------------------------------------------------------------
else if (strcmp (Command, "aliases") == 0)
{
CAlias * pAlias;
CString strAliasName;
for (POSITION pos = GetAliasMap ().GetStartPosition(); pos; iCount++)
{
GetAliasMap ().GetNextAssoc (pos, strAliasName, pAlias);
CString strName = CFormat ("{{%s}}={{%s}}",
(LPCTSTR) pAlias->name,
(LPCTSTR) pAlias->contents);
if (!pAlias->strLabel.IsEmpty ())
strName += CFormat (" label=%s", (LPCTSTR) pAlias->strLabel);
if (!pAlias->strProcedure.IsEmpty ())
strName += CFormat (" script=%s", (LPCTSTR) pAlias->strProcedure);
if (!pAlias->strGroup.IsEmpty ())
strName += CFormat (" group=%s", (LPCTSTR) pAlias->strGroup);
if (!pAlias->strVariable.IsEmpty ())
strName += CFormat (" variable=%s", (LPCTSTR) pAlias->strVariable);
if (!pAlias->bEnabled)
strName += " disabled";
if (pAlias->bExpandVariables)
strName += " expand_variables";
if (pAlias->bOmitFromLog)
strName += " omit_log";
if (pAlias->bOmitFromOutput)
strName += " omit_output";
if (pAlias->bRegexp)
strName += " regexp";
if (pAlias->bOneShot)
strName += " one_shot";
if (pAlias->bIgnoreCase)
strName += " ignore_case";
if (pAlias->bMenu)
strName += " menu";
if (pAlias->bTemporary)
strName += " temporary";
if (pAlias->bIncluded)
strName += " included";
// if (pAlias->bDelayed)
// strName += " delayed";
strName += CFormat (" send_to:%s", (LPCTSTR) GetSendToString (pAlias->iSendTo));
strName += CFormat (" seq:%i", pAlias->iSequence);
Note (strName);
}
Note (TFormat ("%i alias%s.", PLURALES (iCount)));
} // end of aliases
//-----------------------------------------------------------------------
// triggers
//-----------------------------------------------------------------------
else if (strcmp (Command, "triggers") == 0)
{
CTrigger * pTrigger;
CString strTriggerName;
for (POSITION pos = GetTriggerMap ().GetStartPosition(); pos; iCount++)
{
GetTriggerMap ().GetNextAssoc (pos, strTriggerName, pTrigger);
CString strName = CFormat ("{{%s}}={{%s}}",
(LPCTSTR) pTrigger->trigger,
(LPCTSTR) pTrigger->contents);
if (!pTrigger->strLabel.IsEmpty ())
strName += CFormat (" label=%s", (LPCTSTR) pTrigger->strLabel);
if (!pTrigger->strProcedure.IsEmpty ())
strName += CFormat (" script=%s", (LPCTSTR) pTrigger->strProcedure);
if (!pTrigger->strGroup.IsEmpty ())
strName += CFormat (" group=%s", (LPCTSTR) pTrigger->strGroup);
if (!pTrigger->strVariable.IsEmpty ())
strName += CFormat (" variable=%s", (LPCTSTR) pTrigger->strVariable);
#ifdef PANE
if (!pTrigger->strPane.IsEmpty ())
strName += CFormat (" pane=%s", (LPCTSTR) pTrigger->strPane);
#endif // PANE
if (!pTrigger->sound_to_play.IsEmpty ())
strName += CFormat (" sound=%s", (LPCTSTR) pTrigger->sound_to_play);
if (pTrigger->bSoundIfInactive)
strName += " sound_if_inactive";
if (pTrigger->bLowercaseWildcard)
strName += " lowercase_wildcard";
if (pTrigger->colour != SAMECOLOUR)
strName += CFormat (" colour=%i", pTrigger->colour + 1); // make 1-relative
if (!pTrigger->bEnabled)
strName += " disabled";
if (pTrigger->bExpandVariables)
strName += " expand_variables";
if (pTrigger->omit_from_log)
strName += " omit_log";
if (pTrigger->bOmitFromOutput)
strName += " omit_output";
if (pTrigger->bRegexp)
strName += " regexp";
if (pTrigger->ignore_case)
strName += " ignore_case";
if (pTrigger->bKeepEvaluating)
strName += " keep_evaluating";
if (pTrigger->bOneShot)
strName += " one_shot";
if (pTrigger->bRepeat)
strName += " repeat";
if (pTrigger->bTemporary)
strName += " temporary";
if (pTrigger->bIncluded)
strName += " included";
strName += CFormat (" send_to:%s", (LPCTSTR) GetSendToString (pTrigger->iSendTo));
strName += CFormat (" seq:%i", pTrigger->iSequence);
Note (strName);
}
Note (TFormat ("%i trigger%s.", PLURAL (iCount)));
} // end of triggers
//-----------------------------------------------------------------------
// options
//-----------------------------------------------------------------------
else if (strcmp (Command, "options") == 0)
ShowOptions (); // list world options
//-----------------------------------------------------------------------
// alpha_options
//-----------------------------------------------------------------------
else if (strcmp (Command, "alpha_options") == 0)
ShowAlphaOptions (); // list world options
//-----------------------------------------------------------------------
// global_options
//-----------------------------------------------------------------------
else if (strcmp (Command, "global_options") == 0)
App.ShowGlobalOptions (this); // list global options
//-----------------------------------------------------------------------
// option_info
//-----------------------------------------------------------------------
else if (strcmp (Command, "option_info") == 0)
{
CString strType;
CString strRange;
CString strNote;
long i;
for (i = 0; OptionsTable [i].pName; i++)
{
int iMinimum = OptionsTable [i].iMinimum;
int iMaximum = OptionsTable [i].iMaximum;
if ((iMinimum | iMaximum) == 0)
{
strType = "Boolean";
strRange = "y/n";
}
else
{
strType = "Number";
strRange = CFormat ("%i to %i", iMinimum, iMaximum);
}
if (OptionsTable [i].iFlags & OPT_CUSTOM_COLOUR)
strNote = ", Custom colour";
else
if (OptionsTable [i].iFlags & OPT_RGB_COLOUR)
strNote = ", RGB colour";
else
strNote.Empty ();
Note (CFormat ("%s, %s, %s, %0.0f%s", // name, type, range, default, note
OptionsTable [i].pName,
(LPCTSTR) strType,
(LPCTSTR) strRange,
OptionsTable [i].iDefault,
(LPCTSTR) strNote
));
} // end of numeric options
for (i = 0; AlphaOptionsTable [i].pName; i++)
{
strType = "Alpha";
if (AlphaOptionsTable [i].iFlags & OPT_MULTLINE)
strNote = "Multi-line";
else
if (AlphaOptionsTable [i].iFlags & OPT_PASSWORD)
strNote = "Password";
else
strNote.Empty ();
Note (CFormat ("%s, %s, , \"%s\", %s", // name, type, , default, note
(LPCTSTR) AlphaOptionsTable [i].pName,
(LPCTSTR) strType,
AlphaOptionsTable [i].sDefault,
(LPCTSTR) strNote
));
} // end of alpha options
} // end of option_info
//-----------------------------------------------------------------------
// included_options
//-----------------------------------------------------------------------
else if (strcmp (Command, "included_options") == 0)
{
long i;
for (i = 0; OptionsTable [i].pName; i++)
{
if (m_NumericConfiguration [i]->bInclude)
Note (CFormat ("%s = %i", // name, included value
(LPCTSTR) OptionsTable [i].pName,
m_NumericConfiguration [i]->iValue
));
} // end of numeric options
for (i = 0; AlphaOptionsTable [i].pName; i++)
{
if (m_AlphaConfiguration [i]->bInclude)
Note (CFormat ("%s = %s ", // name, included value
(LPCTSTR) AlphaOptionsTable [i].pName,
(LPCTSTR) m_AlphaConfiguration [i]->sValue
));
} // end of alpha options
} // end of option_info
//-----------------------------------------------------------------------
// variables
//-----------------------------------------------------------------------
else if (strcmp (Command, "variables") == 0)
{
for (POSITION pos = GetVariableMap ().GetStartPosition(); pos; iCount++)
{
CString strVariableName;
CVariable * variable_item;
GetVariableMap ().GetNextAssoc (pos, strVariableName, variable_item);
CString strName = CFormat ("%-10s = %s",
(LPCTSTR) strVariableName,
(LPCTSTR) variable_item->strContents);
Note (strName);
}
Note (TFormat ("%i variable%s.", PLURAL (iCount)));
} // end of variables
//-----------------------------------------------------------------------
// arrays
//-----------------------------------------------------------------------
else if (strcmp (Command, "arrays") == 0)
{
// delete our arrays
for (tStringMapOfMaps::iterator it = GetArrayMap ().begin ();
it != GetArrayMap ().end ();
it++, iCount++)
{
Note (CFormat ("Array: \"%s\"", it->first.c_str ()));
// now show key/value pairs
for (tStringToStringMap::iterator i = it->second->begin ();
i != it->second->end ();
i++)
Note (CFormat (" Key \"%s\" = \"%s\"", i->first.c_str (), i->second.c_str ()));
}
Note (TFormat ("%i array%s.", PLURAL (iCount)));
} // end of arrays
//-----------------------------------------------------------------------
// plugins
//-----------------------------------------------------------------------
else if (strcmp (Command, "plugins") == 0)
{
POSITION pos; // other pos
for (PluginListIterator pit = m_PluginList.begin ();
pit != m_PluginList.end ();
++pit, ++iCount)
{
CPlugin * p = *pit;
Note (TFormat ("Name: %s", (LPCTSTR) p->m_strName));
Note (TFormat ("ID: %s", (LPCTSTR) p->m_strID));
Note (TFormat ("Purpose: %s", (LPCTSTR) p->m_strPurpose));
Note (TFormat ("Author: %s", (LPCTSTR) p->m_strAuthor));
Note (TFormat ("Disk file: %s", (LPCTSTR) p->m_strSource));
Note (TFormat ("Language: %s", (LPCTSTR) p->m_strLanguage));
Note (TFormat ("Enabled: %s", SHOW_TRUE (p->m_bEnabled)));
Note (TFormat ("Sequence: %d", p->m_iSequence));
if (!p->m_strScript.IsEmpty ())
{
Note (Translate ("Script:"));
Note (Translate ("-------(start script)----------"));
Note (p->m_strScript);
Note (Translate ("--------(end script)-----------"));
}
CString strName;
CTrigger * pTrigger;
CAlias * pAlias;
CTimer * pTimer;
CVariable * pVariable;
int iCount2;
for (pos = p->m_TriggerMap.GetStartPosition(), iCount2 = 1; pos; iCount2++)
{
p->m_TriggerMap.GetNextAssoc (pos, strName, pTrigger);
Note (TFormat ("Trigger %i: %s=%s",
iCount2,
(LPCTSTR) pTrigger->trigger,
(LPCTSTR) pTrigger->contents));
// warn if no dispid
if (pTrigger->dispid == DISPID_UNKNOWN && !pTrigger->strProcedure.IsEmpty ())
Note (TFormat ("--> Script sub %s NOT active <--", (LPCTSTR) pTrigger->strProcedure));
} // end of triggers
for (pos = p->m_AliasMap.GetStartPosition(), iCount2 = 1; pos; iCount2++)
{
p->m_AliasMap.GetNextAssoc (pos, strName, pAlias);
Note (TFormat ("Alias %i: %s=%s",
iCount2,
(LPCTSTR) pAlias->name,
(LPCTSTR) pAlias->contents));
// warn if no dispid
if (pAlias->dispid == DISPID_UNKNOWN && !pAlias->strProcedure.IsEmpty ())
Note (CFormat ("--> Script sub %s NOT active <--", (LPCTSTR) pAlias->strProcedure));
} // end of aliases
for (pos = p->m_TimerMap.GetStartPosition(), iCount2 = 1; pos; iCount2++)
{
p->m_TimerMap.GetNextAssoc (pos, strName, pTimer);
Note (TFormat ("Timer %i: %02i:%02i:%04.2f=%s",
iCount2,
pTimer->iAtHour + pTimer->iEveryHour,
pTimer->iAtMinute + pTimer->iEveryMinute,
pTimer->fAtSecond + pTimer->fEverySecond,
(LPCTSTR) pTimer->strContents));
// warn if no dispid
if (pTimer->dispid == DISPID_UNKNOWN && !pTimer->strProcedure.IsEmpty ())
Note (TFormat ("--> Script sub %s NOT active <--", (LPCTSTR) pTimer->strProcedure));
} // end of timers
for (pos = p->m_VariableMap.GetStartPosition(), iCount2 = 1; pos; iCount2++)
{
p->m_VariableMap.GetNextAssoc (pos, strName, pVariable);
Note (TFormat ("Variable %i: %s=%s",
iCount2,
(LPCTSTR) pVariable->strLabel,
(LPCTSTR) pVariable->strContents));
} // end of variables
Note (TFormat ("<--- (end plugin \"%s\") --->", (LPCTSTR) p->m_strName));
Note ("");
} // end of doing each plugin
Note (TFormat ("%i plugin%s.", PLURAL (iCount)));
}
//-----------------------------------------------------------------------
// internal commands
//-----------------------------------------------------------------------
else if (strcmp (Command, "internal_commands") == 0)
{
for (iCount = 0; CommandIDs [iCount].iCommandID; iCount++)
Note (CommandIDs [iCount].sCommandName);
Note (TFormat ("%i internal command%s.", PLURAL (iCount)));
} // end of internal commands
//-----------------------------------------------------------------------
// info
//-----------------------------------------------------------------------
else if (strcmp (Command, "info") == 0)
{
for (iCount = 0; InfoTypes [iCount].iInfoType; iCount++)
{
COleVariant v;
v = GetInfo (InfoTypes [iCount].iInfoType);
if (v.vt == VT_NULL)
Note (CFormat ("%s = (UNIMPLEMENTED INFO TYPE)",
InfoTypes [iCount].sDescription));
else
{
v.ChangeType (VT_BSTR);
Note (CFormat ("%03i: %s = %s", InfoTypes [iCount].iInfoType,
InfoTypes [iCount].sDescription,
(LPCTSTR) CString (v.bstrVal)));
v.Clear (); // get rid of string (is this necessary?)
} // end of not VT_NULL
}
Note (TFormat ("%i info item%s.", PLURAL (iCount)));
} // end of info
//-----------------------------------------------------------------------
// summary
//-----------------------------------------------------------------------
else if (strcmp (Command, "summary") == 0)
{
POSITION pos;
CString strName;
CTrigger * pTrigger;
CAlias * pAlias;
CTimer * pTimer;
__int64 nTotalMatches = 0;
__int64 nTotalMatchAttempts = 0;
long nTotal = 0;
long nEnabled = 0;
long nRegexp = 0;
LONGLONG iTimeTaken = 0;
double elapsed_time;
int i;
CString enabledFore = "#0080FF";
CString disabledFore = "gray";
// work out colour for not-disabled messages
if (m_iNoteTextColour >= 0 && m_iNoteTextColour < MAX_CUSTOM)
enabledFore = ColourToName (m_customtext [m_iNoteTextColour]);
Note ("");
ColourNote (SCRIPTERRORCONTEXTFORECOLOUR, "", "-------------- MUSHclient summary --------------");
Note ("");
Note (TFormat ("MUSHclient version: %s", MUSHCLIENT_VERSION));
// show compilation date
Note (TFormat ("Compiled: %s.", __DATE__));
Note (CTime::GetCurrentTime().Format (TranslateTime ("Time now: %A, %B %d, %Y, %#I:%M %p")));
CTimeSpan ts = CTime::GetCurrentTime() - App.m_whenClientStarted;
Note (ts.Format ("Client running for: %Dd %Hh %Mm %Ss"));
ts = CTime::GetCurrentTime() - m_whenWorldStarted;
Note (ts.Format ("World opened for: %Dd %Hh %Mm %Ss"));
if (m_iConnectPhase == eConnectConnectedToMud)
{
ts = CTime::GetCurrentTime() - m_tConnectTime;
Note (ts.Format ("World connected for: %Dd %Hh %Mm %Ss"));
}
// work out operating system
CString sVersion = TFormat ("Unknown (Platform %ld, Major %ld, Minor %ld)",
os_version.dwPlatformId, os_version.dwMajorVersion, os_version.dwMinorVersion);
if (os_version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) // Windows 95-style versions
{
switch (os_version.dwMinorVersion)
{
case 0: sVersion = "Windows 95"; break;
case 10: sVersion = "Windows 98"; break;
case 90: sVersion = "Windows ME"; break;
} // end of switch on dwMinorVersion