Closed MoeMod closed 5 years ago
Hi. Yes, I am aware of that. Engine internally uses const where it's possible, so you can just add const modifier to interface and this will not break anything.
Don't remember though, did I or someone else already added constant modifiers to engine's eiface.h.
Ah, it was already done in "hlsdk-xash3d".
https://github.com/FWGS/hlsdk-xash3d/blob/master/engine/eiface.h
Oh, I am sorry that I thought that the files in this repo is newer than those in that one. Maybe it need to be merged...
I think, it would be better to move Xash3D/HLSDK headers to another repository, so we can sync changes between engine and different SDKs(XashXT, HLSDK and so on) and even track changes! :)
In Modern C++, string literal is typed to (const char ), and it isn't allowed to convert to (char ). Since those interfaces are shared and referenced in both C and C++, it causes lots of warnings and sometimes requires const_cast<const char >. In my opinion, this change won't cause extra compatibility problems because (char ) can be converted to (const char *).
example:
std::string szModel("models/v_usp.mdl");
gEngfuncs.pfnPrecacheModel(szModel.c_str()); // cannot convert const char * to char *
possible solution:
typedef struct enginefuncs_s {
int (*pfnPrecacheModel)( char* s );
totypedef struct enginefuncs_s {
int (*pfnPrecacheModel)( const char* s );