Skip to content

Commit dbc99d4

Browse files
committed
xrEngine: some Linux fix
1 parent 0805db3 commit dbc99d4

20 files changed

+112
-20
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: 32 additions & 3 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;
@@ -194,10 +211,15 @@ typedef struct tagPOINT {
194211
long y;
195212
} POINT, *PPOINT, *LPPOINT;
196213

214+
#define DWORD_PTR UINT_PTR
197215
#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))
198219

199-
#define TRUE 1
200-
#define FALSE 0
220+
221+
#define TRUE true
222+
#define FALSE false
201223
#define NONE 0
202224
#define CONST const
203225

@@ -218,6 +240,7 @@ typedef dirent DirEntryType;
218240
#define strcmpi stricmp
219241
#define lstrcpy strcpy
220242
#define stricmp strcasecmp
243+
#define strupr SDL_strupr
221244
#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num))
222245
#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source))
223246
#define strcat_s(dest, num, source) (dest == strcat(dest, source))
@@ -267,6 +290,9 @@ inline int _filelength(int fd)
267290

268291
#define itoa SDL_itoa
269292
#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)
270296

271297
#define ZeroMemory(p, sz) memset((p), 0, (sz))
272298
#define CopyMemory(d, s, n) memcpy(d, s, n)
@@ -282,3 +308,6 @@ inline int _filelength(int fd)
282308
#define _MAX_DIR 256
283309
#define _MAX_FNAME 256
284310
#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/Feel_Sound.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "xrSound/sound.h"
2+
#include "xrSound/Sound.h"
33

44
// fwd. decl.
55
class IGameObject;

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "xrCore/_types.h"
44

5+
#if defined(WINDOWS)
56
xr_pure_interface IPhDebugRender
67
{
78
virtual void open_cashed_draw() = 0;
@@ -10,3 +11,4 @@ xr_pure_interface IPhDebugRender
1011
};
1112

1213
extern ENGINE_API IPhDebugRender* ph_debug_render;
14+
#endif

0 commit comments

Comments
 (0)