Merge pull request #26 from DanielGibson/64bit-stuff

Some 64bit improvements, lots of 64bit TODOs/STUBBED()
This commit is contained in:
Ryan C. Gordon 2016-04-18 22:33:58 -04:00
commit 1f7bb24a4d
23 changed files with 171 additions and 104 deletions

View File

@ -9,6 +9,9 @@ option(USE_SYSTEM_SDL2 "Use system wide sdl2 libraries/includes" On)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# 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_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(-Wno-switch) add_definitions(-Wno-switch)
add_definitions(-Wno-tautological-undefined-compare) add_definitions(-Wno-tautological-undefined-compare)
add_definitions(-Wno-c++11-compat-deprecated-writable-strings) add_definitions(-Wno-c++11-compat-deprecated-writable-strings)
add_definitions(-Wno-logical-op-parentheses)
MESSAGE(WARNING "reenable -Wlogical-op-parentheses some day!")
endif() endif()
# !!! FIXME: you currently need this, but I'd like to flip this to not use # !!! FIXME: you currently need this, but I'd like to flip this to not use

View File

@ -44,6 +44,18 @@ inline void CRC_AddLONG( ULONG &ulCRC, ULONG ul)
CRC_AddBYTE(ulCRC, UBYTE(ul>> 0)); CRC_AddBYTE(ulCRC, UBYTE(ul>> 0));
}; };
inline void CRC_AddLONGLONG( ULONG &ulCRC, __uint64 x)
{
CRC_AddBYTE(ulCRC, UBYTE(x>>56));
CRC_AddBYTE(ulCRC, UBYTE(x>>48));
CRC_AddBYTE(ulCRC, UBYTE(x>>40));
CRC_AddBYTE(ulCRC, UBYTE(x>>32));
CRC_AddBYTE(ulCRC, UBYTE(x>>24));
CRC_AddBYTE(ulCRC, UBYTE(x>>16));
CRC_AddBYTE(ulCRC, UBYTE(x>> 8));
CRC_AddBYTE(ulCRC, UBYTE(x>> 0));
}
inline void CRC_AddFLOAT(ULONG &ulCRC, FLOAT f) inline void CRC_AddFLOAT(ULONG &ulCRC, FLOAT f)
{ {
CRC_AddLONG(ulCRC, *(ULONG*)&f); CRC_AddLONG(ulCRC, *(ULONG*)&f);

View File

@ -148,6 +148,7 @@ CShell::CShell(void)
{ {
// allocate undefined symbol // allocate undefined symbol
_shell_istUndeclared = _shell_ast.Allocate(); _shell_istUndeclared = _shell_ast.Allocate();
pwoCurrentWorld = NULL;
}; };
CShell::~CShell(void) CShell::~CShell(void)
{ {

View File

@ -33,6 +33,8 @@ public:
CTCriticalSection sh_csShell; // critical section for access to shell data CTCriticalSection sh_csShell; // critical section for access to shell data
CDynamicArray<CShellSymbol> sh_assSymbols; // all defined symbols CDynamicArray<CShellSymbol> sh_assSymbols; // all defined symbols
CWorld* pwoCurrentWorld;
// Get a shell symbol by its name. // Get a shell symbol by its name.
CShellSymbol *GetSymbol(const CTString &strName, BOOL bDeclaredOnly); CShellSymbol *GetSymbol(const CTString &strName, BOOL bDeclaredOnly);
// Report error in shell script processing. // Report error in shell script processing.
@ -66,6 +68,16 @@ public:
CTString GetValue(const CTString &strName); CTString GetValue(const CTString &strName);
void SetValue(const CTString &strName, const CTString &strValue); void SetValue(const CTString &strName, const CTString &strValue);
void SetCurrentWorld(CWorld* pwo)
{
pwoCurrentWorld = pwo;
}
CWorld* GetCurrentWorld(void)
{
return pwoCurrentWorld;
}
}; };
// pointer to global shell object // pointer to global shell object

View File

@ -61,6 +61,37 @@ typedef unsigned int UINT;
#define PLATFORM_LITTLEENDIAN 1 #define PLATFORM_LITTLEENDIAN 1
#endif #endif
#ifdef PLATFORM_WIN32
#ifdef _WIN64
#define PLATFORM_64BIT 1
#else
#define PLATFORM_32BIT 1
#endif
#else
// AFAIK there were versions of MSVC where UINTPTR_MAX was incorrect,
// 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
// 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
@ -182,11 +213,8 @@ typedef unsigned int UINT;
inline ULONG _rotl(ULONG ul, int bits) inline ULONG _rotl(ULONG ul, int bits)
{ {
#if (defined USE_PORTABLE_C) #if (defined USE_PORTABLE_C)
// This is not fast at all, but it works. // DG: according to http://blog.regehr.org/archives/1063 this is fast
for (int i = 0; i < bits; i++) return (ul<<bits) | (ul>>(-bits&31));
ul = ( (ul << 1) | ((ul & 0x80000000) >> 31) );
return(ul);
#elif (defined __GNU_INLINE__) #elif (defined __GNU_INLINE__)
// This, on the other hand, is wicked fast. :) // This, on the other hand, is wicked fast. :)
__asm__ __volatile__ ( __asm__ __volatile__ (

View File

@ -84,7 +84,7 @@ void CBrushPolygon::CreateBSPPolygon(BSPPolygon<DOUBLE, 3> &bspo)
// set the plane of the bsp polygon // set the plane of the bsp polygon
((DOUBLEplane3D &)bspo) = *brpo.bpo_pbplPlane->bpl_ppldPreciseAbsolute; ((DOUBLEplane3D &)bspo) = *brpo.bpo_pbplPlane->bpl_ppldPreciseAbsolute;
bspo.bpo_ulPlaneTag = (ULONG)brpo.bpo_pbscSector->bsc_abplPlanes.Index(brpo.bpo_pbplPlane); bspo.bpo_ulPlaneTag = (size_t)brpo.bpo_pbscSector->bsc_abplPlanes.Index(brpo.bpo_pbplPlane);
// create the array of edges in the bsp polygon // create the array of edges in the bsp polygon
INDEX ctEdges = brpo.bpo_abpePolygonEdges.Count(); INDEX ctEdges = brpo.bpo_abpePolygonEdges.Count();
@ -109,7 +109,7 @@ void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon<DOUBLE, 3> &bspo)
// set the plane of the bsp polygon // set the plane of the bsp polygon
((DOUBLEplane3D &)bspo) = FLOATtoDOUBLE(brpo.bpo_pbplPlane->bpl_plAbsolute); ((DOUBLEplane3D &)bspo) = FLOATtoDOUBLE(brpo.bpo_pbplPlane->bpl_plAbsolute);
bspo.bpo_ulPlaneTag = (ULONG)brpo.bpo_pbscSector->bsc_abplPlanes.Index(brpo.bpo_pbplPlane); bspo.bpo_ulPlaneTag = (size_t)brpo.bpo_pbscSector->bsc_abplPlanes.Index(brpo.bpo_pbplPlane);
// calculate offset for points // calculate offset for points
DOUBLE3D vOffset = FLOATtoDOUBLE(((FLOAT3D&)brpo.bpo_pbplPlane->bpl_plAbsolute))*-fOffset; DOUBLE3D vOffset = FLOATtoDOUBLE(((FLOAT3D&)brpo.bpo_pbplPlane->bpl_plAbsolute))*-fOffset;
// offset the plane // offset the plane

View File

@ -221,8 +221,11 @@ ULONG CDrawPort::GetID(void)
{ {
ULONG ulCRC; ULONG ulCRC;
CRC_Start( ulCRC); CRC_Start( ulCRC);
STUBBED("64-bit issue"); #ifdef PLATFORM_64BIT
CRC_AddLONGLONG( ulCRC, (__uint64)(size_t)dp_Raster);
#else
CRC_AddLONG( ulCRC, (ULONG)(size_t)dp_Raster); CRC_AddLONG( ulCRC, (ULONG)(size_t)dp_Raster);
#endif
CRC_AddLONG( ulCRC, (ULONG)dp_MinI); CRC_AddLONG( ulCRC, (ULONG)dp_MinI);
CRC_AddLONG( ulCRC, (ULONG)dp_MinJ); CRC_AddLONG( ulCRC, (ULONG)dp_MinJ);
CRC_AddLONG( ulCRC, (ULONG)dp_MaxI); CRC_AddLONG( ulCRC, (ULONG)dp_MaxI);

View File

@ -75,6 +75,7 @@ static __forceinline CTStream &operator>>(CTStream &strm, PCXHeader &t) {
strm>>t.HscreenSize; strm>>t.HscreenSize;
strm>>t.VscreenSize; strm>>t.VscreenSize;
strm.Read_t(t.Filler, sizeof (t.Filler)); strm.Read_t(t.Filler, sizeof (t.Filler));
return strm;
} }
static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) { static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) {
@ -96,6 +97,7 @@ static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) {
strm<<t.HscreenSize; strm<<t.HscreenSize;
strm<<t.VscreenSize; strm<<t.VscreenSize;
strm.Write_t(t.Filler, sizeof (t.Filler)); strm.Write_t(t.Filler, sizeof (t.Filler));
return strm;
} }
// TARGA header structure // TARGA header structure

View File

@ -1312,7 +1312,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
// if not already generated, generate bind number(s) and force upload // if not already generated, generate bind number(s) and force upload
const PIX pixTextureSize = pixWidth*pixHeight; const PIX pixTextureSize = pixWidth*pixHeight;
if( td_ulObject==NONE) if((td_ctFrames>1 && td_pulObjects==NULL) || td_ulObject==NONE)
{ {
// check whether frames are present // check whether frames are present
ASSERT( td_pulFrames!=NULL && td_pulFrames[0]!=0xDEADBEEF); ASSERT( td_pulFrames!=NULL && td_pulFrames[0]!=0xDEADBEEF);
@ -1367,7 +1367,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
for( INDEX iFr=0; iFr<td_ctFrames; iFr++) for( INDEX iFr=0; iFr<td_ctFrames; iFr++)
{ // determine frame offset and upload texture frame { // determine frame offset and upload texture frame
ULONG *pulCurrentFrame = td_pulFrames + (iFr * td_slFrameSize/BYTES_PER_TEXEL); ULONG *pulCurrentFrame = td_pulFrames + (iFr * td_slFrameSize/BYTES_PER_TEXEL);
gfxSetTexture( ((ULONG*)td_ulObject)[iFr], td_tpLocal); gfxSetTexture( td_pulObjects[iFr], td_tpLocal);
gfxUploadTexture( pulCurrentFrame, pixWidth, pixHeight, td_ulInternalFormat, bNoDiscard); gfxUploadTexture( pulCurrentFrame, pixWidth, pixHeight, td_ulInternalFormat, bNoDiscard);
} }
} else { } else {
@ -1392,7 +1392,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
td_pulFrames = NULL; td_pulFrames = NULL;
} }
// done uploading // done uploading
ASSERT( td_ulObject!=NONE); ASSERT((td_ctFrames>1 && td_pulObjects!=NULL) || td_ulObject!=NONE);
return; return;
} }
@ -1401,12 +1401,11 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE
// must reset local texture parameters for each frame of animated texture // must reset local texture parameters for each frame of animated texture
for( INDEX iFr=0; iFr<td_ctFrames; iFr++) { for( INDEX iFr=0; iFr<td_ctFrames; iFr++) {
td_tpLocal.Clear(); td_tpLocal.Clear();
gfxSetTexture( ((ULONG*)td_ulObject)[iFr], td_tpLocal); gfxSetTexture( td_pulObjects[iFr], td_tpLocal); // FIXME DG: use that union properly or something?!
} }
} }
// set corresponding probe or texture frame as current // set corresponding probe or texture frame as current
ULONG ulTexObject = td_ulObject; // single-frame ULONG ulTexObject = (td_ctFrames>1) ? td_pulObjects[iFrameNo] : td_ulObject; // single-frame or animation
if( td_ctFrames>1) ulTexObject = ((ULONG*)td_ulObject)[iFrameNo]; // animation
if( bUseProbe) { if( bUseProbe) {
// set probe if burst value doesn't allow real texture // set probe if burst value doesn't allow real texture
if( _pGfx->gl_slAllowedUploadBurst<0) { if( _pGfx->gl_slAllowedUploadBurst<0) {
@ -1437,17 +1436,22 @@ void CTextureData::Unbind(void)
// reset mark // reset mark
td_tvLastDrawn = (__int64) 0; td_tvLastDrawn = (__int64) 0;
// free frame number(s)
if( td_ctFrames>1) { // animation
// only if bound
if( td_pulObjects == NULL || td_pulObjects[0]==NONE) {
ASSERT( td_pulObjects == NULL || td_pulObjects[0]==NONE);
return;
}
for( INDEX iFrame=0; iFrame<td_ctFrames; iFrame++) gfxDeleteTexture( td_pulObjects[iFrame]);
FreeMemory( td_pulObjects);
td_pulObjects = NULL;
} else { // single-frame
// only if bound // only if bound
if( td_ulObject==NONE) { if( td_ulObject==NONE) {
ASSERT( td_ulProbeObject==NONE); ASSERT( td_ulProbeObject==NONE);
return; return;
} }
// free frame number(s)
if( td_ctFrames>1) { // animation
for( INDEX iFrame=0; iFrame<td_ctFrames; iFrame++) gfxDeleteTexture( td_pulObjects[iFrame]);
FreeMemory( td_pulObjects);
td_pulObjects = NULL;
} else { // single-frame
gfxDeleteTexture(td_ulObject); gfxDeleteTexture(td_ulObject);
} }
// delete probe texture, too // delete probe texture, too
@ -1722,8 +1726,7 @@ BOOL CTextureData::IsAutoFreed(void)
SLONG CTextureData::GetUsedMemory(void) SLONG CTextureData::GetUsedMemory(void)
{ {
// readout texture object // readout texture object
ULONG ulTexObject = td_ulObject; ULONG ulTexObject = (td_ctFrames>1) ? td_pulObjects[0] : td_ulObject;
if( td_ctFrames>1) ulTexObject = td_pulObjects[0];
// add structure size and anim block size // add structure size and anim block size
SLONG slUsed = sizeof(*this) + CAnimData::GetUsedMemory()-sizeof(CAnimData); SLONG slUsed = sizeof(*this) + CAnimData::GetUsedMemory()-sizeof(CAnimData);

View File

@ -313,7 +313,10 @@ inline FLOAT NormByteToFloat( const ULONG ul)
inline SLONG FloatToInt( FLOAT f) inline SLONG FloatToInt( FLOAT f)
{ {
#if defined(__arm__) || defined(USE_PORTABLE_C) #if defined(__arm__) || defined(USE_PORTABLE_C)
return((SLONG) (f + 0.5f)); /* best of luck to you. */ // round to nearest by adding/subtracting 0.5 (depending on f pos/neg) before converting to SLONG
float addToRound = 0.5f;
copysignf(addToRound, f); // copy f's signbit to addToRound => if f<0 then addToRound = -addToRound
return((SLONG) (f + addToRound));
#elif (defined __MSVC_INLINE__) #elif (defined __MSVC_INLINE__)
SLONG slRet; SLONG slRet;
@ -341,8 +344,7 @@ inline SLONG FloatToInt( FLOAT f)
// log base 2 of any float numero // log base 2 of any float numero
inline FLOAT Log2( FLOAT f) { inline FLOAT Log2( FLOAT f) {
#if (defined USE_PORTABLE_C) || defined(__arm__) #if (defined USE_PORTABLE_C) || defined(__arm__)
// !!! FIXME: What's wrong with log2()? return log2f(f);
return (FLOAT)(log10(f)*3.321928094887); // log10(x)/log10(2)
#elif (defined __MSVC_INLINE__) #elif (defined __MSVC_INLINE__)
FLOAT fRet; FLOAT fRet;
@ -376,6 +378,11 @@ inline FLOAT Log2( FLOAT f) {
inline SLONG FastLog2( SLONG x) inline SLONG FastLog2( SLONG x)
{ {
#if (defined USE_PORTABLE_C) #if (defined USE_PORTABLE_C)
#ifdef __GNUC__
if(x == 0) return 0; // __builtin_clz() is undefined for 0
int numLeadingZeros = __builtin_clz(x);
return 31 - numLeadingZeros;
#else
register SLONG val = x; register SLONG val = x;
register SLONG retval = 31; register SLONG retval = 31;
while (retval > 0) while (retval > 0)
@ -386,6 +393,7 @@ inline SLONG FastLog2( SLONG x)
} }
return 0; return 0;
#endif
#elif (defined __MSVC_INLINE__) #elif (defined __MSVC_INLINE__)
SLONG slRet; SLONG slRet;
@ -409,6 +417,7 @@ inline SLONG FastLog2( SLONG x)
#endif #endif
} }
/* DG: function is unused => doesn't matter that portable implementation is not optimal :)
// returns log2 of first larger value that is a power of 2 // returns log2 of first larger value that is a power of 2
inline SLONG FastMaxLog2( SLONG x) inline SLONG FastMaxLog2( SLONG x)
{ {
@ -443,6 +452,7 @@ printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__);
#error Fill this in for your platform. #error Fill this in for your platform.
#endif #endif
} }
*/

View File

@ -323,16 +323,14 @@ void CObjectCSG::PolygonEdgesToBSPEdges(
// if it is reversed // if it is reversed
if (ope.ope_Backward) { if (ope.ope_Backward) {
// add bsp edge with reverse vertices // add bsp edge with reverse vertices
STUBBED("64-bit issue"); // we're casting ope.ope_Edge to a 32-bit value. Code really only cares if this is zero or !zero, but one could totally have a non-NULL 64-bit pointer that truncates down to zero!
abed[iEdge] = DOUBLEbspedge3D(*ope.ope_Edge->oed_Vertex1, abed[iEdge] = DOUBLEbspedge3D(*ope.ope_Edge->oed_Vertex1,
*ope.ope_Edge->oed_Vertex0, (ULONG)(size_t)ope.ope_Edge); *ope.ope_Edge->oed_Vertex0, (size_t)ope.ope_Edge);
// if it is not reversed // if it is not reversed
} else{ } else{
// add bsp edge with normal vertices // add bsp edge with normal vertices
STUBBED("64-bit issue"); // we're casting ope.ope_Edge to a 32-bit value. Code really only cares if this is zero or !zero, but one could totally have a non-NULL 64-bit pointer that truncates down to zero!
abed[iEdge] = DOUBLEbspedge3D(*ope.ope_Edge->oed_Vertex0, abed[iEdge] = DOUBLEbspedge3D(*ope.ope_Edge->oed_Vertex0,
*ope.ope_Edge->oed_Vertex1, (ULONG)(size_t)ope.ope_Edge); *ope.ope_Edge->oed_Vertex1, (size_t)ope.ope_Edge);
} }
} }
@ -544,8 +542,7 @@ void CObjectCSG::DoCSGSplitting(
oc_popoPortalB1B2 = NULL; oc_popoPortalB1B2 = NULL;
// create a bsp polygon from first temporary array // create a bsp polygon from first temporary array
STUBBED("64-bit issue"); DOUBLEbsppolygon3D bpoA(*itopoA->opo_Plane, abedRemaining, (size_t)itopoA->opo_Plane);
DOUBLEbsppolygon3D bpoA(*itopoA->opo_Plane, abedRemaining, (ULONG)(size_t)itopoA->opo_Plane);
// create a BSP cutter for B's sector BSP and A's polygon // create a BSP cutter for B's sector BSP and A's polygon
DOUBLEbspcutter3D bcCutter(bpoA, *itoscB->osc_BSPTree.bt_pbnRoot); DOUBLEbspcutter3D bcCutter(bpoA, *itoscB->osc_BSPTree.bt_pbnRoot);

View File

@ -1844,8 +1844,7 @@ void CObjectSector::CreateBSP(void)
// copy the plane // copy the plane
(DOUBLEplane3D &)bpo = *opo.opo_Plane; (DOUBLEplane3D &)bpo = *opo.opo_Plane;
STUBBED("64-bit issue"); bpo.bpo_ulPlaneTag = (size_t)opo.opo_Plane;
bpo.bpo_ulPlaneTag = (ULONG)(size_t)opo.opo_Plane;
// get count of edges in this polygon // get count of edges in this polygon
const INDEX ctEdges = opo.opo_PolygonEdges.Count(); const INDEX ctEdges = opo.opo_PolygonEdges.Count();
@ -1860,13 +1859,11 @@ void CObjectSector::CreateBSP(void)
// if the edge is reversed // if the edge is reversed
if(ope.ope_Backward) { if(ope.ope_Backward) {
// add bsp edge with reversed vertices // add bsp edge with reversed vertices
STUBBED("64-bit issue"); pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex1, *oed.oed_Vertex0, (size_t)&oed);
pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex1, *oed.oed_Vertex0, (ULONG)(size_t)&oed);
// otherwise // otherwise
} else { } else {
// add normal bsp edge // add normal bsp edge
STUBBED("64-bit issue"); pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex0, *oed.oed_Vertex1, (size_t)&oed);
pbed[iEdge] = DOUBLEbspedge3D(*oed.oed_Vertex0, *oed.oed_Vertex1, (ULONG)(size_t)&oed);
} }
} }
opo.opo_PolygonEdges.Unlock(); opo.opo_PolygonEdges.Unlock();

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"); STUBBED("64-bit issue"); // DG: probably ok, because 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,7 @@ void ModelPolygonVertex::Read_t( CTStream *pFile) // throw char *
{ {
INDEX itmp; INDEX itmp;
STUBBED("64-bit issue"); STUBBED("64-bit issue"); // DG: probably ok, because IndicesToPtrs() should be called afterwards
(*pFile) >> itmp; (*pFile) >> itmp;
mpv_ptvTransformedVertex = (struct TransformedVertexData *) (size_t) itmp; mpv_ptvTransformedVertex = (struct TransformedVertexData *) (size_t) itmp;
(*pFile) >> itmp; (*pFile) >> itmp;
@ -1040,14 +1040,14 @@ void CModelData::PtrsToIndices()
if( it2.Current().mpv_ptvTransformedVertex == &md_TransformedVertices[ j]) if( it2.Current().mpv_ptvTransformedVertex == &md_TransformedVertices[ j])
break; break;
} }
it2.Current().mpv_ptvTransformedVertex = (struct TransformedVertexData *) j; it2.Current().mpv_ptvTransformedVertex = (struct TransformedVertexData *)(size_t)j;
for( j=0; j<md_MipInfos[ i].mmpi_TextureVertices.Count(); j++) for( j=0; j<md_MipInfos[ i].mmpi_TextureVertices.Count(); j++)
{ {
if( it2.Current().mpv_ptvTextureVertex == &md_MipInfos[ i].mmpi_TextureVertices[ j]) if( it2.Current().mpv_ptvTextureVertex == &md_MipInfos[ i].mmpi_TextureVertices[ j])
break; break;
} }
it2.Current().mpv_ptvTextureVertex = (ModelTextureVertex *) j; it2.Current().mpv_ptvTextureVertex = (ModelTextureVertex *)(size_t)j;
} }
} }
} }
@ -1068,10 +1068,10 @@ 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"); STUBBED("64-bit issue"); // DG: probably ok, the pointers really 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"); STUBBED("64-bit issue"); // DG: probably ok, the pointers really contain indices from PtrToIndices()
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

@ -86,8 +86,6 @@ BOOL _bTempNetwork = FALSE; // set while using temporary second network object
extern BOOL con_bCapture; extern BOOL con_bCapture;
extern CTString con_strCapture; extern CTString con_strCapture;
static CWorld *_pwoCurrentWorld = NULL;
static FLOAT _bStartDemoRecordingNextTime = FALSE; static FLOAT _bStartDemoRecordingNextTime = FALSE;
static FLOAT _bStopDemoRecordingNextTime = FALSE; static FLOAT _bStopDemoRecordingNextTime = FALSE;
static INDEX dem_iRecordedNumber = 0; static INDEX dem_iRecordedNumber = 0;
@ -254,7 +252,7 @@ extern void CacheShadows(void)
{ {
// mute all sounds // mute all sounds
_pSound->Mute(); _pSound->Mute();
CWorld *pwo = (CWorld*)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
if( pwo!=NULL) { if( pwo!=NULL) {
pwo->wo_baBrushes.CacheAllShadowmaps(); pwo->wo_baBrushes.CacheAllShadowmaps();
CPrintF( TRANS("All shadows recached")); CPrintF( TRANS("All shadows recached"));
@ -522,7 +520,7 @@ static void StockInfo(void)
INDEX ctEntities=0, ctShadowLayers=0, ctPolys=0, ctPlanes=0, ctEdges=0, ctVertices=0, ctSectors=0; INDEX ctEntities=0, ctShadowLayers=0, ctPolys=0, ctPlanes=0, ctEdges=0, ctVertices=0, ctSectors=0;
SLONG slEntBytes=0, slLyrBytes=0, slPlyBytes=0, slPlnBytes=0, slEdgBytes=0, slVtxBytes=0, slSecBytes=0; SLONG slEntBytes=0, slLyrBytes=0, slPlyBytes=0, slPlnBytes=0, slEdgBytes=0, slVtxBytes=0, slSecBytes=0;
SLONG slCgrBytes=0; SLONG slCgrBytes=0;
CWorld *pwo = (CWorld*)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
if( pwo!=NULL) if( pwo!=NULL)
{ {
@ -897,7 +895,6 @@ void CNetworkLibrary::Init(const CTString &strGameID)
_pShell->DeclareSymbol("persistent user CTString ga_strMSLegacy;", (void *)&ga_strMSLegacy); _pShell->DeclareSymbol("persistent user CTString ga_strMSLegacy;", (void *)&ga_strMSLegacy);
_pShell->DeclareSymbol("persistent user INDEX ga_bMSLegacy;", (void *)&ga_bMSLegacy); _pShell->DeclareSymbol("persistent user INDEX ga_bMSLegacy;", (void *)&ga_bMSLegacy);
_pShell->DeclareSymbol("INDEX pwoCurrentWorld;", (void *)&_pwoCurrentWorld);
} }
/* /*
@ -1039,8 +1036,7 @@ void CNetworkLibrary::StartPeerToPeer_t(const CTString &strSessionName,
throw; throw;
} }
// remember the world pointer // remember the world pointer
STUBBED("64-bit issue"); _pShell->SetCurrentWorld(&ga_World);
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World);
SetProgressDescription(TRANS("starting server")); SetProgressDescription(TRANS("starting server"));
CallProgressHook_t(0.0f); CallProgressHook_t(0.0f);
@ -1277,8 +1273,7 @@ void CNetworkLibrary::JoinSession_t(const CNetworkSession &nsSesssion, INDEX ctL
} }
// remember the world pointer // remember the world pointer
STUBBED("64-bit issue"); _pShell->SetCurrentWorld(&ga_World);
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World);
// eventually cache all shadowmaps in world (memory eater!) // eventually cache all shadowmaps in world (memory eater!)
if( shd_bCacheAll) ga_World.wo_baBrushes.CacheAllShadowmaps(); if( shd_bCacheAll) ga_World.wo_baBrushes.CacheAllShadowmaps();
@ -1350,8 +1345,7 @@ void CNetworkLibrary::StartDemoPlay_t(const CTFileName &fnDemo) // throw char *
_bNeedPretouch = TRUE; _bNeedPretouch = TRUE;
// remember the world pointer // remember the world pointer
STUBBED("64-bit issue"); _pShell->SetCurrentWorld(&ga_World);
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World);
// demo synchronization starts at the beginning initially // demo synchronization starts at the beginning initially
ga_fDemoTimer = 0.0f; ga_fDemoTimer = 0.0f;
@ -1560,7 +1554,7 @@ void CNetworkLibrary::StopGame(void)
ga_aplsPlayers.Clear(); ga_aplsPlayers.Clear();
ga_aplsPlayers.New(NET_MAXLOCALPLAYERS); ga_aplsPlayers.New(NET_MAXLOCALPLAYERS);
// remember the world pointer // remember the world pointer
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)NULL); _pShell->SetCurrentWorld(NULL);
// rewind the timer // rewind the timer
_pTimer->SetCurrentTick(0.0f); _pTimer->SetCurrentTick(0.0f);
@ -1684,8 +1678,7 @@ void CNetworkLibrary::ChangeLevel_internal(void)
// remember the world filename // remember the world filename
ga_fnmWorld = ga_fnmNextLevel; ga_fnmWorld = ga_fnmNextLevel;
// remember the world pointer // remember the world pointer
STUBBED("64-bit issue"); _pShell->SetCurrentWorld(&ga_World);
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&ga_World);
// if there is remembered level // if there is remembered level
} else { } else {
// restore it // restore it
@ -2390,8 +2383,7 @@ extern void NET_MakeDefaultState_t(
_pNetwork->ga_fnmWorld = fnmWorld; _pNetwork->ga_fnmWorld = fnmWorld;
_pNetwork->ga_fnmNextLevel = CTString(""); _pNetwork->ga_fnmNextLevel = CTString("");
// remember the world pointer // remember the world pointer
STUBBED("64-bit issue"); _pShell->SetCurrentWorld(&_pNetwork->ga_World);
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)(size_t)&_pNetwork->ga_World);
// reset random number generator // reset random number generator
_pNetwork->ga_sesSessionState.ResetRND(); _pNetwork->ga_sesSessionState.ResetRND();

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; ULONG pe_ulEventID; // FIXME: make this void* or uintptr_t/size_t
CPredictedEvent(void); CPredictedEvent(void);
void Clear(void) {}; void Clear(void) {};

View File

@ -1139,11 +1139,13 @@ void BSPTree<Type, iDimensions>::MoveSubTreeToArray(BSPNode<Type, iDimensions> *
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;
} }
} }

View File

@ -87,12 +87,12 @@ 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;
ULONG bed_ulEdgeTag; // tags for BSPs with tagged edges/planes size_t bed_ulEdgeTag; // tags for BSPs with tagged edges/planes - FIXME DG: or uintprt_t?
/* Default constructor. */ /* Default constructor. */
inline BSPEdge(void) {}; inline BSPEdge(void) {};
/* Constructor with two vectors. */ /* Constructor with two vectors. */
inline BSPEdge(const Vector<Type, iDimensions> &vVertex0, const Vector<Type, iDimensions> &vVertex1, ULONG ulTag) inline BSPEdge(const Vector<Type, iDimensions> &vVertex0, const Vector<Type, iDimensions> &vVertex1, size_t ulTag)
: bed_vVertex0(vVertex0), bed_vVertex1(vVertex1), bed_ulEdgeTag(ulTag) {} : bed_vVertex0(vVertex0), bed_vVertex1(vVertex1), bed_ulEdgeTag(ulTag) {}
/* Clear the object. */ /* Clear the object. */
@ -110,7 +110,7 @@ template<class Type, int iDimensions>
class BSPPolygon : public Plane<Type, iDimensions> { class BSPPolygon : public Plane<Type, iDimensions> {
public: public:
CDynamicArray<BSPEdge<Type, iDimensions> > bpo_abedPolygonEdges; // array of edges in the polygon CDynamicArray<BSPEdge<Type, iDimensions> > bpo_abedPolygonEdges; // array of edges in the polygon
ULONG 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, ULONG ulTag);
@ -119,7 +119,7 @@ public:
inline BSPPolygon(void) : bpo_ulPlaneTag(-1) {}; inline BSPPolygon(void) : bpo_ulPlaneTag(-1) {};
/* Constructor with array of edges and plane. */ /* Constructor with array of edges and plane. */
inline BSPPolygon( inline BSPPolygon(
Plane<Type, iDimensions> &plPlane, CDynamicArray<BSPEdge<Type, iDimensions> > abedPolygonEdges, ULONG ulPlaneTag) Plane<Type, iDimensions> &plPlane, CDynamicArray<BSPEdge<Type, iDimensions> > abedPolygonEdges, size_t ulPlaneTag)
: Plane<Type, iDimensions>(plPlane) : Plane<Type, iDimensions>(plPlane)
, bpo_abedPolygonEdges(abedPolygonEdges) , bpo_abedPolygonEdges(abedPolygonEdges)
, bpo_ulPlaneTag(ulPlaneTag) , bpo_ulPlaneTag(ulPlaneTag)

View File

@ -86,7 +86,7 @@ EntityStats *FindStats(const CTString &strName)
static void MakeWorldStatistics(void) static void MakeWorldStatistics(void)
{ {
// get the world pointer // get the world pointer
CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
// if there is no current world // if there is no current world
if (pwo==NULL) { if (pwo==NULL) {
CPrintF("No current world.\n"); CPrintF("No current world.\n");
@ -152,7 +152,7 @@ static void MakeWorldStatistics(void)
static void ReoptimizeAllBrushes(void) static void ReoptimizeAllBrushes(void)
{ {
// get the world pointer // get the world pointer
CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
// if there is no current world // if there is no current world
if (pwo==NULL) { if (pwo==NULL) {
CPrintF("No current world.\n"); CPrintF("No current world.\n");

View File

@ -1589,9 +1589,10 @@ INDEX Particles_Regeneration(CEntity *pen, FLOAT tmStart, FLOAT tmStop, FLOAT fY
vPos2 = Lerp( vSource, vDestination, fT2); vPos2 = Lerp( vSource, vDestination, fT2);
} }
UBYTE ubR = (UBYTE) (192+afStarsPositions[iRnd][1]*64); // DG: changed indices from 1-3 to 0-2 so they're not out of bounds
UBYTE ubG = (UBYTE) (192+afStarsPositions[iRnd][2]*64); UBYTE ubR = (UBYTE) (192+afStarsPositions[iRnd][0]*64);
UBYTE ubB = (UBYTE) (192+afStarsPositions[iRnd][3]*64); UBYTE ubG = (UBYTE) (192+afStarsPositions[iRnd][1]*64);
UBYTE ubB = (UBYTE) (192+afStarsPositions[iRnd][2]*64);
UBYTE ubA = (UBYTE) CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255; UBYTE ubA = (UBYTE) 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;
@ -2242,7 +2243,7 @@ void Particles_DustFall(CEntity *pen, FLOAT tmStarted, FLOAT3D vStretch)
FLOAT fRndAppearX = afStarsPositions[iRnd][0]*vStretch(1); FLOAT fRndAppearX = afStarsPositions[iRnd][0]*vStretch(1);
FLOAT fRndSpeedY = (afStarsPositions[iRnd][1]+0.5f)*0.125f*vStretch(2); FLOAT fRndSpeedY = (afStarsPositions[iRnd][1]+0.5f)*0.125f*vStretch(2);
FLOAT fRndAppearZ = afStarsPositions[iRnd][2]*vStretch(3); FLOAT fRndAppearZ = afStarsPositions[iRnd][2]*vStretch(3);
FLOAT3D vRndDir=FLOAT3D(afStarsPositions[iRnd][1],0,afStarsPositions[iRnd][3]); FLOAT3D vRndDir=FLOAT3D(afStarsPositions[iRnd][0],0,afStarsPositions[iRnd][2]);
vRndDir.Normalize(); vRndDir.Normalize();
FLOAT fRiseTime=Max(fRatio-0.5f,0.0f); FLOAT fRiseTime=Max(fRatio-0.5f,0.0f);
FLOAT3D vPos=vCenter+vRndDir*fSpeed*3*fStretch+vY*fRiseTime*0.25f; FLOAT3D vPos=vCenter+vRndDir*fSpeed*3*fStretch+vY*fRiseTime*0.25f;
@ -2374,7 +2375,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();
@ -3091,7 +3092,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++)
{ {
@ -3200,12 +3201,12 @@ void Particles_Snow(CEntity *pen, FLOAT fGridSize, INDEX ctGrids, FLOAT fFactor,
FLOAT vYStart=vPos(2)+YGRIDS_VISIBLE_ABOVE*YGRID_SIZE+fD; FLOAT vYStart=vPos(2)+YGRIDS_VISIBLE_ABOVE*YGRID_SIZE+fD;
INDEX iDanceRnd=(iRndXZ+2)%CT_MAX_PARTICLES_TABLE; INDEX iDanceRnd=(iRndXZ+2)%CT_MAX_PARTICLES_TABLE;
FLOAT fDanceAngle=afStarsPositions[iDanceRnd][1]*360.0f; FLOAT fDanceAngle=afStarsPositions[iDanceRnd][0]*360.0f;
FLOAT fAmpX=afStarsPositions[iDanceRnd][2]*2.0f; FLOAT fAmpX=afStarsPositions[iDanceRnd][1]*2.0f;
FLOAT fAmpZ=afStarsPositions[iDanceRnd][3]*2.0f; FLOAT fAmpZ=afStarsPositions[iDanceRnd][2]*2.0f;
FLOAT fX = vPos(1) + (iX+afStarsPositions[iRndXZ][3])*fGridSize+fAmpX*sin(fDanceAngle+fNow*3.0f); FLOAT fX = vPos(1) + (iX+afStarsPositions[iRndXZ][2])*fGridSize+fAmpX*sin(fDanceAngle+fNow*3.0f);
FLOAT fZ = vPos(3) + (iZ+afStarsPositions[iRndXZ][2])*fGridSize+fAmpZ*cos(fDanceAngle+fNow*3.0f); FLOAT fZ = vPos(3) + (iZ+afStarsPositions[iRndXZ][1])*fGridSize+fAmpZ*cos(fDanceAngle+fNow*3.0f);
FLOAT fT0 = afStarsPositions[(INDEX(2+Abs(fX)+Abs(fZ))*262147) % CT_MAX_PARTICLES_TABLE][2]; FLOAT fT0 = afStarsPositions[(INDEX(2+Abs(fX)+Abs(fZ))*262147) % CT_MAX_PARTICLES_TABLE][1];
for( INDEX iY=0; iY<(YGRIDS_VISIBLE_ABOVE+YGRIDS_VISIBLE_BELOW); iY++) for( INDEX iY=0; iY<(YGRIDS_VISIBLE_ABOVE+YGRIDS_VISIBLE_BELOW); iY++)
{ {
@ -3618,7 +3619,7 @@ void Particles_BulletSpray(INDEX iRndBase, FLOAT3D vSource, FLOAT3D vGDir, enum
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 = vSource + (vDirection+vRandomAngle)*(fT*fSpeedRnd)+vGDir*(fT*fT*fGA); FLOAT3D vPos = vSource + (vDirection+vRandomAngle)*(fT*fSpeedRnd)+vGDir*(fT*fT*fGA);
if( (eptType == EPT_BULLET_WATER) && (vPos(2) < vSource(2)) ) if( (eptType == EPT_BULLET_WATER) && (vPos(2) < vSource(2)) )
@ -3756,7 +3757,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)
@ -4781,11 +4782,11 @@ void Particles_AfterBurner(CEntity *pen, FLOAT tmSpawn, FLOAT fStretch, INDEX iG
// smoke // smoke
FLOAT3D vPosS = *pvPos1; FLOAT3D vPosS = *pvPos1;
Particle_SetTexturePart( 512, 512, 1, 0); Particle_SetTexturePart( 512, 512, 1, 0);
FLOAT fAngleS = afStarsPositions[iRnd][2]*360.0f+fT*120.0f*afStarsPositions[iRnd][3]; FLOAT fAngleS = afStarsPositions[iRnd][1]*360.0f+fT*120.0f*afStarsPositions[iRnd][2];
FLOAT fSizeS = (0.5f+aSmoke_sol[iIndex]*2.5f)*fStretch; FLOAT fSizeS = (0.5f+aSmoke_sol[iIndex]*2.5f)*fStretch;
FLOAT3D vVelocityS=FLOAT3D(afStarsPositions[iRnd][2], FLOAT3D vVelocityS=FLOAT3D(afStarsPositions[iRnd][1],
afStarsPositions[iRnd][3], afStarsPositions[iRnd][2],
afStarsPositions[iRnd][1])*5.0f; afStarsPositions[iRnd][0])*5.0f;
vPosS=vPosS+vVelocityS*fT+vGDir*fGA/2.0f*(fT*fT)/32.0f; vPosS=vPosS+vVelocityS*fT+vGDir*fGA/2.0f*(fT*fT)/32.0f;
Particle_RenderSquare( vPosS, fSizeS, fAngleS, ByteSwap(pcolSmoke[iIndex])); Particle_RenderSquare( vPosS, fSizeS, fAngleS, ByteSwap(pcolSmoke[iIndex]));
@ -4899,7 +4900,7 @@ void Particles_RocketMotorBurning(CEntity *pen, FLOAT tmSpawn, FLOAT3D vStretch,
INDEX iIndex=(INDEX) (fT*255); INDEX iIndex=(INDEX) (fT*255);
// smoke // smoke
Particle_SetTexturePart( 512, 512, 1, 0); Particle_SetTexturePart( 512, 512, 1, 0);
FLOAT fAngleS = afStarsPositions[iRnd][2]*360.0f+fT*120.0f*afStarsPositions[iRnd][3]; FLOAT fAngleS = afStarsPositions[iRnd][1]*360.0f+fT*120.0f*afStarsPositions[iRnd][2];
FLOAT fSizeS = (3.0f+fT*4.5f)*fStretch; FLOAT fSizeS = (3.0f+fT*4.5f)*fStretch;
Particle_RenderSquare( vPosS, fSizeS, fAngleS, ByteSwap(pcolSmoke[iIndex])); Particle_RenderSquare( vPosS, fSizeS, fAngleS, ByteSwap(pcolSmoke[iIndex]));
@ -4933,7 +4934,7 @@ void Particles_RocketMotorBurning(CEntity *pen, FLOAT tmSpawn, FLOAT3D vStretch,
INDEX iIndex=(INDEX) (fT*255); INDEX iIndex=(INDEX) (fT*255);
// smoke // smoke
Particle_SetTexturePart( 512, 512, 1, 0); Particle_SetTexturePart( 512, 512, 1, 0);
FLOAT fAngleS = afStarsPositions[iRnd][2]*360.0f+fT*120.0f*afStarsPositions[iRnd][3]; FLOAT fAngleS = afStarsPositions[iRnd][1]*360.0f+fT*120.0f*afStarsPositions[iRnd][2];
FLOAT fSizeS = (1.5f+aSmoke_sol[iIndex]*2.5f)*fStretch*fFireStretch; FLOAT fSizeS = (1.5f+aSmoke_sol[iIndex]*2.5f)*fStretch*fFireStretch;
Particle_RenderSquare( vPosS, fSizeS, fAngleS, ByteSwap(pcolSmoke[iIndex])); Particle_RenderSquare( vPosS, fSizeS, fAngleS, ByteSwap(pcolSmoke[iIndex]));
@ -5303,7 +5304,7 @@ void Particles_CollectEnergy(CEntity *pen, FLOAT tmStart, FLOAT tmStop)
UBYTE ubR = (UBYTE) (255);//+afStarsPositions[iRnd][1]*64; UBYTE ubR = (UBYTE) (255);//+afStarsPositions[iRnd][1]*64;
UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128);//223+afStarsPositions[iRnd][2]*64; UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128);//223+afStarsPositions[iRnd][2]*64;
UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][3]*32+(1.0f-fT)*64); UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64);
UBYTE ubA = (UBYTE) (CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255); UBYTE ubA = (UBYTE) (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;
@ -5339,7 +5340,7 @@ void Particles_CollectEnergy(CEntity *pen, FLOAT tmStart, FLOAT tmStop)
vZ*Cos(fT*360.0f)*fRadius; vZ*Cos(fT*360.0f)*fRadius;
UBYTE ubR = (UBYTE) (255); UBYTE ubR = (UBYTE) (255);
UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128); UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128);
UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][3]*32+(1.0f-fT)*64); UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64);
FLOAT fFader=CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f); FLOAT fFader=CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f);
FLOAT fPulser=(1.0f+(sin((fT*fT)/4.0f)))/2.0f; FLOAT fPulser=(1.0f+(sin((fT*fT)/4.0f)))/2.0f;
UBYTE ubA = (UBYTE) (fFader*fPulser*255); UBYTE ubA = (UBYTE) (fFader*fPulser*255);
@ -5404,9 +5405,9 @@ void Particles_SummonerDisappear( CEntity *pen, FLOAT tmStart)
for( INDEX iVtx=0; iVtx<ctVtx; iVtx+=1) for( INDEX iVtx=0; iVtx<ctVtx; iVtx+=1)
{ {
INDEX iRnd=iVtx%CT_MAX_PARTICLES_TABLE; INDEX iRnd=iVtx%CT_MAX_PARTICLES_TABLE;
FLOAT fRndPulseOffset=afStarsPositions[iRnd][1]; FLOAT fRndPulseOffset=afStarsPositions[iRnd][0];
FLOAT fRndPulseSpeed=afStarsPositions[iRnd][2]*128.0f; FLOAT fRndPulseSpeed=afStarsPositions[iRnd][1]*128.0f;
FLOAT fRndSize=afStarsPositions[iRnd][3]; FLOAT fRndSize=afStarsPositions[iRnd][2];
FLOAT fPulser=1.0f-(fRatio*(1.0f+(Sin(fRatio*360.0f*fRndPulseSpeed+fRndPulseOffset*360.0f)))/2.0f); FLOAT fPulser=1.0f-(fRatio*(1.0f+(Sin(fRatio*360.0f*fRndPulseSpeed+fRndPulseOffset*360.0f)))/2.0f);
UBYTE ubColor = UBYTE(CT_OPAQUE*fColorFactor*fPulser); UBYTE ubColor = UBYTE(CT_OPAQUE*fColorFactor*fPulser);
@ -5720,7 +5721,7 @@ void Particles_LarvaEnergy(CEntity *pen, FLOAT3D vOffset)
UBYTE ubR = (UBYTE) (255);//+afStarsPositions[iRnd][1]*64; UBYTE ubR = (UBYTE) (255);//+afStarsPositions[iRnd][1]*64;
UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128);//223+afStarsPositions[iRnd][2]*64; UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128);//223+afStarsPositions[iRnd][2]*64;
UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][3]*32+(1.0f-fT)*64); UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64);
UBYTE ubA = (UBYTE) (CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255); UBYTE ubA = (UBYTE) (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;
@ -5756,7 +5757,7 @@ void Particles_LarvaEnergy(CEntity *pen, FLOAT3D vOffset)
vZ*Cos(fT*360.0f)*fRadius; vZ*Cos(fT*360.0f)*fRadius;
UBYTE ubR = (UBYTE) (255); UBYTE ubR = (UBYTE) (255);
UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128); UBYTE ubG = (UBYTE) (128+(1.0f-fT)*128);
UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][3]*32+(1.0f-fT)*64); UBYTE ubB = (UBYTE) (16+afStarsPositions[iRnd][2]*32+(1.0f-fT)*64);
FLOAT fFader=CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f); FLOAT fFader=CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f);
FLOAT fPulser=(1.0f+(sin((fT*fT)/4.0f)))/2.0f; FLOAT fPulser=(1.0f+(sin((fT*fT)/4.0f)))/2.0f;
UBYTE ubA = (UBYTE) (fFader*fPulser*255); UBYTE ubA = (UBYTE) (fFader*fPulser*255);
@ -5854,7 +5855,7 @@ void Particles_ModelGlow( CEntity *pen, FLOAT tmEnd, enum ParticleTexture ptText
for( INDEX iVtx=0; iVtx<ctVtx-1; iVtx+=(INDEX)iVtxStep) for( INDEX iVtx=0; iVtx<ctVtx-1; iVtx+=(INDEX)iVtxStep)
{ {
INDEX iRnd=iVtx%CT_MAX_PARTICLES_TABLE; INDEX iRnd=iVtx%CT_MAX_PARTICLES_TABLE;
FLOAT fRndSize=afStarsPositions[iRnd][3]; FLOAT fRndSize=afStarsPositions[iRnd][2];
FLOAT3D vPos = avVertices[iVtx]; FLOAT3D vPos = avVertices[iVtx];
Particle_RenderSquare( vPos, (1.0f+fRndSize)*fSize, 0, iCol|ubCol); Particle_RenderSquare( vPos, (1.0f+fRndSize)*fSize, 0, iCol|ubCol);
@ -5895,7 +5896,7 @@ void Particles_ModelGlow2( CModelObject *mo, CPlacement3D pl, FLOAT tmEnd, enum
for( INDEX iVtx=0; iVtx<ctVtx-1; iVtx+=(INDEX)iVtxStep) for( INDEX iVtx=0; iVtx<ctVtx-1; iVtx+=(INDEX)iVtxStep)
{ {
INDEX iRnd=iVtx%CT_MAX_PARTICLES_TABLE; INDEX iRnd=iVtx%CT_MAX_PARTICLES_TABLE;
FLOAT fRndSize=afStarsPositions[iRnd][3]; FLOAT fRndSize=afStarsPositions[iRnd][2];
FLOAT3D vPos = avVertices[iVtx]; FLOAT3D vPos = avVertices[iVtx];
Particle_RenderSquare( vPos, (1.0f+fRndSize)*fSize, 0, iCol|ubCol); Particle_RenderSquare( vPos, (1.0f+fRndSize)*fSize, 0, iCol|ubCol);
@ -5977,11 +5978,11 @@ void Particles_RunAfterBurner(CEntity *pen, FLOAT tmEnd, FLOAT fStretch, INDEX i
// smoke // smoke
FLOAT3D vPosS = *pvPos1; FLOAT3D vPosS = *pvPos1;
Particle_SetTexturePart( 512, 512, 1, 0); Particle_SetTexturePart( 512, 512, 1, 0);
FLOAT fAngleS = afStarsPositions[iRnd][2]*360.0f+fT*120.0f*afStarsPositions[iRnd][3]; FLOAT fAngleS = afStarsPositions[iRnd][1]*360.0f+fT*120.0f*afStarsPositions[iRnd][2];
FLOAT fSizeS = (0.5f+aSmoke_sol[iIndex]*2.5f)*fStretch; FLOAT fSizeS = (0.5f+aSmoke_sol[iIndex]*2.5f)*fStretch;
FLOAT3D vVelocityS=FLOAT3D(afStarsPositions[iRnd][2], FLOAT3D vVelocityS=FLOAT3D(afStarsPositions[iRnd][1],
afStarsPositions[iRnd][3], afStarsPositions[iRnd][2],
afStarsPositions[iRnd][1])*5.0f; afStarsPositions[iRnd][0])*5.0f;
vPosS=vPosS+vVelocityS*fT+vGDir*fGA/2.0f*(fT*fT)/32.0f; vPosS=vPosS+vVelocityS*fT+vGDir*fGA/2.0f*(fT*fT)/32.0f;
col = ByteSwap(pcolSmoke[iIndex]); col = ByteSwap(pcolSmoke[iIndex]);
col = (col&0xffffff00)|((col&0x000000ff)*ubColMul/255); col = (col&0xffffff00)|((col&0x000000ff)*ubColMul/255);

View File

@ -64,7 +64,7 @@ EntityStats *FindStats(const CTString &strName)
static void MakeWorldStatistics(void) static void MakeWorldStatistics(void)
{ {
// get the world pointer // get the world pointer
CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
// if there is no current world // if there is no current world
if (pwo==NULL) { if (pwo==NULL) {
CPrintF("No current world.\n"); CPrintF("No current world.\n");
@ -130,7 +130,7 @@ static void MakeWorldStatistics(void)
static void ReoptimizeAllBrushes(void) static void ReoptimizeAllBrushes(void)
{ {
// get the world pointer // get the world pointer
CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
// if there is no current world // if there is no current world
if (pwo==NULL) { if (pwo==NULL) {
CPrintF("No current world.\n"); CPrintF("No current world.\n");
@ -157,7 +157,7 @@ static void DoLevelSafetyChecks()
CPrintF("\n**** BEGIN Level safety checking ****\n\n"); CPrintF("\n**** BEGIN Level safety checking ****\n\n");
// get the world pointer // get the world pointer
CWorld *pwo = (CWorld *)_pShell->GetINDEX("pwoCurrentWorld"); CWorld *pwo = _pShell->GetCurrentWorld();
// if there is no current world // if there is no current world
if (pwo==NULL) { if (pwo==NULL) {
CPrintF("Error - no current world.\n"); CPrintF("Error - no current world.\n");

View File

@ -227,8 +227,10 @@ void CControls::Load_t( CTFileName fnFile)
achrActionName[ 0] = 0; achrActionName[ 0] = 0;
FLOAT fSensitivity = 50; FLOAT fSensitivity = 50;
FLOAT fDeadZone = 0; FLOAT fDeadZone = 0;
// FIXME DG: if achrIfSmooth should be read, add another %1024s - but it seems like achrIfSmooth
// is unused - below achrIfRelative is compared to "Smooth"?!
sscanf( achrLine, "%*[^\"]\"%1024[^\"]\"%*[^\"]\"%1024[^\"]\" %g %g %1024s %1024s", sscanf( achrLine, "%*[^\"]\"%1024[^\"]\"%*[^\"]\"%1024[^\"]\" %g %g %1024s %1024s",
achrActionName, achrAxis, &fSensitivity, &fDeadZone, achrIfInverted, achrIfRelative, achrIfSmooth); achrActionName, achrAxis, &fSensitivity, &fDeadZone, achrIfInverted, achrIfRelative /*, achrIfSmooth*/);
// find action axis // find action axis
INDEX iActionAxisNo = -1; INDEX iActionAxisNo = -1;
{for( INDEX iAxis=0; iAxis<AXIS_ACTIONS_CT; iAxis++){ {for( INDEX iAxis=0; iAxis<AXIS_ACTIONS_CT; iAxis++){

View File

@ -1187,7 +1187,7 @@ void JoinNetworkGame(void)
_pNetwork->ga_strRequiredMod.ScanF("%250[^\\]\\%s", &strModName, &strModURL); _pNetwork->ga_strRequiredMod.ScanF("%250[^\\]\\%s", &strModName, &strModURL);
_fnmModSelected = CTString(strModName); _fnmModSelected = CTString(strModName);
_strModURLSelected = strModURL; _strModURLSelected = strModURL;
if (_strModURLSelected="") { if (_strModURLSelected=="") {
_strModURLSelected = "http://www.croteam.com/mods/Old"; _strModURLSelected = "http://www.croteam.com/mods/Old";
} }
_strModServerSelected.PrintF("%s:%s", (const char *) _pGame->gam_strJoinAddress, (const char *) _pShell->GetValue("net_iPort")); _strModServerSelected.PrintF("%s:%s", (const char *) _pGame->gam_strJoinAddress, (const char *) _pShell->GetValue("net_iPort"));

View File

@ -2098,7 +2098,7 @@ BOOL CWorldEditorApp::OnIdle(LONG lCount)
if (pvCurrent!=NULL) { if (pvCurrent!=NULL) {
CWorldEditorDoc *pdocCurrent = pvCurrent->GetDocument(); CWorldEditorDoc *pdocCurrent = pvCurrent->GetDocument();
if (pdocCurrent!=NULL) { if (pdocCurrent!=NULL) {
_pShell->SetINDEX("pwoCurrentWorld", (INDEX)&pdocCurrent->m_woWorld); _pShell->SetCurrentWorld(&pdocCurrent->m_woWorld);
} }
} }