Skip to content

Commit acd0b87

Browse files
eagleivgXottab-DUTY
authored andcommitted
xrEngine: some Linux fix
1 parent 7089912 commit acd0b87

19 files changed

+142
-23
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ os:
99
- linux
1010
before_script:
1111
- g++ --version
12-
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev
12+
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev liblockfile-dev
1313
- sudo apt-get install cmake lua5.1-dev libssl-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev
1414
- mkdir bin
1515
- cd bin

src/Common/PlatformLinux.inl

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@
5050
#define __pragma(...) _Pragma(#__VA_ARGS__)
5151
#define __declspec(x)
5252
#define CALLBACK
53+
#define TEXT(x) strdup(x)
54+
55+
inline char *_strlwr_l(char *str, locale_t loc)
56+
{
57+
//TODO
58+
}
59+
60+
inline char *_strupr_l(char *str, locale_t loc)
61+
{
62+
//TODO
63+
}
64+
65+
#define VOID void
66+
#define HKL void *
67+
#define ActivateKeyboardLayout(x, y) {}
68+
#define GetCursorPos(point) {}
69+
#define ScreenToClient(hwnd, p) {}
5370

5471
#define __except(X) catch(X)
5572

@@ -94,7 +111,7 @@ inline int GetExceptionCode()
94111

95112
#define xr_unlink unlink
96113

97-
typedef char BOOL;
114+
typedef bool BOOL;
98115
typedef char* LPSTR;
99116
typedef char* PSTR;
100117
typedef char* LPTSTR;
@@ -131,6 +148,28 @@ typedef struct {
131148
WORD cbSize;
132149
} WAVEFORMATEX, *LPWAVEFORMATEX;
133150

151+
typedef struct tagSTICKYKEYS
152+
{
153+
DWORD cbSize;
154+
DWORD dwFlags;
155+
} STICKYKEYS, *LPSTICKYKEYS;
156+
157+
typedef struct tagFILTERKEYS
158+
{
159+
UINT cbSize;
160+
DWORD dwFlags;
161+
DWORD iWaitMSec;
162+
DWORD iDelayMSec;
163+
DWORD iRepeatMSec;
164+
DWORD iBounceMSec;
165+
} FILTERKEYS, *LPFILTERKEYS;
166+
167+
typedef struct tagTOGGLEKEYS
168+
{
169+
DWORD cbSize;
170+
DWORD dwFlags;
171+
} TOGGLEKEYS, *LPTOGGLEKEYS;
172+
134173
typedef struct _EXCEPTION_POINTERS {
135174
} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
136175

@@ -172,10 +211,15 @@ typedef struct tagPOINT {
172211
long y;
173212
} POINT, *PPOINT, *LPPOINT;
174213

214+
#define DWORD_PTR UINT_PTR
175215
#define WM_USER 0x0400
216+
#define WA_INACTIVE 0
217+
#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
218+
#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))
219+
176220

177-
#define TRUE 1
178-
#define FALSE 0
221+
#define TRUE true
222+
#define FALSE false
179223
#define NONE 0
180224
#define CONST const
181225

@@ -196,9 +240,12 @@ typedef dirent DirEntryType;
196240
#define strcmpi stricmp
197241
#define lstrcpy strcpy
198242
#define stricmp strcasecmp
199-
#define strncpy_s(dest, size, source, num) strncpy(dest, source, num)
200-
#define strcpy_s(dest, num, source) strcpy(dest, source)
243+
#define strupr SDL_strupr
244+
#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num))
245+
#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source))
246+
#define strcat_s(dest, num, source) (dest == strcat(dest, source))
201247
#define _vsnprintf vsnprintf
248+
#define vsprintf_s(dest, size, format, args) vsprintf(dest, format, args)
202249
#define _alloca alloca
203250
#define _snprintf snprintf
204251
#define sprintf_s(buffer, buffer_size, stringbuffer, ...) sprintf(buffer, stringbuffer, ##__VA_ARGS__)
@@ -241,7 +288,11 @@ inline int _filelength(int fd)
241288
#define __max(a, b) std::max(a, b)
242289
#define __min(a, b) std::min(a, b)
243290

244-
#define xr_itoa SDL_itoa
291+
#define itoa SDL_itoa
292+
#define _itoa_s(value, buffer, radix) SDL_itoa(value, buffer, radix)
293+
#define _locale_t locale_t
294+
#define _isalpha_l isalpha_l
295+
#define _create_locale(category, arg) newlocale(category, arg, (locale_t) 0)
245296

246297
#define ZeroMemory(p, sz) memset((p), 0, (sz))
247298
#define CopyMemory(d, s, n) memcpy(d, s, n)
@@ -256,4 +307,7 @@ inline int _filelength(int fd)
256307
#define _MAX_DRIVE 3
257308
#define _MAX_DIR 256
258309
#define _MAX_FNAME 256
259-
#define _MAX_EXT 256
310+
#define _MAX_EXT 256
311+
312+
#define SEM_FAILCRITICALERRORS 1
313+
#define SetErrorMode(x) {x=x}

src/xrCore/_math.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ extern XRCORE_API void _initialize_cpu_thread();
4040
using thread_t = void(void*);
4141
extern XRCORE_API void thread_name(const char* name);
4242
extern XRCORE_API void thread_spawn(thread_t* entry, const char* name, unsigned stack, void* arglist);
43+
44+
#if defined(LINUX)
45+
void QueryPerformanceCounter(PLARGE_INTEGER result);
46+
DWORD timeGetTime();
47+
#endif

src/xrEngine/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ include_directories(
1111
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/OpenAutomate/inc
1212
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/FreeImage/Dist/x64
1313
${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/include
14+
${CMAKE_CURRENT_SOURCE_DIR}/../../Externals/luabind
1415
/usr/include/SDL2
1516
)
1617

18+
list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./tntQAVI.cpp")
1719
list(REMOVE_ITEM ${PROJECT_NAME}__SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/./editor_environment_manager_properties.cpp")
18-
#list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./xr_cda.h")
20+
21+
list(REMOVE_ITEM ${PROJECT_NAME}__INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/./tntQAVI.h")
1922

2023
add_definitions(-DENGINE_BUILD)
2124
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}__SOURCES} ${${PROJECT_NAME}__INCLUDES})
2225

2326
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
24-
target_link_libraries(${PROJECT_NAME} xrCore luabind xrAPI xrSound xrScriptEngine luajit theora ${OGG_LIBRARIES} xrNetServer xrCDB xrPhysics openal)
27+
target_link_libraries(${PROJECT_NAME} xrCore luabind xrAPI xrSound xrScriptEngine luajit theora ${OGG_LIBRARIES} xrNetServer xrCDB xrPhysics openal lockfile)

src/xrEngine/Device_Initialize.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "PerformanceAlert.hpp"
99
#include "xrCore/ModuleLookup.hpp"
1010

11-
extern LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
12-
1311
void CRenderDevice::initialize_weather_editor()
1412
{
1513
m_editor_module = XRay::LoadModule("xrWeatherEditor");
@@ -48,7 +46,10 @@ void CRenderDevice::Initialize()
4846

4947
if (!m_sdlWnd)
5048
{
51-
Uint32 flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALWAYS_ON_TOP;
49+
Uint32 flags = SDL_WINDOW_BORDERLESS;
50+
#if SDL_VERSION_ATLEAST(2, 0, 5)
51+
flags |= SDL_WINDOW_ALWAYS_ON_TOP;
52+
#endif
5253

5354
if (strstr(Core.Params, "-gl"))
5455
flags |= SDL_WINDOW_OPENGL;

src/xrEngine/Device_wndproc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "stdafx.h"
22

3+
#if defined(WINDOWS)
34
bool CRenderDevice::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result)
45
{
56
switch (uMsg)
@@ -53,6 +54,7 @@ bool CRenderDevice::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
5354

5455
return (false);
5556
}
57+
5658
//-----------------------------------------------------------------------------
5759
// Name: WndProc()
5860
// Desc: Static msg handler which passes messages to the application class.
@@ -65,3 +67,4 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
6567

6668
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
6769
}
70+
#endif

src/xrEngine/EngineAPI.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ CEngineAPI::~CEngineAPI()
4040

4141
bool is_enough_address_space_available()
4242
{
43+
#if defined(WINDOWS)
4344
SYSTEM_INFO system_info;
4445
GetSystemInfo(&system_info);
4546
return (*(u32*)&system_info.lpMaximumApplicationAddress) > 0x90000000;
47+
#else
48+
return TRUE; // In linux allocated memory limited only by pointer size
49+
#endif
4650
}
4751

4852
void CEngineAPI::SetupCurrentRenderer()

src/xrEngine/IObjectPhysicsCollision.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
class IPhysicsShell;
44
class IPhysicsElement;
5+
#if defined(WINDOWS)
56
xr_pure_interface IObjectPhysicsCollision
67
{
78
public:
89
virtual const IPhysicsShell* physics_shell() const = 0;
910
virtual const IPhysicsElement* physics_character() const = 0; // depricated
1011
};
12+
#endif

src/xrEngine/IPHdebug.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
22

3+
#include "xrCore/_types.h"
4+
5+
#if defined(WINDOWS)
36
xr_pure_interface IPhDebugRender
47
{
58
virtual void open_cashed_draw() = 0;
@@ -8,3 +11,4 @@ xr_pure_interface IPhDebugRender
811
};
912

1013
extern ENGINE_API IPhDebugRender* ph_debug_render;
14+
#endif

src/xrEngine/Text_Console_WndProc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "stdafx.h"
22
#include "Text_Console.h"
33

4+
#if defined(WINDOWS)
45
LRESULT CALLBACK TextConsole_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
56
{
67
switch (uMsg)
@@ -51,3 +52,4 @@ LRESULT CALLBACK TextConsole_LogWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
5152
}
5253
return DefWindowProc(hWnd, uMsg, wParam, lParam);
5354
}
55+
#endif

0 commit comments

Comments
 (0)