forked from nickgammon/mushclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.h
2898 lines (2432 loc) · 122 KB
/
doc.h
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
// doc.h : interface of the CMUSHclientDoc class
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "worldsock.h"
#include "chatsock.h"
#include "chatlistensock.h"
#include "dialogs\ColourComboBox.h"
#include "dialogs\world_prefs\prefspropertypages.h"
#include "TimerWnd.h"
#include "xml\xmlparse.h"
#include "paneline.h"
#include "miniwindow.h"
#include "plugins.h"
#include "version.h"
#define COMPRESS_BUFFER_LENGTH 10000 // size of decompression buffer
extern CString MUSHCLIENT_VERSION;
// ============================================================================
#define MY_WEB_PAGE "http://www.gammon.com.au/mushclient/"
#define CHANGES_WEB_PAGE "http://www.gammon.com.au/scripts/showrelnote.php"
#define MUD_LIST "http://www.gammon.com.au/links/muds.htm"
#define BUG_REPORT_PAGE "http://www.gammon.com.au/forum/?bbtopic_id=5"
#define FORUM_URL "http://www.gammon.com.au/forum/"
#define MUSHCLIENT_FORUM_URL "http://www.gammon.com.au/forum/?bbsection_id=1"
#define MUSHCLIENT_FUNCTIONS_URL "http://www.gammon.com.au/mushclient/functions.htm"
#define DOCUMENTATION_PAGE "http://www.gammon.com.au/scripts/doc.php"
#define REGEXP_PAGE "http://www.gammon.com.au/mushclient/regexp.htm"
#define PLUGINS_PAGE "http://www.gammon.com.au/mushclient/plugins/"
#define SECURITY_URL "http://www.gammon.com.au/security"
#define MAX_LINE_WIDTH 500 // max line we will wrap to
#define MAX_RECENT_LINES 200 // maximum recent lines we can use for multi-line triggers
#pragma warning(disable: 4800) // disable warning about bool being forced to BOOL
// program constants
const int JUMP_SIZE = 100; // how many lines we discard when we reach maximum lines
const char ENDLINE [] = "\r\n"; // line terminator
const int VERSION = 15; // version number written to world file
#define MAX_EXECUTION_DEPTH 20 // number of nested calls to world.Execute we permit
#define MAX(arg1, arg2) (((arg1) > (arg2)) ? (arg1) : (arg2))
#define MIN(arg1, arg2) (((arg1) < (arg2)) ? (arg1) : (arg2))
// definitions for Pueblo - see:
// http://www.chaco.com/pueblo/doc/manual/puebloPueblo_Enhancers_Guide.html
// this string identifies a Pueblo-offering server
#define PUEBLO_ID_STRING1 "This world is Pueblo 1.10 enhanced."
#define PUEBLO_ID_STRING2 "This world is Pueblo 1.0 Enhanced"
#define PUEBLO_ID_STRING3 "This world is Pueblo 2.50 enhanced."
// this string identifies that we will use Pueblo - replace %s with a 32-character hash
#define PUEBLO_REPLY1 "PUEBLOCLIENT %s md5=\"%s\""
#define PUEBLO_REPLY2 "PUEBLOCLIENT"
// this string identifies that Pueblo starts after it is received
#define PUEBLO_START "</xch_mudtext>"
class CSendView;
class CMUSHView;
class CChildFrame;
class CSendView;
class CTextDocument;
class UDPsocket;
#define ESC '\x1B'
// ANSI/MXP phases
enum { NONE, // normal text
HAVE_ESC, // just received an escape
DOING_CODE, // process an ANSI escape sequence
HAVE_IAC, // just received a TELNET IAC (interpret as command)
HAVE_WILL, // just received a TELNET WILL
HAVE_WONT, // just received a TELNET WONT
HAVE_DO, // just received a TELNET DO
HAVE_DONT, // just received a TELNET DONT
HAVE_SB, // just received a TELNET IAC SB
HAVE_SUBNEGOTIATION, // received TELNET IAC SB c (collecting data, awaiting IAC SE)
HAVE_SUBNEGOTIATION_IAC, // received TELNET IAC SB c <data> IAC (awaiting IAC or SE)
HAVE_COMPRESS, // received TELNET IAC COMPRESS
HAVE_COMPRESS_WILL, // received TELNET IAC COMPRESS WILL
HAVE_FOREGROUND_256_START, // received ESC[38;
HAVE_FOREGROUND_256_FINISH, // received ESC[38;5;
HAVE_BACKGROUND_256_START, // received ESC[48;
HAVE_BACKGROUND_256_FINISH, // received ESC[48;5;
// utf-8 modes
HAVE_UTF8_CHARACTER, // received 110 xxxxx, 1110 xxxx, or 11110 xxx
// mxp modes
HAVE_MXP_ELEMENT, // collecting element, eg. < xxxxx >. Starts on <, stops on >
HAVE_MXP_COMMENT, // collecting comment, eg. <!-- xxxxx -->. Starts on <!--, stops on -->
HAVE_MXP_QUOTE, // collecting quote inside element, eg. <color='red'>
HAVE_MXP_ENTITY, // collecting entity, eg. > . Starts on &, stops on ;
// mxp special collection modes following a special escape sequence
HAVE_MXP_ROOM_NAME, // the line is parsed as the name of a room.
HAVE_MXP_ROOM_DESCRIPTION, // the line is parsed as a description of a room.
HAVE_MXP_ROOM_EXITS, // the line is parsed as an exit line for a room.
HAVE_MXP_WELCOME, // This text is sent from the MUD at the beginning of a session to welcome the user to the MUD.
};
// TELNET escape sequences - see RFC 854
enum { WILL_END_OF_RECORD = 0x19, // see RFC 885 */
EOR = 0xEF, // see RFC 885
SE = 0xF0, // end of subnegotiation
NOP = 0xF1, // no operation
DATA_MARK = 0xF2, // see RFC 854
BREAK = 0xF3, // BRK
INTERRUPT_PROCESS = 0xF4, // IP
ABORT_OUTPUT = 0xF5, // AO
ARE_YOU_THERE = 0xF6, // AYT
ERASE_CHARACTER = 0xF7, // EC
ERASE_LINE = 0xF8, // EL
GO_AHEAD = 0xF9, // GA
SB = 0xFA, // subnegotiation
WILL = 0xFB,
WONT = 0xFC,
DO = 0xFD,
DONT = 0xFE,
IAC = 0xFF
};
// values for m_iConnectPhase - for connecting via Socks proxy or directly
// - this is so we know what we are up to
enum {
eConnectNotConnected, // 0: not connected and not attempting connection
eConnectMudNameLookup, // 1: finding address of MUD
eConnectProxyNameLookup, // 2: finding address of proxy server
eConnectConnectingToMud, // 3: connecting to MUD (no proxy server)
eConnectConnectingToProxy, // 4: connecting to proxy server
eConnectAwaitingProxyResponse1, // 5: sent SOCKS authentication method, awaiting confirmation
eConnectAwaitingProxyResponse2, // 6: sent SOCKS username/password, awaiting confirmation
eConnectAwaitingProxyResponse3, // 7: sent SOCKS connect details, awaiting confirmation
eConnectConnectedToMud, // 8: connected, we can play now
eConnectDisconnecting, // 9: in process of disconnecting, don't attempt to reconnect
};
// values for m_iSocksProcessing - type of proxy server
enum {
eProxyServerNone, // no proxy server
eProxyServerSocks4, // SOCKS 4
eProxyServerSocks5, // SOCKS 5
// This must be last !!!
eProxyServerLast,
};
// values for m_iCurrentActionSource - why script is currently running
enum {
eDontChangeAction = 999, // leave current action alone (was -1, but must be unsigned)
eUnknownActionSource = 0, // no particular reason, could be plugin saving
eUserTyping = 1, // user typed something in the command area and pressed <Enter>
eUserMacro = 2, // user typed a macro (eg. F2)
eUserKeypad = 3, // user used the numeric keypad
eUserAccelerator = 4, // user used an accelerator key
eUserMenuAction = 5, // item chosen from pop-up menu
eTriggerFired = 6, // trigger fired
eTimerFired = 7, // timer fired
eInputFromServer = 8, // input arrived (eg. packet received)
eWorldAction = 9, // some sort of world action (eg. world open, connect, got focus)
eLuaSandbox = 10, // executing Lua sandbox
eHotspotCallback = 11, // miniwindow hotspot callback
};
// value for m_iStopTriggerEvaluation - should we stop trigger evaluation?
enum {
eKeepEvaluatingTriggers,
eStopEvaluatingTriggers,
eStopEvaluatingTriggersInAllPlugins
};
// MCCP (Mud Client Compression Protocol) stuff
// NB 85 is MCCP v1, 86 is MCCP v2
#define TELOPT_ECHO 1 //just in case you want to know what 1 is :)
#define TELOPT_NAWS 31 // Negotiate About Window Size
#define TELOPT_CHARSET 42 // Negotiate About Character Set
#define TELOPT_TERMINAL_TYPE 24 // want to know terminal type
#define TELOPT_COMPRESS 85 // telet negotiation code for starting compression v1
#define TELOPT_COMPRESS2 86 // telet negotiation code for starting compression v2
#define TELOPT_MUD_SPECIFIC 102 // telet negotiation code MUD-specific negotiations
#define SUPPORT_VERSIONS 0 // MCCP support-versions query
#define VERSION_IS 1 // MCCP version number
#define VERSION_NONE 0 // see web page below for details
#define VERSION_2_1 1
// see http://www.randomly.org/projects/MCCP/protocol.html
#define SGA 3 // suppress go-ahead
#define TELOPT_MSP 90 // telet negotiation code for MUD Sound Protocol (MSP)
#define TELOPT_MXP 91 // telet negotiation code for MUD Extension Protocol (MXP)
#define TELOPT_ZMP 93 // http://zmp.sourcemud.org/spec.shtml
#define TELOPT_ATCP 200 // http://www.ironrealms.com/rapture/manual/files/FeatATCP-txt.html
// bits for m_iFlags1
#define FLAGS1_ArrowRecallsPartial 0x0001
#define FLAGS1_CtrlZGoesToEndOfBuffer 0x0002
#define FLAGS1_CtrlPGoesToPreviousCommand 0x0004
#define FLAGS1_CtrlNGoesToNextCommand 0x0008
#define FLAGS1_HyperlinkAddsToCommandHistory 0x0010
#define FLAGS1_EchoHyperlinkInOutputWindow 0x0020
#define FLAGS1_AutoWrapWindowWidth 0x0040
#define FLAGS1_NAWS 0x0080
#define FLAGS1_Pueblo 0x0100
#define FLAGS1_NoEchoOff 0x0200
#define FLAGS1_UseCustomLinkColour 0x0400
#define FLAGS1_MudCanChangeLinkColour 0x0800
#define FLAGS1_UnderlineHyperlinks 0x1000
#define FLAGS1_MudCanRemoveUnderline 0x2000
//#define FLAGS1_AssumeSecureMode 0x4000
// bits for m_iFlags2
#define FLAGS2_AlternativeInverse 0x0001
#define FLAGS2_ShowConnectDisconnect 0x0002
#define FLAGS2_IgnoreMXPcolourChanges 0x0004
#define FLAGS2_Custom16isDefaultColour 0x0008
#define FLAGS2_LogInColour 0x0010
#define FLAGS2_LogRaw 0x0020
// queued commands echo and send flags - lowercase versions do not log
#define QUEUE_WITH_ECHO 'E'
#define QUEUE_WITHOUT_ECHO 'N'
#define IMMEDIATE_WITH_ECHO 'I'
#define IMMEDIATE_WITHOUT_ECHO 'W'
#define QUEUE_WITH_ECHO_NOLOG 'e'
#define QUEUE_WITHOUT_ECHO_NOLOG 'n'
#define IMMEDIATE_WITH_ECHO_NOLOG 'i'
#define IMMEDIATE_WITHOUT_ECHO_NOLOG 'w'
// reload script file options
enum {
eReloadConfirm,
eReloadAlways,
eReloadNever,
};
// used for iNotepadType
enum {
eNotepadNormal,
eNotepadMXPdebug,
eNotepadTrigger,
eNotepadRecall,
eNotepadScript,
eNotepadPacketDebug,
eNotepadLineInfo,
eNotepadWorldLoadError,
eNotepadXMLcomments,
eNotepadPluginInfo,
};
// values for auto-connect (m_connect_now)
enum
{
eNoAutoConnect,
eConnectMUSH,
eConnectDiku,
eConnectMXP,
eConnectTypeMax, // this must be last!
};
// values for <OL> and <UL> tags
// see m_iListMode
enum
{
eNoList,
eOrderedList,
eUnorderedList,
};
// configuration page numbers
enum
{
ePageGroup0, // name
ePageGeneral,
ePageConnecting,
ePageLogging,
ePageTimers,
ePageChat,
ePageInfo,
ePageNotes,
ePageGroup00, // appearance
ePageOutput,
ePageMXP,
ePageANSIColours,
ePageCustomColours,
ePageTriggers,
// ePageSounds,
ePagePrinting,
ePageGroup000, // input
ePageCommands,
ePageAliases,
ePageKeypad,
ePageMacros,
ePageAutosay,
// ePageGroup0000, // paste
ePagePaste,
ePageSend,
ePageGroup00000, // scripting
ePageScripts,
ePageVariables,
};
// MXP modes - see m_iMXP_mode (based on <esc> [ x z where x is the mode)
enum
{
eMXP_open=0, // only MXP commands in the "open" category are allowed.
eMXP_secure=1, // all tags and commands in MXP are allowed within the line.
eMXP_locked=2, // no MXP or HTML commands are allowed in the line. The line is not parsed for any tags at all.
eMXP_reset=3, // close all open tags
eMXP_secure_once=4, // next tag is secure only
eMXP_perm_open=5, // open mode until mode change
eMXP_perm_secure=6, // secure mode until mode change
eMXP_perm_locked=7, // locked mode until mode change
eMXP_room_name=10, // the line is parsed as the name of a room.
eMXP_room_description=11, // the line is parsed as a description of a room.
eMXP_room_exits=12, // the line is parsed as an exit line for a room.
eMXP_welcome=19, // This text is sent from the MUD at the beginning of a session to welcome the user to the MUD.
//20 to 99 - user defined
};
// use mxp options - see m_iUseMXP
enum {
eOnCommandMXP, // turn on after <IAC><SB><MXP><IAC><SE>
eQueryMXP, // turn on after option query
eUseMXP, // always on
eNoMXP, // always off
};
// MXP debug levels
enum {
DBG_NONE, // no messages
DBG_ERROR, // only errors
DBG_WARNING, // errors and warnings
DBG_INFO, // errors, warnings and info
DBG_ALL, // a whole lot of useless stuff
};
#define OPT_CUSTOM_COLOUR 0x000001 // colour number (add 1 to colour to save, subtract 1 to load)
#define OPT_RGB_COLOUR 0x000002 // colour is RGB colour
#define OPT_DOUBLE 0x000004 // option is a double
#define OPT_UPDATE_VIEWS 0x000100 // if changed, update all views
#define OPT_UPDATE_INPUT_FONT 0x000200 // if changed, update input font
#define OPT_UPDATE_OUTPUT_FONT 0x000400 // if changed, update output font
#define OPT_FIX_OUTPUT_BUFFER 0x000800 // if changed, rework output buffer size
#define OPT_FIX_WRAP_COLUMN 0x001000 // if changed, wrap column has changed
#define OPT_FIX_SPEEDWALK_DELAY 0x002000 // if changed, speedwalk delay has changed
#define OPT_USE_MXP 0x004000 // if changed, use_mxp has changed
#define OPT_PLUGIN_CANNOT_READ 0x100000 // plugin may not read its value
#define OPT_PLUGIN_CANNOT_WRITE 0x200000 // plugin may not write its value
#define OPT_PLUGIN_CANNOT_RW 0x300000 // plugin may not read or write its value
#define OPT_CANNOT_WRITE 0x400000 // cannot be changed by any script
#define OPT_SERVER_CAN_WRITE 0x800000 // CAN be changed by <recommend_option> tag
#define OPT_FIX_INPUT_WRAP 0x1000000 // Added for input wrapping.
#define OPT_FIX_TOOLTIP_VISIBLE 0x2000000 // Added for tooltip delay changing.
#define OPT_FIX_TOOLTIP_START 0x4000000 // Added for tooltip delay changing.
// for debug.options and MXP <option> tag
typedef struct
{
char * pName; // name, eg. "logoutput"
double iDefault; // original (default) value
int iOffset; // offset in CMUSHclientDoc
int iLength; // length of field (ie. 1, 2, 4, 8 bytes)
double iMinimum; // minimum size it can be
double iMaximum; // maximum size it can be, if both zero, assume boolean
int iFlags; // colours etc, see above
} tConfigurationNumericOption;
// for XML load/save
typedef struct
{
char * pName; // name, eg. "server"
char * sDefault; // original (default) value
int iOffset; // offset in CMUSHclientDoc
int iFlags; // flags, see above
} tConfigurationAlphaOption;
#define OPT_MULTLINE 0x000001 // multi-line option (eg. world notes)
#define OPT_KEEP_SPACES 0x000002 // preserve leading/trailing spaces
#define OPT_PASSWORD 0x000004 // use base 64 encoding
#define OPT_COMMAND_STACK 0x000008 // this is the command stack character
#define OPT_WORLD_ID 0x000010 // this is the world ID
// also can have values above: OPT_UPDATE_VIEWS,
// OPT_UPDATE_INPUT_FONT,
// OPT_UPDATE_OUTPUT_FONT etc.
// for Lua tables mainly
typedef struct { const char* key; int val; } flags_pair;
typedef struct { int key; char * val; } int_flags_pair;
typedef struct
{
int iInfoType; // which info number it is
const char * sDescription; // eg. "Server name"
} tInfoTypeMapping;
// for SQLite databases
typedef struct
{
sqlite3 *db; // current database pointer
sqlite3_stmt *pStmt; // current prepared statement, NULL if none
bool bValidRow; // true if last call to DatabaseStep returned SQLITE_ROW
string db_name; // name of database when opened
int iColumns; // number of columns from last prepared statement
} tDatabase;
typedef map<string, tDatabase *> tDatabaseMap;
typedef tDatabaseMap::iterator tDatabaseMapIterator;
// case-independent (ci) string less_than
// returns true if s1 < s2
struct ci_less : binary_function<string, string, bool>
{
// case-independent (ci) compare_less binary function
struct nocase_compare : public binary_function<unsigned char,unsigned char,bool>
{
bool operator() (const unsigned char& c1, const unsigned char& c2) const
{ return tolower (c1) < tolower (c2); }
};
bool operator() (const string & s1, const string & s2) const
{
return lexicographical_compare
(s1.begin (), s1.end (), // source range
s2.begin (), s2.end (), // dest range
nocase_compare ()); // comparison
}
}; // end of ci_less
typedef set<string, ci_less> ci_set;
class ScriptItem
{
public:
// constructor
ScriptItem (CPlugin * pPlugin,
const string sText,
const string sSource) :
pWhichPlugin (pPlugin),
sScriptText (sText),
sScriptSource (sSource) {};
CPlugin * pWhichPlugin; // which plugin
const string sScriptText; // the script to execute
const string sScriptSource; // what it is, eg. "Trigger X"
};
typedef list<ScriptItem> ScriptItemMap;
class OneShotItem
{
public:
// constructor
OneShotItem (CPlugin * pPlugin,
const string sKey) :
pWhichPlugin (pPlugin),
sItemKey (sKey) {};
CPlugin * pWhichPlugin; // which plugin
const string sItemKey; // the key to delete
};
typedef list<OneShotItem> OneShotItemMap;
// option get/set stuff
double GetBaseOptionItem (const int iItem,
tConfigurationNumericOption BaseOptionsTable [],
const int iItemCount,
char * pBase);
CString GetBaseAlphaOptionItem (const int iItem,
tConfigurationAlphaOption BaseAlphaOptionsTable [],
const int iItemCount,
char * pBase);
long SetBaseOptionItem (const int iItem,
tConfigurationNumericOption BaseOptionsTable [],
const int iItemCount,
char * pBase,
double Value,
bool & bChanged);
long SetBaseAlphaOptionItem (const int iItem,
tConfigurationAlphaOption BaseAlphaOptionsTable [],
const int iItemCount,
char * pBase,
CString & strValue,
bool & bChanged);
long FindBaseOption (LPCTSTR OptionName,
tConfigurationNumericOption BaseOptionsTable [],
int & iItem);
long FindBaseAlphaOption (LPCTSTR OptionName,
tConfigurationAlphaOption BaseAlphaOptionsTable [],
int & iItem);
class CNumericConfiguration : public CObject
{
public:
long iValue; // loaded value
bool bInclude; // true if from include file
void Reset (void) { iValue = 0; bInclude = false; }
CNumericConfiguration () { Reset (); }
}; // end of CConfiguration
typedef CTypedPtrArray <CPtrArray, CNumericConfiguration*> CNumericConfigurationArray;
class CAlphaConfiguration : public CObject
{
public:
CString sValue; // loaded value
bool bInclude; // true if from include file
void Reset (void) { sValue.Empty (); bInclude = false; }
CAlphaConfiguration () { Reset (); }
}; // end of CAlphaConfiguration
typedef CTypedPtrArray <CPtrArray, CAlphaConfiguration*> CAlphaConfigurationArray;
#ifdef PANE
class CPaneView;
typedef map<string, CPaneView *> CPaneMap;
typedef CPaneMap::iterator PaneMapIterator;
#endif // PANE
class CMUSHclientDoc : public CDocument
{
friend class CActivityView;
friend class CMapDlg;
friend class CWorldSocket;
friend class CPluginsDlg;
friend class CSendView;
friend class CMUSHView;
friend class CChatSocket;
friend class CChatListenSocket;
friend class CChatListDlg;
friend class CMUSHclientApp;
friend class CScriptEngine;
protected: // create from serialization only
CMUSHclientDoc();
DECLARE_DYNCREATE(CMUSHclientDoc)
// Attributes
public:
CWorldSocket* m_pSocket;
// stuff saved to disk
CString m_server;
CString m_mush_name;
CString m_name;
CString m_password;
CString m_file_postamble;
CString m_file_preamble ;
CString m_line_postamble;
CString m_line_preamble ;
CString m_notes;
CString m_new_activity_sound;
CString m_strScriptEditor;
CString m_strScriptEditorArgument;
CString m_strLogFilePreamble;
CString m_strSpeedWalkFiller;
unsigned short m_wrap;
unsigned short m_port;
unsigned short m_timestamps;
unsigned short m_connect_now;
unsigned short m_match_width;
unsigned short m_enable_aliases;
unsigned short m_enable_triggers;
unsigned short m_bEnableTimers;
unsigned short m_display_my_input;
unsigned short m_echo_colour;
unsigned short m_enable_beeps;
unsigned short m_enable_trigger_sounds;
unsigned short m_indent_paras;
unsigned short m_bSaveWorldAutomatically;
unsigned short m_bLineInformation;
unsigned short m_bStartPaused;
LONG m_font_height;
CString m_font_name;
LONG m_font_weight;
DWORD m_font_charset;
// normal (ANSI) colours
COLORREF m_normalcolour [8];
COLORREF m_boldcolour [8];
// custom (user-defined) colours for triggers etc.
COLORREF m_customtext [MAX_CUSTOM];
COLORREF m_customback [MAX_CUSTOM];
// unsigned short m_log_input;
// unsigned short m_bLogNotes;
unsigned short m_bEscapeDeletesInput;
unsigned short m_bArrowsChangeHistory;
unsigned short m_bConfirmOnPaste;
CString m_macros [MACRO_COUNT]; // for function keys
unsigned short m_macro_type [MACRO_COUNT]; // see macro send types above
CString m_macro_name [MACRO_COUNT];
// numeric keypad stuff
CString m_keypad [eKeypad_Max_Items]; // 30 at present
unsigned short m_keypad_enable;
// other interesting things
unsigned short m_enable_speed_walk;
CString m_speed_walk_prefix;
unsigned short m_enable_command_stack;
// unsigned char m_command_stack_character;
CString m_strCommandStackCharacter;
CString m_connect_text;
CAliasMap m_AliasMap;
CAliasArray m_AliasArray; // array of aliases for sequencing
CAliasRevMap m_AliasRevMap; // for getting name back from pointer
CTriggerMap m_TriggerMap;
CTriggerArray m_TriggerArray; // array of triggers for sequencing
CTriggerRevMap m_TriggerRevMap; // for getting name back from pointer
CTimerMap m_TimerMap;
CTimerRevMap m_TimerRevMap; // for getting name back from pointer
// new in version 7
COLORREF m_input_text_colour;
COLORREF m_input_background_colour;
LONG m_input_font_height;
CString m_input_font_name;
BYTE m_input_font_italic;
LONG m_input_font_weight;
DWORD m_input_font_charset;
// new in version 8
LONG m_maxlines; // maximum lines in scrollback buffer
LONG m_nHistoryLines; // maximum lines in command history
unsigned short m_nWrapColumn; // column to wrap at
CString m_paste_postamble;
CString m_paste_preamble ;
CString m_pasteline_postamble;
CString m_pasteline_preamble ;
CString m_strLanguage; // script language
unsigned short m_bEnableScripts; // enable scripting
COLORREF m_iHyperlinkColour; // colour for hyperlinks
CString m_strWorldOpen; // handler on world open
CString m_strWorldClose; // handler on world close
CString m_strWorldSave; // handler on world save
CString m_strWorldConnect; // handler on world connect
CString m_strWorldDisconnect; // handler on world disconnect
CString m_strScriptFilename; // script filename
CString m_strScriptPrefix; // prefix to invoke scripts from the command window
unsigned short m_iNoteTextColour; // colour for note
unsigned short m_bKeepCommandsOnSameLine; // commands stay on same line as prompt from MUD
CVariableMap m_VariableMap; // program variables (map)
CString m_strAutoSayString;
unsigned short m_bEnableAutoSay;
unsigned short m_bExcludeMacros;
unsigned short m_bExcludeNonAlpha;
CString m_strOverridePrefix;
unsigned short m_bConfirmBeforeReplacingTyping;
unsigned short m_bReEvaluateAutoSay; // send auto-say through command interpreter
int m_nNormalPrintStyle [8]; // when printing, whether to use bold, underline etc.
int m_nBoldPrintStyle [8]; // when printing, whether to use bold, underline etc.
// new in version 9
unsigned short m_bShowBold; // show bold, italic, underline in fonts
unsigned short m_bAltArrowRecallsPartial; // alt+up arrow recalls partially entered command
unsigned short m_iPixelOffset; // pixel offset of text from side of window
unsigned short m_bAutoFreeze; // freeze if not at bottom of buffer
unsigned short m_bAutoRepeat; // auto repeat last command
unsigned short m_bDisableCompression; // don't allow compressed worlds
unsigned short m_bLowerCaseTabCompletion; // tab complete words in lower case
unsigned short m_bDoubleClickInserts; // double-click inserts word into command buffer
unsigned short m_bConfirmOnSend; // confirm preamble, postamble on file send
unsigned short m_bTranslateGerman; // translate German character sequences
// new in version 10
CString m_strTabCompletionDefaults; // initial words to check for tab completion
unsigned int m_iTabCompletionLines; // lines to search
unsigned short m_bTabCompletionSpace; // insert space after word?
CString m_strAutoLogFileName; // name of file to log to
CString m_strLogLinePreambleOutput; // put at start of each log line - output
CString m_strLogLinePreambleInput; // put at start of each log line - input
CString m_strLogLinePreambleNotes; // put at start of each log line - world.Note
CString m_strWorldGetFocus; // script called when the world gets the focus
CString m_strWorldLoseFocus; // script called when the world loses the focus
CString m_strLogFilePostamble; // written when log file closed
CString m_strRecallLinePreamble; // line preamble for recall window
unsigned short m_bPasteCommentedSoftcode; // are we pasting commented softcode?
unsigned short m_bFileCommentedSoftcode; // are we sending commented softcode?
unsigned short m_bShowItalic; // italic text to be shown in italic?
unsigned short m_bShowUnderline; // underlined text to be underlined?
unsigned short m_bFlashIcon; // flash icon on taskbar for new activity?
unsigned short m_bArrowKeysWrap; // arrow keys wrap command history?
unsigned short m_bSpellCheckOnSend; // spell check when you send something
LONG m_nPasteDelay; // delay in milliseconds before pasting each line
LONG m_nFileDelay; // delay in milliseconds before sending each line
LONG m_nReloadOption; // option for reloading changed script file
LONG m_bUseDefaultOutputFont; // Default output font overrides
LONG m_bSaveDeletedCommand; // save deleted command in command history on <esc>
LONG m_bTranslateBackslashSequences; // interpret \n \r etc. on a send
LONG m_bEditScriptWithNotepad; // use inbuilt notepad for editing scripts
LONG m_bWarnIfScriptingInactive; // warn if we can't invoke a script
LONG m_nPasteDelayPerLines; // how many lines to send before the delay
LONG m_nFileDelayPerLines; // how many lines to send before the delay
// new in version 11
unsigned short m_bDoubleClickSends; // double-click sends to MUD
unsigned short m_bWriteWorldNameToLog; // write world name to log file
unsigned short m_bSendEcho;
unsigned short m_bPasteEcho;
unsigned short m_bUseDefaultColours;
unsigned short m_bUseDefaultTriggers;
unsigned short m_bUseDefaultAliases;
unsigned short m_bUseDefaultMacros;
unsigned short m_bUseDefaultTimers;
unsigned short m_bUseDefaultInputFont;
CString m_strCustomColourName [255]; // custom colour names
CString m_strTerminalIdentification; // for telnet negotiation, defaults to ANSI
// new in version 14
CString m_strLogLinePostambleOutput; // put at end of each log line - output
CString m_strLogLinePostambleInput; // put at end of each log line - input
CString m_strLogLinePostambleNotes; // put at end of each log line - world.Note
CString m_strMappingFailure; // message for mapping failure
// callback routines for MXP
CString m_strOnMXP_Start; // MXP starting up
CString m_strOnMXP_Stop; // MXP closing down
CString m_strOnMXP_Error; // MXP error
CString m_strOnMXP_OpenTag; // MXP tag open
CString m_strOnMXP_CloseTag; // MXP tag close
CString m_strOnMXP_SetVariable; // MXP variable set
CString m_strBeepSound; // sound to play for beeps
unsigned short m_bLogHTML; // convert special HTML sequences (eg. < and > )
unsigned short m_bUnpauseOnSend; // cancel pause on next send to MUD
unsigned short m_iSpeedWalkDelay; // delay in ms for speed walking
unsigned short m_bMapFailureRegexp; // for expansion
unsigned short m_iFlags1; // various flags, see below
unsigned short m_iFlags2; // more flags
unsigned short m_iUseMXP; // whether to use MXP - see enum above
unsigned short m_iMXPdebugLevel; // level of MXP debugging
CString m_strWorldID; // unique ID for this world
// new in version 15
unsigned short m_bAlwaysRecordCommandHistory; // record command history even if echo off
unsigned short m_bCopySelectionToClipboard; // automatically copy selection
unsigned short m_bCarriageReturnClearsLine; // \r character empties current line
unsigned short m_bSendMXP_AFK_Response; // reply to <afk> query?
unsigned short m_bMudCanChangeOptions; // server may recommend options
// unsigned short m_bShowGridLinesInListViews; // list views show grid
unsigned short m_bEnableSpamPrevention; // send spam filler every x lines
unsigned short m_iSpamLineCount; // send spam filler after this many lines the same
CString m_strSpamMessage; // what spam filler to send
unsigned short m_bDoNotShowOutstandingLines; // don't show outstanding lines in tabbed windows
unsigned short m_bDoNotTranslateIACtoIACIAC; // don't translate outgoing IAC to IAC/IAC
// new in 3.36
CString m_strProxyServerName; // name/IP address of proxy server
unsigned short m_iProxyServerPort; // proxy server port
unsigned short m_iSocksProcessing; // 0 = none, 1 = Socks 4, 2 = Socks 5
CString m_strProxyUserName; // user name for proxy authentication
CString m_strProxyPassword; // password for proxy authentication
// more new stuff
unsigned short m_bAutoCopyInHTML; // auto-copy to clipboard in HTML
unsigned short m_iLineSpacing; // line spacing, 0 to use font height
unsigned short m_bUTF_8; // want UTF-8 support
unsigned short m_bConvertGAtoNewline; // convert IAC/GA or IAC/EOR to a newline
unsigned short m_iCurrentActionSource;// what caused the current script to run
CString m_strTriggersFilter; // Lua code to filter triggers
CString m_strAliasesFilter; // Lua code to filter aliases
CString m_strTimersFilter; // Lua code to filter timers
CString m_strVariablesFilter; // Lua code to filter variables
unsigned short m_bScriptErrorsToOutputWindow; // write script errors in window
unsigned short m_bAutoResizeCommandWindow; // change command window height automatically
CString m_strEditorWindowName; // What window to bring to the front after editing a text file
unsigned short m_iAutoResizeMinimumLines; // command window minimum number of lines
unsigned short m_iAutoResizeMaximumLines; // command window maximum number of lines
unsigned short m_bDoNotAddMacrosToCommandHistory; // macros not into command history
unsigned short m_bSendKeepAlives; // set the socket option SO_KEEPALIVE on the TCP/IP connections
// version 4.54
unsigned short m_iDefaultTriggerSendTo; // default send-to location for triggers
unsigned short m_iDefaultTriggerSequence; // default sequence for triggers
unsigned short m_bDefaultTriggerRegexp; // default regular expression flag for triggers
unsigned short m_bDefaultTriggerExpandVariables; // default expand-variables flag for triggers
unsigned short m_bDefaultTriggerKeepEvaluating; // default keep-evaluating flag for triggers
unsigned short m_bDefaultTriggerIgnoreCase; // default ignore-case flag for triggers
unsigned short m_iDefaultAliasSendTo; // default send-to location for aliases
unsigned short m_iDefaultAliasSequence; // default sequence for aliases
unsigned short m_bDefaultAliasRegexp; // default regular expression flag for aliases
unsigned short m_bDefaultAliasExpandVariables; // default expand-variables flag for aliases
unsigned short m_bDefaultAliasKeepEvaluating; // default keep-evaluating flag for aliases
unsigned short m_bDefaultAliasIgnoreCase; // default ignore-case flag for aliases
unsigned short m_iDefaultTimerSendTo; // default send-to location for timers
// version 4.56
unsigned short m_bPlaySoundsInBackground; // if true, PlaySound uses a global sound buffer
// version 4.62
CString m_strOutputLinePreambleOutput; // put at start of each output line - MUD output
CString m_strOutputLinePreambleInput; // put at start of each output line - input
CString m_strOutputLinePreambleNotes; // put at start of each output line - world.Note
COLORREF m_OutputLinePreambleOutputTextColour; // text colour - MUD output preamble
COLORREF m_OutputLinePreambleOutputBackColour; // back colour - MUD output preamble
COLORREF m_OutputLinePreambleInputTextColour; // text colour - input preamble
COLORREF m_OutputLinePreambleInputBackColour; // back colour - input preamble
COLORREF m_OutputLinePreambleNotesTextColour; // text colour - Note preamble
COLORREF m_OutputLinePreambleNotesBackColour; // back colour - Note preamble
// version 4.65
unsigned short m_bTreeviewTriggers; // show triggers in tree view?
unsigned short m_bTreeviewAliases; // show aliases in tree view?
unsigned short m_bTreeviewTimers; // show timers in tree view?
// version 4.81
unsigned short m_bAutoWrapInput; // Match input wrap to output?
// version 4.82
unsigned int m_iToolTipVisibleTime; // Time tooltip stays visible (milliseconds)
unsigned int m_iToolTipStartTime; // Time before tooltip appears (milliseconds)
// version 4.92
unsigned short m_bLogScriptErrors; // write scripting error messages to log file?
unsigned short m_bOmitSavedDateFromSaveFiles; // if set, do not write the date saved to save files
// end of stuff saved to disk **************************************************************
// stuff from pre version 11, read from disk but not saved
unsigned short m_page_colour;
unsigned short m_whisper_colour;
unsigned short m_mail_colour;
unsigned short m_game_colour;
unsigned short m_chat_colour;
unsigned short m_remove_channels1;
unsigned short m_remove_channels2;
unsigned short m_remove_pages;
unsigned short m_remove_whispers;
unsigned short m_remove_set;
unsigned short m_remove_mail;
unsigned short m_remove_game;
// end of pre version 11 stuff
// from m_iFlags1;
BOOL m_bArrowRecallsPartial; // arrow key (without ALT) recalls partial command
BOOL m_bCtrlZGoesToEndOfBuffer; // Ctrl+Z goes to end of output buffer
BOOL m_bCtrlPGoesToPreviousCommand; // Ctrl+P gets previous command
BOOL m_bCtrlNGoesToNextCommand; // Ctrl+N gets next command
BOOL m_bHyperlinkAddsToCommandHistory; // MXP hyperlink goes into history
BOOL m_bEchoHyperlinkInOutputWindow; // MXP hyperlink is echoed
BOOL m_bAutoWrapWindowWidth; // auto wrap to current window width
BOOL m_bNAWS; // Negotiate About Window Size
BOOL m_bPueblo; // Allow Pueblo worlds
BOOL m_bNoEchoOff; // ignore attempts to stop command echoing
BOOL m_bUseCustomLinkColour ; // use our custom link colour
BOOL m_bMudCanChangeLinkColour ; // however MUD can override it
BOOL m_bUnderlineHyperlinks ; // underline our hyperlinks
BOOL m_bMudCanRemoveUnderline ; // however MUD can remove the underline
// end of m_iFlags1
// from m_iFlags2;
BOOL m_bAlternativeInverse; // alternative way of displaying bold inverse
BOOL m_bShowConnectDisconnect; // show message in output window on connect/disconnect
BOOL m_bIgnoreMXPcolourChanges; // don't let MXP/Pueblo change output colours
BOOL m_bCustom16isDefaultColour; // user custom colour 16 after ANSI reset
BOOL m_bLogInColour; // HTML logging is in colour
BOOL m_bLogRaw; // write raw input from mud to log file
// end of m_iFlags2
BOOL m_bNAWS_wanted; // server wants NAWS messages
BOOL m_bCHARSET_wanted; // server wants CHARSET messages
bool m_bLoaded; // true if we have loaded from disk
bool m_bSelected; // true if selected in Send To All Worlds
bool m_bVariablesChanged; // true if variables have changed
bool m_bNoEcho; // set if we get IAC WILL ECHO
// cleared if we get IAC WONT ECHO
bool m_bDebugIncomingPackets; // set if we want to display all incoming text
__int64 m_iInputPacketCount; // count of packets received
__int64 m_iOutputPacketCount; // count of packets sent
long m_iUTF8ErrorCount; // count of lines with bad UTF8
long m_iOutputWindowRedrawCount; // count of times output window redrawn
unsigned char m_UTF8Sequence [5]; // we collect up to 4 UTF8 bytes here and a null-terminator
int m_iUTF8BytesLeft; // how many UTF8 bytes to go
long m_iTriggersEvaluatedCount; // how many triggers we evaluated
long m_iTriggersMatchedCount; // how many triggers matched