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

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

Posted 3 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

  • 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 3 years ago2018-09-03 09:45:23 UTC Post #340773
Wow for Linux!!!!

"Added fixes for Linux (GCC 8)" Wait please Ubuntu 18.04 is buggy. Please rollback to gcc6! ( Possible for gcc5.4 )

Why do you not check my problem with Ubuntu 18.04 cause disabled amdgpu or Gtk+3 is very buggy. That is why you need rollback for Ubuntu 16.04 support. Because I am using for Ubuntu 16.04 and I am very happy with C# for Ubuntu 16.04 = No problem 100 %!

My computer runs with Ubuntu 16.04 is very quicker than Windows 10.
But it runs 8 x or 10 x faster than Windows 10.

Oh i have many errors :( I can't compile successful :(
@Shepard, Why do you not explain about "Linux Building libraries" What do I need to install deps?
I found install g++5-multilib

For Ubuntu 16.04
sudo apt install g++-5-multilib -fy
It happens since make-error:

See my Glist

How do I fix? Thanks!
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 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 3 years ago2018-09-03 10:46:20 UTC Post #340775
@Shepard please check Gtk Sharp and OpenTK - I don't say you have not problem. I will laugh you because I have found bug. If you use WaveEngine Editor - You will have fun if you can't get editor of WaveEngine. Same Unity3D crashes sometimes. I am happy because Ubuntu 16.04 is very stabler than Ubuntu 18.04 because Ubuntu 18.04 has many bugs.
Check OpenTK Problem
OpenTK and Ubuntu 18.04
OpenGL.net and Ubuntu 18.04
MonoGame and 3.x and Ubuntu 18.04 It looks sometimes crashing if you move control with MonoGame under Ubuntu with gtk Sharp 3 than it will crashed.

It is really shit for Ubuntu 18.04

My display card is very strong AMD Radeon RX 480 8 GB Video Ram works fine with Ubuntu 16.04 = OK But for Ubuntu 18.04 = Disabled amdgpu.

Ubuntu 16.04 is stably :)
It works fine!

Did you check my Glist I have problem after waiting with gcc
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 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 3 years ago2018-09-03 11:01:51 UTC Post #340777
Thanks for explanation! Because you don't want rolling back. Ok I understand you.

But I have found error because void is not declared. Please check currect declarations!
../pm_shared/pm_shared.cpp: In function ‘void PM_InitTextureTypes()’:
../pm_shared/pm_shared.cpp:248:35: error: ‘min’ was not declared in this scope
j = min (j, CBTEXTURENAMEMAX-1+i);
quoted textMakefile.hldll:163: recipe for target 'release/obj/hldll/pm_shared/pm_shared.o' failed
make[1]: * [release/obj/hldll/pm_shared/pm_shared.o] Error 1
make[1]: * Waiting for unfinished jobs....
make[1]: Leaving directory '/home/sourceskyboxer/halflife-updated/linux'
Makefile:161: recipe for target 'hl' failed
make: * [hl] Error 2
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 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 3 years ago2018-09-03 11:35:58 UTC Post #340779
@Solo, Oh oh oh many const in pm_math.cpp and Util.cpp you should remove all const since Vector3Angle( "const" ....)
Because end of compilations show me error because many const* float .,... like It said "multiple definition"

I have tried fix but it has sill throw because multi definitions :/

I have removed all const if all methods than it compiles output only 2 "multiple definitions"
release/obj/hl1_client/studio_util.o:home/sourceskyboxer/halflife-updated/linux../cl_dll/studio_util.cpp:75: first defined here
release/obj/hl1_client/pm_shared/pm_math.o: In function `Length(float const*)':
home/sourceskyboxer/halflife-updated/linux../pm_shared/pm_math.cpp:318: multiple definition of `Length(float const*)'
release/obj/hl1_client/util.o:home/sourceskyboxer/halflife-updated/linux../cl_dll/util.cpp:38: first defined here
release/obj/hl1_client/pm_shared/pm_math.o: In function `VectorNormalize(float*)':
home/sourceskyboxer/halflife-updated/linux../pm_shared/pm_math.cpp:339: multiple definition of `VectorNormalize(float*)'
release/obj/hl1_client/util.o:home/sourceskyboxer/halflife-updated/linux../cl_dll/util.cpp:80: first defined here
release/obj/hl1_client/pm_shared/pm_math.o: In function `VectorInverse(float*)':
home/sourceskyboxer/halflife-updated/linux../pm_shared/pm_math.cpp:358: multiple definition of `VectorInverse(float*)'
release/obj/hl1_client/util.o:home/sourceskyboxer/halflife-updated/linux../cl_dll/util.cpp:99: first defined here
release/obj/hl1_client/pm_shared/pm_math.o: In function `VectorScale(float const*, float, float*)':
home/sourceskyboxer/halflife-updated/linux../pm_shared/pm_math.cpp:365: multiple definition of `VectorScale(float const*, float, float*)'
release/obj/hl1_client/util.o:home/sourceskyboxer/halflife-updated/linux../cl_dll/util.cpp:106: first defined here
release/obj/hl1_client/pm_shared/pm_math.o: In function `VectorAngles(float const*, float*)':
home/sourceskyboxer/halflife-updated/linux../pm_shared/pm_math.cpp:406: multiple definition of `VectorAngles(float const*, float*)'
release/obj/hl1_client/util.o:home/sourceskyboxer/halflife-updated/linux../cl_dll/util.cpp:51: first defined here
collect2: error: ld returned 1 exit status
Makefile.hl_cdll:139: recipe for target 'client.so' failed
make[1]: * [client.so] Error 1
make[1]: Leaving directory '/home/sourceskyboxer/halflife-updated/linux'
Makefile:152: recipe for target 'hl_cdll' failed
make: * [hl_cdll] Error 2

My god - I have resolved all removing const from pm_math.cpp and Util.cpp than it said errors

But it always shows "multiple definition" errors :/

I already tried with or without "const*"

How do I fix?

Found explanation with gcc need add parametewr "-lm" for <math.h> of Ubuntu 16.04's include
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 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 3 years ago2018-09-03 12:27:38 UTC Post #340781
Yes I have said - I have tried - But why does make show only 2 errors.

Show picture my I already tried:
git clone --recursive https://github.com/SamVanheer/halflife-updated.git
cd halflife-updated
Show 2 errorsShow 2 errors
And I triedd with parameter of gcc / g++ "-lmath"

than I try again
make clean && make
Same error problem with math of Ubuntu's include's math.h

I already tried. No success... What do I need? What do I forget for math.h?
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 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 3 years ago2018-09-03 12:56:18 UTC Post #340783
Oh really? But you can find pm_math.cpp:
#include <math>
That is problem with Ubuntu c language not cpp that is reason

I hope you have fixed it. I will check out if I git pull and try again.
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 years ago2018-09-03 13:08:28 UTC Post #340784
There is no #include <math> in this project. Where are you seeing that?
Posted 3 years ago2018-09-03 13:22:28 UTC Post #340785
Sorry I don't recognize because "<cmath> or <math> I am sorry.

Like this:

Thanks for resolve! Now I am got working dlls - I would like to build without dmc and ricobot.

Now it works fine I know makefile#136

dmc \
icochet \
dmc_cdll \
ricochet_cdll \

And I remove unusable compilations

Now it works fine. Thanks :)
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 years ago2018-09-03 15:53:03 UTC Post #340786
Well done Nice work Solokiller :)
Posted 3 years ago2018-09-03 17:52:23 UTC Post #340787
@hfc please don't forget to remove - if ricochet failed from compilation than you can remove unimportant cl_dlls and dlls of ricochet and dmc
SourceSkyBoxer SourceSkyBoxerC# Developer and Linux Creator
Posted 3 years ago2018-09-03 19:54:23 UTC Post #340788
Ok thanks SourceSkyBoxer.
Posted 2 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.