-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModMaker.bat
More file actions
259 lines (229 loc) · 6.54 KB
/
ModMaker.bat
File metadata and controls
259 lines (229 loc) · 6.54 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
@echo off
cls
echo rFactor 2 ModMaker V1.9
setlocal
rem if '%2' == 'ModManager.exe' then this was called from that program and shouldn't pause
echo %time% > c:\temp\debug
echo %1 %2 >> c:\temp\debug
echo debug1 >> c:\temp\debug
rem Default path, can be overridden in mod file
rem rf2dir=[path to rF2 install]
set rf2dir=%ProgramFiles(x86)%\Steam\steamapps\common\rFactor 2
set SteamCmd=%ProgramFiles(x86)%/Steam/steam.exe
set modfile=%~dpnx1
if '%modfile%' == '' goto helpNoModfile
if not exist %modfile% goto helpNoModfile
echo Using %modfile%
set verbose=0
set dryrun=0
rem Parse the modfile
for /f "eol=# tokens=1,2* delims==" %%i in (%modfile%) do (
if /i '%%i' == 'Name' set modset=%%j
if /i '%%i' == 'rf2dir' set rf2dir=%%j
if /i '%%i' == 'SteamCmd' set SteamCmd=%%j
if /i '%%i' == 'temporary_copy' set temporary_copy=%%j
if /i '%%i' == 'verbose' set verbose=%%j
if /i '%%i' == 'dryrun' set dryrun=%%j
)
set temporary_copy=%rf2dir%\UserData\temporary_copy
if %verbose% GTR 0 echo Full path: %modfile%
if '%modset%' == '' goto helpNoName
:::::::::::::::::::::::::::::::::::::::::::::::::
rem OK, ready to go
echo Name: %modset%
echo rf2dir: %rf2dir%
echo temporary_copy: %temporary_copy%
if %verbose% GTR 0 echo verbose: %verbose%
if %dryrun% GTR 0 echo dryrun ON
if %verbose% GTR 2 echo on
echo.
:::::::::::::::::::::::::::::::::::::::::::::::::
rem Check if Steam running
Set "MyProcess=Steam.exe"
tasklist /NH /FI "imagename eq %MyProcess%" 2>nul |find /i "%MyProcess%">nul
if not errorlevel 1 (
Echo "%MyProcess%" is running
goto :SteamRunning )
rem start it if not
echo Starting "%MyProcess%"
start "" /min "%SteamCmd%"
Set "MySubProcess=SteamService.exe"
:loop
timeout 1 > nul
tasklist /NH /FI "imagename eq %MySubProcess%" 2>nul |find /i "%MySubProcess%">nul
if errorlevel 1 goto loop
echo Steam takes some time to get going, allowing it to load...
timeout 15
echo "%MyProcess%" running
:SteamRunning
:::::::::::::::::::::::::::::::::::::::::::::::::
rem Create a folder for the mod
pushd "%rf2dir%"
if errorlevel 1 goto no_rf2dir
md "%temporary_copy%\%modset%"
if not exist "%temporary_copy%\%modset%" goto temporary_copy_error
pushd "%temporary_copy%\%modset%"
if errorlevel 1 goto temporary_copy_error
set _modfolder=%cd%
if %verbose% GTR 1 (
echo temporary_copy: "%temporary_copy%"
echo modset: "%modset%"
echo _modfolder: "%_modfolder%"
)
echo Creating rFactor copy in %_modfolder%
echo.
:::::::::::::::::::::::::::::::::::::::::::::::::
rem Symlinks (actually "Junctions" which do not require admin rights)
rem back to the main install
for %%d in (Bin
Bin32
Bin64
Core
Launcher
LOG
Manifests
ModDev
PluginData
steamapps
steam_shader_cache
Support
Templates
Updates
UserData
_CommonRedist ) do if %verbose%==0 (
mklink /j "%%d" "%rf2dir%\%%d" > nul
) else (
mklink /j "%%d" "%rf2dir%\%%d"
)
:::::::::::::::::::::::::::::::::::::::::::::::::
rem Symlinks to for the Installed folder, less Locations & Vehicles
md Installed
cd Installed
for %%d in (Commentary
HUD
Nations
rFm
Showroom
Sounds
Talent
UIData ) do if %verbose%==0 (
mklink /j "%%d" "%rf2dir%\Installed\%%d" > nul
) else (
mklink /j "%%d" "%rf2dir%\Installed\%%d"
)
:::::::::::::::::::::::::::::::::::::::::::::::::
rem Symlinks to selected Locations & Vehicles
md Locations
cd Locations
rem Parse the modfile for Locations
for /f "eol=# tokens=1,2* delims==" %%i in (%modfile%) do if /i '%%i' == 'Location' (
if exist "%rf2dir%\Installed\Locations\%%j" (
if %verbose% GTR 1 (
mklink /j "%%j" "%rf2dir%\Installed\Locations\%%j"
) else (
mklink /j "%%j" "%rf2dir%\Installed\Locations\%%j" > nul
echo Added Location %%j
)
) else echo "Locations\%%j" not found
)
cd..
:::::::::::::::::::::::::::::::::::::::::::::::::
md Vehicles
cd Vehicles
rem Parse the modfile for Vehicles
for /f "eol=# tokens=1,2* delims==" %%i in (%modfile%) do if /i '%%i' == 'Vehicle' (
if exist "%rf2dir%\Installed\Vehicles\%%j" (
if %verbose% GTR 1 (
mklink /j "%%j" "%rf2dir%\Installed\Vehicles\%%j"
) else (
mklink /j "%%j" "%rf2dir%\Installed\Vehicles\%%j" > nul
echo Added Vehicle %%j
)
) else echo "Vehicles\%%j" not found
)
:::::::::::::::::::::::::::::::::::::::::::::::::
popd
echo.
echo debug2 >> c:\temp\debug
if %verbose% GTR 1 dir /b Bin64\plugins\*.dll > c:\temp\dlls
echo debug3 >> c:\temp\debug
@echo Starting rFactor 2 singleplayer...
if %dryrun%==0 (
Bin64\rFactor2.exe +singleplayer +path="%temporary_copy%\%modset%"
) else (
echo DRY RUN. rFactor has now exited
if not '%2' == 'ModManager.exe' pause
)
echo.
if %verbose% == 0 goto deleteCopy
if '%2' == 'ModManager.exe' goto deleteCopy
set /p _delete=Enter K if you want to KEEP the temporary rFactor copy "%modset%":
if /I '%_delete%' == 'k' goto :pauseExit
:deleteCopy
rmdir /s /q "%_modfolder%"
rem Delete the temporary_copy folder if there was nothing else in it.
rmdir %temporary_copy% > nul 2>&1
echo %_modfolder% deleted.
if '%2' == 'ModManager.exe' Exit
goto :pauseExit
:::::::::::::::::::::::::::::::::::::::::::::::::
:helpNoModfile
@echo off
echo Usage: %0 ^<Modfile^>
echo (or you can drop ^<Modfile^> on %0)
echo.
:helpNoName
@echo off
echo The Modfile must have
echo NAME=^<Name for the mod^> (preferably one word)
echo LOCATION=^<Track folder name^>
echo repeat as required
echo VEHICLE=^<Vehicle folder name^>
echo repeat as required
echo.
echo For example
echo name=1960s_F1_UK
echo Location=CRYSTAL PALACE 1969
echo Location=Silverstone90s
echo Location=BrandsHatch
echo etc.
echo Vehicle=Brabham_1966
echo Vehicle=Ferrari_312_67
echo Vehicle=Historic Challenge_EVE_1968
echo.
echo Anything on a line after # is a comment
echo.
echo If your rFactor is installed somewhere other than
echo %ProgramFiles(x86)%\Steam\steamapps\common\rFactor 2
echo then you can add a line like this
echo rf2dir=d:\games\Steam\steamapps\common\rFactor 2
echo.
echo Similarly for the command to start Steam
echo SteamCmd=%ProgramFiles(x86)%\Steam\Steam
echo.
echo Advanced options
echo temporary_copy=^<path^> to put the shadow copy somewhere other than
echo %rf2dir%\UserData\temporary_copy
echo verbose=0,1 or 2 for extra progress messages
echo dryrun=1 run %0 but don't start rFactor
echo.
goto pauseExit
:temporary_copy_error
echo.
echo ERROR
echo.
echo Could not create temp folder "%temporary_copy%\%modset%"
echo in %rf2dir%
echo.
echo One answer is to add this to %1
echo temporary_copy=^<path^>
echo to put the shadow copy somewhere else
goto pauseExit
:no_rf2dir
echo.
echo ERROR
echo.
echo Could not find rFactor 2 folder "%rf2dir%"
:pauseExit
echo.
pause