Skip to content

Debugging in Visual Studio

Alex Lo edited this page Aug 13, 2014 · 3 revisions

No doubt, that if you are using Visual Studio, you will also want to debug using Visual Studio as well. It only makes sense and it makes your life a whole lot easier. Due to the way JKA was written, there are a few little snags that you need to over come before you can debug the code. So let's get debugging.

Setting it up

  1. Open up the OpenJK solution and then in the solution explorer, right-click the project you want to debug, and then click Properties. In the screenshot below, we've selected MP Client. It doesn't really matter which project you select, but MP Client made the most sense. Once you launch a program through Visual Studio, all the projects can code can be debugged.

  2. In the top left of this new dialog, select the Configuration drop down and select All Configurations. This will apply your next few changes to all of the build configurations.

  3. Select the Debugging option on the left, under Configuration Properties. In Command Arguments, you want to enter the following: +set fs_game OpenJK +set sv_pure 0 +set fs_basepath "C:/Games/JKA/GameData" +set r_fullscreen 0 You will want to change fs_basepath to be where you have the GameData folder on your own PC. Just make sure you don't have a slash at the end! You can also change fs_game, which is the mod folder to use when loading the game, from OpenJK to your own mod folder name. In Working Directory, enter the same path as you did for fs_basepath. Here's what it will look like: And then click the OK button.

  4. The last final step is to right-click the project you just changed and select Set as Startup Project. This will be explained in just a second...

Debugging

So you should all be set up to debug your code now. To debug your code, make sure have the build configuration set to Debug, and then press F5. Alternatively, you can choose Debug > Start Debugging.

A dialog might pop up that says your build is out of date and needs to be compiled. If this happens, press OK and it will build and then run the code.

You might still be wondering what the startup project is for. When you press F5, or start debugging, it will start debugging the program that is set to the startup project.