-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.cmd
284 lines (210 loc) · 8.65 KB
/
deploy.cmd
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
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
REM Line-feed variable, do not remove two empty lines below
SET LF=^
REM Line-feed variable, do not remove two empty lines above
ECHO Sven Co-op custom resource bouncer
ECHO.
:config
SET DIR=%~dp0
PUSHD %DIR%
SET GAME_DIR_PATHNAME=%CD%
POPD
IF NOT "%~1" == "" (
SET GAME_DIR_PATHNAME=%~1
IF NOT EXIST "!GAME_DIR_PATHNAME!" (
ECHO [Error] Game directory specified not found.
GOTO end
)
)
SET GAME_BASE_DIR_PATHNAME=!GAME_DIR_PATHNAME!\svencoop
FOR /F "delims=" %%i IN ("!GAME_BASE_DIR_PATHNAME!") DO SET GAME_BASE_DIR_NAME=%%~ni
SET GAME_ADDON_DIR_PATHNAME=!GAME_BASE_DIR_PATHNAME!_addon
FOR /F "delims=" %%i IN ("!GAME_ADDON_DIR_PATHNAME!") DO SET GAME_ADDON_DIR_NAME=%%~ni
SET GAME_DOWNLOADS_DIR_PATHNAME=!GAME_BASE_DIR_PATHNAME!_downloads
FOR /F "delims=" %%i IN ("!GAME_DOWNLOADS_DIR_PATHNAME!") DO SET GAME_DOWNLOADS_DIR_NAME=%%~ni
SET REPLACEMENT_RESOURCES_DIR_PATHNAME=%DIR%\resources
SET REPLACEMENT_PLAYER_MODEL_NAME=helmet
SET REPLACEMENT_PLAYER_MODEL_DIR_PATHNAME=!GAME_BASE_DIR_PATHNAME!\models\player\!REPLACEMENT_PLAYER_MODEL_NAME!
SET FILTER_PLAYER_MODELS_FILE_PATHNAME=!DIR!filter-player-models.txt
SET FILTER_SOUNDS_FILE_PATHNAME=!DIR!filter-sounds.txt
:information
ECHO Platform: Windows (Obviously.)
ECHO.
ECHO Directory path names:
ECHO - Tool !DIR!
ECHO - Game !GAME_DIR_PATHNAME!
ECHO - Base content !GAME_BASE_DIR_PATHNAME!
ECHO - Add-on content !GAME_ADDON_DIR_PATHNAME!
ECHO - Downloaded content !GAME_DOWNLOADS_DIR_PATHNAME!
ECHO.
ECHO Player model sub: !REPLACEMENT_PLAYER_MODEL_NAME!
ECHO Player model filter: !FILTER_PLAYER_MODELS_FILE_PATHNAME!
ECHO Sounds filter: !FILTER_SOUNDS_FILE_PATHNAME!
ECHO.
:preFlightChecks
IF NOT EXIST "!GAME_DIR_PATHNAME!\" (
ECHO [Error] Game directory not found.
GOTO end
)
IF NOT EXIST "!GAME_BASE_DIR_PATHNAME!\" (
ECHO [Error] Game base directory not found.
GOTO end
)
IF NOT EXIST "!GAME_BASE_DIR_PATHNAME!\liblist.gam" (
ECHO [Error] Game base content directory invalid.
GOTO end
)
IF NOT EXIST "!GAME_ADDON_DIR_PATHNAME!\..\!GAME_BASE_DIR_NAME!\liblist.gam" (
ECHO [Error] Game add-on content directory invalid.
GOTO end
)
IF NOT EXIST "!GAME_DOWNLOADS_DIR_PATHNAME!\" (
ECHO [Info] Game downloaded content directory not found. It will be created.
MD "!GAME_DOWNLOADS_DIR_PATHNAME!"
IF NOT EXIST "!GAME_DOWNLOADS_DIR_PATHNAME!\" (
ECHO [Error] Game downloaded content directory could not be created.
GOTO end
)
)
IF NOT EXIST "!GAME_DOWNLOADS_DIR_PATHNAME!\..\!GAME_BASE_DIR_NAME!\liblist.gam" (
ECHO [Error] Game downloaded content directory invalid.
GOTO end
)
IF NOT EXIST "!REPLACEMENT_PLAYER_MODEL_DIR_PATHNAME!\" (
ECHO [Error] Replacement player model directory "!REPLACEMENT_PLAYER_MODEL_NAME!" not found.
GOTO end
)
IF NOT EXIST "!REPLACEMENT_PLAYER_MODEL_DIR_PATHNAME!\!REPLACEMENT_PLAYER_MODEL_NAME!.mdl" (
ECHO [Error] Replacement player model file "!REPLACEMENT_PLAYER_MODEL_NAME!" not found.
GOTO end
)
IF NOT EXIST "!REPLACEMENT_PLAYER_MODEL_DIR_PATHNAME!\!REPLACEMENT_PLAYER_MODEL_NAME!.bmp" (
ECHO [Warning] Replacement player model file "!REPLACEMENT_PLAYER_MODEL_NAME!" thumbnail not found.
)
:confirm
CHOICE /C YN /T 30 /D N /M "[Warning] This Windows Batch script is not fully tested yet. Proceed at your own risk?"
IF %ERRORLEVEL%==2 GOTO end
:prepareResourceDirectories
ECHO.
ECHO Preparing resource directories...
ECHO.
IF NOT EXIST "!GAME_ADDON_DIR_PATHNAME!\models\player\" (
MD "!GAME_ADDON_DIR_PATHNAME!\models\player"
)
IF NOT EXIST "!GAME_ADDON_DIR_PATHNAME!\sound\" (
MD "!GAME_ADDON_DIR_PATHNAME!\sound"
)
IF NOT EXIST "!GAME_DOWNLOADS_DIR_PATHNAME!\models\player\" (
MD "!GAME_DOWNLOADS_DIR_PATHNAME!\models\player"
)
IF NOT EXIST "!GAME_DOWNLOADS_DIR_PATHNAME!\sound\" (
MD "!GAME_DOWNLOADS_DIR_PATHNAME!\sound"
)
:filterPlayerModels
ECHO.
ECHO Filtering player models...
ECHO.
SET FILTER_PLAYER_MODELS_FILE_SIZE=-1
IF EXIST "!FILTER_PLAYER_MODELS_FILE_PATHNAME!" (
FOR /F "delims=" %%i IN ("!FILTER_PLAYER_MODELS_FILE_PATHNAME!") DO (
SET FILTER_PLAYER_MODELS_FILE_SIZE=%%~zi
IF NOT DEFINED FILTER_PLAYER_MODELS_FILE_SIZE SET FILTER_PLAYER_MODELS_FILE_SIZE=0
)
IF !FILTER_PLAYER_MODELS_FILE_SIZE! GTR 0 (
FOR /F "usebackq tokens=*" %%L IN ("!FILTER_PLAYER_MODELS_FILE_PATHNAME!") DO (
IF "%%L"=="" GOTO filterPlayerModelsForLineEnd
ECHO %%L:
SET FILTER_PLAYER_MODEL_ADDON_DIR_PATHNAME=!GAME_ADDON_DIR_PATHNAME!\models\player\%%L\
SET FILTER_PLAYER_MODEL_DOWNLOADS_DIR_PATHNAME=!GAME_DOWNLOADS_DIR_PATHNAME!\models\player\%%L\
IF EXIST "!FILTER_PLAYER_MODEL_DOWNLOADS_DIR_PATHNAME!" (
ECHO - Deleting directory from downloads.
RD /S /Q "!FILTER_PLAYER_MODEL_DOWNLOADS_DIR_PATHNAME!"
)
IF NOT EXIST "!FILTER_PLAYER_MODEL_ADDON_DIR_PATHNAME!" (
MD "!FILTER_PLAYER_MODEL_ADDON_DIR_PATHNAME!"
)
COPY /V /Y "!REPLACEMENT_PLAYER_MODEL_DIR_PATHNAME!\!REPLACEMENT_PLAYER_MODEL_NAME!.mdl" "!FILTER_PLAYER_MODEL_ADDON_DIR_PATHNAME!\%%L.mdl" 1>NUL
COPY /V /Y "!REPLACEMENT_PLAYER_MODEL_DIR_PATHNAME!\!REPLACEMENT_PLAYER_MODEL_NAME!.bmp" "!FILTER_PLAYER_MODEL_ADDON_DIR_PATHNAME!\%%L.bmp" 1>NUL
ECHO - Filter installed.
:filterPlayerModelsForLineEnd
REM Equivalent of "CONTINUE" ^
)
) ELSE (
ECHO [Warning] Player models filter file is empty.
)
) ELSE (
ECHO [Warning] Player models filter not found.
)
:filterSounds
ECHO.
ECHO Filtering sounds...
ECHO.
SET FILTER_SOUNDS_FILE_SIZE=-1
IF EXIST "!FILTER_SOUNDS_FILE_PATHNAME!" (
FOR /F "delims=" %%i IN ("!FILTER_SOUNDS_FILE_PATHNAME!") DO (
SET FILTER_SOUNDS_FILE_SIZE=%%~zi
IF NOT DEFINED FILTER_SOUNDS_FILE_SIZE SET FILTER_SOUNDS_FILE_SIZE=0
)
IF !FILTER_SOUNDS_FILE_SIZE! GTR 0 (
FOR /F "usebackq tokens=*" %%L IN ("!FILTER_SOUNDS_FILE_PATHNAME!") DO (
IF "%%L"=="" GOTO filterSoundsForLineEnd
ECHO %%L:
SET FILTER_SOUND_DOWNLOADS_PATHNAME=!GAME_DOWNLOADS_DIR_PATHNAME!\sound\%%L
SET FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES=
IF EXIST "!FILTER_SOUND_DOWNLOADS_PATHNAME!\*" (
FOR /F "delims=|" %%F in ('DIR /B /S "!FILTER_SOUND_DOWNLOADS_PATHNAME!"') DO (
SET FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES=!FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES!%%F!LF!
ECHO - Detected file to filter: %%F
)
) ELSE IF EXIST "!FILTER_SOUND_DOWNLOADS_PATHNAME!" (
SET FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES=!FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES!!FILTER_SOUND_DOWNLOADS_PATHNAME!!LF!
ECHO - Detected file to filter: !FILTER_SOUND_DOWNLOADS_PATHNAME!
) ELSE (
IF NOT "!FILTER_SOUND_DOWNLOADS_PATHNAME:~-1!"=="/" (
SET FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES=!FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES!!FILTER_SOUND_DOWNLOADS_PATHNAME!!LF!
)
ECHO - No downloaded directory or file detected to filter.
)
IF "!FILTER_SOUND_DOWNLOADS_PATHNAME:~-1!"=="/" (
IF NOT EXIST "!FILTER_SOUND_DOWNLOADS_PATHNAME!\*" (
MD "!FILTER_SOUND_DOWNLOADS_PATHNAME!"
)
) ELSE (
FOR /F "delims=*" %%i IN ("!FILTER_SOUND_DOWNLOADS_PATHNAME!") DO SET FILTER_SOUND_DOWNLOADS_DIRNAME=%%~dpi
IF NOT EXIST "!FILTER_SOUND_DOWNLOADS_DIRNAME!\*" (
MD "!FILTER_SOUND_DOWNLOADS_DIRNAME!"
)
)
IF NOT "!FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES!"=="" (
FOR /F "tokens=*" %%S IN ("!FILTER_SOUND_REPLACEMENT_FILE_PATHNAMES!") DO (
SET FILTER_SOUND_REPLACEMENT_PATHNAME=%%~S
SET FILTER_SOUND_REPLACEMENT_SIZE=-1
IF EXIST "!FILTER_SOUND_REPLACEMENT_PATHNAME!" (
FOR /F "delims=" %%i IN ("!FILTER_SOUNDS_FILE_PATHNAME!") DO (
SET FILTER_SOUND_REPLACEMENT_SIZE=%%~zi
IF NOT DEFINED FILTER_SOUND_REPLACEMENT_SIZE SET FILTER_SOUND_REPLACEMENT_SIZE=0
)
IF !FILTER_SOUND_REPLACEMENT_SIZE! GTR 0 (
DEL /F /S /Q "!FILTER_SOUND_REPLACEMENT_PATHNAME!"
COPY /Y NUL "!FILTER_SOUND_REPLACEMENT_PATHNAME!" >NUL
ECHO - Filter installed: !FILTER_SOUND_REPLACEMENT_PATHNAME!
) ELSE (
ECHO - Filter already installed: !FILTER_SOUND_REPLACEMENT_PATHNAME!
)
) ELSE (
COPY /Y NUL "!FILTER_SOUND_REPLACEMENT_PATHNAME!" >NUL
ECHO - Filter pre-emptively installed: !FILTER_SOUND_REPLACEMENT_PATHNAME!
)
)
)
:filterSoundsForLineEnd
REM Equivalent of "CONTINUE" ^
)
) ELSE (
ECHO [Warning] Sounds filter file is empty.
)
) ELSE (
ECHO [Warning] Sounds filter file not found.
)
:end