Difference between revisions of "Source SDK 2013"

From Valve Developer Community
Jump to: navigation, search
m (Removed the common errors section. The "solution" will make the error go away but it'll generate project files VS2010 Express can't open, thus confusing users more.)
Line 171: Line 171:
 
We recommend that you follow the conventions here as you add files for your own mod.
 
We recommend that you follow the conventions here as you add files for your own mod.
  
==Common Errors==
 
Common errors encountered in SDK 2013:
 
  
;<nowiki>"ERROR: Unable to find RegKey for .vcproj files in solutions."</nowiki> while generating project files
 
This can be fixed by going into the Registry Editor (Windows key + R(or Run) then typing in the box 'regedit' without quotes)
 
then for 32bit(x86) operating systems go to: '''''HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Projects''''' <br/>
 
for 64bit(x64) operating systems go to:<br/>'''''HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Projects'''''<br/>
 
Then in there you will see a bunch of numbers (eg. {60dc8134-eba5-43b8-bcc9-bb4bc16c2548}) find any key that has no keys in it(it should be empty but doesn't have to) and right-click on the selected key go to new > String Value and for the name put 'DefaultProjectExtension' without quotes and for the value put 'vcproj' without quotes.
 
  
  
 
[[Category:Source SDK FAQ]]
 
[[Category:Source SDK FAQ]]
 
[[Category:Modding]]
 
[[Category:Modding]]

Revision as of 21:05, 8 July 2013

To get started, you will need to grab the source code from the Valve Software Source SDK repository on GitHub. Then you will be able to build the software and then build great and wonderful mods!

Obtaining the Code

GitHub provides a number of ways to obtain and update the code. Here's a review of the main ways to get the code, but GitHub Help is a great resource to learn more about using Git and the added features of GitHub.

Via Repository

The easiest way to keep updated on the latest released code is to use Git to obtain the repository. Git itself is a CLI for all platforms, but GitHub also provides installers that install both the CLI version and a GUI to help manage your repositories.

GitHub Client (Windows & Mac)

  1. Obtain the GitHub client.
  2. Install the GitHub client.
  3. Visit the Source SDK 2013 repository in your browser and click the "Clone in Desktop" button.
    • This will open the GitHub client. Follow the instructions to clone the desktop onto your computer.

When you wish to update the code, you may do so by hitting the "Sync" or "Sync Branch" button in the repository.

Git CLI (All Platforms)

Detailed instructions on how to set up Git on any platform, including updating the repository, are provided by GitHub.

With the CLI installed, you can obtain the code using a line similar to this:

> git clone git@github.com:ValveSoftware/source-sdk-2013.git

Via Download

You may also download a ZIP bundle. This will give you the latest release, but you will need to manually download and update the code. If you also plan on contributing code back to the repository, you will need to follow the above Git instructions with a separate instance of your local files.

  1. Visit the Source SDK 2013 repository in your browser.
  2. Click the "Download ZIP" button.

Platform Specific Build Instructions

Creating Project & Makefiles

The 2013 SDK uses the Valve Project Creator (VPC) to generate platform-specific project files and makefiles. These files are platform specific an are required in order to build the SDK. Once you complete this step, there will be no need to run this step again unless an update requires new project files.

Windows

# Single Player Project
> <SDK_ROOT>/sp/src/creategameprojects.bat

# Multiplayer Project
> <SDK_ROOT>/mp/src/creategameprojects.bat

This step will create Visual Studio Project (.vcxproj) and Solution (.sln) files in the SRC directory.

Mac OS X & Linux

# Single Player Project
> <SDK_ROOT>/sp/src/creategameprojects

# Multiplayer Project
> <SDK_ROOT>/mp/src/creategameprojects

On Mac OS X, this will create both `.mak` and Xcode project files in the SRC directory.

On Linux, `.mak` will be generated in the SRC directory.

Information about VPC

For more information on how to use VPC, look at the scripts themselves or run the following command on any platform:

> <SDK_ROOT>/<gameType>/src/devtools/vpc /help

Note on Git Repository & Ignored Files

All these generated files from VPC are listed in the .gitignore file and ignored for commits in the repository. Individuals wanting to pull request changes should be aware of this while pushing changes.

Windows

Prerequisites

To build the Source SDK 2013 on Windows you will need Microsoft Visual Studio 2010 with Service Pack 1. It's also possible to use Visual Studio 2012 with the Visual Studio 2010 Express compiler by changing the project settings.

If you want to build the phonemeextractor project you will need to download SAPI 5.1 from Microsoft. We aren't able to ship the Speech SDK with the Source SDK. Just put the sapi51 directory under src/utils/ and phonemeextractor will be able to link.

Building

Remember to create project & make files first!

  1. Open the "everything" solution file for the project type you wish to make.
    • everything.sln
  2. Build the above solution.
  3. Open the solution file for the game you are building the mod for.
    • games.sln
  4. Build the above solution.

At this point you should have client.dll and server.dll to load with the Source Engine game you based the mod on.

Mac OS X

Environment & Tools Setup

Mac OS X, you will need Xcode 4.2 installed. You will also need to have "Command Line Tools" installed. You can find this at:

XCode Preferences -> "Downloads" -> "Components"

Building The Tools

Remember to create project & make files first!

To run the tools, run this command under Terminal:

> make -f games.mak

When successfully built, you should have client.dylib and server.dylib files to load with the Source SDK Base 2013 of your choice.

Linux

Steam Client Runtime

To build the Source SDK 2013 on Linux you will need the Steam Client Runtime.

  1. Download the Steam Client Runtime.
  2. Run the following commands to extract the runtime:
> tar xvf steam-runtime-sdk_latest.tar.xz
> cd steam-runtime-sdk_<version>

Replace <version> with the version you just unpacked.

> ./setup.sh

Pick your architecture and debug/release preferences. Then answer Y to everything else.

> ./shell.sh --arch=i386

SDK Build

Remember to create project & make files first!

With the above prerequisite installed, run the following:

> make -f games.mak

At this point you should have client.so and server.so files to load with the Source SDK Base 2013 of your choice. More instructions on using the Steam runtime can be found in README.txt in the installed runtime directory.

Code Organization

Naming Conventions

The Source SDK is split into two directories at the root for <gameType>, followed by source for <gameName>. If you are building a single player mod, use the "sp" directory. If you are building a multi-player mod you should base yourself on the code in the "mp" directory.

  • <gameType>
    • sp (singleplayer)
    • mp (multiplayer)
  • <gameName>
    • hl2 (Half-Life 2)
    • episodic (Half-Life 2 Episodes)
    • hl2mp (Half-Life 2: Deathmatch)

Each directory has a matching Source SDK 2013 Base appID to use to get the base mod files:

These two base apps are very similar, differing mostly in update schedule. The Singleplayer base will only update with HL2 and the Episodes do, which isn't very often. The Multiplayer base will update a few times a year to incorporate engine changes from TF2 and Counter-Strike: Source. None of these updates should break mod compatibility.

Directory Structure

Under each of these directories is a very similar directory structure:

  • game - Runtime files for the mods themselves. Your 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.

We recommend that you follow the conventions here as you add files for your own mod.