Skip to content

Commit 617e7fa

Browse files
committed
Add SDL submodule
1 parent 10bda87 commit 617e7fa

File tree

7 files changed

+34
-20
lines changed

7 files changed

+34
-20
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Externals/SDL"]
2+
path = Externals/SDL
3+
url = https://github.com/libsdl-org/SDL.git

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ if (MSVC)
1414
add_compile_options(/W3) # Warning level
1515
endif()
1616

17+
add_subdirectory(Externals)
1718
add_subdirectory(SourceCode)

Externals/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(SDL)

Externals/SDL

Submodule SDL added at 4761467

SourceCode/FARCRY/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES})
99

1010
target_include_directories(${PROJECT_NAME} PRIVATE
1111
${CMAKE_SOURCE_DIR}/SourceCode/CryCommon
12+
${CMAKE_SOURCE_DIR}/Externals/SDL/include
1213
)
1314

14-
target_link_libraries(${PROJECT_NAME})
15+
target_link_libraries(${PROJECT_NAME} SDL2)

SourceCode/FARCRY/Main.cpp

+25-19
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
1515

16+
#include <SDL.h>
17+
1618
#ifdef WIN32
1719
#include <windows.h>
1820
#include <process.h>
@@ -96,7 +98,7 @@ static bool g_bSystemRelaunch = false;
9698
static char szMasterCDFolder[_MAX_PATH];
9799

98100
#ifdef WIN32
99-
static HMODULE g_hSystemHandle=NULL;
101+
static void* g_hSystemHandle=NULL;
100102
#define DLL_SYSTEM "CrySystem.dll"
101103
#define DLL_GAME "CryGame.dll"
102104
#endif
@@ -645,7 +647,9 @@ InvokeExternalConfigTool()
645647
//////////////////////////////////////////////////////////////////////////
646648
bool RunGame(HINSTANCE hInstance,const char *sCmdLine)
647649
{
648-
InvokeExternalConfigTool();
650+
SDL_Init(SDL_INIT_EVERYTHING);
651+
652+
// InvokeExternalConfigTool();
649653

650654
HWND hWnd=NULL;
651655
// initialize the system
@@ -673,26 +677,27 @@ bool RunGame(HINSTANCE hInstance,const char *sCmdLine)
673677
#ifndef _XBOX
674678
/////////////////////////////////////////////////////
675679
/////////////////////////////////////////////////////
676-
if (!hWnd && !RegisterWindow(hInstance))
677-
{
678-
if (!hWnd && RegisterWindow(hInstance))
679-
{
680-
MessageBox(0, "Cannot Register Window\n", "Error", MB_OK | MB_DEFAULT_DESKTOP_ONLY);
681-
return false;
682-
}
683-
}
684-
685-
g_hSystemHandle = LoadLibrary(DLL_SYSTEM);
680+
//if (!hWnd && !RegisterWindow(hInstance))
681+
//{
682+
// if (!hWnd && RegisterWindow(hInstance))
683+
// {
684+
// MessageBox(0, "Cannot Register Window\n", "Error", MB_OK | MB_DEFAULT_DESKTOP_ONLY);
685+
// return false;
686+
// }
687+
//}
688+
689+
g_hSystemHandle = SDL_LoadObject(DLL_SYSTEM);
686690
if (!g_hSystemHandle)
687691
{
688-
DWORD dwLastError = GetLastError();
692+
string errorStr = "CrySystem.dll Loading Failed:\n";
693+
errorStr += SDL_GetError();
694+
695+
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "FarCry Error", errorStr.c_str(), nullptr);
689696

690-
MessageBox( NULL,("CrySystem.dll Loading Failed:\n" + TryFormatWinError(dwLastError)).c_str(),"FarCry Error",MB_OK|MB_ICONERROR );
691697
return false;
692698
}
693699

694-
PFNCREATESYSTEMINTERFACE pfnCreateSystemInterface =
695-
(PFNCREATESYSTEMINTERFACE)::GetProcAddress( g_hSystemHandle,"CreateSystemInterface" );
700+
PFNCREATESYSTEMINTERFACE pfnCreateSystemInterface = (PFNCREATESYSTEMINTERFACE)SDL_LoadFunction( g_hSystemHandle,"CreateSystemInterface" );
696701

697702
// Initialize with instance and window handles.
698703
sip.hInstance = hInstance;
@@ -704,7 +709,7 @@ bool RunGame(HINSTANCE hInstance,const char *sCmdLine)
704709
g_pISystem = pfnCreateSystemInterface( sip );
705710
if (!g_pISystem)
706711
{
707-
MessageBox( NULL,"CreateSystemInterface Failed","FarCry Error",MB_OK|MB_ICONERROR );
712+
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "FarCry Error", "CreateSystemInterface Failed", nullptr);
708713
return false;
709714
}
710715
#else
@@ -746,7 +751,7 @@ bool RunGame(HINSTANCE hInstance,const char *sCmdLine)
746751

747752
if (!g_pISystem->CreateGame( ip ))
748753
{
749-
MessageBox( NULL,"CreateGame Failed: CryGame.dll","FarCry Error",MB_OK|MB_ICONERROR );
754+
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "FarCry Error", "CreateGame Failed: CryGame.dll", nullptr);
750755
return false;
751756
}
752757

@@ -848,7 +853,8 @@ bool RunGame(HINSTANCE hInstance,const char *sCmdLine)
848853
*/
849854

850855
if (!bRelaunch)
851-
::FreeLibrary(g_hSystemHandle);
856+
SDL_UnloadObject(g_hSystemHandle);
857+
852858
g_hSystemHandle= NULL;
853859

854860
if (hWnd)

0 commit comments

Comments
 (0)