Compiling with LCC|
OK, so you wanna start building your own mods, do ya? Well, you've come to the right place! Just follow the simple steps to get yourself mod making in no time! Enough crap, lets start.
Firstly, you'll need to download a small kit of utilities and bug fixs, including the LCC compiler and q2 source code here. note: If you have already downloaded one or more of these files, and don't know how to compile, I recommend you still download this file, since it contains some extras, and you might mess up when following this tutorial.
OK, inside the zip you will find two more zips. First extract the LCC zip. This contains the compile and a bug fix for it. Extract all the files in lcc.zip into a suitable directory. (I use C:\Program Files\LCC-WIN32).
Note: when extracting the zips, make sure you are using a newer version of winzip or pkunzip. Older version do not support long filenames and will cause problems when compiling the source.
Anyway, now you'll have to open up your autoexec.bat file. Its normally in the root directory of your HD. Find the line that looks like this:
(yours may look different)
If you can't find anything with SET PATH, add it. Now, add the directory of your LCC BIN to this list, for example:
Great! Now, reboot your system for the changes to take place. Just to check, type "path" at the dos prompt to make sure everything is fine.Go into your /bin directory of LCC. There you will find an exe called setuplcc. Run it, and set the correct directories for the library and include. If you have gone with the default, they should be in LCC/lib and LCC/include, so just put in that.
What this does is set the right directories for the compiler, so it can find the other files necessary for compilation. Now we've got the compiler setup! Now, get back to winzip and extract the next zip, q2code.zip. Open it up and unzip all the files into a subdirectory of your QUAKE2 directory. For example, mine is D:\Quake2\newpatch.
Now, if you have done this correctly, inside quake2/newpatch/src will be all the source code. Edit it all you like. Then, to compile, execute the "compile.bat" file stored in the /src directory. This will compile all the files, fix the bugs etc. and copy the finished dll, into the right directory, as long as your autoexec.bat is properly set! So if I had my source files in d:\quake2\mypatch\src, the gamex86.dll would be copied to d:\quake2\mypatch.
Now, to run this, all you need to do is run the quake2.exe with the path quake2.exe +set game mypatch! Thats it.. Set for life!!
Adding files to the compile list
Say you followed the throw-up tutorial, and created the new throwup.c file that needs to be compiled. To add this file to the list, open the makefile in your src directory, and just simply add it to the list!
'Laser shooting through walls' fix
In some circumstances, the Lasers
will go right through walls... the best place to notice is 'Grid Control'
(security.bsp) or 'Receiving Center' (fact1.bsp) To fix it, open g_target.c and
go to line #491. You should be in target_laser_think and the line should be
tr = gi.trace (start, NULL, NULL, end, ignore,
AND THE SURVEY SAYS: Just make an exact copy of that line right under it, and no more laser bug. It
makes no sense, but it works...
(Thanks very much to Radix for this one !)
IMPORTANT: code fix for LCC-NT users
For some reason, on NT GetGameAPI is not the entry point.
You have to write this function somewhere (that MSVC
and others must write for you) I used g_main.c:
Then change the lcclnk line in the makefile to:
int _stdcall DLLMain(void *hinstDLL, unsigned long dwReason, void *reserved)
(Thanks again to Radix)
lcclnk -subsystem windows -dll -entry DLLMain $(OBJS) game.def -o gamex86.dll