Half-Life SDK uses old C++ (probably C++98) C++20 can make code safer, easier to read, and faster. Using modern C++ features, halflife-updated will be easier to write code, add features, and debug.
Changes
[x] Use C++20.
[ ] Replace #define macros with enum or constexpr. This makes fixing compile-time errors easier. Use enum for group of constants and constexpr for individual constants.
[ ] Replace macro functions with inline functions.
[x] Replace typedef with using. using is added in C++.
[ ] Replace typedef struct with struct. C++ structs work without typedef.
[x] Use mathematical constants added in C++20. (pi and pi_v)
[x] Replace qboolean with bool
[x] Replace unsigned char with std::uint8_t for byte.
[ ] Use auto where it is possible.
[ ] Replace printf with std::cout. But std::endl won't replace \n.
[ ] Use decltype or vec_t to avoid float and double collision for vec_t.
[ ] Use C++ headers.
[ ] Use pragma once for header files.
[ ] Replace array with std::array. C++ std::array is safer.
[ ] Replace call by pointer with call by reference where it is possible.
[ ] Replace C standard functions (malloc, free) with C++ functions (new, delete).
[ ] Replace raw pointers to smart pointers (unique_ptr, shared_ptr)
[ ] Use lambda functions where it is possible.
[ ] Replace std::string with char* strings. `std::string:iterator can be used. Replace related functions such as atof with stof.
Things that will NOT be changed
Variable names, constant names, function names, class names, struct names, etc.
General code structure of Half-Life SDK
Proposals
Can we move project files under projects/vs2019 to projects/? Or do we need to keep the file structure for compatibility?
Half-Life SDK uses old C++ (probably C++98) C++20 can make code safer, easier to read, and faster. Using modern C++ features,
halflife-updated
will be easier to write code, add features, and debug.Changes
#define
macros withenum
orconstexpr
. This makes fixing compile-time errors easier. Useenum
for group of constants andconstexpr
for individual constants.typedef
withusing
.using
is added in C++.typedef struct
withstruct
. C++ structs work withouttypedef
.pi
andpi_v
)qboolean
withbool
unsigned char
withstd::uint8_t
forbyte
.auto
where it is possible.printf
withstd::cout
. Butstd::endl
won't replace\n
.decltype
orvec_t
to avoidfloat
anddouble
collision forvec_t
.pragma once
for header files.array
withstd::array
. C++std::array
is safer.malloc
,free
) with C++ functions (new
,delete
).unique_ptr
,shared_ptr
)std::string
withchar*
strings.`std::string:iterator
can be used. Replace related functions such asatof
withstof
.Things that will NOT be changed
Proposals
projects/vs2019
toprojects/
? Or do we need to keep the file structure for compatibility?