-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminPanel.bat
More file actions
626 lines (507 loc) · 18.2 KB
/
AdminPanel.bat
File metadata and controls
626 lines (507 loc) · 18.2 KB
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
@echo off
setlocal enabledelayedexpansion
:: ************************************************************************************
:: * Directories *
:: ************************************************************************************
:: For Send Game & Db to Binary option
for %%A in ("%~dp0Server\Source\Bin\") do set "ServerSourceBinPath=%%~fA"
for %%A in ("%~dp0Server\Binary\binary\") do set "SvFilesBinaryPath=%%~fA"
:: For Send Protos to Db (From Release) option
set "DumpProtoReleasePath=%~dp0Proto\"
set "SvFilesShareConfPath=%~dp0Server\Binary\share\conf\"
set "PackPath=%~dp0Client\Binary\pack\"
:: =======================
:: Locale configuration
:: =======================
set "LOCALES=cz de dk es fr gr hu it nl pl pt ro ru tr en"
set "PACK_LOCALE_BASE=%PackPath%locale\locale"
:: %TAB% line uses a tab for indentation.
set "TAB= "
:: ************************************************************************************
:: * Menu *
:: ************************************************************************************
:menu
cls
echo --- Yosun Admin Panel ---
echo 1: Send Game ^& Db ^& Qc to Binary
echo 2: Send Protos to DB and Pack
echo 3: Generate symlinks (Executables)
echo 4: Generate symlinks (locale ^& data folders)
echo 5: Delete symlinks
echo 6: Clear
echo 7: Clear Compiled Quests
echo 8: Make Quests
echo 9: Start
echo 10: Clear Before Zipping (Reduce archive size)
echo 0: Exit
echo.
:: Prompt for user input
set /p choice=Choose an option:
:: Process user input
if "%choice%"=="1" goto send_files
if "%choice%"=="2" goto send_protos
if "%choice%"=="3" goto generate_symlinks_executables
if "%choice%"=="4" goto generate_symlinks_folders
if "%choice%"=="5" goto delete_symlinks
if "%choice%"=="6" goto clear
if "%choice%"=="7" goto clear_quests
if "%choice%"=="8" goto make_quests
if "%choice%"=="9" goto start
if "%choice%"=="10" goto clear_before_zipping
if "%choice%"=="0" goto exit_script
:: If invalid option, show the menu again
echo Invalid choice, please select a valid option.
pause
goto menu
:: ************************************************************************************
:: * 1: Send Game & Db & Qc to Binary *
:: ************************************************************************************
:send_files
echo Sending Game ^& Db ^& Qc to Binary...
:: Check and create binary directory
if not exist "%SvFilesBinaryPath%" (
echo [Info] Binary directory does not exist: "%SvFilesBinaryPath%"
echo [Info] Creating binary directory...
mkdir "%SvFilesBinaryPath%" || (echo [Error] : Failed to create binary directory. Exiting script. & exit /b 1)
echo [Success] Binary directory created successfully.
echo.
)
:: Function to copy files from Release
echo [Info] Copying files from Release folder...
for %%F in (db_Win32_Release.exe db_Win32_Debug.exe game_Win32_Release.exe game_Win32_Debug.exe qc_Win32_Release.exe qc_Win32_Debug.exe) do (
copy "%ServerSourceBinPath%%%F" "%SvFilesBinaryPath%" >nul
if errorlevel 1 (
echo [Error] : Failed to copy "%%F" to "%SvFilesBinaryPath%"
) else (
echo [Success] Copied "%%F" to "%SvFilesBinaryPath%"
)
)
echo.
echo [Success] All operations completed.
pause
goto menu
:: ************************************************************************************
:: * 2: Send Protos to Db (From Release) *
:: ************************************************************************************
:send_protos
echo ===============================
echo Sending Protos to Database
echo ===============================
:: Copy proto inputs to each locale
for %%L in (%LOCALES%) do (
copy "%DumpProtoReleasePath%item_proto.txt" "%DumpProtoReleasePath%%%L" >nul 2>&1 ^
&& echo [Success] item_proto.txt%TAB%copied to Release\%%L ^
|| echo [Error] item_proto.txt -> Release\%%L
copy "%DumpProtoReleasePath%mob_proto.txt" "%DumpProtoReleasePath%%%L" >nul 2>&1 ^
&& echo [Success] mob_proto.txt%TAB%%TAB%copied to Release\%%L ^
|| echo [Error] mob_proto.txt -> Release\%%L
copy "%DumpProtoReleasePath%dump_proto.exe" "%DumpProtoReleasePath%%%L" >nul 2>&1 ^
&& echo [Success] dump_proto.exe%TAB%copied to Release\%%L ^
|| echo [Error] dump_proto.exe -> Release\%%L
)
:: Execute dump_proto.exe for each locale
for %%L in (%LOCALES%) do (
pushd "%DumpProtoReleasePath%%%L"
start /wait "Dump Proto %%L" "dump_proto.exe" >nul 2>&1 ^
&& echo [Success] %%L item_proto and mob_proto generated ^
|| echo [Error] dump_proto.exe failed in %%L
popd
)
:: Copy EN protos to server
if not exist "%SvFilesShareConfPath%" (
mkdir "%SvFilesShareConfPath%" || (
echo [Error] Failed to create "%SvFilesShareConfPath%"
goto :menu
)
)
copy "%DumpProtoReleasePath%en\item_names.txt" "%SvFilesShareConfPath%" >nul 2>&1
copy "%DumpProtoReleasePath%item_proto.txt" "%SvFilesShareConfPath%" >nul 2>&1
copy "%DumpProtoReleasePath%en\mob_names.txt" "%SvFilesShareConfPath%" >nul 2>&1
copy "%DumpProtoReleasePath%mob_proto.txt" "%SvFilesShareConfPath%" >nul 2>&1
echo [Success] Server Binary protos updated
:: Move generated binary protos to pack/locale/xx
for %%L in (%LOCALES%) do (
move "%DumpProtoReleasePath%%%L\item_proto" "%PACK_LOCALE_BASE%\%%L\" >nul 2>&1 ^
&& echo [Success] item_proto%TAB%moved to pack/locale/%%L ^
|| echo [Error] item_proto -> pack/locale/%%L
move "%DumpProtoReleasePath%%%L\mob_proto" "%PACK_LOCALE_BASE%\%%L\" >nul 2>&1 ^
&& echo [Success] mob_proto%TAB%moved to pack/locale/%%L ^
|| echo [Error] mob_proto -> pack/locale/%%L
)
:: Cleanup temp files from Release folders
for %%L in (%LOCALES%) do (
del "%DumpProtoReleasePath%%%L\item_proto.txt" >nul 2>&1
del "%DumpProtoReleasePath%%%L\mob_proto.txt" >nul 2>&1
del "%DumpProtoReleasePath%%%L\dump_proto.exe" >nul 2>&1
echo [Clean] Release\%%L
)
:: Pack locale
cd "%PackPath%"
cmd /c "PackMakerLite_p.bat locale"
goto menu
:: ************************************************************************************
:: * 3: Generate Symlinks (Executables) *
:: ************************************************************************************
:generate_symlinks_executables
echo Generating symlinks...
:: Check if script is running with administrator privileges
:: By creating a symlink in a location that requires admin privileges
echo dummy > "%TEMP%\test_symlink.txt"
mklink "%TEMP%\test_symlink_link.txt" "%TEMP%\test_symlink.txt" >nul 2>&1
:: Check if symlink creation was successful
if errorlevel 1 (
echo You need to run the script as administrator.
del "%TEMP%\test_symlink.txt" 2>nul
del "%TEMP%\test_symlink_link.txt" 2>nul
pause
goto menu
)
:: Clean up the test symlink after testing (only if the script ran as admin)
del "%TEMP%\test_symlink.txt" 2>nul
del "%TEMP%\test_symlink_link.txt" 2>nul
:: Set base paths
set "base=%~dp0Server\Binary"
set "binary=%base%\binary"
set "share=%base%\share"
set "cores=%base%\cores"
set "quest=%share%\locale\multilanguage\quest"
:: Initialize EXITCODE to 0
set EXITCODE=0
:: Create symlinks and check for errors
call :create_symlink "%cores%\db\db_Win32_Release.exe" "%binary%\db_Win32_Release.exe"
call :create_symlink "%cores%\db\db_Win32_Debug.exe" "%binary%\db_Win32_Debug.exe"
call :create_symlink "%cores%\db\item_names.txt" "%share%\conf\item_names.txt"
call :create_symlink "%cores%\db\item_proto.txt" "%share%\conf\item_proto.txt"
call :create_symlink "%cores%\db\mob_names.txt" "%share%\conf\mob_names.txt"
call :create_symlink "%cores%\db\mob_proto.txt" "%share%\conf\mob_proto.txt"
call :create_symlink "%cores%\auth\auth.exe" "%binary%\game_Win32_Release.exe"
call :create_symlink "%cores%\auth\auth_d.exe" "%binary%\game_Win32_Debug.exe"
call :create_symlink "%cores%\ch1\ch1.exe" "%binary%\game_Win32_Release.exe"
call :create_symlink "%cores%\ch1\ch1_d.exe" "%binary%\game_Win32_Debug.exe"
call :create_symlink "%cores%\ch2\ch2.exe" "%binary%\game_Win32_Release.exe"
call :create_symlink "%cores%\ch2\ch2_d.exe" "%binary%\game_Win32_Debug.exe"
call :create_symlink "%cores%\ch99\ch99.exe" "%binary%\game_Win32_Release.exe"
call :create_symlink "%cores%\ch99\ch99_d.exe" "%binary%\game_Win32_Debug.exe"
call :create_symlink "%quest%\qc_Win32_Release.exe" "%binary%\qc_Win32_Release.exe"
call :create_symlink "%quest%\qc_Win32_Debug.exe" "%binary%\qc_Win32_Debug.exe"
:: Final check
if %EXITCODE% neq 0 (
echo Some symlinks could not be created due to permission issues.
) else (
echo All symlinks created successfully.
)
pause
goto menu
:: ************************************************************************************
:: * 4: Generate Symlinks (locale & data folders) *
:: ************************************************************************************
:generate_symlinks_folders
echo Generating symlinks...
call :check_for_admin_priviledges
:: Set base paths
set "base=%~dp0Server\Binary"
set "share=%base%\share"
set "cores=%base%\cores"
:: Initialize EXITCODE to 0
set EXITCODE=0
:: Symlink locale directory to cores\auth, ch1, ch2, and ch99
for %%d in (auth ch1 ch2 ch99) do (
call :create_symlink_directory "%cores%\%%d\locale" "%share%\locale"
)
:: Symlink data directory to cores\ch1, ch2, and ch99
for %%d in (ch1 ch2 ch99) do (
call :create_symlink_directory "%cores%\%%d\data" "%share%\data"
)
:: Final check
if %EXITCODE% neq 0 (
echo Some symlinks could not be created due to permission issues.
) else (
echo All symlinks created successfully.
)
pause
goto menu
:create_symlink
:: Parameters: %1 = Symlink path, %2 = Target path
:: Check if the symlink already exists and points to the correct target
if exist "%~1" (
if /i "%~fs1"=="%~fs2" (
echo Symlink already exists: %1 -> %2
goto :eof
)
echo Target already exists but is not the correct symlink: %1
del "%~1" >nul 2>&1
)
:: Create the symlink
mklink /h "%~1" "%~2"
if %ERRORLEVEL% neq 0 (
echo Failed to create symlink: %1 -> %2
set EXITCODE=1
)
goto :eof
:create_symlink_directory
:: Parameters: %1 = Directory Symlink path, %2 = Directory Target path
:: Check if the directory symlink already exists and points to the correct target
if exist "%~1" (
if /i "%~fs1"=="%~fs2" (
echo Directory symlink already exists: %1 -> %2
goto :eof
)
echo Target directory already exists but is not the correct symlink: %1
rmdir "%~1" >nul 2>&1
)
:: Create the directory symlink
mklink /D "%~1" "%~2"
if %ERRORLEVEL% neq 0 (
echo Failed to create directory symlink: %1 -> %2
set EXITCODE=1
)
goto :eof
:check_for_admin_priviledges
:: Check if script is running with administrator privileges
:: By creating a symlink in a location that requires admin privileges
echo dummy > "%TEMP%\test_symlink.txt"
mklink "%TEMP%\test_symlink_link.txt" "%TEMP%\test_symlink.txt" >nul 2>&1
:: Check if symlink creation was successful
if errorlevel 1 (
echo You need to run the script as administrator.
del "%TEMP%\test_symlink.txt" 2>nul
del "%TEMP%\test_symlink_link.txt" 2>nul
pause
goto menu
)
:: Clean up the test symlink after testing (only if the script ran as admin)
del "%TEMP%\test_symlink.txt" 2>nul
del "%TEMP%\test_symlink_link.txt" 2>nul
goto :eof
:: ************************************************************************************
:: * 5: Delete Symlinks *
:: ************************************************************************************
:delete_symlinks
echo Deleting all symlinks...
cd "%~dp0Server/Binary/cores/db"
del db_Win32_Release.exe
del db_Win32_Debug.exe
del item_names.txt
del item_proto.txt
del mob_names.txt
del mob_proto.txt
cd "../auth"
del auth.exe
del auth_d.exe
rmdir /S /Q "locale"
cd "../ch1"
del ch1.exe
del ch1_d.exe
rmdir /S /Q "locale"
rmdir /S /Q "data"
cd "../ch2"
del ch2.exe
del ch2_d.exe
rmdir /S /Q "locale"
rmdir /S /Q "data"
cd "../ch99"
del ch99.exe
del ch99_d.exe
rmdir /S /Q "locale"
rmdir /S /Q "data"
cd "../../share/locale/multilanguage/quest"
del qc_Win32_Release.exe
del qc_Win32_Debug.exe
pause
goto menu
:: ************************************************************************************
:: * 6: Clear *
:: ************************************************************************************
:clear
echo Clearing...
cd "%~dp0Server/Binary/cores/db"
for /D %%i in (log\*) do (
if exist "%%i" rd /s /q "%%i"
)
del syserr.txt
del syslog.txt
del PTS.txt
cd "../auth"
for /D %%i in (log\*) do (
if exist "%%i" rd /s /q "%%i"
)
del packet_info.txt
del syserr.txt
del syslog.txt
del PTS.txt
del p2p_packet_info.txt
cd "../ch1"
for /D %%i in (log\*) do (
if exist "%%i" rd /s /q "%%i"
)
del packet_info.txt
del syserr.txt
del syslog.txt
del PTS.txt
del p2p_packet_info.txt
cd "../ch2"
for /D %%i in (log\*) do (
if exist "%%i" rd /s /q "%%i"
)
del packet_info.txt
del syserr.txt
del syslog.txt
del PTS.txt
del p2p_packet_info.txt
cd "../ch99"
for /D %%i in (log\*) do (
if exist "%%i" rd /s /q "%%i"
)
del packet_info.txt
del syserr.txt
del syslog.txt
del PTS.txt
del p2p_packet_info.txt
pause
goto menu
:: ************************************************************************************
:: * 7: Clear Compiled Quests *
:: ************************************************************************************
:clear_quests
echo Deleting all compiled quests...
cd "%~dp0Server/Binary/share/locale/multilanguage/quest"
rmdir /S /Q "object"
rmdir /S /Q "__pycache__"
rmdir /S /Q "pre_qc"
cd "../../../../cores/auth/locale/multilanguage/quest"
rmdir /S /Q "object"
rmdir /S /Q "__pycache__"
rmdir /S /Q "pre_qc"
cd "../../../../ch1/locale/multilanguage/quest"
rmdir /S /Q "object"
rmdir /S /Q "__pycache__"
rmdir /S /Q "pre_qc"
cd "../../../../ch2/locale/multilanguage/quest"
rmdir /S /Q "object"
rmdir /S /Q "__pycache__"
rmdir /S /Q "pre_qc"
cd "../../../../ch99/locale/multilanguage/quest"
rmdir /S /Q "object"
rmdir /S /Q "__pycache__"
rmdir /S /Q "pre_qc"
pause
goto menu
:: ************************************************************************************
:: * 8: Make Quests *
:: ************************************************************************************
:make_quests
echo Compiling Quests...
cd "%~dp0Server/Binary/share/locale/multilanguage/quest"
python make.py
pause
goto menu
:: ************************************************************************************
:: * 9: Start Server *
:: ************************************************************************************
:start
echo Starting server in Windows Terminal panes...
where wt >nul 2>&1 || (
echo [Error] Windows Terminal not found.
pause
goto menu
)
wt -w 0 ^
new-tab --title "DB" --startingDirectory "%~dp0Server\Binary\cores\db" cmd /k db_Win32_Release.exe ^
; split-pane -V --size 0.55 --title "CH1" --startingDirectory "%~dp0Server\Binary\cores\ch1" cmd /k ch1.exe ^
; split-pane -H --size 0.50 --title "CH2" --startingDirectory "%~dp0Server\Binary\cores\ch2" cmd /k ch2.exe ^
; move-focus left ^
; split-pane -H --size 0.50 --title "AUTH" --startingDirectory "%~dp0Server\Binary\cores\auth" cmd /k auth.exe ^
; move-focus right ^
; split-pane -H --size 0.50 --title "CH99" --startingDirectory "%~dp0Server\Binary\cores\ch99" cmd /k ch99.exe
goto menu
:: ************************************************************************************
:: * 10: Clear Before Zipping *
:: ************************************************************************************
:clear_before_zipping
:: Go to script directory
cd "%~dp0"
echo ===========================================
echo [1/6] Removing Visual Studio cache...
echo ===========================================
if exist ".vs" (
echo Deleting .vs folder...
rmdir /s /q ".vs"
) else (
echo .vs folder not found.
)
cd "Client/Binary/pack"
echo.
echo ===========================================
echo [2/6] Clearing pack folders...
echo ===========================================
for %%F in (ETC Icon locale Maps Property Root Sound Textureset) do (
if exist "%%F" (
echo Deleting %%F...
rmdir /s /q "%%F"
) else (
echo %%F folder not found.
)
)
cd "../screenshot"
echo.
echo ===========================================
echo [3/6] Clearing screenshots...
echo ===========================================
for %%i in (*) do (
if exist "%%i" (
echo Deleting %%i...
del /q "%%i"
)
)
echo Screenshots cleared.
cd "../../Source"
echo.
echo ===========================================
echo [4/6] Removing Debug and Release folders from projects...
echo ===========================================
for /d /r %%D in (Debug Release) do (
if exist "%%D" (
echo Deleting %%D...
rmdir /s /q "%%D"
)
)
cd "../../Tools/DumpProto"
for %%F in (Debug Release) do (
if exist "%%F" (
echo Deleting %%F...
rmdir /s /q "%%F"
) else (
echo %%F folder not found.
)
)
cd "../../Server/Source"
for /d /r %%D in (Debug Release) do (
if exist "%%D" (
echo Deleting %%D...
rmdir /s /q "%%D"
)
)
echo Build folders cleared.
cd "../../Tools/EPack32"
echo.
echo ===========================================
echo [5/6] Removing Property folder in EPack32...
echo ===========================================
if exist "Property" (
echo Deleting Property...
rmdir /s /q "Property"
) else (
echo Property folder not found.
)
echo.
echo ===========================================
echo [6/6] All cleaning operations completed.
echo ===========================================
pause
goto menu
:: ************************************************************************************
:: * 0: Exit *
:: ************************************************************************************
:exit_script
echo Exiting admin panel...
exit /b