remove-ifdefremoves all ifdefs for features. So where originally there was a
#ifdef feature #endifthere is either just the code the ifdef surrounded, or if the feature was disabled the code was removed.
There's also a branch
remove-xashthat removes all Xash specific code.
I ran a tool that counts lines of code on it, here are the results.
For the original codebase with no changes:
Some features were disabled, so their code was removed. Here they are:
- ZHLT_DETAIL: some kind of old func_detail variant, was already obsolete
- ZHLT_PROGRESSFILE: never implemented beyond command line argument handling, so didn't work at all
- ZHLT_NSBOB: the only thing i found was the definition, no code appears to exist for it
- ZHLT_HIDDENSOUNDTEXTURE: would allow you to mark faces as hidden by setting zhlt_hidden on an entity. You can do this by ending a texture name with _HIDDEN, so i guess it was obsolete
- HLBSP_SUBDIVIDE_INMID: seems to be intended to reduce the number of faces, but contributes to AllocBlock:Full errors so it was disabled
cmdlib.hheader is where all of these definitions were, it used to be 712 lines and is now 172 lines. There are 2 definitions left in place because they depend on platform specific functionality.
game_text's UTF8 conversion support, which relies on a Windows API function. It's not that hard to replace it with a cross platform alternative.
The other is Ripent's
-pauseparameter which was implemented only on Windows for some reason. This may have to do with the fact that it's implemented using
atexit, so it may not work on Linux due to differences in how console resources are managed during program shutdown. Reworking Ripent's code to avoid use of
exitshould solve this problem.
I don't see any more
#definestatements used to control features anywhere so i guess it's all cleaned up now.
To make this process easier i used some tools to speed things up. First i used
sunifdefto process all files and remove definitions one by one. I wrote a batch file that does this and also commits all changes to Git automatically, so i could just do
removeifdefs.bat <definition name>. You can find the batch file in the
Note that to remove disabled sections you must modify the batch file to pass
-Ddefinitionor it will turn on the feature.
All in all this took about an hour and a half to do.
My reason for doing this is that the ZHLT/VHLT source code has never been readable, you have to read past the definitions and note which ones are active. More recent versions of Visual Studio do a lot of work for you but it's still hard. For example, the file
wadpath.cppis 92 lines now, but was 174 lines before. That's nearly twice as long, containing code that isn't even used.
wadinclude.cppis even worse. It used to be 212 lines, now it's 5 lines and there's no actual code left in it. This is because are 3 or more different versions of the same feature (wad inclusion) in the source code. Various long files are much easier to read now that they've been cleaned up.
I hope to use this to rebuild the codebase in C# so that the tools can be integrated more easily, and perhaps deal with some issues that exist in the current implementation. I don't know whether i'll have time to do it or not, but in any case, this cleaned up version is available to anyone to check out. I will not be making a build of this since it's identical to the original V34 build, if you want one you'll have to make it yourself.