Compiling and modifying the SDK source code on Windows


(BackSnip3) #1

Hi,

I’ve had a bit of trouble with modifying and compiling the game’s source code for a mod so I thought I’ll just share this here, because the coding part of the ModWiki barely exists.

Of course first you need the retail game v1.5 with SDK.

Here is an absolutely necessary tutorial https://modwiki.xnet.fi/How_to_build_the_SDK_on_Windows.

It says that you need Visual Studio 2005 C++. What you need to know is that you need the full ISO version and not the Web Installer which needs you to register the product on a dead link after 30 days.
Here is the official ISO from Microsoft.

You can dismiss the compatibility warnings on Windows 8.1, it works fine (I suppose same for earlier Windows).

You also need to install the platform SDK for Windows Server 2003 like it is said in the tutorial.

After that you can open VS2005 and load the solution. It will not build yet, you will have errors.
What you have to do is to tell VS2005 to go look for the Platform SDK libraries.

You need to go to “Tools–>Options” then go in “Projects and Solutions–>VC++ Directories”.
In “include files” you need to add a new line pointing to where you installed The Windows Server 2003 platform SDK. For example :

C:\Program Files (x86)\Microsoft Platform SDK\Include

You need to do the same for “library files”.

C:\Program Files (x86)\Microsoft Platform SDK\Lib

At this point, the code should compile.
Now, the tutorial given at the beginning of this post tells you to do this :

You will need to add the following lines to ‘SDK 1.5/source/framework/BuildDefines.inc’:

#ifndef SD_PUBLIC_BUILD
    #define SD_PUBLIC_BUILD
#endif

Actually, you also need to #define SD_PUBLIC_TOOLS. If you don’t you will get an error dialog box about “wrong API_VERSION” when you try your code with the SDK exe.

So, my “BuildDefines.inc” file consists of this :

// Public defines go here 
#ifndef SD_PUBLIC_BUILD
	#define SD_PUBLIC_BUILD
#endif

#ifndef SD_PUBLIC_TOOLS
	#define SD_PUBLIC_TOOLS
#endif

To test that the DLL is actually loaded ingame, we will add one line of code in Game/Entity.cpp inside the spawn function (taken from here) :


// ...
/*
================
idEntity::Spawn
================
*/
void idEntity::Spawn( void ) {
	gameLocal.RegisterEntity( this );

	const char* classname = spawnArgs.GetString( "classname" );
	if ( *classname ) {
		
		const idDeclEntityDef *def = declHolder.declEntityDefType.LocalFind( classname, false );
		if ( def )
		{
			[B]gameLocal.Printf("Hello %s!
", classname);[/B]
			entityDefNumber = def->Index();
		}
	}
// ...
}
// ...

Now, your DLL is “SDK-ready”, you can build the code and get the DLL from the build output.

Now, you have to go to your SDK1.5 root folder and rename “gamex86.dll” to something unusable like “gamex86.dll.old” (to have a working backup).

Now, copy your freshly made DLL to the SDK1.5 root folder (to replace the old one that you have renamed).

This info is from the SDK readme.txt :

  • You can find the final gamex86.dll in source\build\win32<configuration name>
    Copy it to the same folder as your etqw.exe and the game will automatically load your new dll.
  • We recommend setting up a post-build event to automatically copy the dll to the game folder.

As suggested, you can use XCOPY or change the build output directory to avoid copying the DLL manually every time.

Now, you can use the SDK launcher to launch the game and, for example, launch the Valley map.

To display the console : Ctrl+Alt+~

Then you can set “com_allowconsole” to 1 so that later only “~” key will be needed to display/hide the console.

Now, in the console, type : “devmap valley”. You might need to set “si_rules” to “sdGameRulesObjective” if it doesn’t work because the game expects a campaign and not a single map by default.

Now, you can do : “spawn vehicle_husky” and see what happens.


As you can see, the message “Hello vehicle_husky!” appears in the console. It works! Wuhu!:stroggbanana:

I hope this helped you, if you have anything to add or any remarks, feel free to say it here!


(BackSnip3) #2

I’ve implemented double jump functionality in ETQW as a first test of “real new feature”.

//youtu.be/dJAJIteTnck

I will post modified source code if people are interested.


(Runeforce) #3

How does it works with the usual movement, like CSJ? Would like to see a video of that. :slight_smile:


(BackSnip3) #4

Sorry but…what does CSJ stand for?


(Mustang) #5

Circle Strafe Jumping


(BackSnip3) #6

Oh, like trickjump? I actually already changed a variable which prevented players from jumping more frequently than every 850ms. So now you can jump instantly after you land, so you do gain speed over time with the many jumps.


(Assassin4004) #7

Very neat BackSnip3! I tried compiling the files using Microsoft Visual 2010 a while ago and came to the conclusion that 2005 was needed but couldn’t get it working. I may have to revisit the code and try recompiling! :slight_smile: Do you know also how to do linux and mac builds? What made you want to play around with the source code? Thanks again for sharing your experience with this!


(BackSnip3) #8

I scratched my head for days with more recent versions of Visual Studio and I just gave up on it.
It compiles fine in VS2008 but then it crashes when I load a map. It won’t compile with 2010+, even when using old platform toolset.
I think you couldn’t figure it out because you didn’t have the windows SDK installed.
I really wanted it to work with VS2013 for the syntax highlighting and GitHub support but I can’t figure it out.
I haven’t tried compiling with Linux yet. I expect even more problems with it. I hope I’m wrong.
I haven’t got a mac so can’t try the mac build.

Well, I’m a student software engineer so I thought I should dig in some real code and thought of ETQW. Also because for the Wolf:MP mod we never had a programmer so I thought I’ll handle this part of the mod.
I’ll be glad if you started coding too, maybe we could achieve something cool!


(BackSnip3) #9

Found out something right now : I couldn’t launch a custom map from the SDK. It wouldn’t display it in the map list when I typed “map” or “devmap”.
This behavior only occurs with custom gamex86.dll. I wonder what else is broken…

To fix it, you need to add a map declaration in the SDK base folder in pakmeta.conf.

mapMetaData maps/test {  
	"pretty_name" "Test Map" 
}

As simple as this. I need to investigate more to know why it actually works without this using the shipped SDK DLL.


(BackSnip3) #10

//youtu.be/37ZfqPcnDdE


(KeMoN) #11

Nice videos, mate! Good to see you working again :wink:


(Assassin4004) #12

[QUOTE=BackSnip3;547457]Found out something right now : I couldn’t launch a custom map from the SDK. It wouldn’t display it in the map list when I typed “map” or “devmap”.
This behavior only occurs with custom gamex86.dll. I wonder what else is broken…

To fix it, you need to add a map declaration in the SDK base folder in pakmeta.conf.

mapMetaData maps/test {  
	"pretty_name" "Test Map" 
}

As simple as this. I need to investigate more to know why it actually works without this using the shipped SDK DLL.[/QUOTE]

(I used capslock below to emphasize important words, I am not yelling at you)

Are you saying that when you use the vanilla gamex86.dll and compile a CUSTOM map WITHOUT a pakmeta.conf, that you can run the custom map, but when you use a CUSTOM gamex86.dll and compile a CUSTOM map that you need a pakmeta.conf in order to run the custom map?

~Assassin4004


(BackSnip3) #13

Exactly. Can u test this behavior?


(BackSnip3) #14

Hi again,

I successfully built the SDK from Visual Studio 2015 by telling MSBuild to use the Visual Studio 2005 compiler.

Here is a .pdf with instructions.

Can anyone test the instructions and tell me if it is working for them? Thank you


(maggol) #15

Hi

I try to follow your tutorial, but it seems i don’t have microsoft sdk v6.0


Something i miss in following your tutorial?


(BackSnip3) #16

Hi,

Second person telling me this, I realise I wasn’t very clear in my wording…
You have to create the V6.0 key in the registry, then add a field in it called “InstallationFolder”. I hope that helps you. Tell me how it goes. Turns out you might need VS2010 as well and/or Visual Studio 2015 Enterprise (not community). Please let me know


(maggol) #17

[QUOTE=BackSnip3;548760]Hi,

Second person telling me this, I realise I wasn’t very clear in my wording…
You have to create the V6.0 key in the registry, then add a field in it called “InstallationFolder”. I hope that helps you. Tell me how it goes. Turns out you might need VS2010 as well and/or Visual Studio 2015 Enterprise (not community). Please let me know[/QUOTE]

Hi

Already add v6.0 key in my registry and found another problem,


i have no “platform folder” in my microsoft.cpp, any advice?


(BackSnip3) #18

This is what I feared…
I need to investigate more to know why this doesn’t work. I had same problem with Visual Studio 2013 pro. I think you need Visual Studio 2015 Enterprise version, or you need to have Visual Studio 2010 installed too to make it work (for some reason).
Also it seems you need to install the different Visual Studio versions in chronological order like 2005, then 2010 then 2015…
I’m sorry that it doesn’t work. Obviously I missed some steps that I don’t even remember of anymore :confused:


(maggol) #19

Ok. Haven’t try installing vs 2010 and vs 2015 enterprise edition is too expensive T_T, maybe i just need vs 2010, because i have installed 2005 and 2015 in chronological order. Plus, i have vs 2013 express edition installed. Gonna uninstall and reinstall those VSes.


(maggol) #20

Installed Vs 2010 and bam, there it is, a platform folder


And after following the tutorial again, i encountered this

1>------ Build started: Project: idLib, Configuration: Debug with edit and continue Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.

TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1> Lib.cpp
1>d:\sourcecode\etqw\idlib…/idlib/LibOS.h(66): fatal error C1083: Cannot open include file: ‘windows.h’: No such file or directory
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(57,5): error MSB6001: Invalid command line switch for “CL.exe”. Illegal

characters in path.
2>------ Build started: Project: libGameDecl, Configuration: Debug with edit and continue Win32 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.

TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
2> precompiled.cpp
2>d:\sourcecode\etqw\idlib\libos.h(66): fatal error C1083: Cannot open include file: ‘windows.h’: No such file or directory
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(57,5): error MSB6001: Invalid command line switch for “CL.exe”. Illegal

characters in path.
3>------ Build started: Project: game, Configuration: Debug with edit and continue Win32 ------
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.

TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
3> precompiled.cpp
3>d:\sourcecode\etqw\idlib\libos.h(66): fatal error C1083: Cannot open include file: ‘windows.h’: No such file or directory
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(57,5): error MSB6001: Invalid command line switch for “CL.exe”. Illegal

characters in path.
========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========

and this is the warning