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