Merge pull request #31 from DanielGibson/more-64bit-fixes

More 64bit fixes
This commit is contained in:
Ryan C. Gordon 2016-04-21 12:31:05 -04:00
commit e64199441a
14 changed files with 143 additions and 75 deletions

View File

@ -21,6 +21,9 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
# ssam expects the libs to be in Debug/
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)
# Use systemwide SDL2 or custom build # Use systemwide SDL2 or custom build
# RAKE!: Find a way to use their custom built library if # RAKE!: Find a way to use their custom built library if
# they want to use that instead or if their system only # they want to use that instead or if their system only
@ -110,6 +113,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-switch) add_compile_options(-Wno-switch)
add_compile_options(-Wno-format-security) add_compile_options(-Wno-format-security)
add_definitions(-Wno-logical-op-parentheses)
MESSAGE(WARNING, "re-enable -Wlogical-op-parentheses some day!")
if(MACOSX) if(MACOSX)
add_definitions(-DPLATFORM_UNIX=1) add_definitions(-DPLATFORM_UNIX=1)
@ -182,9 +187,8 @@ else()
set(DEBUGSUFFIX "") set(DEBUGSUFFIX "")
endif() endif()
# !!! FIXME: you currently need this, but I'd like to flip this to not use # This should not be needed anymore, but might be faster on 32bit x86
# !!! FIXME: assembly language. And maybe delete the asm code too. option(USE_I386_ASM "Use X86 ASM" FALSE)
option(USE_I386_ASM "Use X86 ASM" TRUE)
if (USE_I386_ASM) if (USE_I386_ASM)
# You need the Netwide Assembler (NASM) to build this on Intel systems. # You need the Netwide Assembler (NASM) to build this on Intel systems.
@ -198,8 +202,10 @@ if (USE_I386_ASM)
else() else()
set(ASMOBJFMT "elf") set(ASMOBJFMT "elf")
endif() endif()
MESSAGE(STATUS "Using i386 assembler")
else() else()
add_definitions(-DUSE_PORTABLE_C=1) add_definitions(-DUSE_PORTABLE_C=1)
MESSAGE(STATUS "Using portable C instead of ASM")
endif() endif()
option(PANDORA "Compile for Pandora" FALSE) option(PANDORA "Compile for Pandora" FALSE)
@ -905,13 +911,24 @@ if(BUILD_DEDICATED_SERVER)
endif() endif()
if(MACOSX) if(MACOSX)
target_link_libraries(ssam ${ZLIB_LIBRARIES})
if(USE_SYSTEM_SDL2) # use sdl2 framework on system
target_link_libraries(ssam ${SDL2_LIBRARY})
else() # use local libsdl2
find_library(COCOA_FRAMEWORK Cocoa) find_library(COCOA_FRAMEWORK Cocoa)
target_link_libraries(ssam "${COCOA_FRAMEWORK}") target_link_libraries(ssam "${COCOA_FRAMEWORK}")
target_link_libraries(ssam "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") target_link_libraries(ssam "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib")
endif()
if(BUILD_DEDICATED_SERVER) if(BUILD_DEDICATED_SERVER)
target_link_libraries(SeriousSamDedicated ${ZLIB_LIBRARIES})
if(USE_SYSTEM_SDL2)
target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY})
else()
target_link_libraries(SeriousSamDedicated "${COCOA_FRAMEWORK}") target_link_libraries(SeriousSamDedicated "${COCOA_FRAMEWORK}")
target_link_libraries(SeriousSamDedicated "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") target_link_libraries(SeriousSamDedicated "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib")
endif() endif()
endif()
endif() endif()
if(LINUX) if(LINUX)

View File

@ -38,6 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifdef PLATFORM_UNIX /* rcg10042001 */ #ifdef PLATFORM_UNIX /* rcg10042001 */
#include "SDL_assert.h" #include "SDL_assert.h"
#define _assert(x, y, z) SDL_assert(0) #define _assert(x, y, z) SDL_assert(0)
#include <signal.h> // raise()
#endif #endif

View File

@ -70,5 +70,35 @@ inline void CRC_AddBlock(ULONG &ulCRC, UBYTE *pubBlock, ULONG ulSize)
// end crc calculation // end crc calculation
inline void CRC_Finish(ULONG &ulCRC) { ulCRC ^= 0xFFFFFFFF; }; inline void CRC_Finish(ULONG &ulCRC) { ulCRC ^= 0xFFFFFFFF; };
// in 32bit mode, it just returns iPtr ULONG,
// in 64bit mode it returns the CRC hash of iPtr (or 0 if ptr == NULL)
// so either way you should get a value that very likely uniquely identifies the pointer
inline ULONG IntPtrToID(size_t iPtr)
{
#if PLATFORM_32BIT
return (ULONG)iPtr;
#else
// in case the code relies on 0 having special meaning because of NULL-pointers...
if(iPtr == 0) return 0;
ULONG ret;
CRC_Start(ret);
CRC_AddLONGLONG(ret, iPtr);
CRC_Finish(ret);
return ret;
#endif
}
// in 32bit mode, it just returns the pointer's address as ULONG,
// in 64bit mode it returns the CRC hash of the pointer's address (or 0 if ptr == NULL)
// so either way you should get a value that very likely uniquely identifies the pointer
inline ULONG PointerToID(void* ptr)
{
#if PLATFORM_32BIT
return (ULONG)(size_t)ptr;
#else
return IntPtrToID((size_t)ptr);
#endif
}
#endif /* include-once check. */ #endif /* include-once check. */

View File

@ -61,37 +61,44 @@ typedef unsigned int UINT;
#define PLATFORM_LITTLEENDIAN 1 #define PLATFORM_LITTLEENDIAN 1
#endif #endif
#ifdef PLATFORM_WIN32 #if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_ARCH_PPC64) \
#ifdef _WIN64 || defined(_M_IA64) || defined(__IA64__)
#define PLATFORM_64BIT 1 #define PLATFORM_64BIT 1
#else
#elif defined(__i386) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) || defined(__POWERPC__) \
|| defined(_M_PPC) || defined(_ARCH_PPC)
#define PLATFORM_32BIT 1 #define PLATFORM_32BIT 1
#endif
#else #else
// AFAIK there were versions of MSVC where UINTPTR_MAX was incorrect, #error "Unknown CPU-Architecture, adapt this code to detect 32/64bitness of your system!"
// so I use different code for Windows above
#include <stdint.h> // UINTPTR_MAX
#ifdef UINTPTR_MAX
#if UINTPTR_MAX == 0xffffffffuL
#define PLATFORM_32BIT 1
#elif UINTPTR_MAX == 0xffffffffffffffffuLL
#define PLATFORM_64BIT 1
#else
#error WTF, your system seems to be neither 32bit nor 64bit?!
#endif
#else
#error Your system does not provide UINTPRT_MAX, find another way!
#endif
#if UINTPTR_MAX != SIZE_MAX
// the code uses size_t to store pointers all over the place, so if size_t and uintptr_t
// don't have the same size on your system, you're in real trouble.
// (before panicking however make sure your headers don't just contain bullshit values for UINTPTR_MAX or SIZE_MAX)
#error Seems like on your system sizeof(size_t) != sizeof(uintptr_t) - that is *very* bad.
#endif
#endif #endif
// if the compiler complains about the typedef created by MY_STATIC_ASSERT being invalid
// (because of array with negative size), it means the check for cond has failed
#define MY_STATIC_ASSERT(namesuffx, cond) \
typedef char sesam__check_ ## namesuffx [ (cond) ? 1 : -1 ];
// some sanity checks to make sure the PLATFORM_*BIT #defines match the pointer size
// and that size_t is the size of a pointer, as expected (as we sometimes use size_t to store pointers)
#ifdef PLATFORM_32BIT
MY_STATIC_ASSERT(32bit_PointerSize, sizeof(void*) == 4);
#ifdef PLATFORM_64BIT
#error "PLATFORM_32BIT and PLATFORM_64BIT must not be #defined at the same time!"
#endif
#endif
#ifdef PLATFORM_64BIT
MY_STATIC_ASSERT(64bit_PointerSize, sizeof(void*) == 8);
#endif
MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
#undef MY_STATIC_ASSERT
// Mac symbols have an underscore prepended... // Mac symbols have an underscore prepended...
#if PLATFORM_MACOSX #if PLATFORM_MACOSX
#define ASMSYM(x) "_" #x #define ASMSYM(x) "_" #x

View File

@ -481,7 +481,7 @@ ModelTextureVertex::ModelTextureVertex(void)
//------------------------------------------ WRITE //------------------------------------------ WRITE
void ModelPolygonVertex::Write_t( CTStream *pFile) // throw char * void ModelPolygonVertex::Write_t( CTStream *pFile) // throw char *
{ {
STUBBED("64-bit issue"); // DG: probably ok, because PtrToIndices() should have been called before this // DG: this looks like a 64-bit issue, but most probably isn't as PtrToIndices() should have been called before this
(*pFile) << (INDEX) (size_t) mpv_ptvTransformedVertex; (*pFile) << (INDEX) (size_t) mpv_ptvTransformedVertex;
(*pFile) << (INDEX) (size_t) mpv_ptvTextureVertex; (*pFile) << (INDEX) (size_t) mpv_ptvTextureVertex;
} }
@ -490,7 +490,8 @@ void ModelPolygonVertex::Read_t( CTStream *pFile) // throw char *
{ {
INDEX itmp; INDEX itmp;
STUBBED("64-bit issue"); // DG: probably ok, because IndicesToPtrs() should be called afterwards // DG: this looks like a 64-bit issue, but most probably isn't as IndicesToPtrs() should be
// called afterwards to restore actually valid pointers.
(*pFile) >> itmp; (*pFile) >> itmp;
mpv_ptvTransformedVertex = (struct TransformedVertexData *) (size_t) itmp; mpv_ptvTransformedVertex = (struct TransformedVertexData *) (size_t) itmp;
(*pFile) >> itmp; (*pFile) >> itmp;
@ -1068,10 +1069,11 @@ void CModelData::IndicesToPtrs()
FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2) FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2)
{ {
struct ModelPolygonVertex * pMPV = &it2.Current(); struct ModelPolygonVertex * pMPV = &it2.Current();
STUBBED("64-bit issue"); // DG: probably ok, the pointers really contain indices from PtrToIndices() // DG: this looks like a 64-bit issue but is most probably ok, as the pointers
// should contain indices from PtrToIndices()
j = (INDEX) (size_t) it2.Current().mpv_ptvTransformedVertex; j = (INDEX) (size_t) it2.Current().mpv_ptvTransformedVertex;
it2.Current().mpv_ptvTransformedVertex = &md_TransformedVertices[ j]; it2.Current().mpv_ptvTransformedVertex = &md_TransformedVertices[ j];
STUBBED("64-bit issue"); // DG: probably ok, the pointers really contain indices from PtrToIndices() // DG: same here
j = (INDEX) (size_t) it2.Current().mpv_ptvTextureVertex; j = (INDEX) (size_t) it2.Current().mpv_ptvTextureVertex;
it2.Current().mpv_ptvTextureVertex = &md_MipInfos[ i].mmpi_TextureVertices[ j]; it2.Current().mpv_ptvTextureVertex = &md_MipInfos[ i].mmpi_TextureVertices[ j];
} }

View File

@ -60,7 +60,7 @@ public:
TIME pe_tmTick; TIME pe_tmTick;
ULONG pe_ulEntityID; ULONG pe_ulEntityID;
ULONG pe_ulTypeID; ULONG pe_ulTypeID;
ULONG pe_ulEventID; // FIXME: make this void* or uintptr_t/size_t ULONG pe_ulEventID;
CPredictedEvent(void); CPredictedEvent(void);
void Clear(void) {}; void Clear(void) {};

View File

@ -213,8 +213,7 @@ void CSoundObject::Play(CSoundData *pCsdLink, SLONG slFlags)
//CPrintF("PLAY: '%s'", (const char*)pCsdLink->GetName().FileName()); //CPrintF("PLAY: '%s'", (const char*)pCsdLink->GetName().FileName());
// get prediction tail // get prediction tail
STUBBED("64-bit issue"); CSoundObject *psoTail = GetPredictionTail(EVENT_SOUNDPLAY, PointerToID(pCsdLink));
CSoundObject *psoTail = GetPredictionTail(EVENT_SOUNDPLAY, (ULONG)(size_t)pCsdLink);
// if the event is predicted // if the event is predicted
if (psoTail==NULL) { if (psoTail==NULL) {
// do nothing; // do nothing;
@ -350,8 +349,7 @@ void CSoundObject::Stop(void)
CSoundObject *psoTail = this; CSoundObject *psoTail = this;
// get prediction tail // get prediction tail
STUBBED("64-bit issue"); psoTail = GetPredictionTail(EVENT_SOUNDSTOP, PointerToID(so_pCsdLink));
psoTail = GetPredictionTail(EVENT_SOUNDSTOP, (ULONG)(size_t)so_pCsdLink);
// if the event is predicted // if the event is predicted
if (psoTail==NULL) { if (psoTail==NULL) {
// do nothing; // do nothing;

View File

@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <Engine/Templates/BSP_internal.h> #include <Engine/Templates/BSP_internal.h>
#include <Engine/Base/Stream.h> #include <Engine/Base/Stream.h>
#include <Engine/Base/CRC.h>
#include <Engine/Math/Vector.h> #include <Engine/Math/Vector.h>
#include <Engine/Math/Plane.h> #include <Engine/Math/Plane.h>
#include <Engine/Math/OBBox.h> #include <Engine/Math/OBBox.h>
@ -219,7 +220,7 @@ void BSPVertexContainer<Type, iDimensions>::ElliminatePairedVertices(void)
* Create edges from vertices in one container -- must be sorted before. * Create edges from vertices in one container -- must be sorted before.
*/ */
template<class Type, int iDimensions> template<class Type, int iDimensions>
void BSPVertexContainer<Type, iDimensions>::CreateEdges(CDynamicArray<BSPEdge<Type, iDimensions> > &abed, ULONG ulEdgeTag) void BSPVertexContainer<Type, iDimensions>::CreateEdges(CDynamicArray<BSPEdge<Type, iDimensions> > &abed, size_t ulEdgeTag)
{ {
// if there are no vertices, or the container is not line // if there are no vertices, or the container is not line
if (bvc_aVertices.Count()==0 || IsPlannar()) { if (bvc_aVertices.Count()==0 || IsPlannar()) {
@ -372,7 +373,7 @@ void BSPEdge<Type, iDimensions>::OptimizeBSPEdges(CDynamicArray<BSPEdge<Type, iD
* Add an edge to the polygon. * Add an edge to the polygon.
*/ */
template<class Type, int iDimensions> template<class Type, int iDimensions>
inline void BSPPolygon<Type, iDimensions>::AddEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, ULONG ulTag) inline void BSPPolygon<Type, iDimensions>::AddEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, size_t ulTag)
{ {
*bpo_abedPolygonEdges.New() = BSPEdge<Type, iDimensions>(vPoint0, vPoint1, ulTag); *bpo_abedPolygonEdges.New() = BSPEdge<Type, iDimensions>(vPoint0, vPoint1, ulTag);
} }
@ -412,7 +413,7 @@ BSPNode<Type, iDimensions>::BSPNode(enum BSPNodeLocation bnl)
* Constructor for a branch node. * Constructor for a branch node.
*/ */
template<class Type, int iDimensions> template<class Type, int iDimensions>
BSPNode<Type, iDimensions>::BSPNode(const Plane<Type, iDimensions> &plSplitPlane, ULONG ulPlaneTag, BSPNode<Type, iDimensions>::BSPNode(const Plane<Type, iDimensions> &plSplitPlane, size_t ulPlaneTag,
BSPNode<Type, iDimensions> &bnFront, BSPNode<Type, iDimensions> &bnBack) BSPNode<Type, iDimensions> &bnFront, BSPNode<Type, iDimensions> &bnBack)
: Plane<Type, iDimensions>(plSplitPlane) : Plane<Type, iDimensions>(plSplitPlane)
, bn_pbnFront(&bnFront) , bn_pbnFront(&bnFront)
@ -731,7 +732,7 @@ void BSPCutter<Type, iDimensions>::CutPolygon(BSPPolygon<Type, iDimensions> &bpo
* -- returns FALSE if polygon is laying on the plane * -- returns FALSE if polygon is laying on the plane
*/ */
template<class Type, int iDimensions> template<class Type, int iDimensions>
BOOL BSPCutter<Type, iDimensions>::SplitPolygon(BSPPolygon<Type, iDimensions> &bpoPolygon, const Plane<Type, iDimensions> &plSplitPlane, ULONG ulPlaneTag, BOOL BSPCutter<Type, iDimensions>::SplitPolygon(BSPPolygon<Type, iDimensions> &bpoPolygon, const Plane<Type, iDimensions> &plSplitPlane, size_t ulPlaneTag,
BSPPolygon<Type, iDimensions> &bpoFront, BSPPolygon<Type, iDimensions> &bpoBack) BSPPolygon<Type, iDimensions> &bpoFront, BSPPolygon<Type, iDimensions> &bpoBack)
{ {
(Plane<Type, iDimensions> &)bpoFront = (Plane<Type, iDimensions> &)bpoPolygon; (Plane<Type, iDimensions> &)bpoFront = (Plane<Type, iDimensions> &)bpoPolygon;
@ -802,7 +803,7 @@ BOOL BSPCutter<Type, iDimensions>::SplitPolygon(BSPPolygon<Type, iDimensions> &b
* Split an edge with a plane. * Split an edge with a plane.
*/ */
template<class Type, int iDimensions> template<class Type, int iDimensions>
void BSPCutter<Type, iDimensions>::SplitEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, ULONG ulEdgeTag, void BSPCutter<Type, iDimensions>::SplitEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, size_t ulEdgeTag,
const Plane<Type, iDimensions> &plSplitPlane, const Plane<Type, iDimensions> &plSplitPlane,
BSPPolygon<Type, iDimensions> &bpoFront, BSPPolygon<Type, iDimensions> &bpoBack, BSPPolygon<Type, iDimensions> &bpoFront, BSPPolygon<Type, iDimensions> &bpoBack,
BSPVertexContainer<Type, iDimensions> &bvcFront, BSPVertexContainer<Type, iDimensions> &bvcBack) BSPVertexContainer<Type, iDimensions> &bvcFront, BSPVertexContainer<Type, iDimensions> &bvcBack)
@ -1132,20 +1133,17 @@ void BSPTree<Type, iDimensions>::MoveSubTreeToArray(BSPNode<Type, iDimensions> *
bnInArray.bn_bnlLocation = pbnSubtree->bn_bnlLocation; bnInArray.bn_bnlLocation = pbnSubtree->bn_bnlLocation;
bnInArray.bn_ulPlaneTag = pbnSubtree->bn_ulPlaneTag; bnInArray.bn_ulPlaneTag = pbnSubtree->bn_ulPlaneTag;
// let plane tag hold pointer to node in array // let plane tag hold pointer to node in array
STUBBED("64-bit issue"); pbnSubtree->bn_ulPlaneTag = (size_t)&bnInArray;
pbnSubtree->bn_ulPlaneTag = (ULONG)(size_t)&bnInArray;
// remap pointers to subnodes // remap pointers to subnodes
if (pbnSubtree->bn_pbnFront==NULL) { if (pbnSubtree->bn_pbnFront==NULL) {
bnInArray.bn_pbnFront = NULL; bnInArray.bn_pbnFront = NULL;
} else { } else {
STUBBED("64-bit issue"); // bn_ulPlaneTag is uint32!
bnInArray.bn_pbnFront = (BSPNode<Type, iDimensions>*)pbnSubtree->bn_pbnFront->bn_ulPlaneTag; bnInArray.bn_pbnFront = (BSPNode<Type, iDimensions>*)pbnSubtree->bn_pbnFront->bn_ulPlaneTag;
} }
if (pbnSubtree->bn_pbnBack==NULL) { if (pbnSubtree->bn_pbnBack==NULL) {
bnInArray.bn_pbnBack = NULL; bnInArray.bn_pbnBack = NULL;
} else { } else {
STUBBED("64-bit issue"); // basically the same as above but for back!
bnInArray.bn_pbnBack = (BSPNode<Type, iDimensions>*)pbnSubtree->bn_pbnBack->bn_ulPlaneTag; bnInArray.bn_pbnBack = (BSPNode<Type, iDimensions>*)pbnSubtree->bn_pbnBack->bn_ulPlaneTag;
} }
} }
@ -1232,8 +1230,9 @@ void BSPTree<Type, iDimensions>::Read_t(CTStream &strm) // throw char *
} else { } else {
bn.bn_pbnBack = &bt_abnNodes[iBack]; bn.bn_pbnBack = &bt_abnNodes[iBack];
} }
ULONG ul;
strm>>bn.bn_ulPlaneTag; strm>>ul;
bn.bn_ulPlaneTag = ul;
} }
// check end id // check end id
@ -1283,7 +1282,7 @@ void BSPTree<Type, iDimensions>::Write_t(CTStream &strm) // throw char *
} }
strm<<iBack; strm<<iBack;
strm<<bn.bn_ulPlaneTag; strm<<IntPtrToID(bn.bn_ulPlaneTag);
} }
// write end id for checking // write end id for checking
strm.WriteID_t("BSPE"); // bsp end strm.WriteID_t("BSPE"); // bsp end

View File

@ -76,7 +76,7 @@ public:
/* Elliminate paired vertices. */ /* Elliminate paired vertices. */
void ElliminatePairedVertices(void); void ElliminatePairedVertices(void);
/* Create edges from vertices in one container -- must be sorted before. */ /* Create edges from vertices in one container -- must be sorted before. */
void CreateEdges(CDynamicArray<BSPEdge<Type, iDimensions> > &abedAll, ULONG ulEdgeTag); void CreateEdges(CDynamicArray<BSPEdge<Type, iDimensions> > &abedAll, size_t ulEdgeTag);
}; };
/* /*
@ -87,7 +87,7 @@ class BSPEdge {
public: public:
Vector<Type, iDimensions> bed_vVertex0; // edge vertices Vector<Type, iDimensions> bed_vVertex0; // edge vertices
Vector<Type, iDimensions> bed_vVertex1; Vector<Type, iDimensions> bed_vVertex1;
size_t bed_ulEdgeTag; // tags for BSPs with tagged edges/planes - FIXME DG: or uintprt_t? size_t bed_ulEdgeTag; // tags for BSPs with tagged edges/planes
/* Default constructor. */ /* Default constructor. */
inline BSPEdge(void) {}; inline BSPEdge(void) {};
@ -113,7 +113,7 @@ public:
size_t bpo_ulPlaneTag; // tags for BSPs with tagged planes (-1 for no tag) size_t bpo_ulPlaneTag; // tags for BSPs with tagged planes (-1 for no tag)
/* Add an edge to the polygon. */ /* Add an edge to the polygon. */
inline void AddEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, ULONG ulTag); inline void AddEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, size_t ulTag);
/* Default constructor. */ /* Default constructor. */
inline BSPPolygon(void) : bpo_ulPlaneTag(-1) {}; inline BSPPolygon(void) : bpo_ulPlaneTag(-1) {};
@ -146,7 +146,7 @@ public:
BSPNode<Type, iDimensions> *bn_pbnFront; // pointer to child node in front of split plane BSPNode<Type, iDimensions> *bn_pbnFront; // pointer to child node in front of split plane
BSPNode<Type, iDimensions> *bn_pbnBack; // pointer to child node behind split plane BSPNode<Type, iDimensions> *bn_pbnBack; // pointer to child node behind split plane
ULONG bn_ulPlaneTag; // tags for BSPs with tagged planes (-1 for no tag) size_t bn_ulPlaneTag; // tags for BSPs with tagged planes (-1 for no tag)
public: public:
/* Defualt constructor (for arrays only). */ /* Defualt constructor (for arrays only). */
@ -154,7 +154,7 @@ public:
/* Constructor for a leaf node. */ /* Constructor for a leaf node. */
inline BSPNode(enum BSPNodeLocation bnl); inline BSPNode(enum BSPNodeLocation bnl);
/* Constructor for a branch node. */ /* Constructor for a branch node. */
inline BSPNode(const Plane<Type, iDimensions> &plSplitPlane, ULONG ulPlaneTag, inline BSPNode(const Plane<Type, iDimensions> &plSplitPlane, size_t ulPlaneTag,
BSPNode<Type, iDimensions> &bnFront, BSPNode<Type, iDimensions> &bnBack); BSPNode<Type, iDimensions> &bnFront, BSPNode<Type, iDimensions> &bnBack);
/* Constructor for cloning a bsp (sub)tree. */ /* Constructor for cloning a bsp (sub)tree. */
BSPNode(BSPNode<Type, iDimensions> &bnRoot); BSPNode(BSPNode<Type, iDimensions> &bnRoot);
@ -180,7 +180,7 @@ template<class Type, int iDimensions>
class BSPCutter { class BSPCutter {
public: public:
/* Split an edge with a plane. */ /* Split an edge with a plane. */
static inline void SplitEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, ULONG ulEdgeTag, static inline void SplitEdge(const Vector<Type, iDimensions> &vPoint0, const Vector<Type, iDimensions> &vPoint1, size_t ulEdgeTag,
const Plane<Type, iDimensions> &plSplitPlane, const Plane<Type, iDimensions> &plSplitPlane,
BSPPolygon<Type, iDimensions> &abedFront, BSPPolygon<Type, iDimensions> &abedBack, BSPPolygon<Type, iDimensions> &abedFront, BSPPolygon<Type, iDimensions> &abedBack,
BSPVertexContainer<Type, iDimensions> &bvcFront, BSPVertexContainer<Type, iDimensions> &bvcBack); BSPVertexContainer<Type, iDimensions> &bvcFront, BSPVertexContainer<Type, iDimensions> &bvcBack);
@ -195,7 +195,7 @@ public:
CDynamicArray<BSPEdge<Type, iDimensions> > bc_abedBorderOutside;// edges of border part of polygon facing outwards CDynamicArray<BSPEdge<Type, iDimensions> > bc_abedBorderOutside;// edges of border part of polygon facing outwards
/* Split a polygon with a plane. */ /* Split a polygon with a plane. */
static inline BOOL SplitPolygon(BSPPolygon<Type, iDimensions> &bpoPolygon, const Plane<Type, iDimensions> &plPlane, ULONG ulPlaneTag, static inline BOOL SplitPolygon(BSPPolygon<Type, iDimensions> &bpoPolygon, const Plane<Type, iDimensions> &plPlane, size_t ulPlaneTag,
BSPPolygon<Type, iDimensions> &bpoFront, BSPPolygon<Type, iDimensions> &bpoBack); BSPPolygon<Type, iDimensions> &bpoFront, BSPPolygon<Type, iDimensions> &bpoBack);
/* Constructor for splitting a polygon with a BSP tree. */ /* Constructor for splitting a polygon with a BSP tree. */

View File

@ -980,9 +980,9 @@ INDEX Particles_Regeneration(CEntity *pen, FLOAT tmStart, FLOAT tmStop, FLOAT fY
vPos2 = Lerp( vSource, vDestination, fT2); vPos2 = Lerp( vSource, vDestination, fT2);
} }
UBYTE ubR = 192+afStarsPositions[iRnd][1]*64; UBYTE ubR = 192+afStarsPositions[iRnd][0]*64;
UBYTE ubG = 192+afStarsPositions[iRnd][2]*64; UBYTE ubG = 192+afStarsPositions[iRnd][1]*64;
UBYTE ubB = 192+afStarsPositions[iRnd][3]*64; UBYTE ubB = 192+afStarsPositions[iRnd][2]*64;
UBYTE ubA = CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255; UBYTE ubA = CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255;
COLOR colLine = RGBToColor( ubR, ubG, ubB) | ubA; COLOR colLine = RGBToColor( ubR, ubG, ubB) | ubA;
@ -1567,7 +1567,7 @@ void Particles_LavaErupting(CEntity *pen, FLOAT fStretchAll, FLOAT fSize,
vPos(2) += (fStretchY+(fStretchY*0.25f*afStarsPositions[iRnd1][1]))*fT-fGA/2.0f*fT*fT; vPos(2) += (fStretchY+(fStretchY*0.25f*afStarsPositions[iRnd1][1]))*fT-fGA/2.0f*fT*fT;
vPos(3) += fRndAppearZ+afStarsPositions[iRnd1][2]*fT*fStretchZ*10; vPos(3) += fRndAppearZ+afStarsPositions[iRnd1][2]*fT*fStretchZ*10;
Particle_RenderSquare( vPos, fSize+afStarsPositions[iRnd2][3]*fSize*0.5f, fRndRotation*300*fT, C_WHITE|CT_OPAQUE); Particle_RenderSquare( vPos, fSize+afStarsPositions[iRnd2][2]*fSize*0.5f, fRndRotation*300*fT, C_WHITE|CT_OPAQUE);
// all done // all done
Particle_Flush(); Particle_Flush();
@ -1713,7 +1713,7 @@ void Particles_Rain(CEntity *pen, FLOAT fGridSize, INDEX ctGrids, FLOAT fFactor,
for( INDEX iZ=0; iZ<ctGrids; iZ++) for( INDEX iZ=0; iZ<ctGrids; iZ++)
{ {
INDEX iRndZ = (ULONG(vPos(3)+iZ)) % CT_MAX_PARTICLES_TABLE; INDEX iRndZ = (ULONG(vPos(3)+iZ)) % CT_MAX_PARTICLES_TABLE;
FLOAT fZOrg = vPos(3) + (iZ+afStarsPositions[iRndZ][3])*fGridSize; FLOAT fZOrg = vPos(3) + (iZ+afStarsPositions[iRndZ][2])*fGridSize;
for( INDEX iX=0; iX<ctGrids; iX++) for( INDEX iX=0; iX<ctGrids; iX++)
{ {
@ -1786,7 +1786,7 @@ void Particles_Snow( CEntity *pen, FLOAT fGridSize, INDEX ctGrids)
for( INDEX iZ=0; iZ<ctGrids; iZ++) for( INDEX iZ=0; iZ<ctGrids; iZ++)
{ {
INDEX iRndZ = (ULONG(vPos(3)+iZ)) % CT_MAX_PARTICLES_TABLE; INDEX iRndZ = (ULONG(vPos(3)+iZ)) % CT_MAX_PARTICLES_TABLE;
FLOAT fZ = vPos(3) + (iZ+afStarsPositions[iRndZ][3])*fGridSize; FLOAT fZ = vPos(3) + (iZ+afStarsPositions[iRndZ][2])*fGridSize;
for( INDEX iX=0; iX<ctGrids; iX++) for( INDEX iX=0; iX<ctGrids; iX++)
{ {
INDEX iRndX = (ULONG(vPos(1)+iX)) % CT_MAX_PARTICLES_TABLE; INDEX iRndX = (ULONG(vPos(1)+iX)) % CT_MAX_PARTICLES_TABLE;
@ -2156,7 +2156,7 @@ void Particles_BulletSpray(CEntity *pen, FLOAT3D vGDir, enum EffectParticlesType
afStarsPositions[ iSpray+iRnd][0]*3.0f* fConeMultiplier, afStarsPositions[ iSpray+iRnd][0]*3.0f* fConeMultiplier,
(afStarsPositions[ iSpray+iRnd][1]+1.0f)*3.0f, (afStarsPositions[ iSpray+iRnd][1]+1.0f)*3.0f,
afStarsPositions[ iSpray+iRnd][2]*3.0f* fConeMultiplier); afStarsPositions[ iSpray+iRnd][2]*3.0f* fConeMultiplier);
FLOAT fSpeedRnd = fSpeedStart+afStarsPositions[ iSpray+iRnd*2][3]; FLOAT fSpeedRnd = fSpeedStart+afStarsPositions[ iSpray+iRnd*2][2];
FLOAT3D vPos = vEntity + (vDirection+vRandomAngle)*(fT*fSpeedRnd)+vGDir*(fT*fT*fGA); FLOAT3D vPos = vEntity + (vDirection+vRandomAngle)*(fT*fSpeedRnd)+vGDir*(fT*fT*fGA);
if( (eptType == EPT_BULLET_WATER) && (vPos(2) < vEntity(2)) ) if( (eptType == EPT_BULLET_WATER) && (vPos(2) < vEntity(2)) )
@ -2294,7 +2294,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData)
FLOAT fXF = cos( afStarsPositions[iRnd+2][0]*PI); FLOAT fXF = cos( afStarsPositions[iRnd+2][0]*PI);
FLOAT fAmpl = ClampUp( fT+afStarsPositions[iRnd+1][1]+0.5f, 2.0f)/64; FLOAT fAmpl = ClampUp( fT+afStarsPositions[iRnd+1][1]+0.5f, 2.0f)/64;
FLOAT fFormulae = fAmpl * sin(afStarsPositions[iRnd][2]+fT*afStarsPositions[iRnd][3]*2); FLOAT fFormulae = fAmpl * sin(afStarsPositions[iRnd][1]+fT*afStarsPositions[iRnd][2]*2);
FLOAT fColorFactor = 1.0f; FLOAT fColorFactor = 1.0f;
if( fT>fLife/2) if( fT>fLife/2)

View File

@ -2238,7 +2238,7 @@ functions:
void RenderGameView(CDrawPort *pdp, void *pvUserData) void RenderGameView(CDrawPort *pdp, void *pvUserData)
{ {
BOOL bShowExtras = (ULONG(pvUserData)&GRV_SHOWEXTRAS); BOOL bShowExtras = (size_t(pvUserData)&GRV_SHOWEXTRAS);
// if not yet initialized // if not yet initialized
if(!(m_ulFlags&PLF_INITIALIZED) || (m_ulFlags&PLF_DONTRENDER)) { if(!(m_ulFlags&PLF_INITIALIZED) || (m_ulFlags&PLF_DONTRENDER)) {

View File

@ -17,7 +17,7 @@ cd $_
#cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. #cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE ..
# Right now we force x86, though... # Right now we force x86, though...
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_ASM=TRUE ..
make -j$NCPU make -j$NCPU

View File

@ -9,6 +9,6 @@ set -x
rm -rf cmake-build rm -rf cmake-build
mkdir $_ mkdir $_
cd $_ cd $_
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 .. cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 -DUSE_I386_ASM=TRUE -DUSE_SYSTEM_SDL2=FALSE ..
make -j$NCPU make -j$NCPU

14
Sources/build-mac64.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
NCPU=`sysctl -n hw.ncpu`
echo "Will build with 'make -j$NCPU' ... please edit this script if incorrect."
set -e
set -x
rm -rf cmake-build
mkdir $_
cd $_
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 -DUSE_I386_ASM=FALSE ..
make -j$NCPU