Skip to content

Commit

Permalink
Work on getting engine to build on other compilers (g++ and codegear)…
Browse files Browse the repository at this point in the history
… and fix warnings.
  • Loading branch information
penenin committed Aug 18, 2012
1 parent 3d35508 commit 458a14f
Show file tree
Hide file tree
Showing 31 changed files with 180 additions and 55 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ else(USE_INTERNAL_FREETYPE)
find_package(Freetype)
endif(USE_INTERNAL_FREETYPE)

if(WIN32)
add_definitions(-D_WINDOWS)
else(WIN32)
add_definitions(-D_LINUX -D__LINUX)
endif(WIN32)

if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)

if(NOT DEBUG)
if(DEBUG)
add_definitions(-D_DEBUG)
else(DEBUG)
add_definitions(-D_FINAL)
endif(NOT DEBUG)
endif(DEBUG)

add_subdirectory(libs/lith) # Lib_Lith
add_subdirectory(libs/stdlith) # Lib_StdLith
Expand Down
5 changes: 4 additions & 1 deletion NOLF2/ClientFxDLL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ include_directories (../Shared

if(MSVC)
set_target_properties(NOLF2_ClientFXDLL PROPERTIES COMPILE_FLAGS "/wd4996")
endif(MSVC)
endif(MSVC)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(NOLF2_ClientFXDLL PROPERTIES COMPILE_FLAGS "-fpermissive")
endif(CMAKE_COMPILER_IS_GNUCXX)
1 change: 0 additions & 1 deletion NOLF2/Shared/FXProp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
};

// Enumerations

enum eDataType
{
STRING,
Expand Down
6 changes: 5 additions & 1 deletion libs/ButeMgr/butemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,11 @@ bool CButeMgr::Save(const char* szNewFileName)
ifstream is(m_sAttributeFilename, ios::nocreate | ios::binary);
#endif // VC7

long nFileLength=0;
#if _MSC_VER >= 1300
std::streamoff nFileLength=0;
#else
streamoff nFileLength=0;
#endif
if (is.is_open())
{
#if _MSC_VER >= 1300
Expand Down
12 changes: 6 additions & 6 deletions libs/ButeMgr/butemgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ class CButeMgr

#if _MSC_VER >= 1300
bool Parse( std::istream& iStream, int decryptCode = 0);
bool Parse( std::istream& iCrypt, int nLen, const char* cryptKey);
bool Parse( std::istream& iCrypt, std::streamsize nLen, const char* cryptKey);
#else
bool Parse( istream& iStream, int decryptCode = 0);
bool Parse( istream& iCrypt, int nLen, const char* cryptKey);
bool Parse( istream& iCrypt, streamsize nLen, const char* cryptKey);
#endif // VC7

#if defined(_USE_REZFILE_)
Expand Down Expand Up @@ -514,14 +514,14 @@ inline bool CButeMgr::Parse( istream& iStream, int decryptCode)
}

#if _MSC_VER >= 1300
inline bool CButeMgr::Parse( std::istream& iCrypt, int nLen, const char* cryptKey)
inline bool CButeMgr::Parse( std::istream& iCrypt, std::streamsize nLen, const char* cryptKey)
#else
inline bool CButeMgr::Parse( istream& iCrypt, int nLen, const char* cryptKey)
inline bool CButeMgr::Parse( istream& iCrypt, streamsize nLen, const char* cryptKey)
#endif // VC7
{
m_bCrypt = true;
m_cryptMgr.SetKey(cryptKey);
char* buf2 = new char[nLen];
char* buf2 = new char[(unsigned int)nLen];
#if _MSC_VER >= 1300
std::ostrstream* pOss = new std::ostrstream(buf2, nLen);
#else
Expand Down Expand Up @@ -695,7 +695,7 @@ inline bool CButeMgr::Parse(CString sAttributeFilename, const char* cryptKey)
#else
pIs->seekg(0, ios::end);
#endif // VC7
long len = pIs->tellg();
std::streamoff len = pIs->tellg();

pIs->seekg(0);

Expand Down
2 changes: 1 addition & 1 deletion libs/Lib_DShow/refclock.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class CBaseReferenceClock
protected:
CAMSchedule * const m_pSchedule;

void Restart (IN REFERENCE_TIME rtMinTime = 0I64) ;
void Restart (IN REFERENCE_TIME rtMinTime = 0) ;
};

#endif
Expand Down
3 changes: 3 additions & 0 deletions libs/lith/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ add_library (Lib_Lith STATIC
if(MSVC)
set_target_properties(Lib_Lith PROPERTIES COMPILE_FLAGS "/wd4996")
endif(MSVC)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(Lib_Lith PROPERTIES COMPILE_FLAGS "-fpermissive")
endif(CMAKE_COMPILER_IS_GNUCXX)
4 changes: 4 additions & 0 deletions libs/lith/lithbaselist.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#ifndef __LITHBASELIST_H__
#define __LITHBASELIST_H__

#ifndef NULL
#define NULL 0
#endif

template<class ItemType>
class CLithBaseList;

Expand Down
5 changes: 3 additions & 2 deletions libs/ltmem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
cmake_minimum_required (VERSION 2.8)
project (ltmem)
export (PACKAGE ltmem)
add_library (ltmem STATIC
ltmem.cpp
ltmemdebug.cpp
ltmemheap.cpp
ltmemstats.cpp
ltmemtrack.cpp
StdAfx.cpp)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
include_directories (../../sdk/inc
../../runtime/shared/src
../../runtime/kernel/src
../stdlith
../../runtime/kernel/mem/src)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(ltmem PROPERTIES COMPILE_FLAGS "-fpermissive")
endif(CMAKE_COMPILER_IS_GNUCXX)
3 changes: 3 additions & 0 deletions libs/rezmgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ include_directories (../../sdk/inc
if(MSVC)
set_target_properties(Lib_RezMgr PROPERTIES COMPILE_FLAGS "/wd4996")
endif(MSVC)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(Lib_RezMgr PROPERTIES COMPILE_FLAGS "-fpermissive")
endif(CMAKE_COMPILER_IS_GNUCXX)
4 changes: 4 additions & 0 deletions libs/stdlith/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ add_library (Lib_StdLith STATIC
stringholder.cpp
struct_bank.cpp
zfstream.cpp)
include_directories(../zlib)
target_link_libraries(Lib_StdLith
Lib_ZLib)
if(MSVC)
set_target_properties(Lib_StdLith PROPERTIES COMPILE_FLAGS "/wd4996")
endif(MSVC)

2 changes: 1 addition & 1 deletion libs/stdlith/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __MEMORY_H__

#ifndef __NEW_H__
#ifndef _LINUX
#ifndef __GNUC__
#include <new.h>
#define __NEW_H__
#endif
Expand Down
5 changes: 4 additions & 1 deletion runtime/info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ include_directories(src
../kernel/src
../shared/src)
set_target_properties(Lib_Info
PROPERTIES OUTPUT_NAME libltinfo)
PROPERTIES OUTPUT_NAME libltinfo)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(Lib_Info PROPERTIES COMPILE_FLAGS "-fpermissive")
endif(CMAKE_COMPILER_IS_GNUCXX)
17 changes: 16 additions & 1 deletion runtime/kernel/mem/src/sys/win/de_memory.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

#include "bdefs.h"
#ifdef _MSC_VER
#include <new.h>
#else
#include <new>
#endif
#include "de_memory.h"
#include "build_options.h"
#include "sysdebugging.h"
Expand All @@ -24,7 +28,12 @@ static uint32 g_nAllocations;
uint32 g_nTotalAllocations, g_nTotalFrees;

static int g_MemRefCount=0;
#ifdef _MSC_VER
static _PNH g_OldNewHandler;
#else
static std::new_handler g_OldNewHandler;
#define _set_new_handler std::set_new_handler
#endif

// PlayDemo profile info.
uint32 g_PD_Malloc=0;
Expand Down Expand Up @@ -53,12 +62,18 @@ void dm_HeapCompact()
}
}


#ifdef _MSC_VER
static int dm_NewHandler(size_t size)
{
dsi_OnMemoryFailure();
return 0;
}
#else
static void dm_NewHandler()
{
dsi_OnMemoryFailure();
}
#endif


void dm_Init()
Expand Down
1 change: 1 addition & 0 deletions runtime/kernel/net/src/netmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ enum EDisconnectReason { DISCONNECTREASON_VOLUNTARY_CLIENTSIDE =0,
DISCONNECTREASON_KICKED =6 };

class BaseService;
class CNetMgr;
// Base class for a network driver (such as DirectPlay).
class CBaseDriver
{
Expand Down
6 changes: 3 additions & 3 deletions runtime/kernel/net/src/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ class CPacket_Read
CPacket_Read()
: m_nStart(0)
{
#ifdef __LINUX
#ifdef _MSC_VER
Init(CPacket_Write());
#else
CPacket_Write cPacketWrite;
Init(cPacketWrite);
#else
Init(CPacket_Write());
#endif

}
Expand Down
2 changes: 2 additions & 0 deletions runtime/kernel/src/sys/win/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ static bool StartClient(ClientGlob *pGlob)
char strVersion[32];
uint32 nResTrees;

#ifdef _M_IX86
short control;
_asm {
fstcw control // Get FPU control word
and control, 0xfcff // PC field = 00 for single precision
fldcw control
}
#endif

// Init the client mugger.
pGlob->m_bHost = command_line_args->FindArgDash("host") != NULL;
Expand Down
22 changes: 16 additions & 6 deletions runtime/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ include_directories(src
../render_b/src
../ui/src
../controlfilemgr)

if(NOT MSVC) # FIXME: this is a hack for geomroutines.h:309
include_directories(../../tools/PreProcessor)
endif(NOT MSVC)

if(WIN32)
include_directories(../kernel/src/sys/win
Expand All @@ -165,16 +169,22 @@ add_library (DLL_Server SHARED ${libsources})
set_target_properties(DLL_Server
PROPERTIES OUTPUT_NAME Server)
target_link_libraries(DLL_Server
Lib_RezMgr
Lib_Info
Lib_Lith
Lib_StdLith
ltmem
Lib_RezMgr)
ltmem)

if(WIN32)
target_link_libraries(DLL_Server
winmm
ws2_32)
endif(WIN32)

if(MSVC)
set_target_properties(DLL_Server PROPERTIES COMPILE_FLAGS "/wd4996")
endif(MSVC)
if(WIN32)
target_link_libraries(DLL_Server winmm)
endif(WIN32)

if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(DLL_Server PROPERTIES COMPILE_FLAGS "-fpermissive")
endif(CMAKE_COMPILER_IS_GNUCXX)
21 changes: 19 additions & 2 deletions runtime/shared/src/geomroutines.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@
#define LOCATE_POINT_STACKSIZE 4000
#define ALL_FLAGS (uint32)0xFFFFFFFF

#ifndef ZERO
#define ZERO 0
#endif

#ifndef NF_IN
#define NF_IN 1
#endif

#ifndef NF_OUT
#define NF_OUT 2
#endif

// Functions....

Expand Down Expand Up @@ -296,7 +306,11 @@ T* g_IntersectRay( T *pRoot, TVector3<F> &pt, TVector3<F> &dir, F &t, TVector3<F
return LTNULL;
}


#ifndef _MSC_VER
#define PVector LTVector
#define PReal float
#include "node.h"
#endif

// ----------------------------------------------------------------------- //
// Routine: g_LocatePointInTree
Expand All @@ -321,10 +335,13 @@ int g_LocatePointInTree( M *pWorld, TVector3<F> &point, int iRoot )
if( pRoot->m_Sides[side] >= 0 )
iRoot = pRoot->m_Sides[side];
else
return (side == FrontSide) ? iRoot : NODE_OUT;
return (side == FrontSide) ? iRoot : (int)NODE_OUT;
}
}

#undef NODE_IN
#undef NODE_OUT


// ----------------------------------------------------------------------- //
//
Expand Down
16 changes: 8 additions & 8 deletions runtime/shared/src/listqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ struct CListQueue_Iterator : public CListQueue_Iterator_Base<T>
CListQueue_Iterator() {}
CListQueue_Iterator(const CListQueue_Iterator<T> &cOther) : CListQueue_Iterator_Base<T>(cOther.m_pFinger) {}
CListQueue_Iterator &operator=(const CListQueue_Iterator<T> &cOther) {
m_pFinger = cOther.m_pFinger;
CListQueue_Iterator_Base<T>::m_pFinger = cOther.m_pFinger;
return *this;
}
T &operator*() const { return m_pFinger->m_cValue; }
T *operator->() const { return &m_pFinger->m_cValue; }
CListQueue_Iterator &operator++() { m_pFinger = m_pFinger->m_pNext; return *this; }
T &operator*() const { return CListQueue_Iterator_Base<T>::m_pFinger->m_cValue; }
T *operator->() const { return &CListQueue_Iterator_Base<T>::m_pFinger->m_cValue; }
CListQueue_Iterator &operator++() { CListQueue_Iterator_Base<T>::m_pFinger = CListQueue_Iterator_Base<T>::m_pFinger->m_pNext; return *this; }
private:
CListQueue_Iterator(typename CListQueue<T>::CItem *pItem) : CListQueue_Iterator_Base<T>(pItem) {}
};
Expand All @@ -277,12 +277,12 @@ struct CListQueue_Const_Iterator : public CListQueue_Iterator_Base<T>
return *this;
}

m_pFinger = cOther.m_pFinger;
CListQueue_Iterator_Base<T>::m_pFinger = cOther.m_pFinger;
return *this;
}
const T &operator*() const { return m_pFinger->m_cValue; }
const T *operator->() const { return &m_pFinger->m_cValue; }
CListQueue_Const_Iterator &operator++() { m_pFinger = m_pFinger->m_pNext; return *this; }
const T &operator*() const { return CListQueue_Iterator_Base<T>::m_pFinger->m_cValue; }
const T *operator->() const { return &CListQueue_Iterator_Base<T>::m_pFinger->m_cValue; }
CListQueue_Const_Iterator &operator++() { CListQueue_Iterator_Base<T>::m_pFinger = CListQueue_Iterator_Base<T>::m_pFinger->m_pNext; return *this; }
private:
CListQueue_Const_Iterator(const typename CListQueue<T>::CItem *pItem) : CListQueue_Iterator_Base<T>(const_cast< typename CListQueue<T>::CItem*>(pItem)) {}
};
Expand Down
2 changes: 2 additions & 0 deletions runtime/shared/src/moveobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class MoveState

void SetupCall()
{
#ifdef _DEBUG
ASSERT(Verify());
#endif
m_bServer = m_pAbstract->IsServer();
}

Expand Down
Loading

0 comments on commit 458a14f

Please sign in to comment.