Compiling under VS2010
Compiling with Visual Studio C++ 2010
Visual Studio 2010 has a lot of great features, unfortunately there's not a lot of support for it yet (it is in beta after all). It takes a fair amount of tweaking to get it working, and your debug DLLs compiled from Visual Studio 2010 will not work - you MUST use release DLLs.
Opening Your Mod
Once you've created your mod, open up Visual Studio and go to File -> Open -> Project\Solution. Navigate to your mod's source directory and open up Game_Episodic-2005.sln. It will ask if you want to convert it, do so. If it's a new mod don't bother choosing the back it up option.
Fixing Compilation
As mentioned above, YOU CANNOT USE DEBUG DLLS with Visual Studio 2010. They will compile but the game will refuse to load them. This means you'll be doing all your work in Release configuration. Up near the top of your Visual Studio window you'll see a drop down box saying Debug, change that to Release. Now to get your solution to compile you'll have to go through a few steps.
- Follow the Fix Debug Compilation step from this tutorial.
- Right click on Client_Episodic and go to Properties. Go to Configuration Properties->General and change Target Name to client.
- Right click on Server_Episodic and go to Properties. Go to Configuration Properties->General and change Target Name to server.
- Right click on Client_Episodic and go to Properties. Go to Custom Build Step. If you click on Command Line a drop down arrow will appear. Click that and go to <Edit...>. Make the appropriate changes to the following code based on your mod location/name and insert them here:
if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.dll" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.dll"
if exist "$(TargetDir)client.dll" copy "$(TargetDir)client.dll" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"
if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb"
if exist "$(TargetDir)client.pdb" copy "$(TargetDir)client.pdb" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"
- Right click on Server_Episodic and go to Properties. Go to Custom Build Step. If you click on Command Line a drop down arrow will appear. Click that and go to <Edit...>. Make the appropriate changes to the following code based on your mod location/name and insert them here:
if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\server.dll" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\server.dll"
if exist "$(TargetDir)server.dll" copy "$(TargetDir)client.dll" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"
if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb"
if exist "$(TargetDir)client.pdb" copy "$(TargetDir)client.pdb" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"
There are times when Visual Studio won't copy your DLLs and PDBs over to the ...\SourceMods\<MODNAME>\bin\ directory even after it's compiled changes in your code. If this happens just delete the contents of ...\SourceMods\<MODNAME>\bin\ and rebuild your solution, or just move them yourself. Either way works.
Fixing Warnings
You're going to be stuck with at least one warning during compilation, but you can get rid of some of them. Open the following files in your Client_Episodic project (Source Files -> HL2 DLL) and move #include "cbase.h" up to the top of the includes:
- hud_locator.cpp
- hud_credits.cpp
- hud_flashlight.cpp
Next highlight both Client_Episodic and Server_Episodic from the main window, right click and go to Properties. Go to Configuration Properties->General and ensure that your configuration is set to release in the drop down window at the top. Change .\Release\ to Release\ (remove the .\) Click OK.
Running Your Mod
At this point you can continue from here then launch your mod through Visual Studio.