Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 804 lines (611 sloc) 23.533 kb
ad0cd12 @nickgammon Main source files
authored
1 // doc_construct.cpp : CMUSHclientDoc constructor/destructor
2 //
3
4 #include "stdafx.h"
5 #include "MUSHclient.h"
6 #include "mainfrm.h"
7
8 #include "doc.h"
9 #include "genprint.h"
10 #include "dialogs\QuickConnectDlg.h"
11 #include "UDPsocket.h"
12
13 extern int gdoccount;
14
15 /////////////////////////////////////////////////////////////////////////////
16 // CMUSHclientDoc construction/destruction
17
18 CMUSHclientDoc::CMUSHclientDoc()
19 : m_eventScriptFileChanged(FALSE, TRUE)
20
21 { // constructor
22
23 int i;
24
25 // each document will have a unique number
26 m_iUniqueDocumentNumber = App.GetUniqueNumber ();
27
baa6353 @nickgammon Added GetInfo (306) - when the world started up
authored
28 m_whenWorldStarted = CTime::GetCurrentTime();
3210dac @nickgammon Remembered when document started in high-precision time
authored
29 QueryPerformanceCounter (&m_whenWorldStartedHighPrecision);
baa6353 @nickgammon Added GetInfo (306) - when the world started up
authored
30
ad0cd12 @nickgammon Main source files
authored
31 AllocateConfigurationArrays ();
32
33 m_bTrace = false; // not tracing yet
34
35 // note - these initialisations merely make the hash lookup more efficient.
36 // until v 3.21 they were the default of 20, so this should help somewhat
37 // The number should be a prime number, hence the strange figures.
38
39 m_VariableMap.InitHashTable (997); // allow for 1000 variables (at least)
40 m_AliasMap.InitHashTable (293); // probably won't have many more than 300 aliases
41 m_TriggerMap.InitHashTable (293); // probably won't have many more than 300 triggers
42 m_TimerMap.InitHashTable (293); // probably won't have many more than 300 timers
43
44 SetDefaults (false); // set up numeric/boolean defaults
45 SetAlphaDefaults (false); // set up alpha defaults
46
47 m_strWorldID = GetUniqueID (); // default world ID
48
49 m_CurrentPlugin = NULL; // no plugin active right now
50
51 m_iBackgroundMode = 0;
52 m_iForegroundMode = 0;
53 m_iBackgroundColour = NO_COLOUR;
54
55 m_TextRectangle = CRect (0, 0, 0, 0);
56 m_TextRectangleBorderOffset = 0;
57 m_TextRectangleBorderColour = 0;
58 m_TextRectangleBorderWidth = 0;
59 m_TextRectangleOutsideFillColour = 0;
60 m_TextRectangleOutsideFillStyle = 0;
61
62 m_iCurrentActionSource = eUnknownActionSource;
63 m_nBytesIn = 0;
64 m_nBytesOut = 0;
65 m_bTabCompleteFunctions = true;
66 m_hSpecialFontHandle = 0;
67
68 m_iTriggersEvaluatedCount = 0;
69 m_iTriggersMatchedCount = 0;
70 m_iAliasesEvaluatedCount = 0;
71 m_iAliasesMatchedCount = 0;
72 m_iTimersFiredCount = 0;
f1f5ef2 @nickgammon Added extra stats to be shown on disconnect.
authored
73 m_iTriggersMatchedThisSessionCount = 0;
74 m_iAliasesMatchedThisSessionCount = 0;
75 m_iTimersFiredThisSessionCount = 0;
ad0cd12 @nickgammon Main source files
authored
76
77 m_bLoaded = false;
78 m_bMapping = false;
79 m_bRemoveMapReverses = true;
80 m_MapFailureRegexp = NULL;
81 m_bPluginProcessingCommand = false;
82 m_bPluginProcessingSend = false;
83 m_bPluginProcessingSent = false;
84 m_iLastCommandCount = 0;
85 m_iExecutionDepth = 0;
86 m_iNextChatID = 0;
87 m_tLastMessageTime = 0;
88 m_tLastGroupMessageTime = 0;
89 m_bOmitFromCommandHistory = false;
90 m_bUTF_8 = false;
91 m_bWorldClosing = false;
92 m_bInSendToScript = true;
93
94 m_bInPlaySoundFilePlugin = false;
95 m_bInCancelSoundFilePlugin = false;
96
97 m_strStatusMessage = Translate ("Ready");
98 m_bShowingMapperStatus = false;
99 m_iMCCP_type = 0;
100 m_bSupports_MCCP_2 = false;
101 m_bNoEcho = false;
102 m_bDebugIncomingPackets = false;
103 m_iInputPacketCount = 0;
104 m_iOutputPacketCount = 0;
105 m_iUTF8ErrorCount = 0;
106 m_lastGoTo = 1;
107 m_bNAWS_wanted = false;
108 m_bCHARSET_wanted = false;
109 m_bSuppressNewline = false;
a9bfa67 @nickgammon Fixed bug where echo input 'no change' would become custom colour 10
authored
110 m_echo_colour = SAMECOLOUR;
ad0cd12 @nickgammon Main source files
authored
111 m_bAlwaysRecordCommandHistory = false;
112 m_bDoNotShowOutstandingLines = false;
113 m_bDoNotTranslateIACtoIACIAC = false;
114 m_bAutoResizeCommandWindow = false;
115 m_iAutoResizeMinimumLines = 1;
116 m_iAutoResizeMaximumLines = 20;
117 m_bDoNotAddMacrosToCommandHistory = false;
118 m_bCopySelectionToClipboard = false;
119 m_bCarriageReturnClearsLine = false;
120 m_bConvertGAtoNewline = false;
121 m_bSendMXP_AFK_Response = true;
122 m_bMudCanChangeOptions = true;
123 // m_bShowGridLinesInListViews = true; // NB - app-wide :P
124 m_bEnableSpamPrevention = false;
125 m_strSpamMessage = "look";
126 m_iSpamLineCount = 20;
127 m_iLastOutgoingChatPort = DEFAULT_CHAT_PORT;
5bb6c97 @nickgammon Added script function SetScroll
authored
128 m_bScrollBarWanted = TRUE;
ad0cd12 @nickgammon Main source files
authored
129
130 m_iSocksProcessing = 0; // no socks processing wanted
131 m_iProxyServerPort = 1080; // default socks port
132
133 // deprecated options - set to zero for saving comparison (for XML testing)
134
135 m_page_colour = 0;
136 m_whisper_colour= 0;
137 m_mail_colour = 0;
138 m_game_colour = 0;
139 m_chat_colour = 0;
140 m_remove_channels1 = 0;
141 m_remove_channels2 = 0;
142 m_remove_pages= 0;
143 m_remove_whispers = 0;
144 m_remove_set= 0;
145 m_remove_mail = 0;
146 m_remove_game = 0;
147
148 // things I found to be not initialised in version 3.43
149
150 m_timestamps = 0;
151 m_iFlags1 = 0;
152 m_iFlags2 = 0;
153 m_iListMode = 0;
154 m_iListCount = 0;
155 m_iMXP_previousMode = eMXP_open;
156 m_code = 0;
157
158 // sound buffers
159 for (i = 0; i < MAX_SOUND_BUFFERS; i++)
160 m_pDirectSoundSecondaryBuffer [i] = NULL;
161
162 /*---------------------------------------------------------
163 I want to be able to time speed walking delays (for pulling things
164 out of the list, so I need a window that can take timer events, however
165 a CDocument isn't a window. Thus, I'll make a hidden window for this
166 specific purpose.
167
168 I previously had speed walking tied to the CSendView window but this was
169 pretty crappy, because you could have multiple send views, thus the timers
170 would be all over the shop, and it was very fiddly when firing a "send" from
171 a trigger, because a trigger is not related to a particular send view.
172
173 --------------------------------------------------------- */
174
175
176 // create window that we can use for firing timers
177 m_pTimerWnd = new CTimerWnd (this);
178
179 m_pTimerWnd->m_hWnd = NULL;
180 if (!m_pTimerWnd->CreateEx(0, AfxRegisterWndClass(0),
181 _T("Document timer window"),
182 WS_OVERLAPPED, 0, 0, 0, 0, NULL, NULL))
183 {
184 TRACE0("Warning: unable to create document timer window!\n");
185 AfxThrowResourceException();
186 }
187 ASSERT(m_pTimerWnd->m_hWnd != NULL);
188 ASSERT(CWnd::FromHandlePermanent(m_pTimerWnd->m_hWnd) == m_pTimerWnd);
189
190
191 for (i = 0; i < 8; i++)
192 m_font [i] = NULL;
193 m_input_font = NULL;
194 m_FontHeight = 0;
195 m_FontWidth = 0;
196 m_InputFontHeight = 0;
197 m_InputFontWidth = 0;
198 m_total_lines = 0;
c8ff618 @nickgammon Count newlines received. Available as GetInfo (310).
authored
199 m_newlines_received = 0;
006ac57 @nickgammon Added selector 289 to GetInfo
authored
200 m_last_line_with_IAC_GA = 0;
ad0cd12 @nickgammon Main source files
authored
201 m_nTotalLinesSent = 0;
f1f5ef2 @nickgammon Added extra stats to be shown on disconnect.
authored
202 m_nTotalLinesReceived = 0;
ad0cd12 @nickgammon Main source files
authored
203 m_phase = NONE;
204
205 m_bVariablesChanged = false;
206
207 m_view_number = 0;
208 m_LastFlushTime = CTime::GetCurrentTime();
209
210 m_bCompress = false; // no compression yet
211 m_bCompressInitOK = false;
212 m_CompressInput = NULL;
213 m_CompressOutput = NULL;
214
215 // initialise zlib decompression
216
217 m_zCompress.next_in = Z_NULL;
218 m_zCompress.avail_in = 0;
219 m_zCompress.zalloc = Z_NULL;
220 m_zCompress.zfree = Z_NULL;
221 m_zCompress.opaque = Z_NULL;
222 m_nTotalUncompressed = 0;
223 m_nTotalCompressed = 0;
224 m_iCompressionTimeTaken = 0;
bf9c23b @nickgammon Fixed bug where Z_BUF_ERROR error was not handled correctly
authored
225 m_nCompressionOutputBufferSize = COMPRESS_BUFFER_LENGTH; // initial value
ad0cd12 @nickgammon Main source files
authored
226
227 // we will defer initialising zlib until we really have to
228
229 m_pSocket = NULL;
230 m_pChatListenSocket = NULL; // no listening socket
231 m_logfile = NULL;
232 m_match_width = 30;
233
234 m_bSelected = true;
235
236 m_bNotesInRGB = false; // notes are in palette colour right now
237 m_iNoteStyle = NORMAL; // notes are not bold right now
238
239 // MXP
240
241 m_bMXP = false; // no MXP yet
242 m_bPuebloActive = false; // no Pueblo yet either <evil grin>
243 m_bInParagraph = false;
244 m_bMXP_script = false;
245 m_bPreMode = false;
246 m_iMXP_defaultMode = eMXP_open;
247 m_iMXP_mode = m_iMXP_defaultMode;
248 m_cLastChar = 0;
249
250 // initial styles
251
252 m_iFlags = 0;
253 m_iForeColour = WHITE;
254 m_iBackColour = BLACK;
255
256 if (m_bCustom16isDefaultColour)
257 {
258 m_iForeColour = 15; // use custom colour 16
259 m_iBackColour = 15;
260 m_iFlags |= COLOUR_CUSTOM;
261 }
262
263 // m_normalcolour [BLACK] = RGB (192, 192, 192) | PALETTE; // black
264 // m_normalcolour [RED] = RGB (128, 0, 64) | PALETTE; // red
265 // m_normalcolour [GREEN] = RGB (128, 255, 128) | PALETTE; // green
266 // m_normalcolour [YELLOW] = RGB (255, 255, 128) | PALETTE; // yellow
267 // m_normalcolour [BLUE] = RGB ( 0, 255, 255) | PALETTE; // blue
268 // m_normalcolour [MAGENTA] = RGB (255, 0, 128) | PALETTE; // magenta
269 // m_normalcolour [CYAN] = RGB (128, 255, 255) | PALETTE; // cyan
270 // m_normalcolour [WHITE] = RGB ( 0, 128, 0) | PALETTE; // white
271
272 // m_boldcolour [BLACK] = RGB ( 0, 0, 0) | PALETTE; // black
273 // m_boldcolour [RED] = RGB (255, 0, 0) | PALETTE; // red
274 // m_boldcolour [GREEN] = RGB ( 0, 255, 0) | PALETTE; // green
275 // m_boldcolour [YELLOW] = RGB (255, 255, 0) | PALETTE; // yellow
276 // m_boldcolour [BLUE] = RGB ( 0, 64, 128) | PALETTE; // blue
277 // m_boldcolour [MAGENTA] = RGB (255, 0, 255) | PALETTE; // magenta
278 // m_boldcolour [CYAN] = RGB ( 0, 255, 255) | PALETTE; // cyan
279 // m_boldcolour [WHITE] = RGB (255, 255, 255) | PALETTE; // white
280
281 // better use ANSI colours as the default
282
283 SetDefaultAnsiColours (m_normalcolour, m_boldcolour);
284
285 // and some nice custom colours
286 SetDefaultCustomColours (m_customtext, m_customback);
287
288 // default custom colour names
289 for (i = 0; i < NUMITEMS (m_strCustomColourName); i++)
290 m_strCustomColourName [i].Format ("Custom%i", i + 1);
291
292 for (i = 0; i < NUMITEMS (m_macro_type); i++)
293 m_macro_type [i] = SEND_NOW;
294
295 // printer styles for printing from the screen
296
297 for (i = 0; i < 8; i++)
298 {
299 m_nNormalPrintStyle [i] = 0;
300 m_nBoldPrintStyle [i] = FONT_BOLD;
301 }
302
303 m_bUseDefaultOutputFont = !App.m_strDefaultOutputFont.IsEmpty ();
304
305 m_bUseDefaultColours = !App.m_strDefaultColoursFile.IsEmpty ();
306 m_bUseDefaultTriggers = !App.m_strDefaultTriggersFile.IsEmpty ();
307 m_bUseDefaultAliases = !App.m_strDefaultAliasesFile.IsEmpty ();
308 m_bUseDefaultMacros = !App.m_strDefaultMacrosFile.IsEmpty ();
309 m_bUseDefaultTimers = !App.m_strDefaultTimersFile.IsEmpty ();
310 m_bUseDefaultInputFont = !App.m_strDefaultInputFont.IsEmpty ();
311
312 setupstrings ();
313
314 m_tStatusTime = CTime::GetCurrentTime();
315 m_tConnectTime = CTime::GetCurrentTime();
316 m_tLastPlayerInput = CTime::GetCurrentTime();
317 m_timeScriptFileMod = 0;
318
319 m_tsConnectDuration = CTimeSpan (0, 0, 0, 0);
320
321 m_iConnectPhase = eConnectNotConnected;
322
323 gdoccount++;
324
325 m_pActiveCommandView = NULL;
326 m_pActiveOutputView = NULL;
327
328 m_new_lines = 0;
329
330 m_last_prefs_page = 1;
331
332 App.m_bUpdateActivity = TRUE;
333
334 // for looking up host names
335
336 ZeroMemory (&m_sockAddr, sizeof m_sockAddr);
337 ZeroMemory (&m_ProxyAddr, sizeof m_ProxyAddr);
338 m_hNameLookup = NULL;
339 m_pGetHostStruct = NULL;
340 m_pLinePositions = NULL;
341
342 m_pCurrentLine = NULL;
343 m_total_lines = 0;
344
345 // set up the dialog box headings for the finding dialogs
346 m_DisplayFindInfo.m_strTitle = "Find in output buffer...";
347 m_MacrosFindInfo.m_strTitle = "Find macro...";
348 m_AliasesFindInfo.m_strTitle = "Find alias...";
349 m_TriggersFindInfo.m_strTitle = "Find trigger...";
350 m_TimersFindInfo.m_strTitle = "Find timer...";
351 m_VariablesFindInfo.m_strTitle = "Find variable...";
352 m_NotesFindInfo.m_strTitle = "Find in notes...";
353 m_RecallFindInfo.m_strTitle = "Recall...";
354
355 m_bRecallCommands = true;
356 m_bRecallOutput = true;
357 m_bRecallNotes = true;
358
359 // set up column counts for use in the loading and saving of the column orders etc.
360 m_MacrosFindInfo.m_iControlColumns = CPrefsP6::eColumnCount;
361 m_AliasesFindInfo.m_iControlColumns = CPrefsP7::eColumnCount;
362 m_TriggersFindInfo.m_iControlColumns = CPrefsP8::eColumnCount;
363 m_TimersFindInfo.m_iControlColumns = CPrefsP16::eColumnCount;
364 m_VariablesFindInfo.m_iControlColumns = CPrefsP18::eColumnCount;
365
366 m_bDisconnectOK = true; // so we don't try to reconnect to prematurely
367
368 m_iMXPerrors = 0;
369 m_iMXPtags = 0;
370 m_iMXPentities = 0;
371
372 // scripting support
373
374 EnableAutomation(); // not needed?
375
376 if (!bWine)
377 AfxOleLockApp(); // not needed?
378
379 m_ScriptEngine = NULL;
380
381 m_bInScriptFileChanged = false;
382 m_pThread = NULL;
383 m_bSyntaxErrorOnly = false;
384
385 m_dispidWorldOpen = DISPID_UNKNOWN;
386 m_dispidWorldClose = DISPID_UNKNOWN;
387 m_dispidWorldSave = DISPID_UNKNOWN;
388 m_dispidWorldConnect = DISPID_UNKNOWN;
389 m_dispidWorldDisconnect = DISPID_UNKNOWN;
390 m_dispidWorldGetFocus = DISPID_UNKNOWN;
391 m_dispidWorldLoseFocus = DISPID_UNKNOWN;
392 m_dispidOnMXP_Start = DISPID_UNKNOWN;
393 m_dispidOnMXP_Stop = DISPID_UNKNOWN;
394 m_dispidOnMXP_OpenTag = DISPID_UNKNOWN;
395 m_dispidOnMXP_CloseTag = DISPID_UNKNOWN;
396 m_dispidOnMXP_SetVariable = DISPID_UNKNOWN;
397 m_dispidOnMXP_Error = DISPID_UNKNOWN;
398
399 m_iScriptTimeTaken = 0; // time taken on scripts
400
401 m_bPluginProcessesOpenTag = false;
402 m_bPluginProcessesCloseTag = false;
403 m_bPluginProcessesSetVariable = false;
404 m_bPluginProcessesSetEntity = false;
405 m_bPluginProcessesError = false;
406
013fcf3 @nickgammon Improved Debug 'summary'
authored
407 ZeroMemory (&m_bClient_sent_IAC_DO, sizeof m_bClient_sent_IAC_DO);
408 ZeroMemory (&m_bClient_sent_IAC_DONT, sizeof m_bClient_sent_IAC_DONT);
409 ZeroMemory (&m_bClient_sent_IAC_WILL, sizeof m_bClient_sent_IAC_WILL);
410 ZeroMemory (&m_bClient_sent_IAC_WONT, sizeof m_bClient_sent_IAC_WONT);
411
412 ZeroMemory (&m_bClient_got_IAC_DO, sizeof m_bClient_got_IAC_DO);
413 ZeroMemory (&m_bClient_got_IAC_DONT, sizeof m_bClient_got_IAC_DONT);
414 ZeroMemory (&m_bClient_got_IAC_WILL, sizeof m_bClient_got_IAC_WILL);
415 ZeroMemory (&m_bClient_got_IAC_WONT, sizeof m_bClient_got_IAC_WONT);
ded9fba @nickgammon Telnet subnegotiation improvements
authored
416
7990fdc @nickgammon Improvements to Debug 'summary'
authored
417 m_nCount_IAC_DO = 0;
418 m_nCount_IAC_DONT = 0;
419 m_nCount_IAC_WILL = 0;
420 m_nCount_IAC_WONT = 0;
421 m_nCount_IAC_SB = 0;
422
1aecfa9 @nickgammon Neatened up Debug 'summary', adding subheadings
authored
423 m_iOutputWindowRedrawCount = 0;
7990fdc @nickgammon Improvements to Debug 'summary'
authored
424
3b4b5cb @nickgammon Remembered treeview or not, fixed focus problem
authored
425 m_bTreeviewTriggers = true;
426 m_bTreeviewAliases = true;
427 m_bTreeviewTimers = true;
428
ad0cd12 @nickgammon Main source files
authored
429 // set up some default triggers for MUSHes
430
431 /*
432 The parameter are:
433
434 Trigger Name
435 Match Text
436 Response Text
437 Flags
438 Colour
439 Wildcard to copy to clipboard
440 Sound File Name
441 Script Name
442 */
443
444 /* No, don't. It just confuses Diku MUD people
445
446 AddTrigger ("Game_messages", "GAME:*", "", eEnabled, 0, 0, "", "");
447 AddTrigger ("Page_poses", "From afar,*", "", eEnabled, 1, 0, "", "");
448 AddTrigger ("Pages", "^\\w+ pages.*$", "", eEnabled | eTriggerRegularExpression, 1, 0, "", "");
449 AddTrigger ("Whisper_poses", "You sense:*", "", eEnabled, 2, 0, "", "");
450 AddTrigger ("Whispers", "^\\w+ whispers.*$", "", eEnabled | eTriggerRegularExpression, 2, 0, "", "");
451 AddTrigger ("Mail_messages", "MAIL:*", "", eEnabled, 3, 0, "", "");
452 AddTrigger ("Chat_channel_1", "^\\<.+?\\>.*$", "", eEnabled | eTriggerRegularExpression, 4, 0, "", "");
453 AddTrigger ("Chat_channel_2", "^\\[.+?\\].*$", "", eEnabled | eTriggerRegularExpression, 4, 0, "", "");
454 */
455
456 m_nextAcceleratorCommand = ACCELERATOR_FIRST_COMMAND;
457 m_accelerator = NULL;
458
459 } // end of CMUSHclientDoc::CMUSHclientDoc()
460
461 #ifdef PANE
462 void closepane (pair<string, CPaneView *> item)
463 {
464 item.second->GetParentFrame ()->SendMessage (WM_CLOSE);
465 }
466 #endif // PANE
467
468 CMUSHclientDoc::~CMUSHclientDoc()
469 {
470 int i;
471
472 // stop sounds playing, release sound buffers
473 for (i = 0; i < MAX_SOUND_BUFFERS; i++)
474 if (m_pDirectSoundSecondaryBuffer [i])
475 {
476 DWORD iStatus;
477 if (SUCCEEDED (m_pDirectSoundSecondaryBuffer [i]->GetStatus (&iStatus)) &&
478 (iStatus & DSBSTATUS_PLAYING))
479 m_pDirectSoundSecondaryBuffer [i]->Stop ();
480
481 m_pDirectSoundSecondaryBuffer [i]->Release ();
482 }
483
484 if (m_pTimerWnd)
485 {
486 m_pTimerWnd->DestroyWindow();
487 delete m_pTimerWnd;
0c625cd @nickgammon Fixed bug where doing SpeedWalkDelay during world close would cause a cr...
authored
488 m_pTimerWnd = NULL;
ad0cd12 @nickgammon Main source files
authored
489 }
490
491 for (i = 0; i < 8; i++)
492 delete m_font [i];
493 delete m_input_font;
494
495 if (m_hNameLookup)
496 WSACancelAsyncRequest (m_hNameLookup); // cancel host name lookup in progress
497
498 delete [] m_pGetHostStruct; // delete buffer used by host name lookup
499
500 delete m_MapFailureRegexp; // delete regexp structure for mapping failures
501
502 if (m_pSocket)
503 {
504
505 ShutDownSocket (*m_pSocket);
506
507 delete m_pSocket;
508 m_pSocket = NULL;
509
510 }
511
512 if (m_pChatListenSocket)
513 {
514
515 ShutDownSocket (*m_pChatListenSocket);
516
517 delete m_pChatListenSocket;
518 m_pChatListenSocket = NULL;
519
520 }
521
522 // UDP listening sockets
523 for (map<int, UDPsocket *>::iterator udpSocketIterator = m_UDPsocketMap.begin ();
524 udpSocketIterator != m_UDPsocketMap.end ();
525 udpSocketIterator++)
526 delete udpSocketIterator->second;
527
cc89eff @nickgammon Improvement to plugin deletion problem
authored
528 // delete chat sessions
ad0cd12 @nickgammon Main source files
authored
529
530 DELETE_LIST (m_ChatList);
531
cc89eff @nickgammon Improvement to plugin deletion problem
authored
532 // delete plugins
f41ba46 @nickgammon Fixed crash if plugins tried to access other plugins during world close
authored
533
534 // we have to do it this way, because otherwise if a plugin attempts to access the
535 // plugin list (eg. BroadcastPlugin, Trace) during the delete operation, then it
536 // may call a plugin that was deleted a moment ago, but is still in the list.
537
cc89eff @nickgammon Improvement to plugin deletion problem
authored
538 for (PluginListIterator pit = m_PluginList.begin ();
539 pit != m_PluginList.end ();
540 pit = m_PluginList.erase (pit)) // erase from list and get next one
541 delete *pit; // delete *this* one
ad0cd12 @nickgammon Main source files
authored
542
543 CloseLog (); // this writes out the log file postamble as well
544
545 // delete triggers
546
547 DELETE_MAP (m_TriggerMap, CTrigger);
548
549 // delete aliass
550
551 DELETE_MAP (m_AliasMap, CAlias);
552
553 // delete lines list
554
555 DELETE_LIST (m_LineList);
556
557 // delete timer map
558
559 DELETE_MAP (m_TimerMap, CTimer);
560
561 // delete variables map
562
563 DELETE_MAP (m_VariableMap, CVariable);
564
565 // delete Element map
566
567 DELETE_MAP (m_CustomElementMap, CElement);
568
569 // delete active tags list
570
571 DELETE_LIST (m_ActiveTagList);
572
573 // delete actions list
574
575 DELETE_LIST (m_ActionList);
576
577
578 // get rid of our positions array
579
580 delete [] m_pLinePositions;
581
582 // one less document
583
584 gdoccount--;
585
586 // update activity window
587
588 App.m_bUpdateActivity = TRUE;
589
590 // ****************** release scripting stuff
591
592 DisableScripting ();
593
594 if (!bWine)
595 AfxOleUnlockApp(); // not needed?
596
597 // free compression stuff
598
599 if (m_CompressOutput)
600 free (m_CompressOutput);
601 if (m_CompressInput)
602 free (m_CompressInput);
603
604 // don't wrap up if not initialised
605 if (m_bCompressInitOK)
606 inflateEnd (&m_zCompress);
607
608 // don't need to know what the configuration was any more
609 DeleteConfigurationArrays ();
610
611 // delete our arrays
612 for (tStringMapOfMaps::iterator it = m_Arrays.begin ();
613 it != m_Arrays.end ();
614 it++)
615 {
616 tStringToStringMap * m = it->second;
617 m->clear ();
618 delete m;
619 }
620
621 // destroy accelerator table, if we had one
622 if (m_accelerator)
623 DestroyAcceleratorTable (m_accelerator);
624
625 // if they loaded a special font, get rid of it
626 RemoveSpecialFont ();
627
628 #ifdef PANE
629
630 // get rid of owned panes
631
632 safe_for_each (m_PaneMap.begin (), m_PaneMap.end (), closepane);
633 #endif // PANE
634
635 // delete MiniWindow map
636
637 for (MiniWindowMapIterator mwit = m_MiniWindows.begin ();
638 mwit != m_MiniWindows.end ();
639 mwit++)
640 delete mwit->second;
641
d11a909 @nickgammon Added script function WindowSetZOrder to specify miniwindow drawing orde...
authored
642 m_MiniWindowsOrder.clear ();
ad0cd12 @nickgammon Main source files
authored
643
644 // delete databases
645 for (tDatabaseMapIterator dbit = m_Databases.begin ();
646 dbit != m_Databases.end ();
647 dbit++)
648 {
649 if (dbit->second->pStmt) // finalize any outstanding statement
650 sqlite3_finalize(dbit->second->pStmt);
651 if (dbit->second->db) // and close the database
652 sqlite3_close(dbit->second->db);
653 delete dbit->second; // now delete memory used by it
654 }
655
c529fba @nickgammon Fixed a couple of memory leaks
authored
656 } // end of CMUSHclientDoc::~CMUSHclientDoc
ad0cd12 @nickgammon Main source files
authored
657
658
659 BOOL CMUSHclientDoc::OnNewDocument()
660 {
661 if (!CDocument::OnNewDocument())
662 return FALSE;
663
664 SetDefaults (false); // set up numeric/boolean defaults
665 SetAlphaDefaults (false); // set up alpha defaults
666
667 // if defaults are wanted, overwrite what we loaded with them :)
668
669 if (m_bLoaded)
670 OnFileReloaddefaults ();
671 else
672 {
673
674 if (!App.m_strDefaultColoursFile.IsEmpty ())
675 {
676 m_bUseDefaultColours = true;
677 Load_Set (COLOUR, App.m_strDefaultColoursFile, &Frame);
678 }
679
680 if (!App.m_strDefaultTriggersFile.IsEmpty ())
681 {
682 m_bUseDefaultTriggers = true;
683 Load_Set (TRIGGER, App.m_strDefaultTriggersFile, &Frame);
684 }
685
686 if (!App.m_strDefaultAliasesFile.IsEmpty ())
687 {
688 m_bUseDefaultAliases = true;
689 Load_Set (ALIAS, App.m_strDefaultAliasesFile, &Frame);
690 }
691
692 if (!App.m_strDefaultTimersFile.IsEmpty ())
693 {
694 m_bUseDefaultTimers = true;
695 Load_Set (TIMER, App.m_strDefaultTimersFile, &Frame);
696 }
697
698 if (!App.m_strDefaultMacrosFile.IsEmpty ())
699 {
700 m_bUseDefaultMacros = true;
701 Load_Set (MACRO, App.m_strDefaultMacrosFile, &Frame);
702 }
703
704 if (!App.m_strDefaultInputFont.IsEmpty ())
705 {
706 m_bUseDefaultInputFont = true;
707 m_input_font_height = App.m_iDefaultInputFontHeight;
708 m_input_font_name = App.m_strDefaultInputFont;
709 m_input_font_italic = App.m_iDefaultInputFontItalic;
710 m_input_font_weight = App.m_iDefaultInputFontWeight;
711 m_input_font_charset = App.m_iDefaultInputFontCharset;
712 } // end of input font override
713
714 if (!App.m_strDefaultOutputFont.IsEmpty ())
715 {
716 m_bUseDefaultOutputFont = true;
717 m_font_height = App.m_iDefaultOutputFontHeight;
718 m_font_name = App.m_strDefaultOutputFont;
719 m_font_weight = FW_NORMAL;
720 m_font_charset = App.m_iDefaultOutputFontCharset;
721 } // end of output font override
722 } // end of not loading an existing world
723
724 m_bLoaded = false; // not really loaded - effectively a new world
725
726 // get name and IP address, give up if cancelled
727
728 if (App.m_TypeOfNewDocument == App.eQuickConnect) // pop up nice simple dialog box
729 {
730 CQuickConnectDlg dlg;
731 dlg.m_iPort = 4000;
732 dlg.m_strWorldName = "Untitled world";
733 dlg.m_strAddress = "";
734 if (dlg.DoModal () != IDOK)
735 return FALSE;
736 m_server = dlg.m_strAddress;
737 m_port = dlg.m_iPort;
738 m_mush_name = dlg.m_strWorldName;
739
740 // save auto connect flag, then set to true, to make sure we connect
741 unsigned int savebAutoConnectWorlds = App.m_bAutoConnectWorlds;
742 App.m_bAutoConnectWorlds = TRUE;
743 SetUpOutputWindow ();
744 OpenSession ();
745 App.m_bAutoConnectWorlds = savebAutoConnectWorlds;
746 SetModifiedFlag ();
747 return TRUE;
748
749 } // end of quick connect
750
751 if (App.m_TypeOfNewDocument == App.eTelnetFromNetscape) // just do it
752 {
753 // get rid of telnet stuff
754 CString strCommandLine = ::Replace (App.m_lpCmdLine, "telnet://", "");
755 int iSpace = strCommandLine.FindOneOf (" :");
756 if (iSpace == -1)
757 {
758 m_server = strCommandLine;
759 m_mush_name = strCommandLine;
760 m_port = 23;
761 }
762 else
763 {
764 m_server = strCommandLine.Left (iSpace);
765 m_mush_name = m_server;
766 m_port = atoi (strCommandLine.Mid (iSpace + 1));
767 }
768
769 // save auto connect flag, then set to true, to make sure we connect
770 unsigned int savebAutoConnectWorlds = App.m_bAutoConnectWorlds;
771 App.m_bAutoConnectWorlds = TRUE;
772 SetUpOutputWindow ();
773 OpenSession ();
774 App.m_bAutoConnectWorlds = savebAutoConnectWorlds;
775 SetModifiedFlag ();
776 return TRUE;
777
778 } // end of telnet called from netscape navigator
779
780 // we have to do this *before* getting the preferences
781 SetUpOutputWindow ();
782
783 if (!GamePreferences (ePageGeneral))
784 return FALSE;
785
786 if(m_mush_name.IsEmpty ())
787 {
788 ::TMessageBox("Your world name cannot be blank.", MB_ICONEXCLAMATION);
789 return FALSE;
790 }
791
792 if(m_server.IsEmpty ())
793 {
794 ::TMessageBox("The world TCP/IP address cannot be blank.", MB_ICONEXCLAMATION);
795 return FALSE;
796 }
797
798
799 OpenSession ();
800
801 return TRUE;
802
803 }
Something went wrong with that request. Please try again.