Merge branch 'loadlibrary-exchndl' into 'master'

core: load exchndl.dll at runtime, RINGRACERSWADDIR

See merge request KartKrew/Kart!857
This commit is contained in:
Eidolon 2023-01-05 23:30:23 +00:00
commit 1094f844a6
4 changed files with 22 additions and 21 deletions

View file

@ -310,15 +310,6 @@ if("${SRB2_CONFIG_HWRENDER}")
endif()
endif()
# TODO: build this with the game
if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32)
target_link_libraries(SRB2SDL2 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libexchndl.a"
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libmgwhelp.a"
)
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/include")
endif()
if(${SRB2_CONFIG_USEASM})
#SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm.
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
@ -401,7 +392,7 @@ target_compile_options(SRB2SDL2 PRIVATE
-Winline
-Wformat-y2k
-Wformat-security
$<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
-Wno-div-by-zero
-Wendif-labels

View file

@ -287,8 +287,8 @@ static void CustomApplicationMain (int argc, char **argv)
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
#endif
if (!getenv("SRB2WADDIR"))
setenv("SRB2WADDIR", [[[NSBundle mainBundle] resourcePath] UTF8String], 1);
if (!getenv("RINGRACERSWADDIR"))
setenv("RINGRACERSWADDIR", [[[NSBundle mainBundle] resourcePath] UTF8String], 1);
/* Hand off to main application code */
status = SDL_main (gArgc, gArgv);

View file

@ -71,10 +71,6 @@ char logfilename[1024];
#endif
#endif
#if defined (_WIN32)
#include <exchndl.h>
#endif
#if defined (_WIN32)
extern "C" {
#include "../win32/win_dbg.h"
@ -202,6 +198,20 @@ static void InitLogging(void)
}
#endif
static void init_exchndl()
{
#ifdef _WIN32
HMODULE exchndl_module = LoadLibraryA("exchndl.dll");
if (exchndl_module != NULL)
{
using PFN_ExcHndlInit = void(*)(void);
PFN_ExcHndlInit pfnExcHndlInit = reinterpret_cast<PFN_ExcHndlInit>(
GetProcAddress(exchndl_module, "ExcHndlInit"));
if (pfnExcHndlInit != NULL)
(pfnExcHndlInit)();
}
#endif
}
#ifdef _WIN32
static void
@ -294,7 +304,7 @@ int main(int argc, char **argv)
)
#endif
{
ExcHndlInit();
init_exchndl();
}
}
#ifndef __MINGW32__

View file

@ -989,7 +989,7 @@ INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev)
SDL_Joystick *joystick = NULL;
joystick = SDL_GameControllerGetJoystick(dev);
if (joystick)
{
return SDL_JoystickInstanceID(joystick);
@ -2242,9 +2242,9 @@ static const char *locateWad(void)
const char *envstr;
const char *WadPath;
I_OutputMsg("SRB2WADDIR");
// does SRB2WADDIR exist?
if (((envstr = I_GetEnv("SRB2WADDIR")) != NULL) && isWadPathOk(envstr))
I_OutputMsg("RINGRACERSWADDIR");
// does RINGRACERSWADDIR exist?
if (((envstr = I_GetEnv("RINGRACERSWADDIR")) != NULL) && isWadPathOk(envstr))
return envstr;
#ifndef NOCWD