Skip to content

Fix C++26 clang compilation #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Descent3/Game2DLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 6 additions & 6 deletions Descent3/OsirisLoadandBind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Descent3/multi_dll_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/osiris_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Descent3/robotfire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because both LHS and RHS are arrays in their own right, the comparison always evaluates to true and should be deleted altogether.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right this test is bogus, I kept it alive to highlight a potential bug that needs to be looked into.

p_dwb->flags |= DWBF_ANIMATING;
p_dwb->wb_anim_frame = static_wb->anim_start_frame[p_dwb->cur_firing_mask];
}
Expand Down
2 changes: 1 addition & 1 deletion editor/ScriptLevelInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions module/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions module/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
//=======================================================================
Expand All @@ -125,7 +125,7 @@ struct module {
#define DLLFUNCIMPORT
#define DLLEXPORT CPPEXTERN DLLFUNCEXPORT

struct module {
struct module_t {
void *handle; // handle to the DLL
};
//=======================================================================
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions netcon/includes/con_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion renderer/HardwareOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions renderer/dyna_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct FnPtr<Ret GLFUNCCALL(Args...)> {

#if defined(DECLARE_OPENGL)
extern char loadedLibrary[_MAX_PATH];
static module OpenGLDLLInst;
static module_t OpenGLDLLInst;


static std::vector<std::tuple<void **, std::string_view, bool>> inits_;
Expand All @@ -104,7 +104,7 @@ FnPtr<Ret GLFUNCCALL(Args...)>::FnPtr(std::string_view name, bool optional) : fn
inits_.push_back(std::make_tuple(reinterpret_cast<void **>(&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);

Expand Down
Loading