Re #361 : Fixed the Windows side of r3454 (made the legacy menu code a real module) and r3453 (new C++ dynamically loadable module system)

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3456 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
pouillot 2011-03-20 10:26:35 +00:00
parent 507a38a150
commit cef514d749
6 changed files with 23 additions and 35 deletions

View File

@ -161,20 +161,6 @@ Section "!Base System" SEC01
SetOutPath "$INSTDIR\data\tracks\circuit\espie"
File /r /x *.lib "${BUILD_INST_DIR}\data\tracks\circuit\espie\*.*"
; Start menu entries
CreateDirectory "$SMPROGRAMS\${GAME_VERSIONNED_NAME}"
SetOutPath "$INSTDIR"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\Speed Dreams.lnk" "$INSTDIR\bin\${GAME_FS_NAME}.exe"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\User Manual.lnk" "$INSTDIR\doc\how_to_drive.html"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\Frequently Asked Questions.lnk" "$INSTDIR\doc\faq.html"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\Read me.lnk" "$INSTDIR\readme.txt"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\Licence.lnk" "$INSTDIR\licence.txt"
; Desktop shortcut
CreateShortCut "$DESKTOP\${GAME_VERSIONNED_NAME}.lnk" "$INSTDIR\bin\${GAME_FS_NAME}.exe"
SectionEnd
Section /o "Basic mod Tools" SEC02
@ -284,11 +270,11 @@ SectionEnd
Section -Shortcuts
SetOutPath "$INSTDIR"
; Start menu entries
CreateDirectory "$SMPROGRAMS\${GAME_VERSIONNED_NAME}"
SetOutPath "$INSTDIR\bin"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\Speed Dreams.lnk" "$INSTDIR\bin\${GAME_FS_NAME}.exe"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\User Manual.lnk" "$INSTDIR\doc\how_to_drive.html"
CreateShortCut "$SMPROGRAMS\${GAME_VERSIONNED_NAME}\Frequently Asked Questions.lnk" "$INSTDIR\doc\faq.html"

View File

@ -26,9 +26,9 @@
#ifdef WIN32
# include <windows.h>
# define dlopen(soFileName) (void*)LoadLibrary(soFileName)
# define dlsym(pvoid) GetProcAddress((HMODULE)pvoid)
# define dlclose(pvoid) !FreeLibrary((HMODULE)pvoid)
# define dlopen(pszShLibFileName) (void*)LoadLibrary(pszShLibFileName)
# define dlsym(pvHandle, pszFuncName) GetProcAddress((HMODULE)pvHandle, pszFuncName)
# define dlclose(pvHandle) !FreeLibrary((HMODULE)pvHandle)
# define soLibHandle(handle) (void*)handle
#else
# include <dlfcn.h>
@ -38,10 +38,10 @@
// Name and type of the 2 extern "C" module interface functions.
typedef int (*tModOpenFunc)(const char*, void*); // Returns 0 on success, !0 otherwise.
static const char* pszOpenModuleFuncName = "GfModuleOpen";
static const char* pszOpenModuleFuncName = "openGfModule";
typedef int (*tModCloseFunc)(); // Returns 0 on success, !0 otherwise.
static const char* pszCloseModuleFuncName = "GfModuleClose";
static const char* pszCloseModuleFuncName = "closeGfModule";
// Error code decoder.
static std::string lastDLErrorString()
@ -109,7 +109,7 @@ GfModule* GfModule::load(const std::string& strShLibName)
{
GfLogError("Library %s doesn't export any '%s' function' ; module NOT loaded\n",
strShLibName.c_str(), pszOpenModuleFuncName);
dlclose(hSOLib);
(void)dlclose(hSOLib);
return 0;
}
@ -118,7 +118,7 @@ GfModule* GfModule::load(const std::string& strShLibName)
{
GfLogError("Library %s '%s' function call failed ; module NOT loaded\n",
strShLibName.c_str(), pszOpenModuleFuncName);
dlclose(hSOLib);
(void)dlclose(hSOLib);
return 0;
}
@ -127,7 +127,7 @@ GfModule* GfModule::load(const std::string& strShLibName)
{
GfLogError("Library %s '%s' function failed to register the open module ; NOT loaded\n",
strShLibName.c_str(), pszOpenModuleFuncName);
dlclose(hSOLib);
(void)dlclose(hSOLib);
return 0;
}

View File

@ -24,6 +24,11 @@
#ifndef __TGF__HPP__
#define __TGF__HPP__
#ifdef _MSC_VER
// Disable useless MSVC warnings
# pragma warning (disable:4251) // class XXX needs a DLL interface ...
#endif
#include <string>
#include <map>

View File

@ -49,9 +49,6 @@ ADD_SDL_INCLUDEDIR()
ADD_ENET_INCLUDEDIR()
IF(WIN32)
# DLL export stuff under Windows (to avoid .def file)
ADD_DEFINITIONS(-DLEGACYMENU_DLL)
# Ignore some run-time libs to avoid link time warnings and sometimes even crashes.
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt.lib")
ENDIF(WIN32)

View File

@ -28,7 +28,7 @@
// The LegacyMenu singleton.
LegacyMenu* LegacyMenu::_pSelf = 0;
int GfModuleOpen(const char* pszShLibName, void* hShLibHandle)
int openGfModule(const char* pszShLibName, void* hShLibHandle)
{
// Instanciate the (only) module instance.
LegacyMenu::_pSelf = new LegacyMenu(pszShLibName, hShLibHandle);
@ -41,7 +41,7 @@ int GfModuleOpen(const char* pszShLibName, void* hShLibHandle)
return LegacyMenu::_pSelf ? 0 : 1;
}
int GfModuleClose()
int closeGfModule()
{
// Delete the (only) module instance.
delete LegacyMenu::_pSelf;
@ -53,7 +53,7 @@ int GfModuleClose()
LegacyMenu& LegacyMenu::self()
{
// Pre-condition : 1 successfull GfModuleOpen call.
// Pre-condition : 1 successfull openGfModule call.
return *_pSelf;
}

View File

@ -31,7 +31,7 @@
// DLL exported symbols declarator for Windows.
#ifdef WIN32
# ifdef LEGACYMENU_DLL
# ifdef legacymenu_EXPORTS
# define LEGACYMENU_API __declspec(dllexport)
# else
# define LEGACYMENU_API __declspec(dllimport)
@ -42,8 +42,8 @@
// The C interface of the module.
LEGACYMENU_API extern "C" int GfModuleOpen(const char* pszShLibName, void* hShLibHandle);
LEGACYMENU_API extern "C" int GfModuleClose();
extern "C" int LEGACYMENU_API openGfModule(const char* pszShLibName, void* hShLibHandle);
extern "C" int LEGACYMENU_API closeGfModule();
// The module main class (inherits GfModule, and implements IUserInterface).
class LEGACYMENU_API LegacyMenu : public GfModule, public IUserInterface
@ -112,8 +112,8 @@ protected:
IRaceEngine* _piRaceEngine;
// Make the C interface functions nearly member functions.
friend LEGACYMENU_API int GfModuleOpen(const char* pszShLibName, void* hShLibHandle);
friend LEGACYMENU_API int GfModuleClose();
friend int openGfModule(const char* pszShLibName, void* hShLibHandle);
friend int closeGfModule();
};
#endif /* _LEGACYMENU_H_ */