Ru/Installing and Debugging the Source Code

From Valve Developer Community
Jump to navigation Jump to search

Статья разъясняет основные действия по установке и debug'у исходного кода

Шаг за шагом

Запуск Create a Mod

  1. Из Steam'а запустите Source SDK и выберите Create a Mod.
  2. Здесь в принципе можно выбрать любой тип мода, но для примера выберите опцию Modify Half-Life 2 Single Player и нажмите Next.
  3. В верхнем текстовом окне введите путь к директории, в которой вы будете создавать мод. В этом туториале предполагается, что вы ввели C:\MyMod - просто для примера.
  4. В нижнем текстовом окне наберите имя вашего мода. Так будет называться папка внутри директории SteamInstallPath\SteamApps\SourceMods. В этом примере, для определенности, пусть имя будет MyMod.
  5. Нажмите кнопку Next. Create a Mod начнет переписывать файлы с исходным кодом на жесткий диск в указанную папку.
  6. Дождитесь, пока копирование не закончится.

Компиляция кода

Для общих сведений о компиляции обратитесь к статье Выбор компилятора

Более конкретная информация:

Note.pngПримечание:По умолчанию компиляция кода идет в режиме Debug. Чтобы запустить мод с отладочным dll, нажмите на имени мода в списке игр Steam правой кнопкой мыши, выберите Properties, и в Set Launch Options... добавьте параметр -allowdebug в конец (если там уже что-то есть; параметры разделяются пробелами). Вы можете переключиться на билд в режиме release (для распространения мода) в Configuration Manager.

На данный момент код лучше компилировать в VS2005. Скачать его можно здесь: http://www.microsoft.com/express/2005/

Пользователям VCE2005 понадобится предварительно скачать Windows SDK (Windows 2000 users: Platform SDK). Тем, кто работает в Visual Studio и VCE2008, это не нужно.

Debugging

Setup debugging parameters

Note.pngПримечание:This will only work if you have installed and launched the Source SDK Base.
  1. In the Solution Explorer window, right-click on the current project (the one in bold) and choose Properties.
  2. In the Property Pages dialog that appears, choose the Debugging item on the left-hand side.
  3. On the right-hand side, in the text control next to Command, enter C:\Steam\SteamApps\Username\source sdk base 2007\hl2.exe (adjusting the folder names given here to reflect your own Steam installation).
  4. Next to Command Arguments, enter -dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod" (where MyMod is the name of your mod you entered in the Create a Mod dialog).
  5. Next to Working Directory, enter C:\Steam\SteamApps\Username\source sdk base 2007 (adjusting the folder names given here to reflect your own Steam installation).
  6. Click the OK button.

Run in the debugger

  1. Important: after an SDK update, you must make sure to run whatever game you're editing through Steam once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger.
  2. Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance.
  3. If you get a warning that hl2.exe has no debugging information, ignore it.
  4. It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes!

Alternative : run-time attachment

  1. Start the mod using Steam
  2. Inside Visual Studio, Main Menu > Debug > Attach to Process...
  3. Select the hl2.exe process with the title of your mod
Tip.pngСовет:you can start the app in windowed mode for better comfort : add a "-window" option in your run_mod.bat

Links

A good next step after mastering this document is to look at the Your First Entity document, in which you will make changes to some of the source code.

If you plan to integrate code updates from Valve, and if you want code backups and revision history, take a look at the Using Source Control with the Source SDK document.

Template:Otherlang:ru Template:Otherlang:ru:en Template:Otherlang:ru:jp Template:Otherlang:ru:es Template:Otherlang:ru:fr