Skip to content

Commit f2d6d1a

Browse files
committed
Aaaand we're up and running again, finally.
1 parent 3373a80 commit f2d6d1a

File tree

5 files changed

+49
-28
lines changed

5 files changed

+49
-28
lines changed

3rdparty/sdl2/COPYING.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Simple DirectMedia Layer
3+
Copyright (C) 1997-2020 Sam Lantinga <[email protected]>
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+

engine/CMakeLists.txt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if (WIN32)
2626
win32/q_shwin.cpp
2727
win32/snd_win.cpp
2828
)
29+
link_directories(../3rdparty/sdl2/lib/)
2930
elseif (APPLE)
3031
file(GLOB ENGINE_PLATFORM_SOURCE
3132
null/cd_null.cpp
@@ -136,29 +137,23 @@ target_include_directories(engine PRIVATE
136137
../3rdparty/glew/include/
137138
)
138139

139-
find_package(SDL2 CONFIG REQUIRED)
140-
if (WIN32)
141-
target_link_libraries(engine SDL2::SDL2 SDL2::SDL2main)
142-
else ()
140+
find_package(SDL2 CONFIG)
141+
if (${SDL2_FOUND})
143142
target_link_libraries(engine SDL2::SDL2-static)
143+
else ()
144+
message("Linking against SDL2 in repository.")
145+
target_include_directories(engine PRIVATE ../3rdparty/sdl2/include/)
146+
target_link_directories(engine PRIVATE ../3rdparty/sdl2/lib/)
147+
target_link_libraries(engine SDL2)
144148
endif ()
145149

146150
set(OpenGL_GL_PREFERENCE GLVND)
147151
find_package(OpenGL REQUIRED)
148152
target_link_libraries(engine ${OPENGL_LIBRARIES})
149153

150154
if (WIN32)
151-
if (MSVC)
152-
target_link_options(engine PRIVATE
153-
/NODEFAULTLIB:libcmt.lib
154-
/NODEFAULTLIB:libcmtd.lib
155-
)
156-
elseif (MINGW)
157-
target_link_libraries(engine
158-
mingw32
159-
)
160-
endif ()
161155
target_link_libraries(engine
156+
mingw32
162157
Imm32
163158
Setupapi
164159
Version

engine/app.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ void nox::App::Initialize()
4343
SDL_INIT_JOYSTICK |
4444
SDL_INIT_TIMER );
4545
if ( status != 0 )
46-
{
4746
Sys_Error( "Failed to initialized SDL2: %s\n", SDL_GetError() );
48-
}
4947

5048
Qcommon_Init( argc_, argv_ );
5149
}
@@ -156,8 +154,15 @@ void nox::App::ShowCursor( bool show )
156154
SDL_ShowCursor( show );
157155
}
158156

157+
#if defined( _WIN32 )
158+
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
159+
{
160+
int argc = __argc;
161+
char **argv = __argv;
162+
#else
159163
extern "C" int main( int argc, char **argv )
160164
{
165+
#endif
161166
nox::globalApp = new nox::App( argc, argv );
162167

163168
// todo: consider combining these??

qcommon/common.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2020
// common.c -- misc functions used in client and server
2121

2222
#include <csetjmp>
23-
#include <csignal>
2423

2524
#include "qcommon.h"
2625
#include "app.h"
@@ -39,15 +38,15 @@ FILE *log_stats_file;
3938
cvar_t *host_speeds;
4039
cvar_t *log_stats;
4140
cvar_t *developer;
42-
cvar_t *timescale;
43-
cvar_t *fixedtime;
44-
cvar_t *logfile_active; // 1 = buffer log, 2 = flush after each print
45-
cvar_t *showtrace;
41+
static cvar_t *timescale;
42+
static cvar_t *fixedtime;
43+
static cvar_t *logfile_active; // 1 = buffer log, 2 = flush after each print
44+
static cvar_t *showtrace;
4645
cvar_t *dedicated;
4746

48-
FILE *logfile;
47+
static FILE *logfile;
4948

50-
int server_state;
49+
static int server_state;
5150

5251
// host_speeds times
5352
unsigned int time_before_game;

qcommon/files.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct Package
8888
file.read( ( char * ) src.data(), fileIndex->compressedLength );
8989

9090
// decompress it
91-
auto dst = new uint8_t[ fileIndex->length ];
91+
auto dst = ( uint8_t *) Z_Malloc( fileIndex->length );
9292
size_t dstLength = fileIndex->length;
9393
bool status = FS_DecompressFile( src.data(), fileIndex->compressedLength, dst, &dstLength, fileIndex->length );
9494

@@ -100,7 +100,7 @@ struct Package
100100
return dst;
101101
}
102102

103-
delete[] dst;
103+
Z_Free( dst );
104104

105105
return nullptr;
106106
}
@@ -245,7 +245,9 @@ The "game directory" is the first tree on the search path and directory that all
245245
*/
246246
long FS_GetLocalFileLength( const char *path )
247247
{
248-
struct stat buf{};
248+
struct stat buf
249+
{
250+
};
249251
if ( stat( path, &buf ) != 0 )
250252
return -1;
251253

@@ -336,7 +338,7 @@ void *FS_FOpenFile( const char *filename, uint32_t *length )
336338
p++;
337339

338340
// see if we have a match!
339-
for ( const auto& i : search->packDirectories )
341+
for ( const auto &i : search->packDirectories )
340342
{
341343
if ( i.second.mappedDir != rootFolder )
342344
continue;
@@ -420,7 +422,7 @@ int FS_LoadFile( const char *path, void **buffer )
420422

421423
// look for it in the filesystem or pack files
422424
uint32_t length;
423-
void *buf = FS_FOpenFile( upath, &length );
425+
void *buf = FS_FOpenFile( upath, &length );
424426
if ( buf == nullptr )
425427
{
426428
if ( buffer != nullptr )

0 commit comments

Comments
 (0)