This article's documentation is for anything that uses the Source engine. Click here for more information.
This article relates to the software/tool "Source SDK". Click here for more information.

Setting up Source SDK Base 2013 Multiplayer: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(103 intermediate revisions by 34 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar|title=Setting up Source SDK 2013 - Multiplayer (TF2 branch)}}
|title=Source SDK 2013
{{source topicon}}{{Srcsdk topicon}}
|ru=Source SDK 2013:ru|es=Source SDK 2013:es|zh-cn=Source SDK 2013:zh-cn|ko=Source SDK 2013:ko}}
{{TabsBar|main=Source SDK Base}}
{{cleanup|OS X instructions are incomplete, the files cannot be possibly built due to the Windows dependencies, they need to be re-written from scratch. Shader build instructions are poorly written, not crossplatform friendly. Valve Project Creator instructions are incomplete.}}{{toc-right}}
{{For|setting up and compiling the Singleplayer SDK|[[Setting_up_Source_SDK_Base_2013_Singleplayer|see this page]]}}
{{cleanup|Some of the additional instructions (VPC, setting up tools) are incomplete. Otherwise, this article can be followed.}}{{toc-right}}
 
This tutorial walks you through creating a multiplayer mod for Source SDK Base 2013 Multiplayer, using the newest {{tf2branch|4}}. This branch includes the source code for Half Life 2: Deathmatch (<code>HL2MP</code> in the code) and Team Fortress 2. You can choose either game as the starting point for your mod.
 


'''Key points'''
'''Key points'''
{{Note|The Source SDK uses the [[Valve Project Creator|Valve Project Creator]] in order to generate the required platform specific files.}}
* 32-bit {{macOS|4|linkto=macOS}} is no longer supported by the Team Fortress 2 SDK. If you need to build macOS binaries, use the singleplayer or the legacy SDK 2013 MP codebases.
{{Note|If you want to create a simple, content-based mod, see [https://www.moddb.com/company/source-forever/downloads/source-sdk-2013-singleplayer-mod-template this fully-compiled template.]}}
{{Note|You can always edit code files with [http://notepad-plus-plus.org Notepad ++] or a similar program, and then compile under Visual Studio.}}
 
=Setting Up (All Platforms)=


==Setting up the Source SDK Base==
== Setting Up (All Platforms) ==
Install Source SDK Base 2013 (multiplayer or singleplayer depending on your mod) from Steam->Library->Tools or from the links below:
===<font size="4">Setting up the Source SDK Base</font>===
Install Source SDK Base 2013 Multiplayer from your {{steamicon|4.1}} library, you can use the search function or enable "Tools" in the filters, or from the links below:


* [steam://rungameid/243730 Install Source SDK Base 2013 (SP) Singleplayer] (AppID: 243730)
* [steam://rungameid/243750 Install/Run Source SDK Base 2013 (MP) Multiplayer] (AppID: 243750)
* [steam://rungameid/243750 Install Source SDK Base 2013 (MP) Multiplayer] (AppID: 243750)
{{Note|Despite it's name, this branch now runs on {{tf2branch|1}}, and mods built on {{src13mp|1}} are incompatible with this version (without switching to {{code|previous2021}} branch).}}


==Getting the code==


===Method one: Using the GitHub Desktop client (Windows/OS X)===
=== <font size="4">Getting the code</font> ===
==== <font size="3">Method 1: Using the GitHub Desktop client (Windows)</font> ====


# Download and install the [https://desktop.github.com/ GitHub Desktop] client
# Download and install the [https://desktop.github.com/ GitHub Desktop] client
# Open the [https://github.com/ValveSoftware/source-sdk-2013 Source SDK git repo] and click "Clone to desktop"
# Open the [https://github.com/ValveSoftware/source-sdk-2013 Source SDK Git repository] and click "Clone to desktop"


===Method two: Using the command line (Windows/OS X/Linux)===
{{Note|Since the February 2025 TF2 SDK release, the multiplayer version of the source code will be cloned by default. Use the <code>singleplayer</code> branch if you are developing for the older SDK 2013 SP branch. On older versions of the SDK 2013 source code, there will be two distinct directories for both multiplayer (<code>mp</code>) and singleplayer (<code>sp</code>).}}


# Download and install the git CLI. Linux users can download it with their distro's package manager (APT, Aptitude, DNF, Pacman, Synaptic...). Mac's users can download git [https://git-scm.com/downloads here].
====<font size="3">Method 2: Using the command line (Windows/Linux)</font>====
# Download and install the Git CLI. {{linux|4.1}} users can download it with their distro's package manager (APT, Aptitude, DNF, Pacman, Synaptic...). {{windows|4.1}} users can download Git [https://git-scm.com/downloads here].
# Open the terminal/command prompt and run this command:
# Open the terminal/command prompt and run this command:
<syntaxhighlight lang="batch">
git clone https://github.com/ValveSoftware/source-sdk-2013.git
</syntaxhighlight>


<pre>git clone https://github.com/ValveSoftware/source-sdk-2013.git</pre>
==Setting up (Platform Specific)==
 
==={{win|4.1}}===
===Method three: Downloading the ZIP archive===


{{Note|Note: You will need to update the code manually whenever changes are committed to the repo}}
====<font size="3">Step One: Installing requirements</font>====
Download from [https://github.com/ValveSoftware/source-sdk-2013/archive/master.zip here]
You will need to install [https://visualstudio.microsoft.com/vs/ Visual Studio 2022]. You don't need a Microsoft account to download the software but you may be prompted to log in with one when launching the software.


=Setting up (Platform Specific)=
During installation, Visual Studio Installer will ask you which workloads you want to install. You don't need to install everything, make sure that the "'''Desktop development with C++'''" workload is ticked otherwise your Visual Studio installation won't be able to do anything C/C++ related.
==Source SDK 2013 on Windows==


===Step One: Installing Visual Studio===
In terms of components, you will need:
{{Note|Although Source SDK 2013 currently does '''NOT''' compile with Visual Studio 2015 ([https://github.com/ValveSoftware/source-sdk-2013/issues/325 bug report]) you can still use VS 2015 as IDE and compile the code with the VS 2013 toolset.<br />
* C++ core features (you can't untick that one).
Just install both VS 2013 and 2015, open the solution in VS 2015, and skip the dialog where VS 2015 tries to upgrade your projects.}}
* Latest version of "MSVC++ v143 - VS 2022 x64/x86 build tools" (don't confuse with ARM ones, no need to grab "special versions" like the Spectre mitigated).
You can also compile without Visual Studio, or using a different version.
* The latest version of the Windows 10 or 11 SDK (for Windows 10, SDK build 10.0.19041.1; for Windows 11, 10.0.26100.1)
* '''Only if you want to support VScript:''' the latest version of [https://www.python.org/ Python] 3 (acquired from the official website or via the Microsoft Store), make sure it's in your "PATH" environment variable as well.


# Download and install [https://go.microsoft.com/fwlink/?LinkId=532495&clcid=0x409 Visual Studio 2013].
# Download and install the [https://download.microsoft.com/download/0/2/3/02389126-40A7-46FD-9D83-802454852703/vc_mbcsmfc.exe Multibyte MFC Library].
{{note|The Multibyte MFC Library add-on doesn't work with Visual Studio Express 2013. The add-on installer doesn't detect Visual Studio Express 2013 as an install because Visual Studio Express 2013 doesn't support MFC.}}


===Step Two: Installing the Microsoft Speech SDK===
====<font size="3">Step Two: Preparing the Project Files</font>====
# Download the [http://www.microsoft.com/en-us/download/confirmation.aspx?id=10121 Microsoft Speech SDK]
Source SDK uses the [[Valve Project Creator|Valve Project Creator (VPC)]] to generate the projects and the solution for Visual Studio.
# Extract install files and run <code>Microsoft Speech SDK 5.1.msi</code>
# Navigate to {{file|<path-to-git>\src\}} and open <code>createallprojects.bat</code>.<br>
# Copy <code>C:\Program Files (x86)\Microsoft Speech SDK 5.1</code> to <code><SDKROOT>\sp\src\utils</code> folder or <code><SDKROOT>\mp\src\utils</code> folder depending on your mod.
#By default, this batch script creates a solution called <code>everything.sln</code> which includes projects for HL2MP and TF2 simultaneously, as well as utlities ([[VBSP]], [[qc_eyes]]...). You probably wouldn't need all this, so we will modify this batch script to better suit our needs:   
# '''Make sure that your directory looks like this : \sp\src\utils\sapi51''' then should contain Bin Docs IDL etc. And not like this : \sp\src\utils\Microsoft Speech SDK 5.1\sapi51. If it's like the latter it will throw up error code 1 on compile.
====<font size="2.5">If you're creating a Team Fortress 2 mod:</font>====
# Open <code>'''sphelper.h'''</code> (located in : <code><SDKROOT>\sp\src\utils\sapi51\include</code>) and fix the following errors:
:* Replace the contents of <code>createallprojects.bat</code> with:<br>
:<syntaxhighlight lang="batch">devtools\bin\vpc.exe /tf /define:SOURCESDK +game /mksln games.sln</syntaxhighlight>
====<font size="2.5">If you're creating a Half Life 2: Deathmatch mod:</font>====
:* Replace the contents of <code>createallprojects.bat</code> with:<br>
:<syntaxhighlight lang="batch">devtools\bin\vpc.exe /hl2mp /define:SOURCESDK +game /mksln games.sln</syntaxhighlight>
====<font size="2.5">If you need the utilities (either game):</font>====
:* Replace <code>+game</code> with <code>+everything</code>.
:{{note|All of these utitlities are already compiled for you under {{file|Steam\steamapps\common\Source SDK Base 2013 Multiplayer\bin\x64\}}. Only use <code>+everything</code> if you need to modify their code.}}




'''Line 769''' :
3. Run <code>createallprojects.bat</code>. This will create a .sln file in the same directory.
<code>
    const size_t ulLenVendorPreferred = wcslen(pszVendorPreferred); // no size_t
</code>


'''Line 1418''' :
<code>
    static long CoMemCopyWFEX(const WAVEFORMATEX * pSrc, WAVEFORMATEX ** ppCoMemWFEX) // missing long
</code>


'''Line 2368''' :
====<font size="3">Step Three: Compiling and Running the Source SDK</font>====
<code>
# Open your solution file, either <code>games.sln</code> or <code>everything.sln</code>.
    const WCHAR * PropertyStringValue() const
# Select the solution, located under the '''Solution Explorer''' list, on the top bar, right next to the '''Debug''' drop down menu (the properties box/pane under the solution explorer), change '''Debug''' to '''Release'''.
    {
# Right Click on the solution, then select '''Build Solution'''.
        // Search for the first NULL and return pointer to the char past it.
{{Warning|When compiling on Windows 10 and 11 make sure you have unchecked "Use Unicode UTF-8 for worldwide language support". In order to disable it go to "Control Panel\Clock and Region", then click "Region" then "Administrative" tab and "Change system locale"}}
        SPDBG_ASSERT(eEventId == SPEI_PROPERTY_STRING_CHANGE);
        const WCHAR * psz = (const WCHAR *)lParam; // moved this from for init
        for (; *psz; psz++) {}
        return psz + 1;
    }
</code>


'''Line 2560''' :
For those who made the choice of not installing Python at the previous step, you will get compile errors when building the server binary because Python scripts that's supposed to generate some C/C++ files required by VScript couldn't be run due to the missing interpreter. The first part of the fix is to open <code>src/game/server/server_base.vpc</code> with the text editor of your choice and comment the entire <code>$CustomBuildStep "nut"</code> section. Re-run VPC ('''createallprojects.bat'''), if Visual Studio was opened and says that things changed outside of the editor, click the "Discard" button so that it reloads the local changes made by VPC. Re-select "Debug" or "Release" configuration and compile again. The remaining C/C++ errors can be fixed by commenting the code.
<code>
    SPPHONEID* pphoneId = (SPPHONEID*)((WCHAR *)dsPhoneId); // improper casting
</code>


'''Line 2634''' :
{{Note|{{clr}}
<code>
* If something fails at the end, then simply rebuild the solution.
    pphoneId += wcslen((const wchar_t *)pphoneId) + 1; // improper casting
* The '''client.dll''' is going to be generated in {{file|<path-to-git>\src\game\client\Release_mod_hl2mp</code> and <code><path-to-git>\src\game\client\Release_mod_tf}}
</code>
* The '''server.dll''' is going to be generated in {{file|<path-to-git>\src\game\server\Release_mod_hl2mp</code> and <code><path-to-git>\src\game\server\Release_mod_tf}}
* The post-build step automatically moves both dlls to {{file|<path-to-git>\'''game'''\mod_hl2mp\bin\x64}} and {{file|<path-to-git>\'''game'''\mod_tf\bin\x64}}, which is where they need to reside when you distribute your mod.
}}


===Step Three: Compiling the Source SDK and preparing project files===
# Navigate to <code><path-to-git>\sp\src\</code> and run '''createallprojects.bat''' and '''creategameprojects.bat'''
# Navigate to <code><path-to-git>\mp\src\</code> and run '''createallprojects.bat''' and '''creategameprojects.bat'''
{{Note|The '''Everything''' solution also contains the '''Game''' solutions along with other tools.}}
# Open '''everything.sln''' for the desired mode (Singleplayer or Multiplayer).
# Select the '''everything''' solution, located under the '''Solution Explorer''' list, then from the middle menu, right next to the '''Auto''' drop down menu (the properties box/pane under the solution explorer), change '''Debug''' to '''Release'''.
# Right Click on the '''everything''' solution, then select '''Build Solution'''.


'''Notes'''
If the code compiles successfully, you can press {{key|F5}} or click 'local windows debugger' to test your mod from Visual Studio. Make sure the client project is the startup project by right clicking on either '''Client (TF)''' or '''Client (HL2MP)''' and selecting "Set as Startup Project." You can hide projects you don't need by right clicking on them in the Solution Explorer and selecting 'Unload Project.'
<br>
{{Note|If something fails at the end, then simply rebuild the solution.}}
{{Note|The '''client.dll''' is going to be generated in <code><path-to-git>\sp\src\game\client\Release_mod_hl2</code> and <code><path-to-git>\sp\src\game\client\Release_mod_episodic</code>}}
{{Note|The '''server.dll''' is going to be generated in <code><path-to-git>\sp\src\game\server\Release_mod_hl2</code> and <code><path-to-git>\sp\src\game\server\Release_mod_episodic</code>}}
{{Note|The current Singleplayer branch will crash on startup, unless you are using the beta-branch of the Source SDK Base 2013. In Steam, go to Tools > Source SDK Base 2013 Singleplayer, right click > Properties > Betas to opt into the beta. This requirement will go away in the very near future. Without the beta, you get two popups about "Entry Point Not Found" in hl2.exe, and then the debugger breaks on engine.dll}}


===Step Four : Building the shaders===
See [[Source SDK 2013: Shader Authoring]].


==Source SDK 2013 on OS X==
====<font size="3">Optional Steps</font>====
These steps are not required for compiling the game DLLs, these are only prerequisites for compiling these specific projects:


===Step One : Requirements===
=====<font size="2.5">Building the shaders</font>=====
# Get OS X Mavericks which is capable of running on a Virtual Machine.
:See [[Source SDK 2013: Shader Authoring]].
# Install [https://developer.apple.com/downloads/more Xcode 5.0.2 (requires an Apple Developer ID account)].
# You will also need to have the "Command Line Tools" installed. You can find this in Xcode ''Preferences -> Downloads -> Components'' window.


{{Note|If you're trying to use a later macOS/Xcode combination, you should modify the <code>src/devtools/base.xcconfig</code> file in order to generate more compatible project settings (the most important one being <code>SDKROOT</code> at the end).}}
=====<font size="2.5">qc_eyes</font>=====
# Download and install the [https://download.microsoft.com/download/0/2/3/02389126-40A7-46FD-9D83-802454852703/vc_mbcsmfc.exe Multibyte MFC Library].
{{note|The Multibyte MFC Library add-on doesn't work with Visual Studio Express 2013. The add-on installer doesn't detect Visual Studio Express 2013 as an install because Visual Studio Express 2013 doesn't support MFC.}}


{{Warning|If you are using macOS Mojave or higher, building the Source SDK 2013 source code will be highly complicated due to Apple deprecating the 32 bits architecture. You will get an error/warning about updating the <code>ARCHS</code> variable in Xcode to be something else than <code>i386</code>.}}
=====<font size="2.5">phonemeextractor</font>=====
# Download a [https://github.com/Electromaster232/ms-sapi51-fixed/archive/master.zip ZIP of the Speech SDK]{{note|Microsoft has removed the Speech SDK download page. The link above will download a ZIP of the SDK's contents, including code fixes made by the SDK2013CE community that were previously documented on this page.}}
# Extract the ZIP Archive, and copy the sapi51 folder to the <code><SDKROOT>\src\utils</code> folder.


===Step Two : Generating the Xcode projects===
{{note|Mounting it now may generate the error <code>unresolved symbol _IID_IspPhoneticAlphabetSelection</code>. This is perhaps because you already had something mounted and the partial build is broken. This issue can be easily fixed by rebuilding the <code>phonemeextractor</code>}}
Run the following scripts to generate project files.
{{Note|You'll only need to run the scripts for the base gamemodes you're creating a mod for; ''sp'' for single player and ''mp'' for multiplayer}}
<pre>
cd <SDK_ROOT>/sp/src
./createallprojects
./creategameprojects
cd <SDK_ROOT>/mp/src
./createallprojects
./creategameprojects
</pre>


'''games.xcodeproj''' and '''everything.xcodeproj''' will be generated in the <code>src</code> folder.
==={{linux|4.1}}===
====<font size="3">Step One: Introduction</font>====


===Step Three : Building===
By default, Steam on Linux and everything on top of it (games, apps...) runs through a sand-boxed environment called the Steam Runtime. It is basically a stripped down Ubuntu installation with the necessary stuff (drivers, libraries...) required to run Steam itself and games.
To compile the tools, server and client libraries open '''everything.xcodeproj''' and '''games.xcodeproj''' in Xcode and build the projects (''Product -> Build'').
{{Note|Using a more modern environment will yield some errors when compiling.}}


===Step Four : Binaries===
Valve recommends that everything destined to be run on Linux and more specifically Steam is built and running through this runtime. Building "natively" is heavily discouraged as there are no guarantees that the build will be a success (especially with modern C/C++ toolchains) and your mod might not run perfectly.
When successfully built, <code>client.dylib</code> and <code>server.dylib</code> will be created and ready to use with the desired Source SDK Base 2013 branch (singleplayer or multiplayer).


==Source SDK 2013 on Linux==
In the past, Valve used the "chroot environment" technique for the Steam Runtime. However, they changed and recommend the usage of containers based solutions like Podman and Docker. Source SDK 2013's updated code has been compiled with the third version of the Steam Runtime (codenamed "sniper") and we will be doing the same.
{{TODO|Add instructions for building with the latest Steam Runtime.}}
{{Note|Due to the usage of the Steam Client Runtime, a Debian based Linux distribution (Linux Mint, Ubuntu...) is recommended. Arch Linux based distributions (Antergos, Manjaro...) seems to work as well. You can take the risk of trying with another GNU/Linux distribution but keep in mind that you will have to adapt the commands and this tutorial may fail.}}


===Step One: Getting the basic C/C++ development tools===
{{Note|This guide has been written and tested on an Ubuntu 22.04.4 LTS (Jammy Jellyfish) virtual machine. If you want to use anything else (ArchLinux, Debian, Gentoo, Linux Mint...), you take the responsibility of adapting the instructions and commands as needed (as well as the factor that it might not work due to system differences and such).}}
You should already have these, but to be sure, you can run the following command in a terminal:


<pre>
====<font size="3">Step Two: Requirements</font>====
sudo apt-get install build-essential
</pre>


AMD64 (64 bits) users will need to download and install additional packages to target the i386 (32 bits) architecture, this can be done with this command in a terminal:
Any operating system capable of running [https://podman.io/ Podman] will do the job. Ubuntu has a package so you can easily download it with <code>apt install podman</code> (use <code>apt-get</code> instead if you're working on a CI/CD pipeline or remotely when you don't have a "fancy" terminal).


<pre>
{{Note|If you're getting "permission denied" while running the command, remember the "magic word" at the beginning: <code>sudo</code>.}}
sudo apt-get install gcc-multilib g++-multilib
</pre>


===Step Two: Preparing the Source SDK 2013===
Next, you need the Source SDK 2013 source code cloned. It is assumed that a non-modified copy is used, if you need to clone the source code, the instructions are at the top of this page.
Assuming you have already cloned the Source SDK 2013 through Git (or downloaded the ZIP file), just run the following commands (by replacing [SDK_ROOT] by the location of the Source SDK 2013, [GAME] by "sp" or "mp" depending on your mod and [SCRIPT] by either "./createallprojects" or "./creategameprojects"), go into :


<pre>
====<font size="3">Step Three: Building the binaries</font>====
cd [SDK_ROOT]/[GAME]/src
[SCRIPT]
</pre>


Depending on the script you ran, you will have a master Makefile called '''games.mak''' or '''everything.mak''' that will be generated in the <code>src</code> folder.
All you have to do is run the <code>$SDK_ROOT/src/buildallprojects</code> shell script (you can also <code>cd src</code> first then <code>./buildallprojects</code> if you prefer), <code>$SDK_ROOT</code> means where you have cloned the source code earlier. By default, you will be building "release" binaries, if you want "debug" binaries instead, simply add <code>debug</code> after <code>buildallprojects</code> (don't forget a space in-between).


===Step Three: Downloading, installing, setting up the Steam Client Runtime===
If you're getting an error that involves "invalid mount point", open the <code>sdk_container</code> shell script with a text editor and find the <code>--mount</code> arguments of the <code>podman run</code> command. You should see some <code>\"</code> characters lying around, remove those but be careful not to remove the rest.


The Steam Client Runtime will help you guarantee compatibility with most GNU/Linux distributions. It is recommended to install it in "/valve/steam-runtime", if you don't like this and wish to install the Steam Client Runtime elsewhere: symbolic link is your friend. We are going to assume you want to do the first option.
Another error you might get is about the <code>.ccache</code> folder being missing in your "home" folder. Creating the folder simply fixes it (<code>mkdir $HOME/.ccache</code>).
Run the following commands in a terminal, make sure to replace "[USER]" by your login and "[GROUP]" by your group name:


<pre>
Binaries should now be built and available assuming everything went fine. If you want to know how the compile process works exactly, look at <code>buildallprojects</code> and <code>sdk_container</code> shell scripts.
cd /
sudo mkdir valve
cd valve
sudo wget http://media.steampowered.com/client/runtime/steam-runtime-sdk_latest.tar.xz
sudo tar xvf steam-runtime-sdk_latest.tar.xz
sudo mv steam-runtime-sdk_2013-09-05 steam-runtime
sudo chown <USER>:<GROUP> * -R
</pre>


Run the "./setup.sh" script in the "steam-runtime" directory, select the "i386" architecture and one configuration of your choice, say "Yes" to everything related to updates.
===Setting up on Steam===
See [[Setup mod on Steam]].


Before compiling the SDK, you have to run the sandbox (chroot environement), this is done by running the "./shell.sh --arch=i386" script.
==Other information==
 
===Step Four: Time to compile===
 
{{Note|If you're on Arch Linux, you'll have to install the <code>[https://aur.archlinux.org/packages/dpkg/ dpkg]</code> AUR package to compile the game.}}
 
In a terminal (like always), "cd" into the "sp" (singleplayer) or "mp" (multiplayer) directory of the SDK and the "src" directory, just run the following command to compile (replace [MAKEFILE] by "games.mak" or "everything.mak" depending on the one available to you):
 
make -f [MAKEFILE].mak
 
If everything went well, you should have the "client.so" and "server.so" files in the "game" directory to load with the appropriate Source SDK Base 2013. You can get more instructions on using the Steam Client Runtime by reading the "README.txt" file in the installed runtime directory.
 
{{Note|If you have an error about "objcopy", edit the "devtools/gendbg.sh" file and change the "OBJCOPY" variable so it points to the default "objcopy" program, usually found at <code>/usr/bin/objcopy</code>.}}
 
{{Note|If you extracted Steam Runtime in directory other than <code>/valve/steam-runtime</code>, specify <code>STEAM_RUNTIME_PATH</code> environment variable specifying path to extracted runtime before running make.}}
 
==Setting up on Steam==
See [[Setup_mod_on_steam|Setup mod on steam]].
 
=Other information=
<!-- Explain how to launch this command
<!-- Explain how to launch this command
== Information about VPC ==
=== Information about VPC ===
For more information on how to use [[Valve Project Creator|VPC]], look at the scripts themselves or run the following command on any platform:
For more information on how to use [[Valve Project Creator|VPC]], look at the scripts themselves or run the following command on any platform:
  > ''<SDK_ROOT>''/''<gameType>''/src/devtools/bin/vpc /help -->
  > ''<SDK_ROOT>''/''<gameType>''/src/devtools/bin/vpc /help -->


== Adding new files with the [[Valve Project Creator]] ==
=== Adding new files with the [[Valve Project Creator]] ===
# Add instructions on how to here.
# Add instructions on how to here.
# Open '''hl2.vpc''' with a text editor and edit this line or something.
# Open '''hl2.vpc''' with a text editor and edit this line or something.
VPC generates project files for all of the platforms that the SDK supports, so if you want to add files to your project in a way that will allow you to easily build on other platforms, consider using VPC.  For example, to add a file to a multiplayer game, you could add a line to src/game/client/client_hl2mp.vpc.
VPC generates project files for all of the platforms that the SDK supports, so if you want to add files to your project in a way that will allow you to easily build on other platforms, consider using VPC.  For example, to add a file to a multiplayer game, you could add a line to src/game/client/client_hl2mp.vpc.


== Directory structure ==
=== Directory structure ===


<ul>
<ul>
Line 237: Line 170:
</ul>
</ul>


=Troubleshooting=
==See also==
===Unable to find RegKey for .vcproj files in solutions (Windows)===
* Install and update Visual Studio 2013. See [[Source SDK 2013#Source SDK 2013 on Windows|Source SDK 2013 on Windows (Step One)]].
 
Or if you don't feel like downgrading to VS2013 you can try this alternative solution and see if works for you.
{{Warning|Editing the Windows registry is dangerous. Changing something you don't know can break the Windows OS.}}
 
* As Found in the [https://github.com/ValveSoftware/source-sdk-2013/issues/72 GitHub repository comments] One of the ways that the issue can be solved is like this:
:Go to the windows registry editing 'regedit.exe' and navigate to:
::<pre> HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\Projects\{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} </pre>
:Add the "'''project'''" and "'''{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}'''" registry keys if they don't already exist.
:#Once inside, add a string key and name it '''DefaultProjectExtension'''.
:#Right click on it and go into 'Modify'
:#Set the data to '''vcproj''' and cick ok.
Once You finish It should look like this:
:https://i.imgur.com/aCD4DLV.png
Now try run the .bat again and your .sln file should generate without issue!
 
===MSB8008: Specified platform toolset (v120_xp) or (v120) is not installed or invalid (Windows)===
# '''Select all Project Files'''
# Right-click on the file, then choose '''"Properties"'''
# Choose '''"Configuration Properties"'''
# Under '''"Platform toolset"'''  this -> '''(v100)'''
 
(Project->Properties->Configuration Properties->General->Platform toolset = Visual Studio 2010(v100))
 
===Issues with "min" or "max" from Steam Runtime when Compiling on Linux===
 
If you get any issues mentioning "min" or "max" while compiling on Linux, it is because you are including something that references the STL, and Valve's macros for min and max are conflicting with it.
 
Usually GCC is pretty good about telling you which files in particular are erroring.
 
Go to those files, and surround the erroneous includes with:
<pre>
#include "tier0/valve_minmax_off.h"
<your include that uses STL>
#include "tier0/valve_minmax_on.h"
</pre>
 
This should allow you to compile. Make sure to only wrap the includes that are using the STL, as other, game-related includes may require the Valve min/max macro defines!
 
=See Also=
 
* [[Programming]]
* [[Programming]]
[[Category:Programming]]
[[Category:Programming]]
Sawarin Trilakiet [088232217092]
[[Category:Source SDK FAQ]]
[[Category:Source SDK FAQ]]
[[Category:Modding]]
[[Category:Modding]]
[[Category:SDK 2013]]
[[Category:SDK 2013]]

Latest revision as of 04:46, 4 July 2025

English (en)Deutsch (de)Español (es)한국어 (ko)Português do Brasil (pt-br)Русский (ru)中文 (zh)Translate (Translate)

edit
For setting up and compiling the Singleplayer SDK, see see this page.
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
Some of the additional instructions (VPC, setting up tools) are incomplete. Otherwise, this article can be followed.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

This tutorial walks you through creating a multiplayer mod for Source SDK Base 2013 Multiplayer, using the newest Team Fortress 2 branch Team Fortress 2 branch. This branch includes the source code for Half Life 2: Deathmatch (HL2MP in the code) and Team Fortress 2. You can choose either game as the starting point for your mod.


Key points

  • 32-bit macOS macOS is no longer supported by the Team Fortress 2 SDK. If you need to build macOS binaries, use the singleplayer or the legacy SDK 2013 MP codebases.

Setting Up (All Platforms)

Setting up the Source SDK Base

Install Source SDK Base 2013 Multiplayer from your Steam Steam library, you can use the search function or enable "Tools" in the filters, or from the links below:

Note.pngNote:Despite it's name, this branch now runs on Team Fortress 2 branch, and mods built on Source 2013 Multiplayer are incompatible with this version (without switching to previous2021 branch).


Getting the code

Method 1: Using the GitHub Desktop client (Windows)

  1. Download and install the GitHub Desktop client
  2. Open the Source SDK Git repository and click "Clone to desktop"
Note.pngNote:Since the February 2025 TF2 SDK release, the multiplayer version of the source code will be cloned by default. Use the singleplayer branch if you are developing for the older SDK 2013 SP branch. On older versions of the SDK 2013 source code, there will be two distinct directories for both multiplayer (mp) and singleplayer (sp).

Method 2: Using the command line (Windows/Linux)

  1. Download and install the Git CLI. Linux Linux users can download it with their distro's package manager (APT, Aptitude, DNF, Pacman, Synaptic...). Windows Windows users can download Git here.
  2. Open the terminal/command prompt and run this command:
git clone https://github.com/ValveSoftware/source-sdk-2013.git

Setting up (Platform Specific)

Windows Windows

Step One: Installing requirements

You will need to install Visual Studio 2022. You don't need a Microsoft account to download the software but you may be prompted to log in with one when launching the software.

During installation, Visual Studio Installer will ask you which workloads you want to install. You don't need to install everything, make sure that the "Desktop development with C++" workload is ticked otherwise your Visual Studio installation won't be able to do anything C/C++ related.

In terms of components, you will need:

  • C++ core features (you can't untick that one).
  • Latest version of "MSVC++ v143 - VS 2022 x64/x86 build tools" (don't confuse with ARM ones, no need to grab "special versions" like the Spectre mitigated).
  • The latest version of the Windows 10 or 11 SDK (for Windows 10, SDK build 10.0.19041.1; for Windows 11, 10.0.26100.1)
  • Only if you want to support VScript: the latest version of Python 3 (acquired from the official website or via the Microsoft Store), make sure it's in your "PATH" environment variable as well.


Step Two: Preparing the Project Files

Source SDK uses the Valve Project Creator (VPC) to generate the projects and the solution for Visual Studio.

  1. Navigate to 🖿<path-to-git>\src\ and open createallprojects.bat.
  2. By default, this batch script creates a solution called everything.sln which includes projects for HL2MP and TF2 simultaneously, as well as utlities (VBSP, qc_eyes...). You probably wouldn't need all this, so we will modify this batch script to better suit our needs:

If you're creating a Team Fortress 2 mod:

  • Replace the contents of createallprojects.bat with:
devtools\bin\vpc.exe /tf /define:SOURCESDK +game /mksln games.sln

If you're creating a Half Life 2: Deathmatch mod:

  • Replace the contents of createallprojects.bat with:
devtools\bin\vpc.exe /hl2mp /define:SOURCESDK +game /mksln games.sln

If you need the utilities (either game):

  • Replace +game with +everything.
Note.pngNote:All of these utitlities are already compiled for you under 🖿Steam\steamapps\common\Source SDK Base 2013 Multiplayer\bin\x64\. Only use +everything if you need to modify their code.


3. Run createallprojects.bat. This will create a .sln file in the same directory.


Step Three: Compiling and Running the Source SDK

  1. Open your solution file, either games.sln or everything.sln.
  2. Select the solution, located under the Solution Explorer list, on the top bar, right next to the Debug drop down menu (the properties box/pane under the solution explorer), change Debug to Release.
  3. Right Click on the solution, then select Build Solution.
Warning.pngWarning:When compiling on Windows 10 and 11 make sure you have unchecked "Use Unicode UTF-8 for worldwide language support". In order to disable it go to "Control Panel\Clock and Region", then click "Region" then "Administrative" tab and "Change system locale"

For those who made the choice of not installing Python at the previous step, you will get compile errors when building the server binary because Python scripts that's supposed to generate some C/C++ files required by VScript couldn't be run due to the missing interpreter. The first part of the fix is to open src/game/server/server_base.vpc with the text editor of your choice and comment the entire $CustomBuildStep "nut" section. Re-run VPC (createallprojects.bat), if Visual Studio was opened and says that things changed outside of the editor, click the "Discard" button so that it reloads the local changes made by VPC. Re-select "Debug" or "Release" configuration and compile again. The remaining C/C++ errors can be fixed by commenting the code.

Note.pngNote:
  • If something fails at the end, then simply rebuild the solution.
  • The client.dll is going to be generated in 🖿<path-to-git>\src\game\client\Release_mod_hl2mp and <path-to-git>\src\game\client\Release_mod_tf
  • The server.dll is going to be generated in 🖿<path-to-git>\src\game\server\Release_mod_hl2mp and <path-to-git>\src\game\server\Release_mod_tf
  • The post-build step automatically moves both dlls to 🖿<path-to-git>\game\mod_hl2mp\bin\x64 and 🖿<path-to-git>\game\mod_tf\bin\x64, which is where they need to reside when you distribute your mod.


If the code compiles successfully, you can press F5 or click 'local windows debugger' to test your mod from Visual Studio. Make sure the client project is the startup project by right clicking on either Client (TF) or Client (HL2MP) and selecting "Set as Startup Project." You can hide projects you don't need by right clicking on them in the Solution Explorer and selecting 'Unload Project.'


Optional Steps

These steps are not required for compiling the game DLLs, these are only prerequisites for compiling these specific projects:

Building the shaders
See Source SDK 2013: Shader Authoring.
qc_eyes
  1. Download and install the Multibyte MFC Library.
Note.pngNote:The Multibyte MFC Library add-on doesn't work with Visual Studio Express 2013. The add-on installer doesn't detect Visual Studio Express 2013 as an install because Visual Studio Express 2013 doesn't support MFC.
phonemeextractor
  1. Download a ZIP of the Speech SDK
    Note.pngNote:Microsoft has removed the Speech SDK download page. The link above will download a ZIP of the SDK's contents, including code fixes made by the SDK2013CE community that were previously documented on this page.
  2. Extract the ZIP Archive, and copy the sapi51 folder to the <SDKROOT>\src\utils folder.
Note.pngNote:Mounting it now may generate the error unresolved symbol _IID_IspPhoneticAlphabetSelection. This is perhaps because you already had something mounted and the partial build is broken. This issue can be easily fixed by rebuilding the phonemeextractor

Linux Linux

Step One: Introduction

By default, Steam on Linux and everything on top of it (games, apps...) runs through a sand-boxed environment called the Steam Runtime. It is basically a stripped down Ubuntu installation with the necessary stuff (drivers, libraries...) required to run Steam itself and games.

Valve recommends that everything destined to be run on Linux and more specifically Steam is built and running through this runtime. Building "natively" is heavily discouraged as there are no guarantees that the build will be a success (especially with modern C/C++ toolchains) and your mod might not run perfectly.

In the past, Valve used the "chroot environment" technique for the Steam Runtime. However, they changed and recommend the usage of containers based solutions like Podman and Docker. Source SDK 2013's updated code has been compiled with the third version of the Steam Runtime (codenamed "sniper") and we will be doing the same.

Note.pngNote:This guide has been written and tested on an Ubuntu 22.04.4 LTS (Jammy Jellyfish) virtual machine. If you want to use anything else (ArchLinux, Debian, Gentoo, Linux Mint...), you take the responsibility of adapting the instructions and commands as needed (as well as the factor that it might not work due to system differences and such).

Step Two: Requirements

Any operating system capable of running Podman will do the job. Ubuntu has a package so you can easily download it with apt install podman (use apt-get instead if you're working on a CI/CD pipeline or remotely when you don't have a "fancy" terminal).

Note.pngNote:If you're getting "permission denied" while running the command, remember the "magic word" at the beginning: sudo.

Next, you need the Source SDK 2013 source code cloned. It is assumed that a non-modified copy is used, if you need to clone the source code, the instructions are at the top of this page.

Step Three: Building the binaries

All you have to do is run the $SDK_ROOT/src/buildallprojects shell script (you can also cd src first then ./buildallprojects if you prefer), $SDK_ROOT means where you have cloned the source code earlier. By default, you will be building "release" binaries, if you want "debug" binaries instead, simply add debug after buildallprojects (don't forget a space in-between).

If you're getting an error that involves "invalid mount point", open the sdk_container shell script with a text editor and find the --mount arguments of the podman run command. You should see some \" characters lying around, remove those but be careful not to remove the rest.

Another error you might get is about the .ccache folder being missing in your "home" folder. Creating the folder simply fixes it (mkdir $HOME/.ccache).

Binaries should now be built and available assuming everything went fine. If you want to know how the compile process works exactly, look at buildallprojects and sdk_container shell scripts.

Setting up on Steam

See Setup mod on Steam.

Other information

Adding new files with the Valve Project Creator

  1. Add instructions on how to here.
  2. Open hl2.vpc with a text editor and edit this line or something.

VPC generates project files for all of the platforms that the SDK supports, so if you want to add files to your project in a way that will allow you to easily build on other platforms, consider using VPC. For example, to add a file to a multiplayer game, you could add a line to src/game/client/client_hl2mp.vpc.

Directory structure

  • game - Runtime files for the mods themselves. Any mod content will go in here.
  • src - All the source code for that kind of mod. The root of the src directory contains .sln or root level .mak files for building the source.
    • common - A few files used by the server and client DLLs
    • devtools - Scripts and utilities that are used to build the source. These are called by the makefiles and projects and you probably won't need to interact with them directly.
    • game - All of the source code for the DLLs.
      • client - Code used by client.dll (or client.dylib or client.so). There are also game-specific directories under here.
      • server - Code used by server.dll. There are also game-specific directories under here.
      • shared - Code used by both client.dll and server.dll.
    • gcsdk - A couple of tools used to build the DLLs.
    • lib - Binary versions of the libraries that the source code depends on. This is also the build target for vgui_controls, tier1, and mathlib.
    • mathlib - Math utilities used by the game.
    • public - Header files for all of the DLLs and libraries that are used by the game. Also includes a few source files.
    • thirdparty - Third party libraries needed to build the source. At the moment this contains only the Google Protocol Buffers (protobuf) library.
    • tier1 - Useful utility classes. Builds into tier1.lib
    • utils - Various development utilities
    • vgui2 - Source code for vgui_controls, which is used by client.dll.

See also