这篇条目有关 Source引擎。如需详情,点击这里。

Zh/Setting up Source SDK Base 2013 Multiplayer: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
No edit summary
m (Kr0tchet moved page Zh/Source SDK 2013 to Zh/Setting up Source SDK Base 2013 Multiplayer: moving page to make the SDK page redirects to (disambig?) page about SDK 2013 with links to setting up SDK on each sub branches.)
 
(20 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar}}
|title=Source SDK 2013:zh-cn
{{source topicon}}
|en=Source SDK 2013|ru=Source SDK 2013:ru|es=Source SDK 2013:es}}{{toc-right}}
{{toc-right}}
{{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.}}


'''Key points'''
'''关键点'''
{{Note:|Source SDK 使用 [[Valve Project Creator|Valve Project Creator]] 来创建针对各个平台的项目文件.}}
{{Note|Source SDK 使用 {{L|Valve Project Creator}} 来创建针对各个平台的项目文件.}}


=设置 Source SDK (所有平台)=
=设置 Source SDK (所有平台)=
Line 41: Line 40:
只要 VS 2013 和 2015 全都装上了, 在 VS 2015 里打开解决方案, 并且在 VS 2015 尝试升级你的项目的时候全部点跳过即可.}}
只要 VS 2013 和 2015 全都装上了, 在 VS 2015 里打开解决方案, 并且在 VS 2015 尝试升级你的项目的时候全部点跳过即可.}}


# 下载并安装 [https://go.microsoft.com/fwlink/?LinkId=532495&clcid=0x409 Visual Studio 2013].
# 下载并安装 [https://go.microsoft.com/fwlink/?LinkId=532495&clcid=0x409 Visual Studio 2013].('''此链接只能下到.exe, [https://archive.org/details/en_visual_studio_community_2013_with_update_5_x86_dvd_6816332 完整可安装版本]''')
# 下载并安装 [https://www.microsoft.com/en-gb/download/details.aspx?id=40770 Multibyte MFC Library].
# 下载并安装 [https://www.microsoft.com/en-gb/download/details.aspx?id=40770 Multibyte MFC Library].(非必须,用于编译qc_eyes)


===第二步: 安装 Microsoft Speech SDK===
===第二步: 安装 Microsoft Speech SDK===
Line 50: Line 49:
# 打开 <code>sphelper.h</code> 并且修复以下错误:
# 打开 <code>sphelper.h</code> 并且修复以下错误:
# 确保你的 \sp\src\utils\sapi51 这个文件夹包含 Bin Docs IDL 等文件/文件夹. 并且不像这样: \sp\src\utils\Microsoft Speech SDK 5.1\sapi51. 如果它像上文一样,编译的时候会报错误 1.
# 确保你的 \sp\src\utils\sapi51 这个文件夹包含 Bin Docs IDL 等文件/文件夹. 并且不像这样: \sp\src\utils\Microsoft Speech SDK 5.1\sapi51. 如果它像上文一样,编译的时候会报错误 1.




Line 84: Line 84:
</code>
</code>


===第三步: 编译你的 Source SDK 并且准备炫目文件===
{{note|如果觉得麻烦直接使用: [https://github.com/Electromaster232/ms-sapi51-fixed/archive/master.zip 修复后的解压即可用的Speech SDK]}}
 
===第三步: 编译你的 Source SDK 并且准备项目文件===
# 打开 <code><path-to-git>\sp\src\</code> 并且运行 '''createallprojects.bat''' 和 '''creategameprojects.bat'''
# 打开 <code><path-to-git>\sp\src\</code> 并且运行 '''createallprojects.bat''' 和 '''creategameprojects.bat'''
# 或者打开 <code><path-to-git>\mp\src\</code> 并且运行 '''createallprojects.bat''' 和 '''creategameprojects.bat'''
# 或者打开 <code><path-to-git>\mp\src\</code> 并且运行 '''createallprojects.bat''' 和 '''creategameprojects.bat'''
Line 98: Line 100:
{{Note|'''server.dll''' 将会编译到 <code><path-to-git>\sp\src\game\server\Release_mod_hl2</code> 和 <code><path-to-git>\sp\src\game\server\Release_mod_episodic</code> 这两个文件夹}}
{{Note|'''server.dll''' 将会编译到 <code><path-to-git>\sp\src\game\server\Release_mod_hl2</code> 和 <code><path-to-git>\sp\src\game\server\Release_mod_episodic</code> 这两个文件夹}}
{{Note|当前最后一个版本的 source SDK (0d8dceea) 会在启动时崩溃, 除非你使用 beta 版的 Source SDK Base 2013. 在 Steam 里, 定位到 工具 > Source SDK Base 2013 Multiplayer, 右键 > 属性 > 测试版本 来使用测试版本. 这会在将来成为必须的. 如果不使用 beta 版, 你会在打开 hl2.exe 的时候看到两个关于 "无法定位程序点" 的错误, 然后调试器将会在 engine.dll 上中断}}
{{Note|当前最后一个版本的 source SDK (0d8dceea) 会在启动时崩溃, 除非你使用 beta 版的 Source SDK Base 2013. 在 Steam 里, 定位到 工具 > Source SDK Base 2013 Multiplayer, 右键 > 属性 > 测试版本 来使用测试版本. 这会在将来成为必须的. 如果不使用 beta 版, 你会在打开 hl2.exe 的时候看到两个关于 "无法定位程序点" 的错误, 然后调试器将会在 engine.dll 上中断}}
===第四步===
===第四步===
请查看 [[Source SDK 2013: Shader Authoring]].
请查看 {{L|Source SDK 2013: Shader Authoring}}.
 
==Source SDK 2013 on OS X==
 
{{Note|下面的太懒了懒得翻}}
===Step One===
# Install [https://developer.apple.com/xcode/ Xcode 4.2].
# You will also need to have "Command Line Tools" installed. You can find this at Xcode ''Preferences -> Downloads -> Components''.
 
===Step Two===
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.
 
===Step Three===
To compile the tools, server and client libraries open '''everything.xcodeproj''' and '''games.xcodeproj''' in Xcode and build the projects (''Product -> Build'').
{{Note|For OS X 10.10 and above, you'll need to change the '''Base SDK''' to the latest SDK for all targets in both projects.}}
'''Notes'''
<br>
{{Note|When successfully built '''client.dylib''' and '''server.dylib''' will be created to load with the desired Source SDK Base 2013 (singleplayer or multiplayer).}}
 
==Source SDK 2013 on Linux==
{{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===
You should already have these, but to be sure, you can run the following command in a terminal:
 
<pre>
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:
 
<pre>
sudo apt-get install gcc-multilib g++-multilib
</pre>
 
===Step Two: Preparing the Source SDK 2013===
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>
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.
 
===Step Three: Downloading, installing, setting up the Steam Client Runtime===
 
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.
Run the following commands in a terminal, make sure to replace "[USER]" by your login and "[GROUP]" by your group name:
 
<pre>
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.
 
Before compiling the SDK, you have to run the sandbox (chroot environement), this is done by running the "./shell.sh --arch=i386" script.


===Step Four: Time to compile===
==macOS 上的 Source SDK 2013==
都用上 Mac 了你还是去看[[Source_SDK_2013#Source_SDK_2013_on_OS_X|英文版]]吧
==Linux 上的 Source SDK 2013==
你都是 Linux 大佬了为什么不看[[Source_SDK_2013#Source_SDK_2013_on_Linux|英文文档]]<br />
或者你可能还需要一份详细的 Linux 文档:[https://wiki.archlinux.org/index.php/Main_page_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) Arch Linux维基]


{{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.}}
==在 Steam 上设置mod==
请查看 {{L|Setup_mod_on_steam|Setup mod on steam}}.


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.}}
 
==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 {{L|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]] ==
== 通过{{L|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 ==
== 目录结构 ==


<ul>
<ul>
Line 226: Line 149:
</ul>
</ul>


=Troubleshooting=
=问题排除=
===Unable to find RegKey for .vcproj files in solutions (Windows)===
===找不到 .vcproj 文件的注册表键值 (Windows)===
* Install and update Visual Studio 2013. See [[Source SDK 2013#Source SDK 2013 on Windows|Source SDK 2013 on Windows (Step One)]].
* 安装并升级 Visual Studio 2013. 插件 [[Source SDK 2013#Windows上的Source SDK 2013|Windows上的Source SDK 2013 (第一步: 安装 Visual Studio)]].
 
===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===
Copy and paste the following lines:
<pre>
#undef min
#undef max
</pre>


to the beginning of the following files:
===MSB8008: 选择的平台工具及 (v120_xp) 或 (v120) 没有安装或安装错误 (Windows)===
<pre>
# '''选择所有项目文件'''
/valve/steam-runtime/amd64/i686-unknown-linux-gnu/i686-unknown-linux-gnu/include/c++/4.6.3/limits
# 在文件上右键, 选择 '''"属性"'''
/valve/steam-runtime/amd64/i686-unknown-linux-gnu/i686-unknown-linux-gnu/include/c++/4.6.3/bits/random.h
# 选择 '''"编辑属性"'''
/valve/steam-runtime/amd64/i686-unknown-linux-gnu/i686-unknown-linux-gnu/include/c++/4.6.3/bits/algorithmfwd.h
# 在 '''"平台工具集"''' 下面选择 '''(v100)'''
/valve/steam-runtime/amd64/i686-unknown-linux-gnu/i686-unknown-linux-gnu/include/c++/4.6.3/bits/stl_algobase.h
</pre>


[[Category:Source SDK FAQ]]
(项目->属性->编辑属性->基本->平台工具集 = Visual Studio 2010(v100))
[[Category:Modding]]
{{ACategory|Programming}}
[[Category:SDK 2013]]
{{ACategory|Source SDK FAQ}}
{{ACategory|Modding}}
{{ACategory|SDK 2013}}

Latest revision as of 05:08, 22 February 2025

English (en)Deutsch (de)Español (es)한국어 (ko)Português do Brasil (pt-br)Русский (ru)中文 (zh)Translate (Translate)
Info content.png
This translated page needs to be updated.
You can help by updating the translation.
Also, please make sure the article complies with the alternate languages guide.(en)
This notice is put here by LanguageBar template and if you want to remove it after updating the translation you can do so on this page.


关键点

Note.png注意:Source SDK 使用 Valve Project Creator(en) 来创建针对各个平台的项目文件.

设置 Source SDK (所有平台)

设置 Source SDK Base

从 Steam->库->工具 或从下面的链接安装 Source SDK Base 2013 (取决于你的 Mod 类型 安装 Multiplayer 或 Singleplayer)

获取源代码

方法一: 使用 Github 桌面客户端 (Windows/OS X)

  1. 下载并且安装 GitHub 桌面 客户端
  2. 打开 Source SDK git 仓库 并且单击 "Clone to desktop"

方法二: 使用命令行 (Windows/OS X/Linux)

  1. 这里 选择你的平台的对应版本后下载并安装 git.
  2. 打开 终端/命令提示符 并运行以下命令:
git clone https://github.com/ValveSoftware/source-sdk-2013.git

方法三: 下载 ZIP 压缩档

Note.png注意:注: 当仓库里的代码更新的时候你需要手动更新代码

这里 下载.

设置 Source SDK (特定平台)

Windows上的Source SDK 2013

第一步: 安装 Visual Studio

Note.png注意:尽管 Source SDK 2013 当前 不能 使用 Visual Studio 2015 (bug report) 编译,你依旧可以用 VS 2015 编写代码并且使用 VS 2013 的工具来编译.
只要 VS 2013 和 2015 全都装上了, 在 VS 2015 里打开解决方案, 并且在 VS 2015 尝试升级你的项目的时候全部点跳过即可.
  1. 下载并安装 Visual Studio 2013.(此链接只能下到.exe, 完整可安装版本
  2. 下载并安装 Multibyte MFC Library.(非必须,用于编译qc_eyes)

第二步: 安装 Microsoft Speech SDK

  1. 下载 Microsoft Speech SDK
  2. 解压安装文件执行 Microsoft Speech SDK 5.1.msi
  3. 取决于你的 Mod 类型,复制 C:\Program Files (x86)\Microsoft Speech SDK 5.1 里的东西到 <SDKROOT>\sp\src\utils\sapi51 或者 <SDKROOT>\mp\src\utils\sapi51.
  4. 打开 sphelper.h 并且修复以下错误:
  5. 确保你的 \sp\src\utils\sapi51 这个文件夹包含 Bin Docs IDL 等文件/文件夹. 并且不像这样: \sp\src\utils\Microsoft Speech SDK 5.1\sapi51. 如果它像上文一样,编译的时候会报错误 1.


769 行

   const size_t ulLenVendorPreferred = wcslen(pszVendorPreferred); // no size_t

1418 行

   static long CoMemCopyWFEX(const WAVEFORMATEX * pSrc, WAVEFORMATEX ** ppCoMemWFEX) // missing long

2368 行

   const WCHAR * PropertyStringValue() const
   {
       // Search for the first NULL and return pointer to the char past it.
       SPDBG_ASSERT(eEventId == SPEI_PROPERTY_STRING_CHANGE);
       const WCHAR * psz = (const WCHAR *)lParam; // moved this from for init
       for (; *psz; psz++) {}
       return psz + 1;
   }

2560 行

   SPPHONEID* pphoneId = (SPPHONEID*)((WCHAR *)dsPhoneId); // improper casting

2634行

   pphoneId += wcslen((const wchar_t *)pphoneId) + 1; // improper casting

Note.png注意:如果觉得麻烦直接使用: 修复后的解压即可用的Speech SDK

第三步: 编译你的 Source SDK 并且准备项目文件

  1. 打开 <path-to-git>\sp\src\ 并且运行 createallprojects.batcreategameprojects.bat
  2. 或者打开 <path-to-git>\mp\src\ 并且运行 createallprojects.batcreategameprojects.bat
Note.png注意:Everything 这个解决方案包含了 Game 这个解决方案和其他的工具.
  1. 打开 everything.sln,
  2. 打开 everything 解决方案,打开解决方案浏览器, 然后从中间的菜单菜单右边的自动下拉菜单,将Debug修改为Release
  3. everything 解决方案三右键, 然后选择 生成项目.

注意

Note.png注意:如果有些东西编译失败了只需要再重新编译一遍即可.
Note.png注意:client.dll 将会编译到 <path-to-git>\sp\src\game\client\Release_mod_hl2<path-to-git>\sp\src\game\client\Release_mod_episodic 这两个文件夹
Note.png注意:server.dll 将会编译到 <path-to-git>\sp\src\game\server\Release_mod_hl2<path-to-git>\sp\src\game\server\Release_mod_episodic 这两个文件夹
Note.png注意:当前最后一个版本的 source SDK (0d8dceea) 会在启动时崩溃, 除非你使用 beta 版的 Source SDK Base 2013. 在 Steam 里, 定位到 工具 > Source SDK Base 2013 Multiplayer, 右键 > 属性 > 测试版本 来使用测试版本. 这会在将来成为必须的. 如果不使用 beta 版, 你会在打开 hl2.exe 的时候看到两个关于 "无法定位程序点" 的错误, 然后调试器将会在 engine.dll 上中断

第四步

请查看 Source SDK 2013: Shader Authoring(en).

macOS 上的 Source SDK 2013

都用上 Mac 了你还是去看英文版

Linux 上的 Source SDK 2013

你都是 Linux 大佬了为什么不看英文文档
或者你可能还需要一份详细的 Linux 文档:Arch Linux维基

在 Steam 上设置mod

请查看 Setup mod on steam(en).

其他信息

通过Valve Project Creator(en)添加新文件

  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.

目录结构

  • 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.

问题排除

找不到 .vcproj 文件的注册表键值 (Windows)

MSB8008: 选择的平台工具及 (v120_xp) 或 (v120) 没有安装或安装错误 (Windows)

  1. 选择所有项目文件
  2. 在文件上右键, 选择 "属性"
  3. 选择 "编辑属性"
  4. "平台工具集" 下面选择 (v100)

(项目->属性->编辑属性->基本->平台工具集 = Visual Studio 2010(v100))