Portal
Not enough ratings
How to reduce memory used by your Source game(s)
By Xyzzy_Swe
This guide'll explain how you can get some bytes back, which SteamPipe curiously takes from you just for its base content in the Source 1 games.
   
Award
Favorite
Favorited
Unfavorite
Story about all this...
When it comes to SteamPipe being advertised as making easier distribution, installation and all that, have you sometimes wondered why your multiplayer games seem to have HL2 files in their respective directories? This is definitely inefficient as someone said in an issue on GitHub[github.com]:

Yep, a whopping extra 2,60 Gigabytes just sounds wrong, even when the original Portal is technically a modification for Half-Life 2. (I don't get it, it's a singleplayer game where the biggest difference is seeing your playermodel in first-person view!)
I'll show you how to do this, though keep in mind that it's complicated and I don't want to try it on a multiplayer game (like HL2DM) out of fear of possible VAC ban for using a modified Gameinfo file!
The procedure!
  1. First, you must have Half-Life 2 installed for this to actually work. It's the base content for the many Source games.
  2. Pick a multiplayer (or singleplayer that isn't Half-Life 2 itself, but uses base content from it) game you want to do this procedure on, I'll show with Portal as an example..., I don't want to risk anything!
  3. Open specific game's Gameinfo.txt file, search for this part below... "SearchPaths" is what I'm talking about:
    SearchPaths { // First, mount all user customizations. This will search for VPKs and subfolders // and mount them in alphabetical order. The easiest way to distribute a mod is to // pack up the custom content into a VPK. To "install" a mod, just drop it in this // folder. // // Note that this folder is scanned only when the game is booted. game+mod portal/custom/* // We search VPK files before ordinary folders, because most files will be found in // VPK and we can avoid making thousands of file system calls to attempt to open files // in folders where they don't exist. (Searching a VPK is much faster than making an operating // system call.) game_lv portal/portal_lv.vpk game+mod portal/portal_sound_vo_english.vpk game+mod portal/portal_pak.vpk game |all_source_engine_paths|hl2/hl2_textures.vpk game |all_source_engine_paths|hl2/hl2_sound_vo_english.vpk game |all_source_engine_paths|hl2/hl2_sound_misc.vpk game |all_source_engine_paths|hl2/hl2_misc.vpk platform |all_source_engine_paths|platform/platform_misc.vpk // Now search loose files. We'll set the directory containing the gameinfo.txt file // as the first "mod" search path (after any user customizations). This is also the one // that's used when writing to the "mod" path. mod+mod_write+default_write_path |gameinfo_path|. // Add the Portal directory as a game search path. This is also where where writes // to the "game" path go. game+game_write portal // Where the game's binaries are gamebin portal/bin // Last, mount in shared HL2 loose files game |all_source_engine_paths|hl2 platform |all_source_engine_paths|platform } } }
    See that? You probably didn't know, but your game is actually using duplicated base HL2 content that rarely even gets used!
    Here's a HL2 mod, Synergy, as another example:
    filesystem { SteamAppId 17520 SearchPaths { // Synergy paths game+mod+game_write+mod_write+default_write_path |gameinfo_path|. gamebin |gameinfo_path|bin game |gameinfo_path|synergy_pak.vpk // Required Half-Life 2 content (assumes default install locaton, this section needs to be edited otherwise) // These are relative paths from this file (gameinfo.txt), to the required files. // If you edit this for a non-default install location, please keep a backup of your changes for this file may update again. platform "|gameinfo_path|../../Half-Life 2/platform/platform_misc.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_misc.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_pak.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_sound_misc.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_sound_vo_english.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_textures.vpk" platform "|gameinfo_path|../../Half-Life 2/platform" game "|gameinfo_path|../../Half-Life 2/hl2" // Extra content for Hammer game "|gameinfo_path|../../Half-Life 2/ep2/ep2_pak.vpk" game "|gameinfo_path|../../Half-Life 2/episodic/ep1_pak.vpk" //game "|gameinfo_path|../../Half-Life 2/lostcoast/lostcoast_pak.vpk" //game "|gameinfo_path|../../Half-Life 2/hl1/hl1_pak.vpk" //game "|gameinfo_path|../../Half-Life 2/hl1_hd/hl1_hd_pak.vpk" // [Add any additional content for Hammer to mount here] // downloaded content here game+download |gameinfo_path|download } } }
  4. Beautiful, ain't it?! Of course, that's because a Source modification needs much of the base content. You can delete the duplicated VPK files in your Source 1 Game's "hl2" and "platform" directories, they're just wasting space.
  5. *YAWN!* Here comes the boring part! Replace those "|all_source_engine_paths|" with "|gameinfo_path|../../Half-Life 2/hl2/hl2_resources.vpk" (textures, sounds, misc, whatever), it should instead of being like this:
    game |all_source_engine_paths|hl2/hl2_textures.vpk game |all_source_engine_paths|hl2/hl2_sound_vo_english.vpk game |all_source_engine_paths|hl2/hl2_sound_misc.vpk game |all_source_engine_paths|hl2/hl2_misc.vpk platform |all_source_engine_paths|platform/platform_misc.vpk
    ...look like this:
    game "|gameinfo_path|../../Half-Life 2/hl2/hl2_textures.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_sound_vo_english.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_sound_misc.vpk" game "|gameinfo_path|../../Half-Life 2/hl2/hl2_misc.vpk" platform "|gameinfo_path|../../Half-Life 2/platform/platform_misc.vpk"
Anything else?
BEFORE YOU START THE GAME, DON'T GO ON JUST YET...!

There's another part waaay down there, that's the loose shared files. As you may have seen in the example for Portal earlier in this guide, they should point towards this for the 'game' path...
"|gameinfo_path|../../Half-Life 2/hl2"
..and this for the 'platform' path.
'"|gameinfo_path|../../Half-Life 2/platform"
You need to deal with those, otherwise you are going to get error messages regarding "surfaceproperties.txt" or other things that we all probably love to hate.
The End
If you did it all right, you may start up your game and check if it works. If it goes well without problem, congratulations on optimizing that SteamPipe can't do by itself!
Q / A section
Q: Should I be concerned about doing this for Multiplayer games like TF2, CSS, etc.?
A: As mentioned in the beginning, I never actually tried this with multiplayer games such as Half-Life 2: Deathmatch because I fear the risk of VAC ban, just for trying to playing an online game using a Gameinfo.txt that doesn't match the one normally used... In short; yes, you probably should until I get a message from Valve that they've tested my idea.
Closing.
...And remember a safety tip from your hateful, friendly biker Francis: Watch out for ♥♥♥♥♥♥♥ SteamPipe!
8 Comments
kotenok2000 Dec 18, 2022 @ 9:10am 
I think word Memory should only be used for RAM. Use Storage for hard drives.
bluegecko Apr 7, 2022 @ 1:01am 
░░░░░█▐▓▓░████▄▄▄█▀▄▓▓▓▌█Help
░░░░░▄█▌▀▄▓▓▄▄▄▄▀▀▀▄▓▓▓▓▓▌█ Doge
░░░▄█▀▀▄▓█▓▓▓▓▓▓▓▓▓▓▓▓▀░▓▌█ Take
░░█▀▄▓▓▓███▓▓▓███▓▓▓▄░░▄▓▐█▌ Over
░█▌▓▓▓▀▀▓▓▓▓███▓▓▓▓▓▓▓▄▀▓▓▐█ Steam
▐█▐██▐░▄▓▓▓▓▓▀▄░▀▓▓▓▓▓▓▓▓▓▌█▌ Copy
█▌███▓▓▓▓▓▓▓▓▐░░▄▓▓███▓▓▓▄▀▐█ And
█▐█▓▀░░▀▓▓▓▓▓▓▓▓▓██████▓▓▓▓▐█ Paste
▌▓▄▌▀░▀░▐▀█▄▓▓██████████▓▓▓▌█▌
▌▓▓▓▄▄▀▀▓▓▓▀▓▓▓▓▓▓▓▓█▓█▓█▓▓▌█▌ DO IT.
█▐▓▓▓▓▓▓▄▄▄▓▓▓▓▓▓█▓█▓█▓█▓▓▓
ubuntuxp Apr 21, 2017 @ 7:48am 
I don't know what the equivalent is on Windows, but on macOS and GNU/Linux, you can use hard links between vpks. The advantange of hard links is that you don't need to edit gameinfo.txt, so it should work with multiplayer as well as singleplayer.
Ohagi-Chan Jan 15, 2017 @ 9:46pm 
Would it be possible to do something similar by replacing the Half Life 2 data with a symbol link of your actual Half Life 2 game?
BreakinBenny - Allkeyshop Aug 4, 2016 @ 8:11am 
Alternatively, you can use "|all_source_engine_paths|../Half-Life 2" because this code is much of the same as "|gameinfo_path|../../Half-Life 2". Just wanted to mention that.
}!{enR May 12, 2015 @ 2:09am 
HL2 is Source-based, so multiplayer base is the same. But as it was told on a GitHub by a contributor, all this manipulations are not recommended, because those changes has been done to make the games independent of each other, so these files can be changed in a future. And the future is now, TF2 files already differs from CSS and DoDS files, unfortunately. :meatytears:
Xyzzy_Swe  [author] May 8, 2015 @ 10:22am 
}!{enR Makes sense, seeing as Half-Life 2 has all the content for it in that game's directory. It'd be nice to also have a Source Multiplayer folder for them multiplayer games... Say, where on GitHub is, was, or has that been proposed? I saw "Source-1-Games"
}!{enR May 7, 2015 @ 9:04am 
You actually can just copy the base files (from any game that is using them, I think) in a separate directory and just symlink all the games there (as has been proposed on a GitHub).