mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2025-09-09 15:20:06 +02:00
commit
ad5841d319
@ -458,15 +458,15 @@ void CAnimData::Write_t( CTStream *ostrFile) // throw char *
|
||||
// First we save main ID
|
||||
ostrFile->WriteID_t( CChunkID( "ADAT"));
|
||||
// Then we save number of how many animations do we have and then save them all
|
||||
ostrFile->Write_t( &ad_NumberOfAnims, sizeof( INDEX));
|
||||
(*ostrFile)<<ad_NumberOfAnims;
|
||||
for( i=0; i<ad_NumberOfAnims; i++)
|
||||
{
|
||||
// Next block saves all data for one animation
|
||||
ostrFile->Write_t( &ad_Anims[i].oa_Name, sizeof( NAME));
|
||||
ostrFile->Write_t( &ad_Anims[i].oa_SecsPerFrame, sizeof( TIME));
|
||||
ostrFile->Write_t( &ad_Anims[i].oa_NumberOfFrames, sizeof( INDEX));
|
||||
ostrFile->Write_t( ad_Anims[i].oa_FrameIndices,
|
||||
ad_Anims[i].oa_NumberOfFrames * sizeof( INDEX));
|
||||
(*ostrFile)<<ad_Anims[i].oa_SecsPerFrame;
|
||||
(*ostrFile)<<ad_Anims[i].oa_NumberOfFrames;
|
||||
for (SLONG j = 0; j < ad_Anims[i].oa_NumberOfFrames; j++)
|
||||
(*ostrFile)<<ad_Anims[i].oa_FrameIndices[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,6 +498,7 @@ SLONG CTStream::GetSize_t(void) // throws char *
|
||||
SLONG chunkSize;
|
||||
|
||||
Read_t( (char *) &chunkSize, sizeof( SLONG));
|
||||
BYTESWAP(chunkSize);
|
||||
return( chunkSize);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ void CBrushPolygonTexture::Read_t( CTStream &strm) // throw char *
|
||||
void CBrushPolygonTexture::Write_t( CTStream &strm) // throw char *
|
||||
{
|
||||
strm<<bpt_toTexture.GetName();
|
||||
strm.Write_t(&bpt_mdMapping, sizeof(bpt_mdMapping));
|
||||
strm<<bpt_mdMapping;
|
||||
strm<<s.bpt_ubScroll;
|
||||
strm<<s.bpt_ubBlend;
|
||||
strm<<s.bpt_ubFlags;
|
||||
@ -280,7 +280,7 @@ void CBrushSector::Write_t( CTStream *postrm) // throw char *
|
||||
// for each vertex
|
||||
{FOREACHINSTATICARRAY(bsc_abvxVertices, CBrushVertex, itbvx) {
|
||||
// write precise vertex coordinates
|
||||
postrm->Write_t(&itbvx->bvx_vdPreciseRelative, sizeof(DOUBLE3D));
|
||||
(*postrm)<<itbvx->bvx_vdPreciseRelative;
|
||||
}}
|
||||
|
||||
(*postrm).WriteID_t("PLNs"); // 'planes'
|
||||
@ -289,7 +289,7 @@ void CBrushSector::Write_t( CTStream *postrm) // throw char *
|
||||
// for each plane
|
||||
{FOREACHINSTATICARRAY(bsc_abplPlanes, CBrushPlane, itbpl) {
|
||||
// write precise plane coordinates
|
||||
postrm->Write_t(&itbpl->bpl_pldPreciseRelative, sizeof(DOUBLEplane3D));
|
||||
(*postrm)<<itbpl->bpl_pldPreciseRelative;
|
||||
}}
|
||||
|
||||
(*postrm).WriteID_t("EDGs"); // 'edges'
|
||||
@ -320,7 +320,7 @@ void CBrushSector::Write_t( CTStream *postrm) // throw char *
|
||||
bpo.bpo_abptTextures[1].Write_t(*postrm);
|
||||
bpo.bpo_abptTextures[2].Write_t(*postrm);
|
||||
// write other polygon properties
|
||||
(*postrm).Write_t(&bpo.bpo_bppProperties, sizeof(bpo.bpo_bppProperties));
|
||||
(*postrm)<<bpo.bpo_bppProperties;
|
||||
|
||||
// write number of polygon edges
|
||||
(*postrm)<<bpo.bpo_abpePolygonEdges.Count();
|
||||
@ -350,7 +350,9 @@ void CBrushSector::Write_t( CTStream *postrm) // throw char *
|
||||
(*postrm)<<ctElements;
|
||||
// write all element indices
|
||||
if (ctElements>0) {
|
||||
(*postrm).Write_t(&bpo.bpo_aiTriangleElements[0], ctElements*sizeof(INDEX));
|
||||
for (INDEX i = 0; i < ctElements; i++) {
|
||||
(*postrm)<<bpo.bpo_aiTriangleElements[i];
|
||||
}
|
||||
}
|
||||
|
||||
// write the shadow-map (if it exists)
|
||||
|
@ -3405,7 +3405,7 @@ void CEntity::Write_t( CTStream *ostr) // throw char *
|
||||
<<en_ulCollisionFlags
|
||||
<<en_ulSpawnFlags
|
||||
<<en_ulFlags;
|
||||
(*ostr).Write_t(&en_mRotation, sizeof(en_mRotation));
|
||||
(*ostr)<<en_mRotation;
|
||||
// if this is a brush
|
||||
if ( en_RenderType == RT_BRUSH || en_RenderType == RT_FIELDBRUSH) {
|
||||
// write brush index in world's brush archive
|
||||
|
@ -124,6 +124,12 @@ BOOL CompareChroma( COLOR col1, COLOR col2)
|
||||
SLONG slR2=0, slG2=0, slB2=0;
|
||||
ColorToRGB( col1, (UBYTE&)slR1, (UBYTE&)slG1, (UBYTE&)slB1);
|
||||
ColorToRGB( col2, (UBYTE&)slR2, (UBYTE&)slG2, (UBYTE&)slB2);
|
||||
BYTESWAP(slR1);
|
||||
BYTESWAP(slG1);
|
||||
BYTESWAP(slB1);
|
||||
BYTESWAP(slR2);
|
||||
BYTESWAP(slG2);
|
||||
BYTESWAP(slB2);
|
||||
SLONG slMax1 = Max(Max(slR1,slG1),slB1);
|
||||
SLONG slMax2 = Max(Max(slR2,slG2),slB2);
|
||||
// trivial?
|
||||
|
@ -462,6 +462,7 @@ void CDrawPort::DrawPoint( PIX pixI, PIX pixJ, COLOR col, PIX pixRadius/*=1*/) c
|
||||
if( eAPI==GAT_OGL) {
|
||||
const FLOAT fI = pixI+0.5f;
|
||||
const FLOAT fJ = pixJ+0.5f;
|
||||
BYTESWAP(col);
|
||||
glCOLOR(col);
|
||||
pglPointSize(fR);
|
||||
pglBegin(GL_POINTS);
|
||||
@ -508,6 +509,7 @@ void CDrawPort::DrawPoint3D( FLOAT3D v, COLOR col, FLOAT fRadius/*=1.0f*/) const
|
||||
|
||||
// OpenGL
|
||||
if( eAPI==GAT_OGL) {
|
||||
BYTESWAP(col);
|
||||
glCOLOR(col);
|
||||
pglPointSize(fRadius);
|
||||
pglBegin(GL_POINTS);
|
||||
@ -569,6 +571,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col,
|
||||
if( eAPI==GAT_OGL) {
|
||||
const FLOAT fI0 = pixI0+0.5f; const FLOAT fJ0 = pixJ0+0.5f;
|
||||
const FLOAT fI1 = pixI1+0.5f; const FLOAT fJ1 = pixJ1+0.5f;
|
||||
BYTESWAP(col);
|
||||
glCOLOR(col);
|
||||
pglBegin( GL_LINES);
|
||||
pglTexCoord2f( 0,0); pglVertex2f(fI0,fJ0);
|
||||
@ -615,6 +618,7 @@ void CDrawPort::DrawLine3D( FLOAT3D v0, FLOAT3D v1, COLOR col) const
|
||||
col = AdjustColor( col, _slTexHueShift, _slTexSaturation);
|
||||
// OpenGL
|
||||
if( eAPI==GAT_OGL) {
|
||||
BYTESWAP(col);
|
||||
glCOLOR(col);
|
||||
pglBegin( GL_LINES);
|
||||
pglVertex3f( v0(1),v0(2),v0(3));
|
||||
@ -680,6 +684,7 @@ void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COL
|
||||
|
||||
// OpenGL
|
||||
if( eAPI==GAT_OGL) {
|
||||
BYTESWAP(col);
|
||||
glCOLOR(col);
|
||||
pglBegin( GL_LINES);
|
||||
pglTexCoord2f(0,0); pglVertex2f(fI0,fJ0); pglTexCoord2f(fD,0); pglVertex2f(fI1, fJ0); // up
|
||||
|
@ -109,7 +109,11 @@ pixLoop:
|
||||
DWORD* dst = (DWORD*)(pubTexture+pixTextureSize);
|
||||
for (int i=0; i<pixTextureSize; i++) {
|
||||
const DWORD tmp = ((DWORD)*src) | 0xFFFFFF00;
|
||||
#if PLATFORM_LITTLEENDIAN
|
||||
*dst = BYTESWAP32_unsigned((ULONG)tmp);
|
||||
#else
|
||||
*dst = tmp;
|
||||
#endif
|
||||
src++;
|
||||
dst++;
|
||||
}
|
||||
|
@ -372,6 +372,10 @@ STUBBED("Byte swapping TGA data");
|
||||
|
||||
// TGA header starts at the begining of the TGA file
|
||||
pTGAHdr = (struct TGAHeader*)pTGABuffer;
|
||||
BYTESWAP(pTGAHdr->Width);
|
||||
BYTESWAP(pTGAHdr->Height);
|
||||
BYTESWAP(pTGAHdr->Xorigin);
|
||||
BYTESWAP(pTGAHdr->Yorigin);
|
||||
// TGA image bytes definition follows up
|
||||
pTGAImage = pTGABuffer + sizeof(struct TGAHeader) + pTGAHdr->IdLength;
|
||||
|
||||
@ -475,9 +479,13 @@ void CImageInfo::SaveTGA_t( const CTFileName &strFileName) const // throw char *
|
||||
// set TGA picture size dimensions
|
||||
memset( pTGABuffer, 0x0, sizeof(struct TGAHeader));
|
||||
pTGAHdr->Width = (UWORD)ii_Width;
|
||||
BYTESWAP(pTGAHdr->Width);
|
||||
pTGAHdr->Height = (UWORD)ii_Height;
|
||||
BYTESWAP(pTGAHdr->Height);
|
||||
pTGAHdr->BitsPerPixel = (UBYTE)ii_BitsPerPixel;
|
||||
pTGAHdr->ImageType = 2;
|
||||
BYTESWAP(pTGAHdr->Xorigin);
|
||||
BYTESWAP(pTGAHdr->Yorigin);
|
||||
|
||||
// flip image vertically
|
||||
BOOL bAlphaChannel = (slBytesPerPixel==4);
|
||||
|
@ -752,8 +752,9 @@ void CTextureData::Read_t( CTStream *inFile)
|
||||
// alloc memory block and read mip-maps
|
||||
inFile->Read_t( td_pulFrames, slTexSize);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
for (SLONG i = 0; i < slTexSize/4; i++)
|
||||
BYTESWAP(td_pulFrames[i]);
|
||||
UWORD *uwptr = (UWORD *)td_pulFrames;
|
||||
for (SLONG i = 0; i < slTexSize/2; i++)
|
||||
BYTESWAP(uwptr[i]);
|
||||
#endif
|
||||
}
|
||||
// if current version
|
||||
@ -765,10 +766,6 @@ void CTextureData::Read_t( CTStream *inFile)
|
||||
if( bAlphaChannel) {
|
||||
// read texture with alpha channel from file
|
||||
inFile->Read_t( pulCurrentFrame, pixFrameSizeOnDisk *4);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
for (SLONG i = 0; i < pixFrameSizeOnDisk; i++)
|
||||
BYTESWAP(pulCurrentFrame[i]);
|
||||
#endif
|
||||
} else {
|
||||
// read texture without alpha channel from file
|
||||
inFile->Read_t( pulCurrentFrame, pixFrameSizeOnDisk *3);
|
||||
@ -825,6 +822,15 @@ void CTextureData::Read_t( CTStream *inFile)
|
||||
ULONG ulSize = AllocEffectBuffers(this);
|
||||
inFile->Read_t( td_pubBuffer1, ulSize);
|
||||
inFile->Read_t( td_pubBuffer2, ulSize);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
SWORD* pNew = (SWORD*)td_pubBuffer1;
|
||||
SWORD* pOld = (SWORD*)td_pubBuffer2;
|
||||
for (int i = 0; i < ulSize / 2; i++)
|
||||
{
|
||||
BYTESWAP(pNew[i]);
|
||||
BYTESWAP(pOld[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// if this is chunk containing effect data
|
||||
else if( idChunk == CChunkID("FXDT"))
|
||||
@ -1008,10 +1014,6 @@ void CTextureData::Read_t( CTStream *inFile)
|
||||
// writes texutre to file
|
||||
void CTextureData::Write_t( CTStream *outFile) // throw char *
|
||||
{
|
||||
#if PLATFORM_BIGENDIAN
|
||||
STUBBED("Byte swapping");
|
||||
#endif
|
||||
|
||||
// cannot write textures that have been mangled somehow
|
||||
_bExport = FALSE;
|
||||
if( td_ptegEffect==NULL && IsModified()) throw( TRANS("Cannot write texture that has modified frames."));
|
||||
@ -1084,14 +1086,15 @@ void CTextureData::Write_t( CTStream *outFile) // throw char *
|
||||
{ // write type of effect source
|
||||
*outFile << itEffectSource->tes_ulEffectSourceType;
|
||||
// write structure holding effect source properties
|
||||
outFile->Write_t( &itEffectSource->tes_tespEffectSourceProperties, sizeof( struct TextureEffectSourceProperties));
|
||||
*outFile >> itEffectSource->tes_tespEffectSourceProperties;
|
||||
INDEX ctEffectSourcePixels = itEffectSource->tes_atepPixels.Count();
|
||||
// write count of effect pixels
|
||||
*outFile << ctEffectSourcePixels;
|
||||
// if there are any effect pixels
|
||||
if( ctEffectSourcePixels>0) {
|
||||
// write all effect pixels in one block
|
||||
outFile->Write_t( &itEffectSource->tes_atepPixels[0], sizeof(struct TextureEffectPixel)*ctEffectSourcePixels);
|
||||
for (INDEX i = 0; i < ctEffectSourcePixels; i++)
|
||||
*outFile >> itEffectSource->tes_atepPixels[i];
|
||||
}
|
||||
}
|
||||
// if effect buffers are valid
|
||||
|
@ -143,21 +143,48 @@ static inline void IncrementColorWithClip( UBYTE &ubR, UBYTE &ubG, UBYTE &ubB,
|
||||
// add the intensity to the pixel
|
||||
inline void CLayerMixer::AddToCluster( UBYTE *pub)
|
||||
{
|
||||
#if PLATFORM_LITTLEENDIAN
|
||||
IncrementByteWithClip(pub[0], ((UBYTE*)&lm_colLight)[3]);
|
||||
IncrementByteWithClip(pub[1], ((UBYTE*)&lm_colLight)[2]);
|
||||
IncrementByteWithClip(pub[2], ((UBYTE*)&lm_colLight)[1]);
|
||||
#else
|
||||
IncrementByteWithClip(pub[0], ((UBYTE*)&lm_colLight)[0]);
|
||||
IncrementByteWithClip(pub[1], ((UBYTE*)&lm_colLight)[1]);
|
||||
IncrementByteWithClip(pub[2], ((UBYTE*)&lm_colLight)[2]);
|
||||
IncrementByteWithClip(pub[3], ((UBYTE*)&lm_colLight)[3]);
|
||||
#endif
|
||||
}
|
||||
inline void CLayerMixer::AddAmbientToCluster( UBYTE *pub)
|
||||
{
|
||||
#if PLATFORM_LITTLEENDIAN
|
||||
IncrementByteWithClip(pub[0], ((UBYTE*)&lm_colAmbient)[3]);
|
||||
IncrementByteWithClip(pub[1], ((UBYTE*)&lm_colAmbient)[2]);
|
||||
IncrementByteWithClip(pub[2], ((UBYTE*)&lm_colAmbient)[1]);
|
||||
#else
|
||||
IncrementByteWithClip(pub[0], ((UBYTE*)&lm_colAmbient)[0]);
|
||||
IncrementByteWithClip(pub[1], ((UBYTE*)&lm_colAmbient)[1]);
|
||||
IncrementByteWithClip(pub[2], ((UBYTE*)&lm_colAmbient)[2]);
|
||||
IncrementByteWithClip(pub[3], ((UBYTE*)&lm_colAmbient)[3]);
|
||||
#endif
|
||||
}
|
||||
inline void CLayerMixer::AddToCluster( UBYTE *pub, SLONG slIntensity)
|
||||
{
|
||||
#if PLATFORM_LITTLEENDIAN
|
||||
IncrementByteWithClip(pub[0], (long) (((UBYTE*)&lm_colLight)[3] *slIntensity)>>16);
|
||||
IncrementByteWithClip(pub[1], (long) (((UBYTE*)&lm_colLight)[2] *slIntensity)>>16);
|
||||
IncrementByteWithClip(pub[2], (long) (((UBYTE*)&lm_colLight)[1] *slIntensity)>>16);
|
||||
#else
|
||||
UBYTE r, g, b, a;
|
||||
ColorToRGBA(lm_colLight, r, g, b, a);
|
||||
|
||||
SLONG dR = ((SLONG)r * (SLONG)slIntensity) >> 16;
|
||||
SLONG dG = ((SLONG)g * (SLONG)slIntensity) >> 16;
|
||||
SLONG dB = ((SLONG)b * (SLONG)slIntensity) >> 16;
|
||||
|
||||
IncrementByteWithClip(pub[0], dR);
|
||||
IncrementByteWithClip(pub[1], dG);
|
||||
IncrementByteWithClip(pub[2], dB);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1406,6 +1433,12 @@ rowDone:
|
||||
SLONG slR1=0,slG1=0,slB1=0;
|
||||
ColorToRGB( col0, (UBYTE&)slR0,(UBYTE&)slG0,(UBYTE&)slB0);
|
||||
ColorToRGB( col1, (UBYTE&)slR1,(UBYTE&)slG1,(UBYTE&)slB1);
|
||||
BYTESWAP(slR0);
|
||||
BYTESWAP(slG0);
|
||||
BYTESWAP(slB0);
|
||||
BYTESWAP(slR1);
|
||||
BYTESWAP(slG1);
|
||||
BYTESWAP(slB1);
|
||||
if( gp.gp_bDark) {
|
||||
slR0 = -slR0; slG0 = -slG0; slB0 = -slB0;
|
||||
slR1 = -slR1; slG1 = -slG1; slB1 = -slB1;
|
||||
@ -1813,10 +1846,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
|
||||
// Forces C fallback; BYTESWAP itself is a no-op on little endian.
|
||||
ULONG swapped = BYTESWAP32_unsigned(colAmbient);
|
||||
#else
|
||||
STUBBED("actually need byteswap?");
|
||||
// (uses inline asm on MacOS PowerPC)
|
||||
ULONG swapped = colAmbient;
|
||||
BYTESWAP(swapped);
|
||||
#endif
|
||||
|
||||
for (ULONG *ptr = this->lm_pulShadowMap; count; count--)
|
||||
@ -1964,7 +1994,11 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col)
|
||||
#else
|
||||
DWORD* dst = (DWORD*)lm_pulShadowMap;
|
||||
int n = lm_pixCanvasSizeU*lm_pixCanvasSizeV;
|
||||
#if PLATFORM_LITTLEENDIAN
|
||||
DWORD color = BYTESWAP32_unsigned(col);
|
||||
#else
|
||||
DWORD color = col;
|
||||
#endif
|
||||
while(n--) {*(dst++)=color;}
|
||||
#endif
|
||||
}
|
||||
|
@ -68,11 +68,38 @@ public:
|
||||
friend __forceinline CTStream &operator>>(CTStream &strm, Matrix<Type, iRows, iColumns> &matrix)
|
||||
{
|
||||
strm.Read_t(&matrix, sizeof(matrix));
|
||||
#if PLATFORM_BIGENDIAN
|
||||
for (int i = 0; i < iRows; i++)
|
||||
{
|
||||
for (int j = 0; j < iColumns; j++)
|
||||
{
|
||||
BYTESWAP(matrix.matrix[i][j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return strm;
|
||||
}
|
||||
friend __forceinline CTStream &operator<<(CTStream &strm, Matrix<Type, iRows, iColumns> &matrix)
|
||||
{
|
||||
#if PLATFORM_BIGENDIAN
|
||||
for (int i = 0; i < iRows; i++)
|
||||
{
|
||||
for (int j = 0; j < iColumns; j++)
|
||||
{
|
||||
BYTESWAP(matrix.matrix[i][j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
strm.Write_t(&matrix, sizeof(matrix));
|
||||
#if PLATFORM_BIGENDIAN
|
||||
for (int i = 0; i < iRows; i++)
|
||||
{
|
||||
for (int j = 0; j < iColumns; j++)
|
||||
{
|
||||
BYTESWAP(matrix.matrix[i][j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return strm;
|
||||
}
|
||||
};
|
||||
|
@ -1178,10 +1178,6 @@ void CModelData::Write_t( CTStream *pFile) // throw char *
|
||||
// Save flags
|
||||
(*pFile) << md_Flags;
|
||||
|
||||
#if PLATFORM_BIGENDIAN
|
||||
STUBBED("byte order");
|
||||
#endif
|
||||
|
||||
// Save vertices and frames ct
|
||||
pFile->WriteFullChunk_t( CChunkID("IVTX"), &md_VerticesCt, sizeof(INDEX));
|
||||
pFile->WriteFullChunk_t( CChunkID("IFRM"), &md_FramesCt, sizeof(INDEX));
|
||||
@ -1689,6 +1685,7 @@ void CModelData::Read_t( CTStream *pFile) // throw char *
|
||||
// Read color names (Read count, read existing names)
|
||||
INDEX iValidColorsCt;
|
||||
pFile->ReadFullChunk_t( CChunkID("ICLN"), &iValidColorsCt, sizeof(INDEX));
|
||||
BYTESWAP(iValidColorsCt);
|
||||
for( i=0; i<iValidColorsCt; i++)
|
||||
{
|
||||
INDEX iExistingColorName;
|
||||
@ -1935,9 +1932,9 @@ void CModelObject::Write_t( CTStream *pFile) // throw char *
|
||||
|
||||
pFile->WriteID_t( CChunkID( "MODT"));
|
||||
*pFile << mo_colBlendColor;
|
||||
pFile->Write_t( &mo_PatchMask, sizeof(ULONG));
|
||||
pFile->Write_t( &mo_Stretch, sizeof(FLOAT3D));
|
||||
pFile->Write_t( &mo_ColorMask, sizeof(ULONG));
|
||||
*pFile << mo_PatchMask;
|
||||
*pFile << mo_Stretch;
|
||||
*pFile << mo_ColorMask;
|
||||
}
|
||||
//------------------------------------------ READ
|
||||
void CModelObject::Read_t( CTStream *pFile) // throw char *
|
||||
|
@ -915,7 +915,13 @@ CNetworkMessage &operator<<(CNetworkMessage &nm, const CPlayerAction &pa)
|
||||
} else {
|
||||
UBYTE ub=1;
|
||||
nm.WriteBits(&ub, 1);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
ULONG tmp = *pul;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 32);
|
||||
#else
|
||||
nm.WriteBits(pul, 32);
|
||||
#endif
|
||||
}
|
||||
pul++;
|
||||
}
|
||||
@ -933,27 +939,57 @@ CNetworkMessage &operator<<(CNetworkMessage &nm, const CPlayerAction &pa)
|
||||
} else if (ulFlags <= 3) {
|
||||
UBYTE ub=4;
|
||||
nm.WriteBits(&ub, 3);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
ULONG tmp = ulFlags;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 1);
|
||||
#else
|
||||
nm.WriteBits(&ulFlags, 1);
|
||||
#endif
|
||||
// (4-15) 0001 = 4 bit value follows
|
||||
} else if (ulFlags <= 15) {
|
||||
UBYTE ub=8;
|
||||
nm.WriteBits(&ub, 4);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
ULONG tmp = ulFlags;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 4);
|
||||
#else
|
||||
nm.WriteBits(&ulFlags, 4);
|
||||
#endif
|
||||
// (16-255) 00001 = 8 bit value follows
|
||||
} else if (ulFlags <= 255) {
|
||||
UBYTE ub=16;
|
||||
nm.WriteBits(&ub, 5);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
ULONG tmp = ulFlags;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 8);
|
||||
#else
|
||||
nm.WriteBits(&ulFlags, 8);
|
||||
#endif
|
||||
// (256-65535) 000001 = 16 bit value follows
|
||||
} else if (ulFlags <= 65535) {
|
||||
UBYTE ub=32;
|
||||
nm.WriteBits(&ub, 6);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
ULONG tmp = ulFlags;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 16);
|
||||
#else
|
||||
nm.WriteBits(&ulFlags, 16);
|
||||
#endif
|
||||
// (65536-) 000000 = 32 bit value follows
|
||||
} else {
|
||||
UBYTE ub=0;
|
||||
nm.WriteBits(&ub, 6);
|
||||
#if PLATFORM_BIGENDIAN
|
||||
ULONG tmp = ulFlags;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 32);
|
||||
#else
|
||||
nm.WriteBits(&ulFlags, 32);
|
||||
#endif
|
||||
}
|
||||
return nm;
|
||||
}
|
||||
@ -970,6 +1006,7 @@ CNetworkMessage &operator>>(CNetworkMessage &nm, CPlayerAction &pa)
|
||||
*pul = 0;
|
||||
} else {
|
||||
nm.ReadBits(pul, 32);
|
||||
BYTESWAP(*pul);
|
||||
}
|
||||
pul++;
|
||||
}
|
||||
@ -995,23 +1032,28 @@ CNetworkMessage &operator>>(CNetworkMessage &nm, CPlayerAction &pa)
|
||||
} else if (iZeros==2) {
|
||||
ulFlags = 0;
|
||||
nm.ReadBits(&ulFlags, 1);
|
||||
BYTESWAP(ulFlags);
|
||||
ulFlags |= 2;
|
||||
// (4-15) 0001 = 4 bit value follows
|
||||
} else if (iZeros==3) {
|
||||
ulFlags = 0;
|
||||
nm.ReadBits(&ulFlags, 4);
|
||||
BYTESWAP(ulFlags);
|
||||
// (16-255) 00001 = 8 bit value follows
|
||||
} else if (iZeros==4) {
|
||||
ulFlags = 0;
|
||||
nm.ReadBits(&ulFlags, 8);
|
||||
// (256-65535) 000001 = 16 bit value follows
|
||||
BYTESWAP(ulFlags);
|
||||
} else if (iZeros==5) {
|
||||
ulFlags = 0;
|
||||
nm.ReadBits(&ulFlags, 16);
|
||||
BYTESWAP(ulFlags);
|
||||
// (65536-) 000000 = 32 bit value follows
|
||||
} else {
|
||||
ulFlags = 0;
|
||||
nm.ReadBits(&ulFlags, 32);
|
||||
BYTESWAP(ulFlags);
|
||||
}
|
||||
pa.pa_ulButtons = ulFlags;
|
||||
return nm;
|
||||
|
@ -160,23 +160,24 @@ public:
|
||||
void WriteBits(const void *pvBuffer, INDEX ctBits);
|
||||
|
||||
/* Read an object from message. */
|
||||
inline CNetworkMessage &operator>>(float &f) { Read( &f, sizeof( f)); return *this; }
|
||||
inline CNetworkMessage &operator>>(ULONG &ul) { Read(&ul, sizeof(ul)); return *this; }
|
||||
inline CNetworkMessage &operator>>(UWORD &uw) { Read(&uw, sizeof(uw)); return *this; }
|
||||
inline CNetworkMessage &operator>>(float &f) { Read( &f, sizeof( f)); BYTESWAP(f); return *this; }
|
||||
inline CNetworkMessage &operator>>(double &d) { Read( &d, sizeof( d)); BYTESWAP(d); return *this; }
|
||||
inline CNetworkMessage &operator>>(ULONG &ul) { Read(&ul, sizeof(ul)); BYTESWAP(ul); return *this; }
|
||||
inline CNetworkMessage &operator>>(UWORD &uw) { Read(&uw, sizeof(uw)); BYTESWAP(uw); return *this; }
|
||||
inline CNetworkMessage &operator>>(UBYTE &ub) { Read(&ub, sizeof(ub)); return *this; }
|
||||
inline CNetworkMessage &operator>>(SLONG &sl) { Read(&sl, sizeof(sl)); return *this; }
|
||||
inline CNetworkMessage &operator>>(SWORD &sw) { Read(&sw, sizeof(sw)); return *this; }
|
||||
inline CNetworkMessage &operator>>(SLONG &sl) { Read(&sl, sizeof(sl)); BYTESWAP(sl); return *this; }
|
||||
inline CNetworkMessage &operator>>(SWORD &sw) { Read(&sw, sizeof(sw)); BYTESWAP(sw); return *this; }
|
||||
inline CNetworkMessage &operator>>(SBYTE &sb) { Read(&sb, sizeof(sb)); return *this; }
|
||||
inline CNetworkMessage &operator>>(MESSAGETYPE &mt) { Read(&mt, sizeof(mt)); return *this; }
|
||||
CNetworkMessage &operator>>(CTString &str);
|
||||
/* Write an object into message. */
|
||||
inline CNetworkMessage &operator<<(const float &f) { Write( &f, sizeof( f)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const double &d) { Write( &d, sizeof( d)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const ULONG &ul) { Write(&ul, sizeof(ul)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const UWORD &uw) { Write(&uw, sizeof(uw)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const float &f) { float zf = f; BYTESWAP( zf); Write( &zf, sizeof( zf)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const double &d) { double zd = d; BYTESWAP( zd); Write( &zd, sizeof( zd)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const ULONG &ul) { ULONG zul = ul; BYTESWAP(zul); Write(&zul, sizeof(zul)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const UWORD &uw) { UWORD zuw = uw; BYTESWAP(zuw); Write(&zuw, sizeof(zuw)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const UBYTE &ub) { Write(&ub, sizeof(ub)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const SLONG &sl) { Write(&sl, sizeof(sl)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const SWORD &sw) { Write(&sw, sizeof(sw)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const SLONG &sl) { SLONG zsl = sl; BYTESWAP(zsl); Write(&zsl, sizeof(zsl)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const SWORD &sw) { SWORD zsw = sw; BYTESWAP(zsw); Write(&zsw, sizeof(zsw)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const SBYTE &sb) { Write(&sb, sizeof(sb)); return *this; }
|
||||
inline CNetworkMessage &operator<<(const MESSAGETYPE &mt) { Write(&mt, sizeof(mt)); return *this; }
|
||||
CNetworkMessage &operator<<(const CTString &str);
|
||||
|
@ -71,6 +71,7 @@ void CPlayerBuffer::ReceiveActionPacket(CNetworkMessage *pnm, INDEX iMaxBuffer)
|
||||
// read sendbehind
|
||||
INDEX iSendBehind = 0;
|
||||
pnm->ReadBits(&iSendBehind, 2);
|
||||
BYTESWAP(iSendBehind);
|
||||
// foreach resent action
|
||||
for(INDEX i=0; i<iSendBehind; i++) {
|
||||
CPlayerAction paOld;
|
||||
|
@ -199,9 +199,21 @@ void CPlayerSource::WriteActionPacket(CNetworkMessage &nm)
|
||||
|
||||
// write all in the message
|
||||
BOOL bActive = 1;
|
||||
#if PLATFORM_BIGENDIAN
|
||||
SLONG tmp = bActive;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 1);
|
||||
tmp = pls_Index;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 4);
|
||||
tmp = iPing;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 10);
|
||||
#else
|
||||
nm.WriteBits(&bActive, 1);
|
||||
nm.WriteBits(&pls_Index, 4); // your index
|
||||
nm.WriteBits(&iPing, 10); // your ping
|
||||
#endif
|
||||
nm<<pls_paAction; // action
|
||||
//CPrintF("%.2f - written: %d\n", _pTimer->GetRealTimeTick(), SLONG(pls_paAction.pa_llCreated));
|
||||
|
||||
@ -217,7 +229,13 @@ void CPlayerSource::WriteActionPacket(CNetworkMessage &nm)
|
||||
}
|
||||
|
||||
// save sendbehind if needed
|
||||
#if PLATFORM_BIGENDIAN
|
||||
tmp = iSendBehind;
|
||||
BYTESWAP(tmp);
|
||||
nm.WriteBits(&tmp, 2);
|
||||
#else
|
||||
nm.WriteBits(&iSendBehind, 2);
|
||||
#endif
|
||||
for(INDEX i=0; i<iSendBehind; i++) {
|
||||
nm<<pls_apaLastActions[i];
|
||||
}
|
||||
|
@ -510,11 +510,26 @@ void CServer::SendGameStreamBlocks(INDEX iClient)
|
||||
CPlayerBuffer &plb = srv_aplbPlayers[i];
|
||||
if (plb.IsActive()) {
|
||||
BOOL b = 1;
|
||||
#if PLATFORM_BIGENDIAN
|
||||
SLONG tmp = b;
|
||||
BYTESWAP(tmp);
|
||||
nmPings.WriteBits(&tmp, 1);
|
||||
tmp = plb.plb_iPing;
|
||||
BYTESWAP(tmp);
|
||||
nmPings.WriteBits(&tmp, 10);
|
||||
#else
|
||||
nmPings.WriteBits(&b, 1);
|
||||
nmPings.WriteBits(&plb.plb_iPing, 10);
|
||||
#endif
|
||||
} else {
|
||||
BOOL b = 0;
|
||||
#if PLATFORM_BIGENDIAN
|
||||
SLONG tmp = b;
|
||||
BYTESWAP(tmp);
|
||||
nmPings.WriteBits(&tmp, 1);
|
||||
#else
|
||||
nmPings.WriteBits(&b, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
_pNetwork->SendToClient(iClient, nmPings);
|
||||
@ -1354,11 +1369,13 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage)
|
||||
// see if saved in the message
|
||||
BOOL bSaved = 0;
|
||||
nmMessage.ReadBits(&bSaved, 1);
|
||||
BYTESWAP(bSaved);
|
||||
// if saved
|
||||
if (bSaved) {
|
||||
// read client index
|
||||
INDEX iPlayer = 0;
|
||||
nmMessage.ReadBits(&iPlayer, 4);
|
||||
BYTESWAP(iPlayer);
|
||||
CPlayerBuffer &plb = srv_aplbPlayers[iPlayer];
|
||||
// if the player is not on that client
|
||||
if (plb.plb_iClient!=iClient) {
|
||||
@ -1369,6 +1386,7 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage)
|
||||
// read ping
|
||||
plb.plb_iPing = 0;
|
||||
nmMessage.ReadBits(&plb.plb_iPing, 10);
|
||||
BYTESWAP(plb.plb_iPing);
|
||||
// let the corresponding client buffer receive the message
|
||||
INDEX iMaxBuffer = sso.sso_sspParams.ssp_iBufferActions;
|
||||
extern INDEX cli_bPredictIfServer;
|
||||
|
@ -43,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <Engine/Templates/StaticArray.cpp>
|
||||
#include <Engine/Base/ListIterator.inl>
|
||||
#include <Engine/Base/CRC.h>
|
||||
#include <GameMP/SessionProperties.h>
|
||||
|
||||
#define SESSIONSTATEVERSION_OLD 1
|
||||
#define SESSIONSTATEVERSION_WITHBULLETTIME 2
|
||||
@ -1614,6 +1615,46 @@ void CSessionState::Read_t(CTStream *pstr) // throw char *
|
||||
// read session properties from stream
|
||||
(*pstr)>>_pNetwork->ga_strSessionName;
|
||||
pstr->Read_t(_pNetwork->ga_aubProperties, NET_MAXSESSIONPROPERTIES);
|
||||
CSessionProperties* psp = (CSessionProperties*)_pNetwork->ga_aubProperties;
|
||||
BYTESWAP(psp->sp_ctMaxPlayers);
|
||||
BYTESWAP(psp->sp_bWaitAllPlayers);
|
||||
BYTESWAP(psp->sp_bQuickTest);
|
||||
BYTESWAP(psp->sp_bCooperative);
|
||||
BYTESWAP(psp->sp_bSinglePlayer);
|
||||
BYTESWAP(psp->sp_bUseFrags);
|
||||
BYTESWAP((INDEX&)psp->sp_gmGameMode);
|
||||
BYTESWAP((INDEX&)psp->sp_gdGameDifficulty);
|
||||
BYTESWAP(psp->sp_ulSpawnFlags);
|
||||
BYTESWAP(psp->sp_bMental);
|
||||
BYTESWAP(psp->sp_iScoreLimit);
|
||||
BYTESWAP(psp->sp_iFragLimit);
|
||||
BYTESWAP(psp->sp_iTimeLimit);
|
||||
BYTESWAP(psp->sp_bTeamPlay);
|
||||
BYTESWAP(psp->sp_bFriendlyFire);
|
||||
BYTESWAP(psp->sp_bWeaponsStay);
|
||||
BYTESWAP(psp->sp_bAmmoStays);
|
||||
BYTESWAP(psp->sp_bHealthArmorStays);
|
||||
BYTESWAP(psp->sp_bPlayEntireGame);
|
||||
BYTESWAP(psp->sp_bAllowHealth);
|
||||
BYTESWAP(psp->sp_bAllowArmor);
|
||||
BYTESWAP(psp->sp_bInfiniteAmmo);
|
||||
BYTESWAP(psp->sp_bRespawnInPlace);
|
||||
BYTESWAP(psp->sp_fEnemyMovementSpeed);
|
||||
BYTESWAP(psp->sp_fEnemyAttackSpeed);
|
||||
BYTESWAP(psp->sp_fDamageStrength);
|
||||
BYTESWAP(psp->sp_fAmmoQuantity);
|
||||
BYTESWAP(psp->sp_fManaTransferFactor);
|
||||
BYTESWAP(psp->sp_iInitialMana);
|
||||
BYTESWAP(psp->sp_fExtraEnemyStrength);
|
||||
BYTESWAP(psp->sp_fExtraEnemyStrengthPerPlayer);
|
||||
BYTESWAP(psp->sp_ctCredits);
|
||||
BYTESWAP(psp->sp_ctCreditsLeft);
|
||||
BYTESWAP(psp->sp_tmSpawnInvulnerability);
|
||||
BYTESWAP(psp->sp_iBlood);
|
||||
BYTESWAP(psp->sp_bGibs);
|
||||
BYTESWAP(psp->sp_bEndOfGame);
|
||||
BYTESWAP(psp->sp_ulLevelsMask);
|
||||
BYTESWAP(psp->sp_bUseExtraEnemies);
|
||||
|
||||
// read world and its state
|
||||
ReadWorldAndState_t(pstr);
|
||||
@ -1764,7 +1805,48 @@ void CSessionState::Write_t(CTStream *pstr) // throw char *
|
||||
(*pstr)<<ses_fRealTimeFactor;
|
||||
// write session properties to stream
|
||||
(*pstr)<<_pNetwork->ga_strSessionName;
|
||||
pstr->Write_t(_pNetwork->ga_aubProperties, NET_MAXSESSIONPROPERTIES);
|
||||
CUniversalSessionProperties sp;
|
||||
memcpy(&sp, _pNetwork->ga_aubProperties, NET_MAXSESSIONPROPERTIES);
|
||||
BYTESWAP(sp.usp_sp.sp_ctMaxPlayers);
|
||||
BYTESWAP(sp.usp_sp.sp_bWaitAllPlayers);
|
||||
BYTESWAP(sp.usp_sp.sp_bQuickTest);
|
||||
BYTESWAP(sp.usp_sp.sp_bCooperative);
|
||||
BYTESWAP(sp.usp_sp.sp_bSinglePlayer);
|
||||
BYTESWAP(sp.usp_sp.sp_bUseFrags);
|
||||
BYTESWAP((INDEX&)sp.usp_sp.sp_gmGameMode);
|
||||
BYTESWAP((INDEX&)sp.usp_sp.sp_gdGameDifficulty);
|
||||
BYTESWAP(sp.usp_sp.sp_ulSpawnFlags);
|
||||
BYTESWAP(sp.usp_sp.sp_bMental);
|
||||
BYTESWAP(sp.usp_sp.sp_iScoreLimit);
|
||||
BYTESWAP(sp.usp_sp.sp_iFragLimit);
|
||||
BYTESWAP(sp.usp_sp.sp_iTimeLimit);
|
||||
BYTESWAP(sp.usp_sp.sp_bTeamPlay);
|
||||
BYTESWAP(sp.usp_sp.sp_bFriendlyFire);
|
||||
BYTESWAP(sp.usp_sp.sp_bWeaponsStay);
|
||||
BYTESWAP(sp.usp_sp.sp_bAmmoStays);
|
||||
BYTESWAP(sp.usp_sp.sp_bHealthArmorStays);
|
||||
BYTESWAP(sp.usp_sp.sp_bPlayEntireGame);
|
||||
BYTESWAP(sp.usp_sp.sp_bAllowHealth);
|
||||
BYTESWAP(sp.usp_sp.sp_bAllowArmor);
|
||||
BYTESWAP(sp.usp_sp.sp_bInfiniteAmmo);
|
||||
BYTESWAP(sp.usp_sp.sp_bRespawnInPlace);
|
||||
BYTESWAP(sp.usp_sp.sp_fEnemyMovementSpeed);
|
||||
BYTESWAP(sp.usp_sp.sp_fEnemyAttackSpeed);
|
||||
BYTESWAP(sp.usp_sp.sp_fDamageStrength);
|
||||
BYTESWAP(sp.usp_sp.sp_fAmmoQuantity);
|
||||
BYTESWAP(sp.usp_sp.sp_fManaTransferFactor);
|
||||
BYTESWAP(sp.usp_sp.sp_iInitialMana);
|
||||
BYTESWAP(sp.usp_sp.sp_fExtraEnemyStrength);
|
||||
BYTESWAP(sp.usp_sp.sp_fExtraEnemyStrengthPerPlayer);
|
||||
BYTESWAP(sp.usp_sp.sp_ctCredits);
|
||||
BYTESWAP(sp.usp_sp.sp_ctCreditsLeft);
|
||||
BYTESWAP(sp.usp_sp.sp_tmSpawnInvulnerability);
|
||||
BYTESWAP(sp.usp_sp.sp_iBlood);
|
||||
BYTESWAP(sp.usp_sp.sp_bGibs);
|
||||
BYTESWAP(sp.usp_sp.sp_bEndOfGame);
|
||||
BYTESWAP(sp.usp_sp.sp_ulLevelsMask);
|
||||
BYTESWAP(sp.usp_sp.sp_bUseExtraEnemies);
|
||||
pstr->Write_t(&sp, NET_MAXSESSIONPROPERTIES);
|
||||
|
||||
// write world and its state
|
||||
WriteWorldAndState_t(pstr);
|
||||
@ -2003,10 +2085,12 @@ void CSessionState::SessionStateLoop(void)
|
||||
CPlayerTarget &plt = ses_apltPlayers[i];
|
||||
BOOL bHas = 0;
|
||||
nmMessage.ReadBits(&bHas, 1);
|
||||
BYTESWAP(bHas);
|
||||
if (bHas) {
|
||||
if (plt.IsActive() && plt.plt_penPlayerEntity!=NULL) {
|
||||
INDEX iPing = 0;
|
||||
nmMessage.ReadBits(&iPing, 10);
|
||||
BYTESWAP(iPing);
|
||||
plt.plt_penPlayerEntity->en_tmPing = iPing/1000.0f;
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,10 @@ void CAnimSet::Write_t(CTStream *ostrFile)
|
||||
// write bone envelope ID
|
||||
(*ostrFile)<<pstrNameID;
|
||||
// write default pos(matrix12)
|
||||
ostrFile->Write_t(&be.be_mDefaultPos[0],sizeof(FLOAT)*12);
|
||||
for(int i = 0; i < 12; i++)
|
||||
{
|
||||
(*ostrFile)<<be.be_mDefaultPos[i];
|
||||
}
|
||||
// count positions
|
||||
INDEX ctp = be.be_apPos.Count();
|
||||
// write position count
|
||||
@ -405,7 +408,7 @@ void CAnimSet::Write_t(CTStream *ostrFile)
|
||||
for(INDEX ip=0;ip<ctp;ip++)
|
||||
{
|
||||
// write position
|
||||
ostrFile->Write_t(&be.be_apPos[ip],sizeof(AnimPos));
|
||||
(*ostrFile)<<be.be_apPos[ip];
|
||||
}
|
||||
// count rotations
|
||||
INDEX ctRotations = be.be_arRot.Count();
|
||||
@ -415,7 +418,7 @@ void CAnimSet::Write_t(CTStream *ostrFile)
|
||||
{
|
||||
// write rotation
|
||||
AnimRot &arRot = be.be_arRot[ir];
|
||||
ostrFile->Write_t(&arRot,sizeof(AnimRot));
|
||||
(*ostrFile)<<arRot;
|
||||
}
|
||||
INDEX ctOptRotations = be.be_arRotOpt.Count();
|
||||
if(ctOptRotations>0)
|
||||
@ -439,7 +442,10 @@ void CAnimSet::Write_t(CTStream *ostrFile)
|
||||
// write morph factors count
|
||||
INDEX ctmf = me.me_aFactors.Count();
|
||||
(*ostrFile)<<ctmf;
|
||||
ostrFile->Write_t(&me.me_aFactors[0],sizeof(FLOAT)*ctmf);
|
||||
for(int i = 0; i < ctmf; i++)
|
||||
{
|
||||
(*ostrFile)<<me.me_aFactors[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -546,9 +546,9 @@ void CMesh::Write_t(CTStream *ostrFile)
|
||||
// write wertex count
|
||||
(*ostrFile)<<ctVx;
|
||||
// write wertices
|
||||
ostrFile->Write_t(&mLod.mlod_aVertices[0],sizeof(MeshVertex)*ctVx);
|
||||
for (int i = 0; i < ctVx; i++) (*ostrFile)<<(MeshVertex)mLod.mlod_aVertices[i];
|
||||
// write normals
|
||||
ostrFile->Write_t(&mLod.mlod_aNormals[0],sizeof(MeshNormal)*ctVx);
|
||||
for (int i = 0; i < ctVx; i++) (*ostrFile)<<(MeshNormal)mLod.mlod_aNormals[i];
|
||||
|
||||
// write uvmaps count
|
||||
(*ostrFile)<<ctUV;
|
||||
@ -558,11 +558,11 @@ void CMesh::Write_t(CTStream *ostrFile)
|
||||
CTString strNameID = ska_GetStringFromTable(mLod.mlod_aUVMaps[iuv].muv_iID);
|
||||
(*ostrFile)<<strNameID;
|
||||
// write uvmaps texcordinates
|
||||
ostrFile->Write_t(&mLod.mlod_aUVMaps[iuv].muv_aTexCoords[0],sizeof(MeshTexCoord)*ctVx);
|
||||
for (int i = 0; i < ctVx; i++) (*ostrFile)<<(MeshTexCoord)mLod.mlod_aUVMaps[iuv].muv_aTexCoords[i];
|
||||
}
|
||||
|
||||
// write surfaces count
|
||||
ostrFile->Write_t(&ctSf,sizeof(INDEX));
|
||||
(*ostrFile)<<ctSf;
|
||||
// write surfaces
|
||||
for(INDEX isf=0;isf<ctSf;isf++) {
|
||||
MeshSurface &msrf = mLod.mlod_aSurfaces[isf];
|
||||
@ -577,7 +577,7 @@ void CMesh::Write_t(CTStream *ostrFile)
|
||||
// write tris count
|
||||
(*ostrFile)<<ctTris;
|
||||
// write triangles
|
||||
ostrFile->Write_t(&mLod.mlod_aSurfaces[isf].msrf_aTriangles[0],sizeof(MeshTriangle)*ctTris);
|
||||
for (int i = 0; i < ctTris; i++) (*ostrFile)<<(MeshTriangle)mLod.mlod_aSurfaces[isf].msrf_aTriangles[i];
|
||||
|
||||
// write bool that this surface has a shader
|
||||
INDEX bShaderExists = (msrf.msrf_pShader!=NULL);
|
||||
@ -652,7 +652,7 @@ void CMesh::Write_t(CTStream *ostrFile)
|
||||
// write wertex weights count
|
||||
(*ostrFile)<<ctWw;
|
||||
// write wertex weights
|
||||
ostrFile->Write_t(&mLod.mlod_aWeightMaps[iwm].mwm_aVertexWeight[0],sizeof(MeshVertexWeight)*ctWw);
|
||||
for (int i = 0; i < ctWw; i++) (*ostrFile)<<(MeshVertexWeight)mLod.mlod_aWeightMaps[ctWw].mwm_aVertexWeight[i];
|
||||
}
|
||||
|
||||
// write morphmaps count
|
||||
@ -667,9 +667,9 @@ void CMesh::Write_t(CTStream *ostrFile)
|
||||
(*ostrFile)<<mLod.mlod_aMorphMaps[imm].mmp_bRelative;
|
||||
//ostrFile->Write_t(&mLod.mlod_aMorphMaps[imm].mmp_bRelative,sizeof(BOOL));
|
||||
// write morph sets count
|
||||
ostrFile->Write_t(&ctms,sizeof(INDEX));
|
||||
(*ostrFile)<<ctms;
|
||||
// write morph sets
|
||||
ostrFile->Write_t(&mLod.mlod_aMorphMaps[imm].mmp_aMorphMap[0],sizeof(MeshVertexMorph)*ctms);
|
||||
for (int i = 0; i < ctms; i++) (*ostrFile)<<mLod.mlod_aMorphMaps[imm].mmp_aMorphMap[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static inline CTStream &operator>>(CTStream &strm, MeshVertex &mv)
|
||||
return(strm);
|
||||
}
|
||||
|
||||
static inline CTStream &operator>>(CTStream &strm, const MeshVertex &mv)
|
||||
static inline CTStream &operator<<(CTStream &strm, const MeshVertex &mv)
|
||||
{
|
||||
strm<<mv.x;
|
||||
strm<<mv.y;
|
||||
@ -70,7 +70,7 @@ static inline CTStream &operator>>(CTStream &strm, MeshNormal &mn)
|
||||
return(strm);
|
||||
}
|
||||
|
||||
static inline CTStream &operator>>(CTStream &strm, const MeshNormal &mn)
|
||||
static inline CTStream &operator<<(CTStream &strm, const MeshNormal &mn)
|
||||
{
|
||||
strm<<mn.nx;
|
||||
strm<<mn.ny;
|
||||
@ -193,7 +193,7 @@ static inline CTStream &operator>>(CTStream &strm, MeshVertexMorph &mwm)
|
||||
return(strm);
|
||||
}
|
||||
|
||||
static inline CTStream &operator>>(CTStream &strm, const MeshVertexMorph &mwm)
|
||||
static inline CTStream &operator<<(CTStream &strm, const MeshVertexMorph &mwm)
|
||||
{
|
||||
strm<<mwm.mwm_iVxIndex;
|
||||
strm<<mwm.mwm_x;
|
||||
|
@ -192,9 +192,9 @@ void CSkeleton::Write_t(CTStream *ostrFile)
|
||||
(*ostrFile)<<strParentID;
|
||||
//(*ostrFile)<<slod.slod_aBones[ib].sb_iParentIndex;
|
||||
// write AbsPlacement matrix
|
||||
ostrFile->Write_t(&sb.sb_mAbsPlacement,sizeof(FLOAT)*12);
|
||||
for (int i = 0; i < 12; i++) (*ostrFile)<<sb.sb_mAbsPlacement[i];
|
||||
// write RelPlacement Qvect stuct
|
||||
ostrFile->Write_t(&sb.sb_qvRelPlacement,sizeof(QVect));
|
||||
(*ostrFile)<<sb.sb_qvRelPlacement;
|
||||
// write offset len
|
||||
(*ostrFile)<<sb.sb_fOffSetLen;
|
||||
// write bone length
|
||||
|
@ -583,7 +583,7 @@ INDEX CSoundDecoder::Decode(void *pvDestBuffer, INDEX ctBytesToDecode)
|
||||
long iRes = pov_read(sdc_pogg->ogg_vfVorbisFile, pch, ctBytesToDecode-ctDecoded, &iCurrrentSection);
|
||||
#else
|
||||
long iRes = pov_read(sdc_pogg->ogg_vfVorbisFile, pch, ctBytesToDecode-ctDecoded,
|
||||
0, 2, 1, &iCurrrentSection);
|
||||
PLATFORM_BIGENDIAN, 2, 1, &iCurrrentSection);
|
||||
#endif
|
||||
if (iRes<=0) {
|
||||
return ctDecoded;
|
||||
|
@ -219,9 +219,9 @@ static BOOL StartUp_SDLaudio( CSoundLibrary &sl, BOOL bReport=TRUE)
|
||||
if (bps <= 8)
|
||||
desired.format = AUDIO_U8;
|
||||
else if (bps <= 16)
|
||||
desired.format = AUDIO_S16LSB;
|
||||
desired.format = AUDIO_S16SYS;
|
||||
else if (bps <= 32)
|
||||
desired.format = AUDIO_S32LSB;
|
||||
desired.format = AUDIO_S32SYS;
|
||||
else {
|
||||
CPrintF(TRANSV("Unsupported bits-per-sample: %d\n"), bps);
|
||||
return FALSE;
|
||||
|
@ -1972,10 +1972,12 @@ void CTerrain::Write_t( CTStream *ostrFile)
|
||||
INDEX iShadingMapSize = GetShadingMapWidth() * GetShadingMapHeight() * sizeof(UWORD);
|
||||
// Write shadow map
|
||||
ASSERT(tr_tdShadowMap.td_pulFrames!=NULL);
|
||||
ostrFile->Write_t(&tr_tdShadowMap.td_pulFrames[0],iShadowMapSize);
|
||||
for (INDEX i = 0; i < iShadowMapSize; i++)
|
||||
(*ostrFile)<<tr_tdShadowMap.td_pulFrames[i];
|
||||
// Write shading map
|
||||
ASSERT(tr_auwShadingMap!=NULL);
|
||||
ostrFile->Write_t(&tr_auwShadingMap[0],iShadingMapSize);
|
||||
for (INDEX i = 0; i < iShadingMapSize; i++)
|
||||
(*ostrFile)<<tr_auwShadingMap[i];
|
||||
|
||||
ostrFile->WriteID_t("TSEN"); // 'Terrain shadowmap end'
|
||||
|
||||
@ -1989,7 +1991,7 @@ void CTerrain::Write_t( CTStream *ostrFile)
|
||||
|
||||
(*ostrFile).WriteID_t("TRHM"); // 'Terrain heightmap'
|
||||
// write height map
|
||||
(*ostrFile).Write_t(&tr_auwHeightMap[0],sizeof(UWORD)*tr_pixHeightMapWidth*tr_pixHeightMapHeight);
|
||||
for (int i = 0; i < (tr_pixHeightMapWidth * tr_pixHeightMapHeight); i++) (*ostrFile)<<tr_auwHeightMap[i];
|
||||
(*ostrFile).WriteID_t("THEN"); // 'Terrain heightmap end'
|
||||
|
||||
(*ostrFile).WriteID_t("TRLR"); // 'Terrain layers'
|
||||
|
@ -95,6 +95,26 @@ struct DECL_DLL PlayerStats {
|
||||
PlayerStats(void): ps_iScore(0), ps_iKills(0), ps_iDeaths(0), ps_iSecrets(0), ps_tmTime(0.0f){}
|
||||
};
|
||||
|
||||
static inline CTStream &operator>>(CTStream &strm, PlayerStats &ps)
|
||||
{
|
||||
strm>>ps.ps_iScore;
|
||||
strm>>ps.ps_iKills;
|
||||
strm>>ps.ps_iDeaths;
|
||||
strm>>ps.ps_iSecrets;
|
||||
strm>>ps.ps_tmTime;
|
||||
return strm;
|
||||
}
|
||||
|
||||
static inline CTStream &operator<<(CTStream &strm, const PlayerStats &ps)
|
||||
{
|
||||
strm<<ps.ps_iScore;
|
||||
strm<<ps.ps_iKills;
|
||||
strm<<ps.ps_iDeaths;
|
||||
strm<<ps.ps_iSecrets;
|
||||
strm<<ps.ps_tmTime;
|
||||
return strm;
|
||||
}
|
||||
|
||||
// get info position for entity
|
||||
DECL_DLL void GetEntityInfoPosition(CEntity *pen, FLOAT *pf, FLOAT3D &vPos);
|
||||
// get source and target positions for ray cast
|
||||
|
@ -1280,10 +1280,10 @@ functions:
|
||||
for(INDEX iMsg=0; iMsg<ctMsg; iMsg++) {
|
||||
m_acmiMessages[iMsg].Write_t(*ostr);
|
||||
}
|
||||
ostr->Write_t(&m_psLevelStats, sizeof(m_psLevelStats));
|
||||
ostr->Write_t(&m_psLevelTotal, sizeof(m_psLevelTotal));
|
||||
ostr->Write_t(&m_psGameStats , sizeof(m_psGameStats ));
|
||||
ostr->Write_t(&m_psGameTotal , sizeof(m_psGameTotal ));
|
||||
(*ostr)<<m_psLevelStats;
|
||||
(*ostr)<<m_psLevelTotal;
|
||||
(*ostr)<<m_psGameStats;
|
||||
(*ostr)<<m_psGameTotal;
|
||||
}
|
||||
/* Read from stream. */
|
||||
void Read_t( CTStream *istr) // throw char *
|
||||
@ -1307,10 +1307,10 @@ functions:
|
||||
}
|
||||
}
|
||||
|
||||
istr->Read_t(&m_psLevelStats, sizeof(m_psLevelStats));
|
||||
istr->Read_t(&m_psLevelTotal, sizeof(m_psLevelTotal));
|
||||
istr->Read_t(&m_psGameStats , sizeof(m_psGameStats ));
|
||||
istr->Read_t(&m_psGameTotal , sizeof(m_psGameTotal ));
|
||||
(*istr)>>m_psLevelStats;
|
||||
(*istr)>>m_psLevelTotal;
|
||||
(*istr)>>m_psGameStats;
|
||||
(*istr)>>m_psGameTotal;
|
||||
|
||||
// set your real appearance if possible
|
||||
ValidateCharacter();
|
||||
|
@ -1530,10 +1530,10 @@ functions:
|
||||
for(INDEX iMsg=0; iMsg<ctMsg; iMsg++) {
|
||||
m_acmiMessages[iMsg].Write_t(*ostr);
|
||||
}
|
||||
ostr->Write_t(&m_psLevelStats, sizeof(m_psLevelStats));
|
||||
ostr->Write_t(&m_psLevelTotal, sizeof(m_psLevelTotal));
|
||||
ostr->Write_t(&m_psGameStats , sizeof(m_psGameStats ));
|
||||
ostr->Write_t(&m_psGameTotal , sizeof(m_psGameTotal ));
|
||||
(*ostr)<<m_psLevelStats;
|
||||
(*ostr)<<m_psLevelTotal;
|
||||
(*ostr)<<m_psGameStats;
|
||||
(*ostr)<<m_psGameTotal;
|
||||
}
|
||||
/* Read from stream. */
|
||||
void Read_t( CTStream *istr) // throw char *
|
||||
|
Loading…
x
Reference in New Issue
Block a user