Half-Life SDK updated for use with VS2017 Created 6 years ago2018-09-03 08:59:06 UTC by Solokiller Solokiller

Created 6 years ago2018-09-03 08:59:06 UTC by Solokiller Solokiller

Posted 6 years ago2018-09-03 08:59:06 UTC Post #340772
By request i've updated the Half-Life SDK to work out of the box with VS2017. The projects have been converted to use the v141_xp toolset, all warnings and errors have been fixed.

You can get it here: https://github.com/SamVanheer/halflife-updated

Changelist:
  • Converted project files to VS2017, toolset changed to v141_xp (utils may not compile due to missing third party dependencies such as 3DS Max headers, GLAux library headers)
  • Removed VS2010 projects
  • Removed fabs macro definition, updated ambiguous uses of abs to use fabs function
  • Removed old dll copy build step (depends on relative location to game install, would cause errors)
  • Disabled CRT secure warnings (codebase is full of unsafe function uses)
  • Refactored platform specific code handling (Platform.h handles abstractions now)
  • Corrected invalid fprintf variadic arguments in nodes.cpp
  • Removed unused typedef specifier that caused copious amounts of warnings
  • Converted player movement code to C++
  • Fixed some incorrect math function declarations & definitions (declaration used vec3_t or float*, definition was other way around)
  • Updated Makefiles and gendbg.sh
  • Added fixes for Linux (GCC 8)
  • Fixed signed/unsigned comparison warning
  • Refactored dllexport macro definitions (defined in Platform.h now)
  • Removed invalid preprocessor command start token (#)
  • Use Platform.h instead of Windows.h where winsani is required (workaround for sprite handle type conflicting with Windows handle type)
  • Commented out EIFACE_H following #endif (can cause compiler warnings/errors)
  • Set /Zc:threadSafeInit- to ensure mods work properly on XP
Thanks to Shepard for providing the fixes for Linux.
Posted 6 years ago2018-09-03 10:31:37 UTC Post #340774
SourceSkyBoxer said:Wait please Ubuntu 18.04 is buggy.
I don't have any problems with Ubuntu 18.04 so if you have a problem, it's your fault.
SourceSkyBoxer said:Please rollback to gcc6! ( Possible for gcc5.4 )
Have you actually tried to compile it with GCC 6 or 5.4 before complaining?

UPDATE: I just tried compiling with GCC 6 and it works, no errors, no warnings.
Posted 6 years ago2018-09-03 10:52:37 UTC Post #340776
We're not rolling back because unrelated programs don't work on 18.04.

You're having issues compiling because you're on a 64 bit system trying to compile a 32 bit, but the error that's stopping compilation is that it can't find pm_shared files. I converted those to C++ after Shepard's pull request, so he didn't see it. I've pushed changes to the makefiles to make it find the correct files, pull it and try again.

You'll probably have issues linking due to cross-compiling issues, i suggest you look at tutorials for setting that up properly before trying to compile this.
Posted 6 years ago2018-09-03 11:07:40 UTC Post #340778
I've updated references to min & max to use V_min & V_max. Your problem should be solved now.
Posted 6 years ago2018-09-03 12:17:17 UTC Post #340780
It has nothing to do with const. The problem here is that there are overloads of functions that use types that are actually the same.
Some compilers consider typedefs to create distinct types, others just use the underlying type.
A function taking a vec3_t is identical to a function taking a float[3], which is identical to float*.

I've correct a couple of them to make things work, try it out and see if there are any more.
Posted 6 years ago2018-09-03 12:44:59 UTC Post #340782
I've fixed a couple other functions, it should be good now.

Normally i'd clean this all up by moving all of the function declarations to mathlib.h, rename pm_math.cpp to mathlib.cpp, use the same file for all games (there are 3 copies of pm_math.cpp, one for each game in the SDK), and use the Vector class everywhere. Unfortunately that would take a fair bit of time to clean up, and this was supposed to be a quick fix for people trying to make mods with VS2017. The fix i've done here is pretty ugly (multiple forward declarations of math functions to avoid conflicts between the old C and C++ code), so if you want something clean you'll have to deal with this.

Math.h isn't related to this by the way.
Posted 6 years ago2018-09-03 13:08:28 UTC Post #340784
There is no #include <math> in this project. Where are you seeing that?
Posted 6 years ago2018-09-03 15:53:03 UTC Post #340786
Well done Nice work Solokiller :)
Posted 6 years ago2018-09-03 19:54:23 UTC Post #340788
Ok thanks SourceSkyBoxer.
Posted 5 years ago2019-05-24 19:23:52 UTC Post #342649
I've created a branch off this repository that makes adding weapons easier: https://github.com/SamVanheer/half-life-better-weapons

I've reworked the code that precaches weapons and the code that handles prediction so when adding new weapons you only need to replace the LINK_ENTITY_TO_CLASS macro with LINK_WEAPON_TO_CLASS. It is no longer necessary to hook in the weapon in the client side prediction code, which is completely automatic now. Just make sure the source file is included in the client project and you're set.

You will still need to assign a weapon id manually as before.

Note that the impulse 101 command does not learn weapon names automatically, but that's pretty easy to add.
I can automate ammo types as well if the manual precaching is a problem.

More details here: https://github.com/SamVanheer/half-life-better-weapons/blob/1bfb94b43c7a8069bae51690a260adf1135d6743/dlls/weapons.h#L459-L467
You must be logged in to post a response.