Upvote Upvoted 13 Downvote Downvoted
Demo Support ds_prefix on any map
posted in Customization
1
#1
0 Frags +

After switching to valve's alternative to P-REC, my demos looked like this:

https://i.imgur.com/qcH2wol.png

The thing I missed the most from P-REC was being able to tell what map the demo was on, at the very least

To fix this, I wrote a short script you can run on your tf/custom folder, and it'll generate a config for every map you have there.
For example, it'll see you have arena_byre.bsp, and write an arena_byre.cfg:

ds_prefix "arena_byre_"

With this, you don't only get a date and time on the filename,

https://i.imgur.com/1nyyYO3.png

https://i.imgur.com/XxqI0ml.png

you also get the map name.

Here's the script: github.com
Linux version: github.com

To use this , open this link (linux version), press Ctrl+S on your keyboard, and save this file to your tf/custom folder, then go there and double click the script.
It'll create a new folder in tf/maps named "map_cfg". Move this folder to tf_custom.
*EDIT*
I've compiled one of these for official maps only: MEGA download (22KB)

This folder has a cfg folder with a config named after every map in your maps folder. When you enter a map in TF2, the game tries to run a config named after the map, so we generate one of those for every map you have. This will obviously conflict with any other mapname.cfg files you might already have (why?)
Another issue is you will have to either manually add new map scripts or run the script again for every new map you play on.

This is a batch script so I think windows might freak out and tell you it's a virus or something.
Any feedback is appreciated

If you use this, make sure to have ds_prefix "" somewhere on your autoexec
otherwise, if you join a new map, it'll save the demo with the prefix for the last map you played on.

*EDIT* The script now also checks for maps in tf/download/maps and places the files in a folder in tf/custom
*EDIT* linux version
*EDIT* warning about playing on new maps

(25/04/2019) Update: I stopped using this and the links here are dead. If you want the scripts they're under the spoilers below:

gen_map_cfgs.bat

Show Content
:: gen_map_cfgs.bat
:: run from the top of your TF2 custom folder
:: eg. C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\custom

setlocal enabledelayedexpansion

set "tf2_custom=%~dp0"
set "tf2_maps=%~dp0..\maps\"
set "tf2_custom_maps=%~dp0..\download\maps\"

:: move to tf2 maps folder
cd %tf2_maps%

:: make a folder in which we'll store the cfgs
rmdir map_cfg /S /Q
mkdir map_cfg
mkdir map_cfg\cfg

:: iterate over maps
for %%i in ("*.bsp") do (
set o_name=%%i
:: remove the last 4 characters (file extension)
set _name=!o_name:~0,-4!
:: echo the command into the config
echo ds_prefix "!_name!_" > .\map_cfg\cfg\!_name!.cfg
)

:: move map_cfg to tf/download/maps
move "map_cfg" "%tf2_custom_maps%"
:: and follow it
cd %tf2_custom_maps%

:: iterate over maps again
for %%i in ("*.bsp") do (
set o_name=%%i
set _name=!o_name:~0,-4!
echo ds_prefix "!_name!_" > .\map_cfg\cfg\!_name!.cfg
)

:: finally, move the map_cfg to tf/custom
move "map_cfg" "%tf2_custom%"

gen_map_cfgs.sh

Show Content
#!/usr/bin/env bash
# gen_map_cfgs.sh
# run from the top of your TF2 custom folder
# eg. C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\custom

# we start from TF2/tf/custom

# make a folder for the cfgs
rm -r map_cfg
mkdir map_cfg
mkdir map_cfg/cfg

# move to tf/maps
cd ./../maps

# iterate over maps
for i in *.bsp; do
# break if there's not a single file here (???)
[ -f "$i" ] || break
# remove last 4 characters (file extension)
a=${i::-4}
# echo command into config in map_cfg
echo "ds_prefix \""$a"_\"" > ./../custom/map_cfg/cfg/$a.cfg
done

# move to tf/download/maps
cd ./../download/maps

# iterate again
for i in *.bsp; do
[ -f "$i" ] || break
a=${i::-4}
# this time we go up two directories
echo "ds_prefix \""$a"_\"" > ./../../custom/map_cfg/cfg/$a.cfg
done

# return to starting folder
cd ./../../custom
After switching to valve's alternative to P-REC, my demos looked like this:
[img]https://i.imgur.com/qcH2wol.png[/img] The thing I missed the most from P-REC was being able to tell what map the demo was on, at the very least

To fix this, I wrote a short script you can run on your tf/custom folder, and it'll generate a config for [b]every[/b] map you have there.
For example, it'll see you have arena_byre.bsp, and write an arena_byre.cfg:
[code]ds_prefix "arena_byre_"[/code]
With this, you don't only get a date and time on the filename,
[img]https://i.imgur.com/1nyyYO3.png[/img]
[img]https://i.imgur.com/XxqI0ml.png[/img] you also get the map name.

Here's the script: [s][url=https://duckduckgo.com/?q=dead+link]github.com[/url][/s]
Linux version: [s][url=https://duckduckgo.com/?q=dead+link]github.com[/url][/s]

To use this , open[s] [url=https://duckduckgo.com/?q=dead+link]this link[/url] ([url=https://duckduckgo.com/?q=dead+link]linux version[/url])[/s], press Ctrl+S on your keyboard, and save this file to your tf/custom folder, then go there and double click the script.
It'll create a new folder in tf/maps named "map_cfg". Move this folder to tf_custom.
*EDIT*
I've compiled one of these for [b]official maps only[/b]: [s][url=https://mega.nz/#!dURxhYiC!3tws7Wgqa2ZI4sYLe6qcq3J1P6124xJjf3PeEGJ0-J8]MEGA download (22KB)[/url][/s]

This folder has a cfg folder with a config named after every map in your maps folder. When you enter a map in TF2, the game tries to run a config named after the map, so we generate one of those for every map you have. This will obviously conflict with any other mapname.cfg files you might already have (why?)
Another issue is you will have to either manually add new map scripts or run the script again for every new map you play on.

This is a batch script so I think windows might freak out and tell you it's a virus or something.
Any feedback is appreciated

[b]If you use this, make sure to have ds_prefix "" somewhere on your autoexec[/b]
otherwise, if you join a new map, it'll save the demo with the prefix for the last map you played on.

*EDIT* The script now also checks for maps in tf/download/maps and places the files in a folder in tf/custom
*EDIT* linux version
*EDIT* warning about playing on new maps

[b](25/04/2019) Update:[/b] I stopped using this and the links here are dead. If you want the scripts they're under the spoilers below:

[u]gen_map_cfgs.bat[/u]
[spoiler]
:: gen_map_cfgs.bat
:: run from the top of your TF2 custom folder
:: eg. C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\custom

setlocal enabledelayedexpansion

set "tf2_custom=%~dp0"
set "tf2_maps=%~dp0..\maps\"
set "tf2_custom_maps=%~dp0..\download\maps\"

:: move to tf2 maps folder
cd %tf2_maps%

:: make a folder in which we'll store the cfgs
rmdir map_cfg /S /Q
mkdir map_cfg
mkdir map_cfg\cfg

:: iterate over maps
for %%i in ("*.bsp") do (
set o_name=%%i
:: remove the last 4 characters (file extension)
set _name=!o_name:~0,-4!
:: echo the command into the config
echo ds_prefix "!_name!_" > .\map_cfg\cfg\!_name!.cfg
)

:: move map_cfg to tf/download/maps
move "map_cfg" "%tf2_custom_maps%"
:: and follow it
cd %tf2_custom_maps%

:: iterate over maps again
for %%i in ("*.bsp") do (
set o_name=%%i
set _name=!o_name:~0,-4!
echo ds_prefix "!_name!_" > .\map_cfg\cfg\!_name!.cfg
)

:: finally, move the map_cfg to tf/custom
move "map_cfg" "%tf2_custom%"
[/spoiler]

[u]gen_map_cfgs.sh[/u]
[spoiler]
#!/usr/bin/env bash
# gen_map_cfgs.sh
# run from the top of your TF2 custom folder
# eg. C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\custom

# we start from TF2/tf/custom

# make a folder for the cfgs
rm -r map_cfg
mkdir map_cfg
mkdir map_cfg/cfg

# move to tf/maps
cd ./../maps

# iterate over maps
for i in *.bsp; do
# break if there's not a single file here (???)
[ -f "$i" ] || break
# remove last 4 characters (file extension)
a=${i::-4}
# echo command into config in map_cfg
echo "ds_prefix \""$a"_\"" > ./../custom/map_cfg/cfg/$a.cfg
done

# move to tf/download/maps
cd ./../download/maps

# iterate again
for i in *.bsp; do
[ -f "$i" ] || break
a=${i::-4}
# this time we go up two directories
echo "ds_prefix \""$a"_\"" > ./../../custom/map_cfg/cfg/$a.cfg
done

# return to starting folder
cd ./../../custom
[/spoiler]
2
#2
whitelist.tf
3 Frags +

To be able to run this file from anywhere on your PC and have it autodetect the TF2 folder you could modify it with the following:

:: Find TF2 install location in the registry
REM https://stackoverflow.com/questions/39940343/how-to-find-the-directory-of-an-executable-using-a-batch-file
(for /f "usebackq tokens=1,2,*" %%a in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 440" /v InstallLocation`) do set TF2x86=%%c)>nul 2>&1
(for /f "usebackq tokens=1,2,*" %%a in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 440" /v InstallLocation`) do set TF2x64=%%c)>nul 2>&1
set TF2Path=%TF2x64%%TF2x86%

set "tf2_custom=%TF2Path%\tf\custom"
set "tf2_maps=%TF2Path%\tf\maps"
set "tf2_custom_maps=%TF2Path%\tf\download\maps"

You could also modify the echo to be >> and point it to an already existing map config file so it simply appends the ds_prefix line to the file.

Making the script even smarter if you have it in the file with existing map configs you could use findstr to check if the .cfg already contains the ds_prefix and if not to append it to it.

To be able to run this file from anywhere on your PC and have it autodetect the TF2 folder you could modify it with the following:

[code]:: Find TF2 install location in the registry
REM https://stackoverflow.com/questions/39940343/how-to-find-the-directory-of-an-executable-using-a-batch-file
(for /f "usebackq tokens=1,2,*" %%a in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 440" /v InstallLocation`) do set TF2x86=%%c)>nul 2>&1
(for /f "usebackq tokens=1,2,*" %%a in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 440" /v InstallLocation`) do set TF2x64=%%c)>nul 2>&1
set TF2Path=%TF2x64%%TF2x86%

set "tf2_custom=%TF2Path%\tf\custom"
set "tf2_maps=%TF2Path%\tf\maps"
set "tf2_custom_maps=%TF2Path%\tf\download\maps"[/code]

You could also modify the echo to be [b]>>[/b] and point it to an already existing map config file so it simply appends the ds_prefix line to the file.

Making the script even smarter if you have it in the file with existing map configs you could use [i]findstr[/i] to check if the .cfg already contains the [i]ds_prefix[/i] and if not to append it to it.
3
#3
0 Frags +
Wiethoofdetc

Right now I'm having an issue where my registry has TF2 in drive E:/, while it's actually in drive C:/. I think I moved the game folder manually at one point.
Maybe it would be best to run the script from the base TF2 folder as a baseline instead of checking the registry?

your other suggestions are pretty good also

[quote=Wiethoofd]etc[/quote]
Right now I'm having an issue where my registry has TF2 in drive E:/, while it's actually in drive C:/. I think I moved the game folder manually at one point.
Maybe it would be best to run the script from the base TF2 folder as a baseline instead of checking the registry?

your other suggestions are pretty good also
4
#4
0 Frags +

actually, I'm not sure scanning peoples tf/custom and tf/cfg for map configs is a good idea. I doubt many people have enough of those to justify automating it. the approach i'm thinking of is:
1. you use the script
2. you manually delete the generated configs for maps you already have a config of
3. you append ds_prefix "mapname_" to those map configs manually

actually, I'm not sure scanning peoples tf/custom and tf/cfg for map configs is a good idea. I doubt many people have enough of those to justify automating it. the approach i'm thinking of is:
1. you use the script
2. you manually delete the generated configs for maps you already have a config of
3. you append ds_prefix "mapname_" to those map configs manually
Please sign in through STEAM to post a comment.