Installing and Debugging the Source Code/zh

From Valve Developer Community
Jump to: navigation, search

Source SDK 2013

Source SDK 2013

安装

  1. 启动Source SDK选择 Create a Mod. 见 Create a Mod 获得更多细节.
  2. 选择编译器
  3. 完成!可以先选择编写你的第一个实体来开始你的Mod制作。

在Linux上编译, 见 Compiling under Linux. 见 GitHub来获得最新代码

调试

调试 是一个人仔细检查程序内部工作的过程。它可以找到崩溃和其他错误的原因。

Windows

  1. 确保你是在 Debug 状态下工作,而并非是 Release.
  2. 在解决方案浏览器 (Microsoft Visual C++,也可以是Visual Studio),右击可用的项目 (加粗的) 并选择 Properties. 在Server或者Client上工作都没关系,但最好选择Client(HL2).
  3. 在弹出的窗口中的左栏中选择 Debugging
  4. 路径必须定位到使用的 SDK 版本. 例如 Source SDK 2013,单人模式模组的设置应该如下:
   Command:           C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\hl2.exe
   Command Arguments: -allowdebug -dev -sw -condebug -console -toconsole -game "C:\My_Mod\source-sdk-2013\sp\game\mod_hl2" +map my_map
   Working Directory: C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\
  1. 在调试前你必须解包所有的游戏资源到你的模组文件夹或者SDK里 (不低于 2006 版). 不然会白屏, 粉色控制台或者别的BUG! 这很重要. 你需要着色器 (白屏bug) ,从 Source SDK Base\vpks里获取,然后是 resources\ to Source SDK Base\hl2\ (修复目录字段) 最后是 Source SDK Base\platform (粉色控制台), 不要忘记t expressions\, 否则NPC不会动他们的嘴唇,以及别的东西 像是模型,材质之类,不要尝试使用不同的起源引擎模型除了来自你的SDK的,不然会有BUG

你任何时间都可以按下F5来调试.

Note.png注意: Visual Studio 2013 调试前可能会需要点击 “生成——重新生成解决方案”
Note.png注意:"Command Arguments"所定位的mod文件目录最好是 “项目——属性——配置属性——Build Events——Post-Build Events”中命令行所设置的,
Note.png注意:在点击调试时可能会弹出一个警告窗口,显示“找不到或打开PDB文件”,勾选不再显示,然后点击“确定”即可


Linux

(译者:没用过Linux,偷懒了 :D)

  1. Use the environment variable CFG=debug when running the command you normally use to generate the makefiles with the VPC script. (Run again with CFG=release to go back to producing release binaries.)
  2. Make and Install
  3. Open a terminal window and cd to the location of the executable you are running
  4. Perform gdb srcds_linux (or whatever the name is)
  5. Perform run <parameters> to start the program
  • On a crash ("segfault"), do bt ("backtrace") to see the callstack.
  • To break into the debugger, press Ctrl+C; to continue afterwards perform cont.
  • To set a breakpoint, do break <function>. See help breakpoint for more details.
  • To print an expression, do print <expr>.