-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MaxBatch.bat
1685 lines (1527 loc) · 45.3 KB
/
MaxBatch.bat
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
@echo off
rem ---------------------------------------------------------------------
rem --- Init ---
rem ---------------------------------------------------------------------
set var_Debug=0
set str_Title= MaxPayne Conversion Tool by Darkje, v1.12 - 21-Feb-2010
if not "%1"=="" cd "%*"
rem --- Adjust conversion delay here (var_ConversionDelay=seconds) ---
set var_ConversionDelay=1
set var_ExitDelay=2
set var_ActionFinishedDelay=3
set var_DbgL2Delay=1
call :sub_DetectUac
rem ---------------------------------------------------------------------
rem --- Game Conv Screen, Menu control structure ---
rem ---------------------------------------------------------------------
:lbl_GameMenu
call :msg_Welcome
call :msg_GameConvScreen
call :sub_DetectionPhase
if %flag_FreshGame%==1 (
if %var_TotModCount%==0 (
call :sub_GameMenu1
) else (
call :sub_GameMenu2
)
) else (
if exist backup\*.ras (
if %var_TotModCount%==0 (
call :sub_GameMenu3
) else (
call :sub_GameMenu4
)
) else (
if %var_TotModCount%==0 (
call :sub_GameMenu5
) else (
call :sub_GameMenu6
)
)
)
rem ---------------------------------------------------------------------
rem Game Conv Screen menus
rem ---------------------------------------------------------------------
:sub_GameMenu1
rem --- just fresh game, no mods ---
call :msg_YouWantTo 1
call :msg_GameConvOpt
call :msg_LaunchOpt
call :msg_OtherOpt
call :msg_SdeOpt
choice /c clsde
if errorlevel 5 goto :lbl_Exit
if errorlevel 4 goto :lbl_ToggleDebug
if errorlevel 3 goto :lbl_GameMenu
if errorlevel 2 goto :lbl_LaunchGame
call :sub_CvrtGame
goto :lbl_GameMenu
rem ---------------------------------------------------------------------
:sub_GameMenu2
rem --- fresh game and mods too ---
call :msg_YouWantTo 2
call :msg_GameConvOpt
call :msg_LaunchOpt
call :msg_OtherOpt
call :msg_ModOpt
call :msg_SdeOpt
choice /c clmsde
if errorlevel 6 goto :lbl_Exit
if errorlevel 5 goto :lbl_ToggleDebug
if errorlevel 4 goto :lbl_GameMenu
if errorlevel 3 goto :lbl_ModMenu
if errorlevel 2 goto :lbl_LaunchGame
call :sub_CvrtGame
goto :lbl_GameMenu
rem ---------------------------------------------------------------------
:sub_GameMenu3
rem --- just converted game, no mods ---
call :msg_YouWantTo 3
call :msg_LaunchConvOpt
call :msg_RestoreGameOpt
call :msg_OtherOpt
call :msg_SdeOpt
choice /c lrsde
if errorlevel 5 goto :lbl_Exit
if errorlevel 4 goto :lbl_ToggleDebug
if errorlevel 3 goto :lbl_GameMenu
if errorlevel 2 (
call :sub_RestoreGame
goto :lbl_GameMenu
)
goto :lbl_LaunchGame
rem ---------------------------------------------------------------------
:sub_GameMenu4
rem --- converted game and mods too ---
call :msg_YouWantTo 4
call :msg_LaunchConvOpt
call :msg_RestoreGameOpt
call :msg_OtherOpt
call :msg_ModOpt
call :msg_SdeOpt
choice /c lrmsde
if errorlevel 6 goto :lbl_Exit
if errorlevel 5 goto :lbl_ToggleDebug
if errorlevel 4 goto :lbl_GameMenu
if errorlevel 3 goto :lbl_ModMenu
if errorlevel 2 (
call :sub_RestoreGame
goto :lbl_GameMenu
)
goto :lbl_LaunchGame
rem ---------------------------------------------------------------------
:sub_GameMenu5
rem --- no game, no mods ---
call :msg_YouWantTo 5
call :msg_NoMainOpt
call :msg_OtherOpt
call :msg_SdeOpt
choice /c sde
if errorlevel 3 goto :lbl_Exit
if errorlevel 2 goto :lbl_ToggleDebug
goto :lbl_GameMenu
rem ---------------------------------------------------------------------
:sub_GameMenu6
rem --- no game, only mods ---
call :msg_YouWantTo 6
call :msg_ModOpt
call :msg_OtherOpt
call :msg_SdeOpt
choice /c msde
if errorlevel 4 goto :lbl_Exit
if errorlevel 3 goto :lbl_ToggleDebug
if errorlevel 2 goto :lbl_GameMenu
goto :lbl_ModMenu
rem ---------------------------------------------------------------------
rem --- Mod Conv Screen, Menu control structure ---
rem ---------------------------------------------------------------------
:lbl_ModMenu
call :msg_Welcome
call :msg_ModConvScreen
call :sub_DetectionPhase
call :sub_ListMods
if %var_NewModCount% gtr 0 (
if %var_ConvModCount% == 0 (
if %var_ExcludedModCount% == 0 (
call :sub_ModMenu1
) else (
call :sub_ModMenu5
)
) else (
if %var_ExcludedModCount% == 0 (
call :sub_ModMenu3
) else (
call :sub_ModMenu7
)
)
) else (
if %var_ConvModCount% == 0 (
call :sub_ModMenu4
) else (
if %var_ExcludedModCount% == 0 (
call :sub_ModMenu2
) else (
call :sub_ModMenu6
)
)
)
call :sub_Waitasec %var_ActionFinishedDelay%
goto :lbl_GameMenu
rem ---------------------------------------------------------------------
rem Mod Conv Screen menus
rem ---------------------------------------------------------------------
:sub_ModMenu1
rem --- only unconverted mods ---
call :msg_ModYouWantTo 1
call :msg_ConvModOpt
call :msg_AddModExclOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c mase
if errorlevel 4 goto :lbl_GameMenu
if errorlevel 3 goto :lbl_ModMenu
if errorlevel 2 (
call :sub_AddExclusion
) else (
call :sub_AddNewMods
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_ModMenu2
rem --- only converted mods ---
call :msg_ModYouWantTo 2
call :msg_RestoreModOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c rse
if errorlevel 3 goto :lbl_GameMenu
if errorlevel 2 goto :lbl_ModMenu
call :sub_RestoreMods
goto :EOF
rem ---------------------------------------------------------------------
:sub_ModMenu3
rem --- converted and unconverted mods ---
call :msg_ModYouWantTo 3
call :msg_ConvModOpt
call :msg_RestoreModOpt
call :msg_AddModExclOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c mrase
if errorlevel 5 goto :lbl_GameMenu
if errorlevel 4 goto :lbl_ModMenu
if errorlevel 3 (
call call :sub_AddExclusion
goto :EOF
)
if errorlevel 2 (
call :sub_RestoreMods
) else (
call :sub_AddNewMods
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_ModMenu4
rem --- only excluded mods ---
call :msg_ModYouWantTo 4
call :msg_RestoreModOpt
call :msg_ClrModExclOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c rhse
if errorlevel 4 goto :lbl_GameMenu
if errorlevel 3 goto :lbl_ModMenu
if errorlevel 2 (
call :sub_ClrModExcl
) else (
call :sub_RestoreMods
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_ModMenu5
rem --- unconverted and excluded mods ---
call :msg_ModYouWantTo 5
call :msg_ConvModOpt
call :msg_AddModExclOpt
call :msg_ClrModExclOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c mahse
if errorlevel 5 goto :lbl_GameMenu
if errorlevel 4 goto :lbl_ModMenu
if errorlevel 3 (
call :sub_ClrModExcl
goto :EOF
)
if errorlevel 2 (
call call :sub_AddExclusion
) else (
call :sub_AddNewMods
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_ModMenu6
rem --- converted and excluded mods ---
call :msg_ModYouWantTo 6
call :msg_RestoreModOpt
call :msg_ClrModExclOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c rhse
if errorlevel 4 goto :lbl_GameMenu
if errorlevel 3 goto :lbl_ModMenu
if errorlevel 2 (
call :sub_ClrModExcl
) else (
call :sub_RestoreMods
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_ModMenu7
rem --- unconverted, converted and excluded mods ---
call :msg_ModYouWantTo 7
call :msg_ConvModOpt
call :msg_AddModExclOpt
call :msg_RestoreModOpt
call :msg_ClrModExclOpt
call :msg_OtherOpt
call :msg_EndmodOpt
choice /c marhse
if errorlevel 6 goto :lbl_GameMenu
if errorlevel 5 goto :lbl_ModMenu
if errorlevel 4 (
call :sub_ClrModExcl
goto :EOF
)
if errorlevel 3 (
call :sub_RestoreMods
goto :EOF
)
if errorlevel 2 (
call call :sub_AddExclusion
) else (
call :sub_AddNewMods
)
goto :EOF
rem ---------------------------------------------------------------------
rem --- conversion subs ---
rem ---------------------------------------------------------------------
:sub_Convert
set flag_Dont=0
if /i %1=="x_level1.ras" set flag_Dont=1
if /i %1=="x_level2.ras" set flag_Dont=1
if /i %1=="x_level3.ras" set flag_Dont=1
if %flag_Dont%==0 (
if %var_Debug% gtr 0 call :msg_StartConvfileDbg %1
if not exist backup md backup
copy %1 backup >nul
md tmp
if %var_Debug% gtr 0 call :msg_ExtractDbg %1
rasmaker -x %1 tmp >nul
if %var_Debug% gtr 0 call :msg_ConvertDbg
for /r tmp\data %%i in (*.wav ) do call :sub_SoxLoop "%%i"
if %var_Debug% gtr 0 call :msg_PackDbg %1
rasmaker -a -p tmp %1 >nul
call :sub_CheckConv %1 %2
call :sub_Waitasec %var_ConversionDelay%
if %var_Debug% gtr 0 call :msg_DeltmpDbg
call :sub_RemoveTmp
if %var_Debug% gtr 0 call :msg_FiledoneDbg %1
)
set flag_Dont=
goto :EOF
rem ---------------------------------------------------------------------
:sub_SoxLoop
if %var_Debug%==0 SoX -q %1 -u -b "%~dp1outfile.wav" 2>nul
if %var_Debug%==1 SoX -q %1 -u -b "%~dp1outfile.wav" 2>nul
if %var_Debug%==2 (
call :msg_LineDbg
SoX -V %1 -u -b "%~dp1outfile.wav"
call :sub_Waitasec %var_DbgL2Delay%
)
del %1
ren "%~dp1outfile.wav" "%~nx1"
goto :EOF
rem ---------------------------------------------------------------------
:sub_CheckConv
set flag_RasMsg=0
if %var_Debug% gtr 0 call :msg_CheckConvDbg
if %~z1==%~z2 (
call :sub_KeepExcl %1
if %var_Debug% gtr 0 call :msg_BadConvEqualDbg
call :sub_BadConv %1 %2
if %var_Debug% gtr 0 call :msg_BackupRestDbg %1
set flag_RasCheck=1
set flag_RasMsg=1
) else (
if %~z1==0 (
call :sub_KeepExcl %1
if %var_Debug% gtr 0 call :msg_BadConvZeroDbg
call :sub_BadConv %1 %2
if %var_Debug% gtr 0 call :msg_BackupRestDbg %1
set flag_RasCheck=1
set flag_RasMsg=1
)
)
if exist x_english.ras (
if "%~nx1"=="x_data.ras" (
if not "%~z1"=="151433969" (
call :msg_ConvFileSizeBad %1
set flag_RasCheck=1
set flag_RasMsg=1
)
)
if "%~nx1"=="x_english.ras" (
if not "%~z1"=="412658843" (
call :msg_ConvFileSizeBad %1
set flag_RasCheck=1
set flag_RasMsg=1
)
)
)
if "%~nx1"=="x_music.ras" (
if not "%~z1"=="286777161" (
call :msg_ConvFileSizeBad %1
set flag_RasCheck=1
set flag_RasMsg=1
)
)
if not %flag_RasMsg%==1 call :msg_ConvFileOk "%~nx1"
set flag_RasMsg=
goto :EOF
rem ---------------------------------------------------------------------
:sub_KeepExcl
if not exist convexcl md convexcl
call :msg_ConvFileBad "%~nx1"
goto :EOF
rem ---------------------------------------------------------------------
:sub_BadConv
del %1
copy %2 "%~dp1" >nul
del %2
call :sub_DelBakIfEmpty
goto :EOF
rem ---------------------------------------------------------------------
:sub_CvrtGame
call :msg_working
call :msg_StartConvGame
set flag_RasCheck=0
for %%i in (*.ras) do call :sub_Convert "%%i" "backup\%%i"
if not %flag_RasCheck%==1 (
call :msg_FileSizeGood
) else (
call :msg_ConvFailed
call :sub_RestoreExt ras
call :sub_DelBakIfEmpty
pause
)
call :msg_GameConvDone
call :sub_Waitasec %var_ActionFinishedDelay%
if not %flag_RasCheck%==1 call :msg_finished
goto :EOF
rem ---------------------------------------------------------------------
:sub_AddNewMods
call :msg_StartConvMod
set var_File=
call :msg_TypeFileName
set /p var_File= -^>
if not "%var_File%"=="" (
if not "%var_File%" == "*" (
if exist "%var_File%.mpm" (
if not exist "backup\%var_File%.mpm" (
if not exist "convexcl\%var_File%.log" (
set flag_RasCheck=0
call :msg_ConvFile "%var_File%"
call :sub_Convert "%var_File%.mpm" "backup\%var_File%.mpm"
)
)
) else (
call :msg_FileNotFound "%var_File%"
goto :sub_AddNewMods
)
) else (
for %%i in (*.mpm) do (
if not exist "backup\%%i" (
if not exist "convexcl\%%~ni.log" (
set flag_RasCheck=0
call :sub_Convert "%%i" "backup\%%i"
)
)
)
)
) else (
call :msg_NoAction
)
call :msg_ModConvDone
call :sub_Waitasec %var_ActionFinishedDelay%
goto :EOF
rem ---------------------------------------------------------------------
rem --- restore subs ---
rem ---------------------------------------------------------------------
:sub_RestoreGame
call :msg_working
call :msg_StartRestore
call :sub_RestoreExt ras
call :sub_DelBakIfEmpty
call :msg_RestoreDone
call :sub_Waitasec %var_ActionFinishedDelay%
call :msg_finished
goto :EOF
rem ---------------------------------------------------------------------
:sub_RestoreMods
call :msg_StartRestore
set var_File=
call :msg_TypeFileName
set /p var_File= -^>
if not "%var_File%"=="" (
if not "%var_File%" == "*" (
if exist "backup\%var_File%.mpm" (
call :Sub_RestoreFile "backup\%var_File%.mpm"
) else (
call :msg_FileNotFound "%var_File%"
goto :sub_RestoreMods
)
) else (
call :sub_RestoreExt mpm
call :sub_DelBakIfEmpty
)
) else (
call :msg_NoAction
)
call :msg_RestoreDone
call :sub_Waitasec %var_ActionFinishedDelay%
goto :EOF
rem ---------------------------------------------------------------------
:sub_RestoreFile
copy %1 . >nul
call :msg_FileRestored %~nx1
del %1 /q
goto :EOF
rem ---------------------------------------------------------------------
:sub_RestoreExt
if %var_Debug% gtr 0 call :msg_RestoreDbg
for %%i in (backup\*.%1) do (
copy "%%i" . >nul
call :msg_FileRestored "%%~nxi"
)
del backup\*.%1 /q
if %var_Debug% gtr 0 call :msg_DelbakDbg
goto :EOF
rem ---------------------------------------------------------------------
:sub_DelBakIfEmpty
if not exist backup\*.mpm (
if not exist backup\*.ras rd backup /s /q
)
goto :EOF
rem ---------------------------------------------------------------------
rem --- History subs ---
rem ---------------------------------------------------------------------
:sub_ClrModExcl
call :msg_StartDelExclusion
set var_File=
call :msg_TypeFileName
set /p var_File= -^>
if not "%var_File%"=="" (
if not "%var_File%" == "*" (
if exist "convexcl\%var_File%.log" (
call :msg_ExcludeRemove "%var_File%"
del "convexcl\%var_File%.log"
if not exist convexcl\*.log rd convexcl /s /q
) else (
call :msg_FileNotFound "%var_File%"
goto :sub_ClrModExcl
)
) else (
call :msg_ExcludeListRemoved
rd convexcl /s /q
)
) else (
call :msg_NoAction
)
call :msg_ExclusionDone
call :sub_Waitasec %var_ActionFinishedDelay%
goto :EOF
rem ---------------------------------------------------------------------
:sub_AddExclusion
call :msg_StartAddExclusion
set var_File=
call :msg_TypeFileName
set /p var_File= -^>
if not "%var_File%"=="" (
if not "%var_File%" == "*" (
if exist "%var_File%.mpm" (
if not exist "backup\%var_File%.mpm" (
if not exist "convexcl\%var_File%.log" (
if not exist convexcl md convexcl
call :msg_LogExcludedFile "%var_File%.mpm"
call :msg_FileExclude "%var_File%"
)
)
) else (
call :msg_FileNotFound "%var_File%"
goto sub_AddExclusion
)
) else (
for %%i in (*.mpm) do (
if not exist "backup\%%i" (
if not exist "convexcl\%%~ni.log" (
if not exist convexcl md convexcl
call :msg_LogExcludedFile "%%~nxi"
call :msg_FileExclude "%%~nxi"
)
)
)
)
) else (
call :msg_NoAction
)
call :msg_ExclusionDone
call :sub_Waitasec %var_ActionFinishedDelay%
goto :EOF
rem ---------------------------------------------------------------------
rem --- listing subs ---
rem ---------------------------------------------------------------------
:sub_ListNewMods
for %%i in (*.mpm) do if not exist "backup\%%i" if not exist "convexcl\%%~ni.log" echo - %%i
goto :EOF
rem ---------------------------------------------------------------------
:sub_ListConvMods
for %%i in (backup/*.mpm) do echo - %%i
goto :EOF
rem ---------------------------------------------------------------------
:sub_ListExcludedMods
for %%i in (*.mpm) do if not exist "backup\%%i" if exist "convexcl\%%~ni.log" echo - %%i
goto :EOF
rem ---------------------------------------------------------------------
:sub_ListMods
if %var_NewModCount% gtr 0 (
call :msg_NewModFnd
call :sub_ListNewMods
)
if %var_ConvModCount% gtr 0 (
call :msg_ConvModsFnd
call :sub_ListConvMods
)
if %var_ExcludedModCount% gtr 0 (
call :msg_ExcludedModsFnd
call :sub_ListExcludedMods
)
goto :EOF
rem ---------------------------------------------------------------------
rem --- detection phase control and report structure ---
rem ---------------------------------------------------------------------
:sub_DetectionPhase
call :msg_HorLine
call :msg_AnalyseCurrent
if %var_Debug% gtr 0 call :msg_DebugStat
call :msg_WorkDir
call :sub_DetectTmp 1
call :sub_DetectBackupProbs
call :sub_DetectFreshGame
if %var_Debug% gtr 0 call :msg_FilesdetectedDbg
call :sub_DetectScriptNeeds
if %flag_ScriptNeeds%==1 (
if %var_Debug% gtr 0 call :msg_ScriptNeedFndDbg
) else (
if %var_Debug% gtr 0 (
call :msg_ScriptNeedBadDbg
call :sub_DetectScriptNeeds 1
)
)
call :sub_DetectGame
call :sub_DetectLang
call :sub_DetectConvData
if %flag_ConvData%==1 (
if %var_Debug% gtr 0 call :msg_ConvDataFndDbg
) else (
if %var_Debug% gtr 0 (
call :msg_ConvDataBadDbg
call :sub_DetectConvData 1
)
)
call :sub_DetectRun
if %flag_GameExe%==1 (
if %var_Debug% gtr 0 call :msg_GameExeFndDbg
) else (
if %var_Debug% gtr 0 call :msg_GameExeBadDbg
)
if %flag_RunFiles%==1 (
if %var_Debug% gtr 0 call :msg_AdtlFndDbg
) else (
if %var_Debug% gtr 0 (
call :msg_AdtlBadDbg
call :sub_DetectRun 1
)
)
if %flag_LangFiles%==1 (
if %var_Debug% gtr 0 for %%i in (*.ras) do call :sub_CheckLang %%i,1
) else (
if %var_Debug% gtr 0 call :msg_LangBadDbg
)
if %var_Debug% gtr 0 if exist backup call :msg_BackupFndDbg
call :sub_DetectMods
set flag_AllFiles=0
if %flag_ScriptNeeds%==1 (
if %flag_GameExe%==1 (
if %flag_RunFiles%==1 (
set flag_AllFiles=1
)
)
)
if %flag_FreshGame%==1 (
if %flag_RunFiles%==1 call :msg_FreshGameFnd
) else (
if exist backup\*.ras if %flag_RunFiles%==1 call :msg_ConvGameFnd
)
set flag_OnlyMods=0
if %var_TotModCount% gtr 0 (
if %flag_ScriptNeeds% == 1 set flag_OnlyMods=1
)
if %flag_AllFiles%==1 (
color 2F
if %var_Debug% gtr 0 call :msg_NoProbsDbg
if %var_TotModCount% gtr 0 (
call :msg_TotMods
) else (
call :msg_NoModsFnd
)
) else (
if %var_Debug% == 0 call :msg_NoValidGame
if %var_TotModCount% gtr 0 (
call :msg_TotMods
) else (
call :msg_NoModsFnd
)
if %flag_OnlyMods% == 1 (
color 2F
if %var_Debug% gtr 0 call :msg_NoProbsModsDbg
if %var_Debug% == 0 call :msg_NoProbsMods
) else (
color 4F
if %var_Debug% gtr 0 call :msg_ProbsDbg
if %var_Debug%==0 call :msg_PosProbs
)
)
goto :EOF
rem ---------------------------------------------------------------------
rem --- detection subs ---
rem ---------------------------------------------------------------------
:sub_DetectMods
set /a var_NewModCount=0
set /a var_ConvModCount=0
set /a var_ExcludedModCount=0
for %%i in (*.mpm) do (
if not exist "backup\%%i" (
if not exist "convexcl\%%~ni.log" (
set /a var_NewModCount += 1
) else (
set /a var_ExcludedModCount += 1
)
) else (
set /a var_ConvModCount += 1
)
)
set /a var_TotModCount=%var_NewModCount%+%var_ConvModCount%+%var_ExcludedModCount%
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectGame
set flag_GameExe=0
if /i exist maxpayne.exe set flag_GameExe=1
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectScriptNeeds
set flag_ScriptNeeds=1
set flag_CanConvert=1
if /i not exist rasmaker.exe (
set flag_ScriptNeeds=0
set flag_CanConvert=0
if "%1"=="1" call :msg_Miss rasmaker.exe
)
if /i not exist rl.dll (
set flag_ScriptNeeds=0
if "%1"=="1" call :msg_Miss rl.dll
set flag_CanConvert=0
)
if /i not exist shortcut.exe (
set flag_ScriptNeeds=0
if "%1"=="1" call :msg_Miss shortcut.exe
)
if /i not exist sox.exe (
set flag_ScriptNeeds=0
if "%1"=="1" call :msg_Miss sox.exe
set flag_CanConvert=0
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectConvData
set flag_ConvData=1
if /i not exist x_data.ras (
set flag_ConvData=0
if "%1"=="1" call :msg_Miss x_data.ras
)
if /i not exist x_music.ras (
set flag_ConvData=0
if "%1"=="1" call :msg_Miss x_music.ras
)
if %flag_LangFiles%==0 (
set flag_ConvData=0
if "%1"=="1" call :msg_Miss x_^(language^).ras
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectLang
set flag_LangFiles=0
for %%i in (*.ras) do call :sub_CheckLang %%i
goto :EOF
rem ---------------------------------------------------------------------
:sub_CheckLang
set flag_Dont=0
if /i %1==x_level1.ras set flag_Dont=1
if /i %1==x_level2.ras set flag_Dont=1
if /i %1==x_level3.ras set flag_Dont=1
if /i %1==x_data.ras set flag_Dont=1
if /i %1==x_music.ras set flag_Dont=1
if %flag_Dont%==0 (
if "%2"=="" (
set flag_LangFiles=1
) else (
call :msg_LangFndDbg %1
)
)
set flag_Dont=
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectRun
set flag_RunFiles=1
if /i not exist e2driver\e2_d3d8_driver_mfc.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss e2driver\e2_d3d8_driver_mfc.dll
)
if /i not exist movies\intro.mpg (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss movies\intro.mpg
)
if /i not exist e2mfc.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss e2mfc.dll
)
if /i not exist grphmfc.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss grphmfc.dll
)
if %flag_GameExe%==0 (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss maxpayne.exe
)
if /i not exist mfc42.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss mfc42.dll
)
if /i not exist msvcirt.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss msvcirt.dll
)
if /i not exist msvcp60.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss msvcp60.dll
)
if /i not exist msvcrt.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss msvcrt.dll
)
if /i not exist rlmfc.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss rlmfc.dll
)
if /i not exist sndmfc.dll (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss sndmfc.dll
)
if /i not exist x_data.ras (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss x_data.ras
)
if %flag_LangFiles%==0 (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss x_^(language^).ras
)
if /i not exist x_level1.ras (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss x_level1.ras
)
if /i not exist x_level2.ras (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss x_level2.ras
)
if /i not exist x_level3.ras (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss x_level3.ras
)
if /i not exist x_music.ras (
set flag_RunFiles=0
if "%1"=="1" call :msg_Miss x_music.ras
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectFreshGame
set flag_FreshGame=0
if exist *.ras (
set flag_FreshGame=1
for %%i in (*.ras) do call :sub_FreshSize %%i
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_FreshSize
if exist x_english.ras if %1==x_data.ras if not "%~z1" == "134236027" set flag_FreshGame=0
if %1==x_music.ras if not "%~z1" == "144606272" set flag_FreshGame=0
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectUac
set flag_Uac=0
mkdir uactest 2>nul
if errorlevel 1 (
set flag_Uac=1
) else (
rd uactest /s /q
echo.
)
if %flag_Uac%==1 goto :lbl_Handle_Uac
goto :EOF
rem ---------------------------------------------------------------------
:sub_DetectTmp
if exist tmp (
:sub_RemoveTmp
rd tmp /s /q 2>nul
call :sub_Waitasec %var_ConversionDelay%
if exist tmp (
call :msg_TmpProb
pause >nul
goto :sub_RemoveTmp
)
if "%1"=="1" call :msg_TmpCleared
)
goto :EOF
rem ---------------------------------------------------------------------
rem --- backup sync steam verify ---
rem ---------------------------------------------------------------------
:sub_DetectBackupProbs
set flag_BackupProbs=0
for %%i in (backup/*.ras) do call :sub_CompareGameFileSize %%i
call :sub_SyncBackupDir
if %flag_BackupProbs%==1 call :msg_BackupsSynced
set flag_BackupProbs=
set var_UsedFileSize=
set var_BakFileSize=
goto :EOF
rem ---------------------------------------------------------------------
:sub_CompareGameFileSize
if exist %1 set var_UsedFileSize=%~z1
call :sub_CheckBakFileSize backup\%1
goto :EOF
rem ---------------------------------------------------------------------
:sub_CheckBakFileSize
if exist %1 set var_BakFileSize=%~z1
if "%var_UsedFileSize%" == "%var_BakFileSize%" (
set flag_BackupProbs=1
del %1
)
goto :EOF
rem ---------------------------------------------------------------------
:sub_SyncBackupDir
if exist backup (
if not exist backup\*.mpm (
if not exist backup\*.ras (
set flag_BackupProbs=1
rd backup /s /q
)
)
)
goto :EOF
rem ---------------------------------------------------------------------
rem --- helper subs ---
rem ---------------------------------------------------------------------
:sub_Waitasec
timeout /t %1 >nul
goto :EOF
rem ---------------------------------------------------------------------
:sub_CreateShortcut
if not exist "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\MaxBatch.lnk" shortcut /f:"%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\MaxBatch.lnk" /a:c /i:"%cd%\maxpayne.exe",1 /t:"%cd%\MaxBatch.bat" /w:"%cd%" >nul
goto :EOF