diff --git a/Descent3/Game2DLL.cpp b/Descent3/Game2DLL.cpp index 959c1a121..1e96325d6 100644 --- a/Descent3/Game2DLL.cpp +++ b/Descent3/Game2DLL.cpp @@ -71,7 +71,7 @@ extern int Camera_view_mode[NUM_CAMERA_VIEWS]; // This function initializes a Module Init Struct with all the needed data to get sent // to the module during initialization. extern void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi); -module GameDLLHandle = {NULL}; +module_t GameDLLHandle = {NULL}; extern ddgr_color Player_colors[]; struct game_api { int *objs; @@ -547,7 +547,7 @@ void GetGameAPI(game_api *api) { Multi_d3m_osiris_funcs.script_identifier = Netgame.scriptname; } // Closes and deletes any tempfiles for the game module -void CloseGameModule(module *mod) { +void CloseGameModule(module_t *mod) { // Clear out error queue mod_GetLastError(); mod_FreeModule(mod); @@ -560,7 +560,7 @@ void CloseGameModule(module *mod) { mod->handle = NULL; } // this function will load up the DLL, but not get any symbols -bool InitGameModule(const char *name, module *mod) { +bool InitGameModule(const char *name, module_t *mod) { std::filesystem::path lib_name; std::filesystem::path dll_name; std::filesystem::path tmp_dll_name; @@ -744,7 +744,7 @@ int GameDLLGetConnectingPlayersTeam(int slot) { } // Call this function to get information/options from a unloaded mod bool GetDLLGameInfo(const char *name, tDLLOptions *options) { - module mod = {NULL}; + module_t mod = {NULL}; memset(options, 0, sizeof(tDLLOptions)); DLLGetGameInfo_fp modGetGameInfo; if (!InitGameModule(name, &mod)) diff --git a/Descent3/OsirisLoadandBind.cpp b/Descent3/OsirisLoadandBind.cpp index 73f10fa48..0b97702c3 100644 --- a/Descent3/OsirisLoadandBind.cpp +++ b/Descent3/OsirisLoadandBind.cpp @@ -481,7 +481,7 @@ struct tOSIRISModule { GetTriggerScriptID_fp GetTriggerScriptID; GetCOScriptList_fp GetCOScriptList; SaveRestoreState_fp SaveRestoreState; - module mod; + module_t mod; char *module_name; char **string_table; int strings_loaded; @@ -1010,7 +1010,7 @@ int Osiris_LoadLevelModule(const std::filesystem::path &module_name) { // the module has loaded, attempt to import all the level functions tOSIRISModule *osm = &OSIRIS_loaded_modules[loaded_id]; - module *mod = &osm->mod; + module_t *mod = &osm->mod; // there are 9 functions we need to import // InitializeDLL@4 @@ -1205,7 +1205,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) { // the module has loaded, attempt to import all the level functions tOSIRISModule *osm = &OSIRIS_loaded_modules[loaded_id]; - module *mod = &osm->mod; + module_t *mod = &osm->mod; // there are 7 functions we need to import // InitializeDLL@4 @@ -1311,7 +1311,7 @@ int Osiris_LoadGameModule(const std::filesystem::path &module_name) { // Returns -3 if the module is not a game module. Returns -4 if no module slots are available. // This technically doesn't load a mission module, as it should already be loaded by // Descent 3 prior. -int Osiris_LoadMissionModule(module *module_handle, const char *filename) { +int Osiris_LoadMissionModule(module_t *module_handle, const char *filename) { if ((Game_mode & GM_MULTI) && (Netgame.local_role != LR_SERVER)) { // no scripts for a client! return -1; @@ -1348,8 +1348,8 @@ int Osiris_LoadMissionModule(module *module_handle, const char *filename) { // the module has loaded, attempt to import all the game functions tOSIRISModule *osm = &OSIRIS_loaded_modules[loaded_id]; - memcpy(&osm->mod, module_handle, sizeof(module)); - module *mod = &osm->mod; + memcpy(&osm->mod, module_handle, sizeof(module_t)); + module_t *mod = &osm->mod; // there are 5 functions we need to import // GetGOScriptID@4 diff --git a/Descent3/multi_dll_mgr.cpp b/Descent3/multi_dll_mgr.cpp index 1ec0e14a4..0e3971335 100644 --- a/Descent3/multi_dll_mgr.cpp +++ b/Descent3/multi_dll_mgr.cpp @@ -318,7 +318,7 @@ #endif void *callback = NULL; -module MultiDLLHandle = {NULL}; +module_t MultiDLLHandle = {NULL}; int SearchForLocalGamesTCP(uint32_t ask, uint16_t port); int SearchForGamesPXO(uint32_t ask, uint16_t port); extern uint8_t NewUIWindow_alpha; diff --git a/Descent3/osiris_dll.h b/Descent3/osiris_dll.h index 1c0d28f25..8c638ac1a 100644 --- a/Descent3/osiris_dll.h +++ b/Descent3/osiris_dll.h @@ -180,7 +180,7 @@ extern void Osiris_UnloadModule(int module_id); // Returns -3 if the module is not a game module. Returns -4 if no module slots are available. // This technically doesn't load a mission module, as it should already be loaded by // Descent 3 prior. -extern int Osiris_LoadMissionModule(module *module_handle, const char *filename); +extern int Osiris_LoadMissionModule(module_t *module_handle, const char *filename); // Osiris_UnloadMissionModule // Purpose: diff --git a/Descent3/robotfire.cpp b/Descent3/robotfire.cpp index f620f926e..f061c6eca 100644 --- a/Descent3/robotfire.cpp +++ b/Descent3/robotfire.cpp @@ -68,7 +68,8 @@ void WBSetupFireAnim(object *obj, otype_wb_info *static_wb, int wb_index) { p_dwb->wb_anim_mask = p_dwb->cur_firing_mask; - if (static_wb->anim_start_frame != static_wb->anim_end_frame) { + // LGT: Awkward array comparison by pointer, needs investivation to understand the actual intent + if (+static_wb->anim_start_frame != static_wb->anim_end_frame) { p_dwb->flags |= DWBF_ANIMATING; p_dwb->wb_anim_frame = static_wb->anim_start_frame[p_dwb->cur_firing_mask]; } diff --git a/editor/ScriptLevelInterface.cpp b/editor/ScriptLevelInterface.cpp index ef7714c86..d5c67aa58 100644 --- a/editor/ScriptLevelInterface.cpp +++ b/editor/ScriptLevelInterface.cpp @@ -2305,7 +2305,7 @@ bool IsScriptOutofSync(char *name) { bool out_of_sync = false; InitializeDLL_fp initdll; ShutdownDLL_fp shutdowndll; - module mod; + module_t mod; char filename[_MAX_PATH], ext[_MAX_EXT]; char path[_MAX_PATH]; diff --git a/module/module.cpp b/module/module.cpp index da12376ed..717767817 100644 --- a/module/module.cpp +++ b/module/module.cpp @@ -140,7 +140,7 @@ std::filesystem::path mod_GetRealModuleName(const std::filesystem::path &mod_fil // Loads a dynamic module into memory for use. // Returns true on success, false otherwise // modfilename is the name of the module (without an extension such as DLL, or so) -bool mod_LoadModule(module *handle, const std::filesystem::path &imodfilename, int flags) { +bool mod_LoadModule(module_t *handle, const std::filesystem::path &imodfilename, int flags) { if (imodfilename.empty()) { ModLastError = MODERR_OTHER; return false; @@ -209,7 +209,7 @@ bool mod_LoadModule(module *handle, const std::filesystem::path &imodfilename, i } // Frees a previously loaded module from memory, it can no longer be used // Returns true on success, false otherwise -bool mod_FreeModule(module *handle) { +bool mod_FreeModule(module_t *handle) { bool ret = true; if (!handle) { @@ -232,7 +232,7 @@ bool mod_FreeModule(module *handle) { // Returns a pointer to a function within a loaded module. If it returns NULL there was an error. Check // mod_GetLastError to see if there was an error symstr is the name of the function you want to get the symbol for (Do // NOT give any pre/suffix to this name) parmbytes is the size (in bytes) of the parameter list the function should have -MODPROCADDRESS mod_GetSymbol(module *handle, const char *symstr, uint8_t parmbytes) { +MODPROCADDRESS mod_GetSymbol(module_t *handle, const char *symstr, uint8_t parmbytes) { MODPROCADDRESS sym; if (!handle) { ModLastError = MODERR_INVALIDHANDLE; diff --git a/module/module.h b/module/module.h index a625754c8..e1aa56c06 100644 --- a/module/module.h +++ b/module/module.h @@ -113,7 +113,7 @@ #define DLLFUNCEXPORT __declspec(dllexport) #define DLLFUNCIMPORT __declspec(dllimport) #define DLLEXPORT CPPEXTERN DLLFUNCEXPORT -struct module { +struct module_t { HINSTANCE handle; // handle to the DLL }; //======================================================================= @@ -125,7 +125,7 @@ struct module { #define DLLFUNCIMPORT #define DLLEXPORT CPPEXTERN DLLFUNCEXPORT -struct module { +struct module_t { void *handle; // handle to the DLL }; //======================================================================= @@ -157,16 +157,16 @@ std::filesystem::path mod_GetRealModuleName(const std::filesystem::path &mod_fil // Loads a dynamic module into memory for use. If no extension is given, the default // system specific extension is used. // Returns true on success, false otherwise -bool mod_LoadModule(module *handle, const std::filesystem::path &imodfilename, int flags = MODF_LAZY); +bool mod_LoadModule(module_t *handle, const std::filesystem::path &imodfilename, int flags = MODF_LAZY); // Frees a previously loaded module from memory, it can no longer be used // Returns true on success, false otherwise -bool mod_FreeModule(module *handle); +bool mod_FreeModule(module_t *handle); // Returns a pointer to a function within a loaded module. If it returns NULL there was an error. Check // mod_GetLastError to see if there was an error symstr is the name of the function you want to get the symbol for (Do // NOT give any pre/suffix to this name) parmbytes is the size (in bytes) of the parameter list the function should have -MODPROCADDRESS mod_GetSymbol(module *handle, const char *symstr, uint8_t parmbytes); +MODPROCADDRESS mod_GetSymbol(module_t *handle, const char *symstr, uint8_t parmbytes); // Returns an error code to what the last error was. When this function is called the last error is cleared, so by // calling this function it not only returns the last error, but it removes it, so if you were to call this function diff --git a/netcon/includes/con_dll.h b/netcon/includes/con_dll.h index edf67e576..f6b2b3c3c 100644 --- a/netcon/includes/con_dll.h +++ b/netcon/includes/con_dll.h @@ -273,6 +273,7 @@ #include "crossplat.h" #include "ship.h" #include "pstypes.h" +#include "module.h" // Uncomment out this line of code to build the demo version of the multiplayer connection dlls // #define DEMO 1 @@ -657,18 +658,18 @@ MultiGameOptionsMenu_fp DLLMultiGameOptionsMenu; // Loads a dynamic module into memory for use. // Returns true on success, false otherwise -typedef bool (*mod_LoadModule_fp)(module *handle, const std::filesystem::path &modfilename, int flags); +typedef bool (*mod_LoadModule_fp)(module_t *handle, const std::filesystem::path &modfilename, int flags); mod_LoadModule_fp DLLmod_LoadModule; // Frees a previously loaded module from memory, it can no longer be used // Returns true on success, false otherwise -typedef bool (*mod_FreeModule_fp)(module *handle); +typedef bool (*mod_FreeModule_fp)(module_t *handle); mod_FreeModule_fp DLLmod_FreeModule; // Returns a pointer to a function within a loaded module. If it returns NULL there was an error. Check // mod_GetLastError to see if there was an error symstr is the name of the function you want to get the symbol for (Do // NOT give any pre/suffix to this name) parmbytes is the size (in bytes) of the parameter list the function should have -typedef MODPROCADDRESS (*mod_GetSymbol_fp)(module *handle, const char *symstr, uint8_t parmbytes); +typedef MODPROCADDRESS (*mod_GetSymbol_fp)(module_t *handle, const char *symstr, uint8_t parmbytes); mod_GetSymbol_fp DLLmod_GetSymbol; // Returns an error code to what the last error was. When this function is called the last error is cleared, so by @@ -820,7 +821,7 @@ char *DLLAuto_login_port; bool Use_netgame_flags; -module MTAVDLLHandle = {NULL}; +module_t MTAVDLLHandle = {NULL}; #if defined(WIN32) typedef void(DLLFUNCCALL DLLAVInit_fp)(int *ptr); diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index 3f50525d0..845058e69 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -214,7 +214,7 @@ extern rendering_state gpu_state; extern renderer_preferred_state gpu_preferred_state; bool OpenGL_multitexture_state = false; -module *OpenGLDLLHandle = nullptr; +module_t *OpenGLDLLHandle = nullptr; int Already_loaded = 0; bool opengl_Blending_on = false; diff --git a/renderer/dyna_gl.h b/renderer/dyna_gl.h index 239db9802..8c1b9d2e8 100644 --- a/renderer/dyna_gl.h +++ b/renderer/dyna_gl.h @@ -85,7 +85,7 @@ struct FnPtr { #if defined(DECLARE_OPENGL) extern char loadedLibrary[_MAX_PATH]; -static module OpenGLDLLInst; +static module_t OpenGLDLLInst; static std::vector> inits_; @@ -104,7 +104,7 @@ FnPtr::FnPtr(std::string_view name, bool optional) : fn inits_.push_back(std::make_tuple(reinterpret_cast(&fn_), name, optional)); } -static module *LoadOpenGLDLL(const char *dllname) { +static module_t *LoadOpenGLDLL(const char *dllname) { LOG_INFO << "Loading OpenGL dll..."; int rc = SDL_GL_LoadLibrary(dllname[0] ? dllname : nullptr);