-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfrmMegaMUDPathing.frm
1361 lines (1228 loc) · 43.2 KB
/
frmMegaMUDPathing.frm
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
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "mscomctl.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Begin VB.Form frmMegaMUDPath
BorderStyle = 3 'Fixed Dialog
Caption = "MegaMUD Pathing"
ClientHeight = 6780
ClientLeft = 45
ClientTop = 390
ClientWidth = 9165
Icon = "frmMegaMUDPathing.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 6780
ScaleWidth = 9165
Begin VB.Timer timWindowMove
Enabled = 0 'False
Interval = 250
Left = 5520
Top = 60
End
Begin VB.TextBox txtPickLock
Height = 315
Left = 6540
MaxLength = 4
TabIndex = 32
Text = "300"
Top = 360
Width = 495
End
Begin VB.CommandButton cmdMove
Caption = "+"
Height = 255
Index = 11
Left = 4000
MaskColor = &H80000016&
TabIndex = 31
Top = 420
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "D"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 9
Left = 3960
MaskColor = &H80000016&
TabIndex = 20
Top = 1200
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "U"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 8
Left = 3240
MaskColor = &H80000016&
TabIndex = 21
Top = 1200
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "SE"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 6
Left = 3960
MaskColor = &H80000016&
TabIndex = 22
Top = 960
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "S"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 3600
MaskColor = &H80000016&
TabIndex = 23
Top = 960
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "SW"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 7
Left = 3240
MaskColor = &H80000016&
TabIndex = 24
Top = 960
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "E"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 3960
MaskColor = &H80000016&
TabIndex = 25
Top = 720
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "X"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 10
Left = 3600
MaskColor = &H80000016&
TabIndex = 30
Top = 720
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "W"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 3240
MaskColor = &H80000016&
TabIndex = 26
Top = 720
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "NE"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 4
Left = 3960
MaskColor = &H80000016&
TabIndex = 27
Top = 480
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "N"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 3600
MaskColor = &H80000016&
TabIndex = 28
Top = 480
Width = 375
End
Begin VB.CommandButton cmdMove
Caption = "NW"
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 5
Left = 3240
MaskColor = &H80000016&
TabIndex = 29
Top = 480
Width = 375
End
Begin VB.CommandButton cmdUndoNote
Caption = "!"
Height = 315
Left = 8760
TabIndex = 19
Top = 360
Width = 315
End
Begin VB.CommandButton cmdUndoStep
Caption = "Undo Step"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 7380
TabIndex = 18
Top = 360
Width = 1275
End
Begin VB.CommandButton cmdResetCurrent
Caption = "Set to Current Room"
Height = 435
Left = 7200
TabIndex = 13
Top = 6240
Width = 1875
End
Begin VB.TextBox txtCurrentRoom
BackColor = &H8000000F&
Height = 285
Left = 4920
Locked = -1 'True
TabIndex = 11
Top = 5880
Width = 4155
End
Begin VB.CommandButton cmdGotoLast
Caption = "Go to Current Posiiton"
Height = 435
Left = 4920
TabIndex = 12
Top = 6240
Width = 2055
End
Begin VB.CommandButton cmdGotoStart
Caption = "Go to Starting Room"
Height = 375
Left = 4920
TabIndex = 8
Top = 5160
Width = 2055
End
Begin VB.CommandButton cmdResetStart
Caption = "Set to Current Room"
Height = 375
Left = 7200
TabIndex = 9
Top = 5160
Width = 1875
End
Begin VB.TextBox txtStartingRoom
BackColor = &H8000000F&
Height = 285
Left = 4920
Locked = -1 'True
TabIndex = 7
Top = 4800
Width = 4155
End
Begin VB.TextBox txtMapMove
BackColor = &H00000000&
BeginProperty Font
Name = "Terminal"
Size = 9
Charset = 255
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000C000&
Height = 4215
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 360
Width = 4575
End
Begin VB.CommandButton cmdMapMoveClear
Caption = "Cl&ear All"
Height = 375
Left = 2700
TabIndex = 15
Top = 5700
Width = 1995
End
Begin VB.CommandButton cmdMapCopyToClip
Caption = "Cop&y to Clipboard"
Height = 375
Left = 120
TabIndex = 14
Top = 5700
Width = 2355
End
Begin VB.CommandButton cmdMapSwitch
Caption = "&Switch to Manual Edit"
Height = 495
Left = 2700
TabIndex = 4
Top = 5100
Width = 1995
End
Begin VB.CommandButton cmdMapAddMegaCodes
Caption = "Add Headers and Save Path"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 17
Top = 6180
Width = 4575
End
Begin VB.CommandButton cmdMapCommand
Caption = "Enter a Manual Command in the Current Room"
Height = 495
Left = 120
TabIndex = 3
Top = 5100
Width = 2355
End
Begin MSComctlLib.ListView lvHistory
Height = 3795
Left = 4800
TabIndex = 16
Tag = "STRETCHALL"
Top = 720
Width = 4275
_ExtentX = 7541
_ExtentY = 6694
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
Begin MSComDlg.CommonDialog oComDag
Left = 240
Top = 60
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
End
Begin VB.Label lblLabelArray
AutoSize = -1 'True
Caption = "Place your cursor in the black box below and move around the map with your keypad."
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 21
Left = 120
TabIndex = 0
Top = 60
Width = 8790
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "Picklock flag if < than:"
Height = 195
Left = 4860
TabIndex = 1
Top = 420
Width = 1575
End
Begin VB.Label Label2
Caption = "Note: You can double-click teleports from the main window references. The command will be recorded."
BeginProperty Font
Name = "Small Fonts"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 120
TabIndex = 5
Top = 4680
Width = 4500
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Current Pathing Position:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 4920
TabIndex = 10
Top = 5640
Width = 2130
End
Begin VB.Label lblStartingRoom
AutoSize = -1 'True
Caption = "Starting Room:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 4920
TabIndex = 6
Top = 4560
Width = 1275
End
End
Attribute VB_Name = "frmMegaMUDPath"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 0
Enum MegaRoomFlags
STEPF_NONE = &H0
STEPF_DARK = &H1
STEPF_REST = &H2
STEPF_DONTREST = &H4
STEPF_NOLIGHT = &H8
STEPF_STASH = &H10
STEPF_NOATTACK = &H40
STEPF_RELEARN = &H80
STEPF_SUSPECT = &H100
STEPF_DISARM = &H200
STEPF_CANPICK = &H400
STEPF_CYCLED = &H8000
STEPF_MASK = &HFFFF
End Enum
Dim nLocalMapStartMap As Long
Dim nLocalMapStartRoom As Long
Public nLastMapRecorded As Long
Public nLastRoomRecorded As Long
Public nLastPosTop As Long
Public nLastPosLeft As Long
Public nLastPosMoved As Long
Public nLastPosMonitor As Long
Public nLastTimerTop As Long
Public nLastTimerLeft As Long
Private Sub cmdGotoLast_Click()
On Error GoTo error:
Call frmMain.MapStartMapping(nLastMapRecorded, nLastRoomRecorded)
out:
On Error Resume Next
Exit Sub
error:
Call HandleError("cmdGotoLast_Click")
Resume out:
End Sub
Private Sub cmdGotoStart_Click()
On Error GoTo error:
Call frmMain.MapStartMapping(nLocalMapStartMap, nLocalMapStartRoom)
out:
On Error Resume Next
Exit Sub
error:
Call HandleError("cmdGotoStart_Click")
Resume out:
End Sub
Private Sub cmdMapCommand_Click()
On Error GoTo error:
Dim sTemp As String
sTemp = InputBox("Enter Command")
If Len(sTemp) > 0 Then
If Not Trim(txtMapMove.Text) = "" Then txtMapMove.Text = Trim(txtMapMove.Text) & vbCrLf
txtMapMove.Text = txtMapMove.Text & Get_MegaMUD_RoomHash("", frmMain.nMapStartMap, frmMain.nMapStartRoom) & Get_MegaMUD_ExitsCode(frmMain.nMapStartMap, frmMain.nMapStartRoom)
txtMapMove.Text = Replace(txtMapMove.Text, vbCrLf & vbCrLf, vbCrLf)
txtMapMove.Text = txtMapMove.Text & ":0000:" & sTemp
txtMapMove.SetFocus
txtMapMove.SelStart = Len(txtMapMove.Text)
txtMapMove.SelLength = 0
Call AddHistory(sTemp, "", frmMain.nMapStartMap, frmMain.nMapStartRoom)
End If
out:
On Error Resume Next
Exit Sub
error:
Call HandleError("cmdMapCommand_Click")
Resume out:
End Sub
Private Sub cmdMapAddMegaCodes_Click()
On Error GoTo error:
Dim sText As String, sNewText As String, x As Long, y As Long, nSteps As Long
Dim sFile As String, fso As FileSystemObject, oTS As TextStream, oFile As File, oFolder As Folder
Dim sLine As String, sArr() As String, oSubFolder As Folder, oSubFolder2 As Folder
Dim sFileHeader(3) As String, sNeededItem As String, sPathSteps() As String
Dim sStartingRoomChecksum As String, sEndingRoomChecksum As String
Dim sStartRoomName As String, sEndRoomName As String
Dim sStartRoomCode As String, sEndRoomCode As String
txtMapMove.Text = Replace(txtMapMove.Text, vbCrLf & vbCrLf, vbCrLf)
sText = txtMapMove.Text
If Len(sText) < 1 Then
MsgBox "No text to copy.", vbInformation
Exit Sub
End If
'sText = "[LOOP NAME][AUTHOR]" & vbCrLf _
& "[CODE:FROM ROOM GROUP:FROM ROOM NAME]" & vbCrLf _
& "[CODE:TO ROOM GROUP:TO ROOM NAME]" & vbCrLf _
& "START ROOM CHECKSUM:END ROOM CHECKSUM:" & nSteps & ":-1:0:Needed Items:Path fails:when finished"
sPathSteps() = Split(txtMapMove.Text, vbCrLf)
If Not IsDimmed(sPathSteps) Then GoTo out:
nSteps = UBound(sPathSteps()) + 1
If Len(sPathSteps(0)) > 2 And Left(sPathSteps(0), 1) = ":" And Right(sPathSteps(0), 1) = ":" Then
sNeededItem = Replace(sPathSteps(0), ":", "")
sPathSteps(0) = ""
nSteps = nSteps - 1
End If
sStartRoomName = GetRoomName("", nLocalMapStartMap, nLocalMapStartRoom, True)
sStartingRoomChecksum = Get_MegaMUD_RoomHash(sStartRoomName) & Get_MegaMUD_ExitsCode(nLocalMapStartMap, nLocalMapStartRoom)
sStartRoomCode = Get_MegaMUD_RoomHash(sStartRoomName) & "9"
sEndRoomName = GetRoomName("", nLastMapRecorded, nLastRoomRecorded, True)
sEndingRoomChecksum = Get_MegaMUD_RoomHash(sEndRoomName) & Get_MegaMUD_ExitsCode(nLastMapRecorded, nLastRoomRecorded)
sEndRoomCode = Get_MegaMUD_RoomHash(sEndRoomName) & "9"
sFileHeader(0) = "[][]"
'sFileHeader(1) = "[FFFF:Custom Paths:" & sStartRoomName
'sFileHeader(2) = "[FFFF:Custom Paths:" & sEndRoomName
sFileHeader(3) = sStartingRoomChecksum & ":" & sEndingRoomChecksum & ":" & nSteps & ":-1:0:" & sNeededItem & "::"
MsgBox "On the next screen you will be asked to select the MegaMUD rooms.md database file. " _
& "Choose the MAIN rooms.md file (the one under the ""Default"" folder). Other rooms.md files around it will also be examined." _
& vbCrLf & "This will allow us to lookup matching starting and ending rooms and populate those fields.", vbInformation
Set fso = CreateObject("Scripting.FileSystemObject")
oComDag.Filter = "Rooms.md file (Rooms.md)|Rooms.md"
oComDag.DialogTitle = "Select MegaMUD Rooms.md File"
oComDag.FileName = "Rooms.md"
If fso.FolderExists(ReadINI("Settings", "Last_MegaMUD_DBFolder", , "C:\Program Files (x86)\Megamud\Default")) Then
oComDag.InitDir = ReadINI("Settings", "Last_MegaMUD_DBFolder")
ElseIf fso.FileExists("C:\Program Files (x86)\Megamud\Default\Rooms.md") Then
oComDag.InitDir = "C:\Program Files (x86)\Megamud\Default"
ElseIf fso.FileExists("C:\Megamud\Default\Rooms.md") Then
oComDag.InitDir = "C:\Megamud\Default"
ElseIf fso.FileExists(Environ("USERPROFILE") & "\AppData\Local\VirtualStore\Program Files (x86)\Megamud\Default\Rooms.md") Then
oComDag.InitDir = Environ("USERPROFILE") & "\AppData\Local\VirtualStore\Program Files (x86)\Megamud\Default"
Else
oComDag.InitDir = App.Path
End If
On Error GoTo canceled:
oComDag.ShowOpen
If oComDag.FileName = "" Then GoTo canceled:
continue1:
On Error GoTo error:
sFile = oComDag.FileName
If Not UCase(Right(sFile, 3)) = ".MD" Then sFile = sFile & ".MD"
If Not fso.FileExists(sFile) Then
x = MsgBox("File not found or file open canceled, continue anyway?", vbYesNo + vbQuestion)
If Not x = vbYes Then GoTo out:
GoTo skip_room_lookup:
End If
Set oFile = fso.GetFile(sFile)
Call WriteINI("Settings", "Last_MegaMUD_DBFolder", oFile.ParentFolder)
Set oFile = Nothing
Set oTS = fso.OpenTextFile(sFile, ForReading)
Call ScanRoomsDatabase(oTS, sFileHeader(), sStartRoomCode, sEndRoomCode, sStartingRoomChecksum, sEndingRoomChecksum)
oTS.Close
Set oTS = Nothing
If sFileHeader(1) = "" Or sFileHeader(2) = "" Then
Set oFile = fso.GetFile(sFile)
Set oFolder = oFile.ParentFolder
Set oFolder = oFolder.ParentFolder
If oFolder.SubFolders.Count > 0 Then
For Each oSubFolder In oFolder.SubFolders
If fso.FileExists(oSubFolder.Path & "\rooms.md") Then
Set oTS = fso.OpenTextFile(oSubFolder.Path & "\rooms.md", ForReading)
Call ScanRoomsDatabase(oTS, sFileHeader(), sStartRoomCode, sEndRoomCode, sStartingRoomChecksum, sEndingRoomChecksum)
oTS.Close
Set oTS = Nothing
If Not sFileHeader(1) = "" And Not sFileHeader(2) = "" Then GoTo skip_room_lookup
End If
If oSubFolder.SubFolders.Count > 0 Then
If oSubFolder.SubFolders.Count > 0 Then
For Each oSubFolder2 In oSubFolder.SubFolders
If fso.FileExists(oSubFolder2.Path & "\rooms.md") Then
Set oTS = fso.OpenTextFile(oSubFolder2.Path & "\rooms.md", ForReading)
Call ScanRoomsDatabase(oTS, sFileHeader(), sStartRoomCode, sEndRoomCode, sStartingRoomChecksum, sEndingRoomChecksum)
oTS.Close
Set oTS = Nothing
If Not sFileHeader(1) = "" And Not sFileHeader(2) = "" Then GoTo skip_room_lookup
End If
Next oSubFolder2
End If
End If
Next oSubFolder
End If
End If
skip_room_lookup:
If Not sFileHeader(1) = "" And Not sFileHeader(2) = "" Then
MsgBox "Starting and ending rooms matched to existing MegaMUD rooms!" & vbCrLf _
& "Start: " & sFileHeader(1) & vbCrLf _
& "End: " & sFileHeader(2), vbInformation
End If
If sFileHeader(1) = "" Then
'[FFFF:Custom Paths:" & sStartRoomName
sText = InputBox("START room code / group not found for " & vbCrLf & sStartRoomName & vbCrLf & vbCrLf & "Enter 4 character megamud room code to use (must be unique if new to avoid conflict).", , "FFFF")
If sText = "" Then GoTo out:
sFileHeader(1) = "[" & sText & ":"
sText = InputBox("START room code / group not found for " & vbCrLf & sStartRoomName & vbCrLf & vbCrLf & "Enter group name to associate with the room.", , "Custom Rooms")
If sText = "" Then GoTo out:
sFileHeader(1) = sFileHeader(1) & sText & ":" & sStartRoomName & "]"
End If
If sFileHeader(2) = "" And Not sStartingRoomChecksum = sEndingRoomChecksum Then
'[FFFF:Custom Paths:" & sEndRoomName
sText = InputBox("END room code / group not found for " & vbCrLf & sEndRoomName & vbCrLf & vbCrLf & "Enter 4 character megamud room code to use (must be unique if new to avoid conflict).", , "FFFF")
If sText = "" Then GoTo out:
sFileHeader(2) = "[" & sText & ":"
sText = InputBox("END room code / group not found for " & vbCrLf & sEndRoomName & vbCrLf & vbCrLf & "Enter group name to associate with the room.", , "Custom Rooms")
If sText = "" Then GoTo out:
sFileHeader(2) = sFileHeader(2) & sText & ":" & sEndRoomName & "]"
End If
If sStartingRoomChecksum = sEndingRoomChecksum Then
sText = InputBox("This appears to be a loop. Enter the name of the loop:")
If sText = "" Then GoTo out:
sFileHeader(0) = "[" & sText & "]"
sFileHeader(2) = ""
Else
sFileHeader(0) = "[]"
End If
sText = InputBox("Enter Author", , ReadINI("Settings", "MegaMUD_Path_Author", , "Custom"))
If sText = "" Then GoTo out:
Call WriteINI("Settings", "MegaMUD_Path_Author", sText)
sFileHeader(0) = sFileHeader(0) & "[" & sText & "]"
sText = ""
For x = 0 To 3
If Not Trim(sFileHeader(x)) = "" Then
sText = sText & sFileHeader(x) & vbCrLf
End If
Next x
For x = 0 To UBound(sPathSteps())
If Not Trim(sPathSteps(x)) = "" Then
sText = sText & sPathSteps(x) & vbCrLf
End If
Next x
MsgBox "We are ready to save the path. It is recommended to save the file *outside* of your megamud install " _
& "(such as your desktop) and then utilize the Add path feature from the" & vbCrLf _
& "Options -> Game Data -> Paths -> ""Add..."" button. " & vbCrLf _
& "Any new rooms included in the path will automatically be added by megamud.", vbInformation
oComDag.Filter = "MegaMUD .MP (*.mp)|*.mp"
oComDag.DialogTitle = "Save MegaMUD Path"
If sStartingRoomChecksum = sEndingRoomChecksum Then
oComDag.FileName = sStartRoomCode & "LOOP.mp"
Else
oComDag.FileName = sStartRoomCode & sEndRoomCode & ".mp"
End If
oComDag.InitDir = ReadINI("Settings", "LastMegaPathDir", , Environ("USERPROFILE") & "\Desktop")
saveagain:
On Error GoTo out:
oComDag.ShowSave
If oComDag.FileName = "" Then GoTo out:
If fso.FileExists(oComDag.FileName) Then
x = MsgBox("File Exists, Overwrite?", vbQuestion + vbYesNoCancel + vbDefaultButton2)
If x = vbCancel Then
GoTo out:
ElseIf x = vbYes Then
Call fso.DeleteFile(oComDag.FileName, True)
Else
GoTo saveagain:
End If
End If
Set oTS = fso.OpenTextFile(oComDag.FileName, ForWriting, True)
oTS.Write sText
oTS.Close
Set oTS = Nothing
Set oFile = fso.GetFile(oComDag.FileName)
Call WriteINI("Settings", "LastMegaPathDir", oFile.ParentFolder)
out:
On Error Resume Next
Set fso = Nothing
Set oTS = Nothing
Set oFile = Nothing
Exit Sub
canceled:
Resume continue1:
Exit Sub
error:
Call HandleError("cmdMapAddMegaCodes_Click")
Resume out:
End Sub
Private Sub ScanRoomsDatabase(ByRef oTS, ByRef sFileHeader() As String, ByRef sStartRoomCode As String, ByRef sEndRoomCode As String, _
ByRef sStartingRoomChecksum As String, ByRef sEndingRoomChecksum As String)
Dim sLine As String, sArr() As String
Do While oTS.AtEndOfStream = False
'0 1 2 3 4 5 6 7
'CAB00180:00004040:0:0:0:AALY:Ancient Ruin:Ancient Ruin Dark Alley
sLine = oTS.ReadLine
sArr() = Split(sLine, ":")
If UBound(sArr()) >= 7 Then
If sArr(0) = sStartingRoomChecksum And sFileHeader(1) = "" Then
'[CODE:FROM ROOM GROUP:FROM ROOM NAME]
sFileHeader(1) = "[" & sArr(5) & ":" & sArr(6) & ":" & sArr(7) & "]"
sStartRoomCode = sArr(5)
End If
If sArr(0) = sEndingRoomChecksum And sFileHeader(2) = "" Then
'[CODE:TO ROOM GROUP:TO ROOM NAME]
sFileHeader(2) = "[" & sArr(5) & ":" & sArr(6) & ":" & sArr(7) & "]"
sEndRoomCode = sArr(5)
End If
End If
Loop
End Sub
Private Sub cmdMapSwitch_Click()
If cmdMapSwitch.Tag = "1" Then
cmdMapSwitch.Tag = ""
cmdMapSwitch.Caption = "&Switch to Manual Edit"
Else
cmdMapSwitch.Tag = "1"
cmdMapSwitch.Caption = "&Switch to Map Move"
End If
txtMapMove.SetFocus
End Sub
Private Sub cmdMapCopyToClip_Click()
On Error GoTo error:
Dim sText As String
sText = txtMapMove.Text
If Len(sText) < 1 Then
MsgBox "No text to copy.", vbInformation
Exit Sub
End If
Clipboard.clear
Clipboard.SetText sText
MsgBox "Copied.", vbInformation
Exit Sub
error:
Call HandleError("cmdMapCopyToClip_Click")
End Sub
Private Sub cmdMapMoveClear_Click()
Dim nYesNo As Integer
nYesNo = MsgBox("Are you sure you want to clear all?", vbYesNo + vbDefaultButton2 + vbQuestion)
If nYesNo = vbYes Then
txtMapMove.Text = ""
nLocalMapStartMap = 0
nLocalMapStartRoom = 0
nLastMapRecorded = 0
nLastRoomRecorded = 0
txtCurrentRoom.Text = ""
txtStartingRoom.Text = ""
lvHistory.ListItems.clear
End If
End Sub
Private Sub cmdMove_Click(Index As Integer)
Dim x As Integer
On Error GoTo error:
Select Case Index
Case 0: Call txtMapMove_KeyPress(56) 'n
Case 1: Call txtMapMove_KeyPress(50) 's
Case 2: Call txtMapMove_KeyPress(54) 'e
Case 3: Call txtMapMove_KeyPress(52) 'w
Case 4: Call txtMapMove_KeyPress(57) 'ne
Case 5: Call txtMapMove_KeyPress(55) 'nw
Case 6: Call txtMapMove_KeyPress(51) 'se
Case 7: Call txtMapMove_KeyPress(49) 'sw
Case 8: Call txtMapMove_KeyPress(48) 'u
Case 9: Call txtMapMove_KeyPress(46) 'd
End Select
If Index = 10 Then
For x = 0 To 10
cmdMove(x).Visible = False
Next x
cmdMove(11).Visible = True
ElseIf Index = 11 Then
cmdMove(11).Visible = False
For x = 0 To 10
cmdMove(x).Visible = True
Next x
End If
out:
On Error Resume Next
Exit Sub
error:
Call HandleError("cmdMove_Click")
Resume out:
End Sub
Private Sub cmdResetCurrent_Click()
On Error GoTo error:
Dim x As Integer
If Len(Trim(txtMapMove.Text)) > 0 Then
x = MsgBox("Are you sure?", vbQuestion + vbYesNo)
If Not x = vbYes Then Exit Sub
End If
Call SetCurrentPosition(frmMain.nMapStartMap, frmMain.nMapStartRoom)
out:
On Error Resume Next
Exit Sub
error:
Call HandleError("cmdResetCurrent_Click")
Resume out:
End Sub
Private Sub cmdResetStart_Click()
On Error GoTo error:
Dim x As Integer
If Len(Trim(txtMapMove.Text)) > 0 Then
x = MsgBox("Are you sure? If you have steps in the path the preceed this room then when you add the megamud codes later the wrong starting room codes will be entered.", vbQuestion + vbYesNo)
If Not x = vbYes Then Exit Sub
End If
Call ResetStartingRoom
out:
On Error Resume Next
Exit Sub
error:
Call HandleError("cmdResetStart_Click")
Resume out:
End Sub
Private Sub cmdUndoNote_Click()
MsgBox "Note: This simply removes the last line in the box and sets the current position to the previous room in the history. If you've made manual edits and start undo'ing past those edits then things will start to get messed up.", vbInformation
End Sub
Private Sub cmdUndoStep_Click()
Dim sArr() As String, sText As String, x As Integer, nRoom As RoomExitType
On Error GoTo error:
If Right(txtMapMove.Text, 2) = vbCrLf Then txtMapMove.Text = Left(txtMapMove.Text, Len(txtMapMove.Text) - 2)
If Not Trim(txtMapMove.Text) = "" Then
txtMapMove.Text = Replace(Trim(txtMapMove.Text), vbCrLf & vbCrLf, vbCrLf)
sArr() = Split(txtMapMove.Text, vbCrLf)
If IsDimmed(sArr()) Then
For x = 0 To UBound(sArr()) - 1
sText = sText & sArr(x) & vbCrLf
Next x
If Len(sText) > 1 Then sText = Left(sText, Len(sText) - 2)
txtMapMove.Text = sText
txtMapMove.SetFocus
txtMapMove.SelStart = Len(txtMapMove.Text)
txtMapMove.SelLength = 0
End If
End If
If lvHistory.ListItems.Count = 0 Then Exit Sub
nRoom = ExtractMapRoom(lvHistory.ListItems(lvHistory.ListItems.Count).Tag)
If nRoom.Map > 0 And nRoom.Room > 0 Then