spacing (only)
This commit is contained in:
@@ -131,7 +131,7 @@ void Bookkeeper::ReadFromDisk()
|
||||
void Bookkeeper::WriteToDisk()
|
||||
{
|
||||
// Write data. Use SLOW_FLUSH, to help ensure that we don't lose coin data.
|
||||
RageFile f;
|
||||
RageFile f;
|
||||
if( !f.Open(COINS_DAT, RageFile::WRITE|RageFile::SLOW_FLUSH) )
|
||||
{
|
||||
LOG->Warn( "Couldn't open file \"%s\" for writing: %s", COINS_DAT.c_str(), f.GetError().c_str() );
|
||||
@@ -181,7 +181,7 @@ int Bookkeeper::GetCoinsTotal() const
|
||||
void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] ) const
|
||||
{
|
||||
time_t lOldTime = time(NULL);
|
||||
tm time;
|
||||
tm time;
|
||||
localtime_r( &lOldTime, &time );
|
||||
|
||||
time.tm_hour = 0;
|
||||
@@ -197,7 +197,7 @@ void Bookkeeper::GetCoinsLastDays( int coins[NUM_LAST_DAYS] ) const
|
||||
void Bookkeeper::GetCoinsLastWeeks( int coins[NUM_LAST_WEEKS] ) const
|
||||
{
|
||||
time_t lOldTime = time(NULL);
|
||||
tm time;
|
||||
tm time;
|
||||
localtime_r( &lOldTime, &time );
|
||||
|
||||
time = GetNextSunday( time );
|
||||
|
||||
@@ -234,27 +234,27 @@ static RString BinaryToHex( const unsigned char *string, int iNumBytes )
|
||||
|
||||
RString CryptManager::GetMD5( RString fn )
|
||||
{
|
||||
struct MD5Context md5c;
|
||||
unsigned char digest[16];
|
||||
int iBytesRead;
|
||||
unsigned char buffer[1024];
|
||||
struct MD5Context md5c;
|
||||
unsigned char digest[16];
|
||||
int iBytesRead;
|
||||
unsigned char buffer[1024];
|
||||
|
||||
RageFile file;
|
||||
if( !file.Open( fn, RageFile::READ ) )
|
||||
{
|
||||
LOG->Warn( "GetMD5: Failed to open file '%s'", fn.c_str() );
|
||||
return RString();
|
||||
}
|
||||
RageFile file;
|
||||
if( !file.Open( fn, RageFile::READ ) )
|
||||
{
|
||||
LOG->Warn( "GetMD5: Failed to open file '%s'", fn.c_str() );
|
||||
return RString();
|
||||
}
|
||||
|
||||
MD5Init(&md5c);
|
||||
while( !file.AtEOF() && file.GetError().empty() )
|
||||
{
|
||||
iBytesRead = file.Read( buffer, sizeof(buffer) );
|
||||
MD5Update(&md5c, buffer, iBytesRead);
|
||||
}
|
||||
MD5Final(digest, &md5c);
|
||||
MD5Init(&md5c);
|
||||
while( !file.AtEOF() && file.GetError().empty() )
|
||||
{
|
||||
iBytesRead = file.Read( buffer, sizeof(buffer) );
|
||||
MD5Update(&md5c, buffer, iBytesRead);
|
||||
}
|
||||
MD5Final(digest, &md5c);
|
||||
|
||||
return BinaryToHex( digest, sizeof(digest) );
|
||||
return BinaryToHex( digest, sizeof(digest) );
|
||||
}
|
||||
|
||||
RString CryptManager::GetPublicKeyFileName()
|
||||
|
||||
+69
-69
@@ -96,7 +96,7 @@ void Model::LoadPieces( RString sMeshesPath, RString sMaterialsPath, RString sBo
|
||||
|
||||
|
||||
//
|
||||
// Setup temp vertices (if necessary)
|
||||
// Setup temp vertices (if necessary)
|
||||
//
|
||||
if( m_pGeometry->HasAnyPerVertexBones() )
|
||||
{
|
||||
@@ -146,102 +146,102 @@ void Model::LoadMaterialsFromMilkshapeAscii( RString sPath )
|
||||
RString sLine;
|
||||
int iLineNum = 0;
|
||||
|
||||
while( f.GetLine( sLine ) > 0 )
|
||||
{
|
||||
while( f.GetLine( sLine ) > 0 )
|
||||
{
|
||||
iLineNum++;
|
||||
|
||||
if( !strncmp (sLine, "//", 2) )
|
||||
continue;
|
||||
if( !strncmp (sLine, "//", 2) )
|
||||
continue;
|
||||
|
||||
int nFrame;
|
||||
if( sscanf(sLine, "Frames: %d", &nFrame) == 1 )
|
||||
{
|
||||
int nFrame;
|
||||
if( sscanf(sLine, "Frames: %d", &nFrame) == 1 )
|
||||
{
|
||||
// ignore
|
||||
// m_pModel->nTotalFrames = nFrame;
|
||||
}
|
||||
if( sscanf(sLine, "Frame: %d", &nFrame) == 1 )
|
||||
{
|
||||
}
|
||||
if( sscanf(sLine, "Frame: %d", &nFrame) == 1 )
|
||||
{
|
||||
// ignore
|
||||
// m_pModel->nFrame = nFrame;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// materials
|
||||
//
|
||||
int nNumMaterials = 0;
|
||||
if( sscanf(sLine, "Materials: %d", &nNumMaterials) == 1 )
|
||||
{
|
||||
m_Materials.resize( nNumMaterials );
|
||||
|
||||
char szName[256];
|
||||
//
|
||||
// materials
|
||||
//
|
||||
int nNumMaterials = 0;
|
||||
if( sscanf(sLine, "Materials: %d", &nNumMaterials) == 1 )
|
||||
{
|
||||
m_Materials.resize( nNumMaterials );
|
||||
|
||||
for( int i = 0; i < nNumMaterials; i++ )
|
||||
{
|
||||
char szName[256];
|
||||
|
||||
for( int i = 0; i < nNumMaterials; i++ )
|
||||
{
|
||||
msMaterial& Material = m_Materials[i];
|
||||
|
||||
// name
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// name
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
if( sscanf(sLine, "\"%[^\"]\"", szName) != 1 )
|
||||
if( sscanf(sLine, "\"%[^\"]\"", szName) != 1 )
|
||||
THROW;
|
||||
Material.sName = szName;
|
||||
Material.sName = szName;
|
||||
|
||||
// ambient
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// ambient
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
RageVector4 Ambient;
|
||||
if( sscanf(sLine, "%f %f %f %f", &Ambient[0], &Ambient[1], &Ambient[2], &Ambient[3]) != 4 )
|
||||
RageVector4 Ambient;
|
||||
if( sscanf(sLine, "%f %f %f %f", &Ambient[0], &Ambient[1], &Ambient[2], &Ambient[3]) != 4 )
|
||||
THROW;
|
||||
memcpy( &Material.Ambient, &Ambient, sizeof(Material.Ambient) );
|
||||
memcpy( &Material.Ambient, &Ambient, sizeof(Material.Ambient) );
|
||||
|
||||
// diffuse
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// diffuse
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
RageVector4 Diffuse;
|
||||
if( sscanf(sLine, "%f %f %f %f", &Diffuse[0], &Diffuse[1], &Diffuse[2], &Diffuse[3]) != 4 )
|
||||
RageVector4 Diffuse;
|
||||
if( sscanf(sLine, "%f %f %f %f", &Diffuse[0], &Diffuse[1], &Diffuse[2], &Diffuse[3]) != 4 )
|
||||
THROW;
|
||||
memcpy( &Material.Diffuse, &Diffuse, sizeof(Material.Diffuse) );
|
||||
memcpy( &Material.Diffuse, &Diffuse, sizeof(Material.Diffuse) );
|
||||
|
||||
// specular
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// specular
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
RageVector4 Specular;
|
||||
if( sscanf(sLine, "%f %f %f %f", &Specular[0], &Specular[1], &Specular[2], &Specular[3]) != 4 )
|
||||
RageVector4 Specular;
|
||||
if( sscanf(sLine, "%f %f %f %f", &Specular[0], &Specular[1], &Specular[2], &Specular[3]) != 4 )
|
||||
THROW;
|
||||
memcpy( &Material.Specular, &Specular, sizeof(Material.Specular) );
|
||||
memcpy( &Material.Specular, &Specular, sizeof(Material.Specular) );
|
||||
|
||||
// emissive
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// emissive
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
RageVector4 Emissive;
|
||||
if( sscanf (sLine, "%f %f %f %f", &Emissive[0], &Emissive[1], &Emissive[2], &Emissive[3]) != 4 )
|
||||
RageVector4 Emissive;
|
||||
if( sscanf (sLine, "%f %f %f %f", &Emissive[0], &Emissive[1], &Emissive[2], &Emissive[3]) != 4 )
|
||||
THROW;
|
||||
memcpy( &Material.Emissive, &Emissive, sizeof(Material.Emissive) );
|
||||
memcpy( &Material.Emissive, &Emissive, sizeof(Material.Emissive) );
|
||||
|
||||
// shininess
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// shininess
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
char *p;
|
||||
float fShininess = strtof( sLine, &p );
|
||||
if( p == sLine )
|
||||
float fShininess = strtof( sLine, &p );
|
||||
if( p == sLine )
|
||||
THROW;
|
||||
Material.fShininess = fShininess;
|
||||
Material.fShininess = fShininess;
|
||||
|
||||
// transparency
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// transparency
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
float fTransparency = strtof( sLine, &p );
|
||||
if( p == sLine )
|
||||
float fTransparency = strtof( sLine, &p );
|
||||
if( p == sLine )
|
||||
THROW;
|
||||
Material.fTransparency = fTransparency;
|
||||
Material.fTransparency = fTransparency;
|
||||
|
||||
// diffuse texture
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// diffuse texture
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
strcpy( szName, "" );
|
||||
sscanf( sLine, "\"%[^\"]\"", szName );
|
||||
RString sDiffuseTexture = szName;
|
||||
strcpy( szName, "" );
|
||||
sscanf( sLine, "\"%[^\"]\"", szName );
|
||||
RString sDiffuseTexture = szName;
|
||||
|
||||
if( sDiffuseTexture != "" )
|
||||
{
|
||||
@@ -257,11 +257,11 @@ void Model::LoadMaterialsFromMilkshapeAscii( RString sPath )
|
||||
}
|
||||
}
|
||||
|
||||
// alpha texture
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
// alpha texture
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
strcpy( szName, "" );
|
||||
sscanf( sLine, "\"%[^\"]\"", szName );
|
||||
strcpy( szName, "" );
|
||||
sscanf( sLine, "\"%[^\"]\"", szName );
|
||||
RString sAlphaTexture = szName;
|
||||
|
||||
if( sAlphaTexture != "" )
|
||||
@@ -277,9 +277,9 @@ void Model::LoadMaterialsFromMilkshapeAscii( RString sPath )
|
||||
RageException::Throw( sError );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f.Close();
|
||||
}
|
||||
|
||||
@@ -229,111 +229,111 @@ bool msAnimation::LoadMilkshapeAsciiBones( RString sAniName, RString sPath )
|
||||
msAnimation &Animation = *this;
|
||||
|
||||
bool bLoaded = false;
|
||||
while( f.GetLine( sLine ) > 0 )
|
||||
{
|
||||
while( f.GetLine( sLine ) > 0 )
|
||||
{
|
||||
iLineNum++;
|
||||
|
||||
if (!strncmp (sLine, "//", 2))
|
||||
continue;
|
||||
|
||||
//
|
||||
// bones
|
||||
//
|
||||
int nNumBones = 0;
|
||||
if( sscanf (sLine, "Bones: %d", &nNumBones) != 1 )
|
||||
if (!strncmp (sLine, "//", 2))
|
||||
continue;
|
||||
|
||||
char szName[MS_MAX_NAME];
|
||||
//
|
||||
// bones
|
||||
//
|
||||
int nNumBones = 0;
|
||||
if( sscanf (sLine, "Bones: %d", &nNumBones) != 1 )
|
||||
continue;
|
||||
|
||||
Animation.Bones.resize( nNumBones );
|
||||
char szName[MS_MAX_NAME];
|
||||
|
||||
for( int i = 0; i < nNumBones; i++ )
|
||||
{
|
||||
Animation.Bones.resize( nNumBones );
|
||||
|
||||
for( int i = 0; i < nNumBones; i++ )
|
||||
{
|
||||
msBone& Bone = Animation.Bones[i];
|
||||
|
||||
// name
|
||||
// name
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
if (sscanf (sLine, "\"%[^\"]\"", szName) != 1)
|
||||
if (sscanf (sLine, "\"%[^\"]\"", szName) != 1)
|
||||
THROW;
|
||||
Bone.sName = szName;
|
||||
Bone.sName = szName;
|
||||
|
||||
// parent
|
||||
// parent
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
strcpy (szName, "");
|
||||
sscanf (sLine, "\"%[^\"]\"", szName);
|
||||
strcpy (szName, "");
|
||||
sscanf (sLine, "\"%[^\"]\"", szName);
|
||||
|
||||
Bone.sParentName = szName;
|
||||
Bone.sParentName = szName;
|
||||
|
||||
// flags, position, rotation
|
||||
RageVector3 Position, Rotation;
|
||||
// flags, position, rotation
|
||||
RageVector3 Position, Rotation;
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
|
||||
int nFlags;
|
||||
if (sscanf (sLine, "%d %f %f %f %f %f %f",
|
||||
&nFlags,
|
||||
&Position[0], &Position[1], &Position[2],
|
||||
&Rotation[0], &Rotation[1], &Rotation[2]) != 7)
|
||||
{
|
||||
if (sscanf (sLine, "%d %f %f %f %f %f %f",
|
||||
&nFlags,
|
||||
&Position[0], &Position[1], &Position[2],
|
||||
&Rotation[0], &Rotation[1], &Rotation[2]) != 7)
|
||||
{
|
||||
THROW;
|
||||
}
|
||||
}
|
||||
Rotation = RadianToDegree(Rotation);
|
||||
|
||||
Bone.nFlags = nFlags;
|
||||
memcpy( &Bone.Position, &Position, sizeof(Bone.Position) );
|
||||
memcpy( &Bone.Rotation, &Rotation, sizeof(Bone.Rotation) );
|
||||
memcpy( &Bone.Position, &Position, sizeof(Bone.Position) );
|
||||
memcpy( &Bone.Rotation, &Rotation, sizeof(Bone.Rotation) );
|
||||
|
||||
// position key count
|
||||
// position key count
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
int nNumPositionKeys = 0;
|
||||
if (sscanf (sLine, "%d", &nNumPositionKeys) != 1)
|
||||
int nNumPositionKeys = 0;
|
||||
if (sscanf (sLine, "%d", &nNumPositionKeys) != 1)
|
||||
THROW;
|
||||
|
||||
Bone.PositionKeys.resize( nNumPositionKeys );
|
||||
Bone.PositionKeys.resize( nNumPositionKeys );
|
||||
|
||||
for( int j = 0; j < nNumPositionKeys; ++j )
|
||||
{
|
||||
for( int j = 0; j < nNumPositionKeys; ++j )
|
||||
{
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
|
||||
float fTime;
|
||||
if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
|
||||
if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4)
|
||||
THROW;
|
||||
|
||||
msPositionKey key;
|
||||
key.fTime = fTime;
|
||||
key.Position = RageVector3( Position[0], Position[1], Position[2] );
|
||||
Bone.PositionKeys[j] = key;
|
||||
}
|
||||
}
|
||||
|
||||
// rotation key count
|
||||
// rotation key count
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
int nNumRotationKeys = 0;
|
||||
if (sscanf (sLine, "%d", &nNumRotationKeys) != 1)
|
||||
int nNumRotationKeys = 0;
|
||||
if (sscanf (sLine, "%d", &nNumRotationKeys) != 1)
|
||||
THROW;
|
||||
|
||||
Bone.RotationKeys.resize( nNumRotationKeys );
|
||||
Bone.RotationKeys.resize( nNumRotationKeys );
|
||||
|
||||
for( int j = 0; j < nNumRotationKeys; ++j )
|
||||
{
|
||||
for( int j = 0; j < nNumRotationKeys; ++j )
|
||||
{
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
|
||||
float fTime;
|
||||
if (sscanf (sLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4)
|
||||
if (sscanf (sLine, "%f %f %f %f", &fTime, &Rotation[0], &Rotation[1], &Rotation[2]) != 4)
|
||||
THROW;
|
||||
Rotation = RadianToDegree(Rotation);
|
||||
|
||||
msRotationKey key;
|
||||
key.fTime = fTime;
|
||||
key.Rotation = RageVector3( Rotation[0], Rotation[1], Rotation[2] );
|
||||
Bone.RotationKeys[j] = key;
|
||||
}
|
||||
}
|
||||
Bone.RotationKeys[j] = key;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore "Frames:" in file. Calculate it ourself
|
||||
Animation.nTotalFrames = 0;
|
||||
|
||||
@@ -181,60 +181,62 @@ static void mad_timer_sub(mad_timer_t *a, mad_timer_t b)
|
||||
/* internal->decoder_private field */
|
||||
struct madlib_t
|
||||
{
|
||||
uint8_t inbuf[16384], outbuf[8192];
|
||||
int outpos;
|
||||
uint8_t inbuf[16384], outbuf[8192];
|
||||
int outpos;
|
||||
unsigned outleft;
|
||||
|
||||
struct mad_stream Stream;
|
||||
struct mad_frame Frame;
|
||||
struct mad_synth Synth;
|
||||
/* Timestamp of the next frame. */
|
||||
mad_timer_t Timer;
|
||||
struct mad_stream Stream;
|
||||
struct mad_frame Frame;
|
||||
struct mad_synth Synth;
|
||||
/* Timestamp of the next frame. */
|
||||
mad_timer_t Timer;
|
||||
|
||||
/* Whether Timer is trusted; this is false after doing a quick seek. */
|
||||
int timer_accurate;
|
||||
/* Whether Timer is trusted; this is false after doing a quick seek. */
|
||||
int timer_accurate;
|
||||
|
||||
/* Frame index of each percentage of the file. This is like the
|
||||
* Xing TOC, except it's actual byte indices, not percentages, so
|
||||
* it's accurate enough for "precise" seeking. -1 indicates we don't
|
||||
* yet know; we always fill this in from beginning to end, so if n
|
||||
* is not -1, 0..n-1 are also not -1.
|
||||
*
|
||||
* If we're VBR and have no Xing tag, we don't know the exact length
|
||||
* ahead of time, so we might end up going past the length we thought
|
||||
* the file was. We don't want to change length after we've set it
|
||||
* (that would change all of the toc entries), so allow the TOC to
|
||||
* go up to 200%. (Beyond that, we'll always hard seek; perhaps this
|
||||
* should be larger?) */
|
||||
int toc[200];
|
||||
/*
|
||||
* Frame index of each percentage of the file. This is like the
|
||||
* Xing TOC, except it's actual byte indices, not percentages, so
|
||||
* it's accurate enough for "precise" seeking. -1 indicates we don't
|
||||
* yet know; we always fill this in from beginning to end, so if n
|
||||
* is not -1, 0..n-1 are also not -1.
|
||||
*
|
||||
* If we're VBR and have no Xing tag, we don't know the exact length
|
||||
* ahead of time, so we might end up going past the length we thought
|
||||
* the file was. We don't want to change length after we've set it
|
||||
* (that would change all of the toc entries), so allow the TOC to
|
||||
* go up to 200%. (Beyond that, we'll always hard seek; perhaps this
|
||||
* should be larger?)
|
||||
*/
|
||||
int toc[200];
|
||||
|
||||
/* Position in the file of inbuf: */
|
||||
int inbuf_filepos;
|
||||
/* Position in the file of inbuf: */
|
||||
int inbuf_filepos;
|
||||
|
||||
/* File size. */
|
||||
int filesize;
|
||||
/* File size. */
|
||||
int filesize;
|
||||
|
||||
/* Number of bytes of header data at the beginning; used for seeking. */
|
||||
int header_bytes;
|
||||
/* Number of bytes of header data at the beginning; used for seeking. */
|
||||
int header_bytes;
|
||||
|
||||
/* Whether we've decoded the first frame of real audio yet. If this
|
||||
* is false, we're somewhere before the first frame; we might be in
|
||||
* the middle of headers. */
|
||||
int first_frame;
|
||||
|
||||
/* This data is filled in when the first frame is decoded. */
|
||||
int has_xing; /* whether xingtag is valid */
|
||||
struct xing xingtag;
|
||||
/* This data is filled in when the first frame is decoded. */
|
||||
int has_xing; /* whether xingtag is valid */
|
||||
struct xing xingtag;
|
||||
|
||||
/* If has_xing is true, this is filled in based on the xing header.
|
||||
* If it's false, this is filled in based on the size of the file
|
||||
* and the first frame. */
|
||||
int length;
|
||||
mad_timer_t framelength;
|
||||
/* If has_xing is true, this is filled in based on the xing header.
|
||||
* If it's false, this is filled in based on the size of the file
|
||||
* and the first frame. */
|
||||
int length;
|
||||
mad_timer_t framelength;
|
||||
|
||||
/* If we have a Xing tag, this is the average bitrate; otherwise it's
|
||||
* the bitrate of the first frame. */
|
||||
int bitrate;
|
||||
/* If we have a Xing tag, this is the average bitrate; otherwise it's
|
||||
* the bitrate of the first frame. */
|
||||
int bitrate;
|
||||
};
|
||||
|
||||
|
||||
@@ -246,28 +248,28 @@ struct madlib_t
|
||||
|
||||
static signed int scale(mad_fixed_t sample)
|
||||
{
|
||||
/* round */
|
||||
sample += (1L << (MAD_F_FRACBITS - 16));
|
||||
/* round */
|
||||
sample += (1L << (MAD_F_FRACBITS - 16));
|
||||
|
||||
/* clip */
|
||||
if (sample >= MAD_F_ONE)
|
||||
sample = MAD_F_ONE - 1;
|
||||
else if (sample < -MAD_F_ONE)
|
||||
sample = -MAD_F_ONE;
|
||||
/* clip */
|
||||
if (sample >= MAD_F_ONE)
|
||||
sample = MAD_F_ONE - 1;
|
||||
else if (sample < -MAD_F_ONE)
|
||||
sample = -MAD_F_ONE;
|
||||
|
||||
/* quantize */
|
||||
return sample >> (MAD_F_FRACBITS + 1 - 16);
|
||||
/* quantize */
|
||||
return sample >> (MAD_F_FRACBITS + 1 - 16);
|
||||
}
|
||||
|
||||
static int get_this_frame_byte( const madlib_t *mad )
|
||||
{
|
||||
int ret = mad->inbuf_filepos;
|
||||
int ret = mad->inbuf_filepos;
|
||||
|
||||
/* If we have a frame, adjust. */
|
||||
if( mad->Stream.this_frame != NULL )
|
||||
/* If we have a frame, adjust. */
|
||||
if( mad->Stream.this_frame != NULL )
|
||||
ret += mad->Stream.this_frame-mad->inbuf;
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -617,9 +619,9 @@ RageSoundReader_MP3::RageSoundReader_MP3()
|
||||
|
||||
RageSoundReader_MP3::~RageSoundReader_MP3()
|
||||
{
|
||||
mad_synth_finish( &mad->Synth );
|
||||
mad_frame_finish( &mad->Frame );
|
||||
mad_stream_finish( &mad->Stream );
|
||||
mad_synth_finish( &mad->Synth );
|
||||
mad_frame_finish( &mad->Frame );
|
||||
mad_stream_finish( &mad->Stream );
|
||||
|
||||
delete mad;
|
||||
}
|
||||
@@ -662,8 +664,8 @@ SoundReader_FileReader::OpenResult RageSoundReader_MP3::Open( RString filename_
|
||||
* the stream. */
|
||||
synth_output();
|
||||
|
||||
if(mad->length == -1)
|
||||
{
|
||||
if(mad->length == -1)
|
||||
{
|
||||
/* If vbr and !xing, this is just an estimate. */
|
||||
int bps = mad->bitrate / 8;
|
||||
float secs = (float)(mad->filesize - mad->header_bytes) / bps;
|
||||
@@ -774,7 +776,7 @@ bool RageSoundReader_MP3::MADLIB_rewind()
|
||||
* set it, then we'll be desynced by a frame after an accurate seek. */
|
||||
// mad->header_bytes = 0;
|
||||
mad->first_frame = true;
|
||||
mad->Stream.this_frame = NULL;
|
||||
mad->Stream.this_frame = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -801,18 +803,18 @@ bool RageSoundReader_MP3::MADLIB_rewind()
|
||||
/* Returns actual position on success, 0 if past EOF, -1 on error. */
|
||||
int RageSoundReader_MP3::SetPosition_toc( int ms, bool Xing )
|
||||
{
|
||||
int percent;
|
||||
|
||||
ASSERT( !Xing || mad->has_xing );
|
||||
ASSERT( mad->length != -1 );
|
||||
int percent;
|
||||
|
||||
/* This leaves our timer accurate if we're using our own TOC, and inaccurate
|
||||
* if we're using Xing. */
|
||||
mad->timer_accurate = !Xing;
|
||||
ASSERT( !Xing || mad->has_xing );
|
||||
ASSERT( mad->length != -1 );
|
||||
|
||||
/* We can speed up the seek using the XING tag. First, figure
|
||||
* out what percentage the requested position falls in. */
|
||||
percent = ms * 100 / mad->length;
|
||||
/* This leaves our timer accurate if we're using our own TOC, and inaccurate
|
||||
* if we're using Xing. */
|
||||
mad->timer_accurate = !Xing;
|
||||
|
||||
/* We can speed up the seek using the XING tag. First, figure
|
||||
* out what percentage the requested position falls in. */
|
||||
percent = ms * 100 / mad->length;
|
||||
|
||||
if(percent >= 0)
|
||||
{
|
||||
@@ -857,7 +859,7 @@ int RageSoundReader_MP3::SetPosition_toc( int ms, bool Xing )
|
||||
}
|
||||
}
|
||||
|
||||
return ms;
|
||||
return ms;
|
||||
}
|
||||
|
||||
int RageSoundReader_MP3::SetPosition_hard( int ms )
|
||||
|
||||
@@ -46,10 +46,10 @@ static long OggRageFile_tell_func( void *datasource )
|
||||
|
||||
static RString ov_ssprintf( int err, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
RString s = vssprintf( fmt, va );
|
||||
va_end(va);
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
RString s = vssprintf( fmt, va );
|
||||
va_end( va );
|
||||
|
||||
RString errstr;
|
||||
switch( err )
|
||||
@@ -66,7 +66,7 @@ static RString ov_ssprintf( int err, const char *fmt, ...)
|
||||
case OV_EBADPACKET: errstr = "OV_EBADPACKET"; break;
|
||||
case OV_EBADLINK: errstr = "Link corrupted"; break;
|
||||
case OV_ENOSEEK: errstr = "Stream is not seekable"; break;
|
||||
default: errstr = ssprintf( "unknown error %i", err ); break;
|
||||
default: errstr = ssprintf( "unknown error %i", err ); break;
|
||||
}
|
||||
|
||||
return s + ssprintf( " (%s)", errstr.c_str() );
|
||||
@@ -100,7 +100,7 @@ SoundReader_FileReader::OpenResult RageSoundReader_Vorbisfile::Open( RageFileBas
|
||||
callbacks.tell_func = OggRageFile_tell_func;
|
||||
|
||||
int ret = ov_open_callbacks( f, vf, NULL, 0, callbacks );
|
||||
if(ret < 0)
|
||||
if( ret < 0 )
|
||||
{
|
||||
SetError( ov_ssprintf(ret, "ov_open failed") );
|
||||
delete f;
|
||||
@@ -122,7 +122,7 @@ SoundReader_FileReader::OpenResult RageSoundReader_Vorbisfile::Open( RageFileBas
|
||||
ASSERT_M( vi->channels == 1 || vi->channels == 2, ssprintf("%i", vi->channels) );
|
||||
channels = vi->channels;
|
||||
|
||||
return OPEN_OK;
|
||||
return OPEN_OK;
|
||||
}
|
||||
|
||||
int RageSoundReader_Vorbisfile::GetLength() const
|
||||
@@ -132,7 +132,7 @@ int RageSoundReader_Vorbisfile::GetLength() const
|
||||
#else
|
||||
int len = int(ov_time_total(vf, -1) * 1000);
|
||||
#endif
|
||||
if(len == OV_EINVAL)
|
||||
if( len == OV_EINVAL )
|
||||
RageException::Throw("RageSoundReader_Vorbisfile::GetLength: ov_time_total returned OV_EINVAL");
|
||||
|
||||
return len;
|
||||
|
||||
@@ -7,41 +7,41 @@
|
||||
|
||||
uint32_t RageSurfaceUtils::decodepixel( const uint8_t *p, int bpp )
|
||||
{
|
||||
switch(bpp)
|
||||
switch(bpp)
|
||||
{
|
||||
case 1: return *p;
|
||||
case 2: return *(uint16_t *)p;
|
||||
case 1: return *p;
|
||||
case 2: return *(uint16_t *)p;
|
||||
case 3:
|
||||
if( BYTE_ORDER == BIG_ENDIAN )
|
||||
return p[0] << 16 | p[1] << 8 | p[2];
|
||||
else
|
||||
return p[0] | p[1] << 8 | p[2] << 16;
|
||||
if( BYTE_ORDER == BIG_ENDIAN )
|
||||
return p[0] << 16 | p[1] << 8 | p[2];
|
||||
else
|
||||
return p[0] | p[1] << 8 | p[2] << 16;
|
||||
|
||||
case 4: return *(uint32_t *)p;
|
||||
default: return 0; /* shouldn't happen, but avoids warnings */
|
||||
}
|
||||
case 4: return *(uint32_t *)p;
|
||||
default: return 0; /* shouldn't happen, but avoids warnings */
|
||||
}
|
||||
}
|
||||
|
||||
void RageSurfaceUtils::encodepixel( uint8_t *p, int bpp, uint32_t pixel )
|
||||
{
|
||||
switch(bpp)
|
||||
switch(bpp)
|
||||
{
|
||||
case 1: *p = uint8_t(pixel); break;
|
||||
case 2: *(uint16_t *)p = uint16_t(pixel); break;
|
||||
case 3:
|
||||
if( BYTE_ORDER == BIG_ENDIAN )
|
||||
case 1: *p = uint8_t(pixel); break;
|
||||
case 2: *(uint16_t *)p = uint16_t(pixel); break;
|
||||
case 3:
|
||||
if( BYTE_ORDER == BIG_ENDIAN )
|
||||
{
|
||||
p[0] = uint8_t((pixel >> 16) & 0xff);
|
||||
p[1] = uint8_t((pixel >> 8) & 0xff);
|
||||
p[2] = uint8_t(pixel & 0xff);
|
||||
} else {
|
||||
p[0] = uint8_t(pixel & 0xff);
|
||||
p[1] = uint8_t((pixel >> 8) & 0xff);
|
||||
p[2] = uint8_t((pixel >> 16) & 0xff);
|
||||
}
|
||||
break;
|
||||
case 4: *(uint32_t *)p = pixel; break;
|
||||
}
|
||||
p[0] = uint8_t((pixel >> 16) & 0xff);
|
||||
p[1] = uint8_t((pixel >> 8) & 0xff);
|
||||
p[2] = uint8_t(pixel & 0xff);
|
||||
} else {
|
||||
p[0] = uint8_t(pixel & 0xff);
|
||||
p[1] = uint8_t((pixel >> 8) & 0xff);
|
||||
p[2] = uint8_t((pixel >> 16) & 0xff);
|
||||
}
|
||||
break;
|
||||
case 4: *(uint32_t *)p = pixel; break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get and set colors without scaling to 0..255. */
|
||||
@@ -145,7 +145,7 @@ bool RageSurfaceUtils::ConvertSurface( RageSurface *src, RageSurface *&dst,
|
||||
int width, int height, int bpp,
|
||||
uint32_t R, uint32_t G, uint32_t B, uint32_t A )
|
||||
{
|
||||
dst = CreateSurface( width, height, bpp, R, G, B, A );
|
||||
dst = CreateSurface( width, height, bpp, R, G, B, A );
|
||||
|
||||
/* If the formats are the same, no conversion is needed. Ignore the palette. */
|
||||
if( width == src->w && height == src->h && src->format->Equivalent( *dst->format ) )
|
||||
@@ -163,7 +163,7 @@ void RageSurfaceUtils::ConvertSurface(RageSurface *&image,
|
||||
int width, int height, int bpp,
|
||||
uint32_t R, uint32_t G, uint32_t B, uint32_t A)
|
||||
{
|
||||
RageSurface *ret_image;
|
||||
RageSurface *ret_image;
|
||||
if( !ConvertSurface( image, ret_image, width, height, bpp, R, G, B, A ) )
|
||||
return;
|
||||
|
||||
@@ -492,16 +492,16 @@ static bool blit_same_type( const RageSurface *src_surf, const RageSurface *dst_
|
||||
/* If possible, memcpy the whole thing. */
|
||||
if( src_surf->w == width && dst_surf->w == width && src_surf->pitch == dst_surf->pitch )
|
||||
{
|
||||
memcpy( dst, src, height*src_surf->pitch );
|
||||
memcpy( dst, src, height*src_surf->pitch );
|
||||
return true;
|
||||
}
|
||||
|
||||
/* The rows don't line up, so memcpy row by row. */
|
||||
while( height-- )
|
||||
{
|
||||
memcpy( dst, src, width*src_surf->format->BytesPerPixel );
|
||||
src += src_surf->pitch;
|
||||
dst += dst_surf->pitch;
|
||||
memcpy( dst, src, width*src_surf->format->BytesPerPixel );
|
||||
src += src_surf->pitch;
|
||||
dst += dst_surf->pitch;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -939,7 +939,7 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
|
||||
|
||||
RageSurface *RageSurfaceUtils::MakeDummySurface( int height, int width )
|
||||
{
|
||||
RageSurface *ret_image = CreateSurface( width, height, 8, 0,0,0,0 );
|
||||
RageSurface *ret_image = CreateSurface( width, height, 8, 0,0,0,0 );
|
||||
|
||||
RageSurfaceColor pink( 0xFF, 0x10, 0xFF, 0xFF );
|
||||
ret_image->fmt.palette->colors[0] = pink;
|
||||
|
||||
@@ -94,7 +94,7 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst )
|
||||
|
||||
/* This is where all of the real work is done. */
|
||||
const uint8_t *sp = (uint8_t *) src->pixels;
|
||||
for( int y = 0; y < dst->h; y++ )
|
||||
for( int y = 0; y < dst->h; y++ )
|
||||
{
|
||||
uint32_t *dp = (uint32_t *) (dst->pixels + dst->pitch*y);
|
||||
/* current source pointer and next source pointer (first and second
|
||||
@@ -127,7 +127,7 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst )
|
||||
/* Advance destination pointer. */
|
||||
++dp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ void RageSurfaceUtils::Zoom( RageSurface *&src, int dstwidth, int dstheight )
|
||||
{
|
||||
ASSERT_M( dstwidth > 0, ssprintf("%i",dstwidth) );
|
||||
ASSERT_M( dstheight > 0, ssprintf("%i",dstheight) );
|
||||
if( src == NULL )
|
||||
if( src == NULL )
|
||||
return;
|
||||
|
||||
if( src->w == dstwidth && src->h == dstheight )
|
||||
|
||||
@@ -35,7 +35,7 @@ static bool ReadPalette( RageFile &f, int number, RageSurfaceColor buffer[MAXCOL
|
||||
buffer[i].a = 0xFF;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const RString &sPath, RageSur
|
||||
|
||||
GlobalBitPixel = 2 << (buf[4] & 0x07);
|
||||
|
||||
if( BitSet(buf[4], LOCALCOLORMAP) )
|
||||
if( BitSet(buf[4], LOCALCOLORMAP) )
|
||||
{
|
||||
/* Global Colormap */
|
||||
if( !ReadPalette(f, GlobalBitPixel, GlobalColorMap ) )
|
||||
@@ -113,11 +113,11 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const RString &sPath, RageSur
|
||||
error = "error reading global colormap";
|
||||
return RageSurfaceUtils::OPEN_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int transparency = -1;
|
||||
int transparency = -1;
|
||||
|
||||
while(1)
|
||||
while(1)
|
||||
{
|
||||
unsigned char type;
|
||||
if( !ReadOK(f, &type, 1) )
|
||||
@@ -202,18 +202,18 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const RString &sPath, RageSur
|
||||
}
|
||||
}
|
||||
|
||||
return RageSurfaceUtils::OPEN_FATAL_ERROR;
|
||||
return RageSurfaceUtils::OPEN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
struct LWZState
|
||||
{
|
||||
bool fresh;
|
||||
int code_size, set_code_size;
|
||||
int max_code, max_code_size;
|
||||
int firstcode, oldcode;
|
||||
int clear_code, end_code;
|
||||
int table[2][(1 << MAX_LWZ_BITS)];
|
||||
int stack[(1 << (MAX_LWZ_BITS)) * 2], *sp;
|
||||
int code_size, set_code_size;
|
||||
int max_code, max_code_size;
|
||||
int firstcode, oldcode;
|
||||
int clear_code, end_code;
|
||||
int table[2][(1 << MAX_LWZ_BITS)];
|
||||
int stack[(1 << (MAX_LWZ_BITS)) * 2], *sp;
|
||||
|
||||
struct Code
|
||||
{
|
||||
@@ -273,14 +273,14 @@ int LWZState::Code::Get( RageFile &f, int code_size )
|
||||
|
||||
bool LWZState::Init( RageFile &f )
|
||||
{
|
||||
unsigned char input_code_size;
|
||||
unsigned char input_code_size;
|
||||
|
||||
/* code size: */
|
||||
if( !ReadOK(f, &input_code_size, 1) )
|
||||
if( !ReadOK(f, &input_code_size, 1) )
|
||||
{
|
||||
// RWSetMsg("EOF / read error on image data");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
set_code_size = input_code_size;
|
||||
code_size = set_code_size + 1;
|
||||
@@ -317,7 +317,7 @@ int LWZState::ReadByte( RageFile &f )
|
||||
if( sp > stack )
|
||||
return *--sp;
|
||||
|
||||
int code;
|
||||
int code;
|
||||
while( (code = m_Code.Get(f, code_size)) >= 0 )
|
||||
{
|
||||
if( code == clear_code )
|
||||
@@ -384,23 +384,23 @@ int LWZState::ReadByte( RageFile &f )
|
||||
|
||||
if( sp > stack )
|
||||
return *--sp;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static RageSurface *ReadImage( RageFile &f, int len, int height,
|
||||
const RageSurfaceColor localColorMap[MAXCOLORMAPSIZE],
|
||||
int interlace, int ignore )
|
||||
{
|
||||
int xpos = 0, ypos = 0, pass = 0;
|
||||
int xpos = 0, ypos = 0, pass = 0;
|
||||
|
||||
/* Initialize the compression routines */
|
||||
/* Initialize the compression routines */
|
||||
LWZState state;
|
||||
if( !state.Init(f) )
|
||||
if( !state.Init(f) )
|
||||
{
|
||||
// RWSetMsg("error reading image");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* If this is an "uninteresting picture" ignore it. */
|
||||
if( ignore )
|
||||
{
|
||||
@@ -409,7 +409,7 @@ static RageSurface *ReadImage( RageFile &f, int len, int height,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RageSurface *image = CreateSurface( len, height, 8, 0, 0, 0, 0 );
|
||||
RageSurface *image = CreateSurface( len, height, 8, 0, 0, 0, 0 );
|
||||
memcpy( image->fmt.palette->colors, localColorMap, 256*sizeof(RageSurfaceColor) );
|
||||
|
||||
int v;
|
||||
@@ -431,7 +431,7 @@ static RageSurface *ReadImage( RageFile &f, int len, int height,
|
||||
{
|
||||
++pass;
|
||||
if( pass == 4 )
|
||||
return image;
|
||||
return image;
|
||||
int start[] = { 0, 4, 2, 1 };
|
||||
ypos = start[pass];
|
||||
}
|
||||
@@ -443,7 +443,7 @@ static RageSurface *ReadImage( RageFile &f, int len, int height,
|
||||
break;
|
||||
}
|
||||
|
||||
return image;
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -113,7 +113,7 @@ RageSurface *RageSurface_Load_XPM( char * const *xpm, RString &error )
|
||||
}
|
||||
}
|
||||
|
||||
return img;
|
||||
return img;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -211,9 +211,9 @@ void ScreenSelectGroup::MenuStart( PlayerNumber pn )
|
||||
GAMESTATE->m_sPreferredSongGroup.Set( m_GroupList.GetSelectionName()==ALL_MUSIC_STRING.GetValue() ? GROUP_ALL : m_GroupList.GetSelectionName() );
|
||||
|
||||
if( GAMESTATE->m_sPreferredSongGroup == GROUP_ALL )
|
||||
SOUND->PlayOnceFromAnnouncer( "select group comment all music" );
|
||||
SOUND->PlayOnceFromAnnouncer( "select group comment all music" );
|
||||
else
|
||||
SOUND->PlayOnceFromAnnouncer( "select group comment general" );
|
||||
SOUND->PlayOnceFromAnnouncer( "select group comment general" );
|
||||
|
||||
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user