The big NULL replacement party part 6.
...and ', NULL' had even more to replace.
This commit is contained in:
+1
-1
@@ -467,7 +467,7 @@ namespace
|
||||
LIST_METHOD( LoadAllCommands ),
|
||||
LIST_METHOD( LoadAllCommandsFromName ),
|
||||
LIST_METHOD( LoadAllCommandsAndSetXY ),
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ static const char *aliases[][2] = {
|
||||
{ "gameplay combo 900", "gameplay 900 combo" },
|
||||
{ "gameplay combo 1000", "gameplay 1000 combo" },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
|
||||
/* Find an announcer directory with sounds in it. First search sFolderName,
|
||||
|
||||
+1
-1
@@ -294,7 +294,7 @@ RString Course::GetTranslitFullTitle() const
|
||||
/* This is called by many simple functions, like Course::GetTotalSeconds, and may
|
||||
* be called on all songs to sort. It can take time to execute, so we cache the
|
||||
* results. Returned pointers remain valid for the lifetime of the Course. If the
|
||||
* course difficulty doesn't exist, NULL is returned. */
|
||||
* course difficulty doesn't exist, nullptr is returned. */
|
||||
Trail* Course::GetTrail( StepsType st, CourseDifficulty cd ) const
|
||||
{
|
||||
ASSERT( cd != Difficulty_Invalid );
|
||||
|
||||
+1
-1
@@ -975,7 +975,7 @@ ZRESULT TZip::AddCentral()
|
||||
ulg center_size = writ - pos_at_start_of_central;
|
||||
if (okay)
|
||||
{
|
||||
int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, NULL, swrite,this);
|
||||
int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, nullptr, swrite,this);
|
||||
if (res!=ZE_OK)
|
||||
okay=false;
|
||||
writ += 4 + ENDHEAD + 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ PRNGWrapper::PRNGWrapper( const struct ltc_prng_descriptor *pPRNGDescriptor )
|
||||
m_iPRNG = register_prng( pPRNGDescriptor );
|
||||
ASSERT( m_iPRNG >= 0 );
|
||||
|
||||
int iRet = rng_make_prng( 128, m_iPRNG, &m_PRNG, NULL );
|
||||
int iRet = rng_make_prng( 128, m_iPRNG, &m_PRNG, nullptr );
|
||||
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void PRNGWrapper::AddEntropy( const void *pData, int iSize )
|
||||
void PRNGWrapper::AddRandomEntropy()
|
||||
{
|
||||
unsigned char buf[256];
|
||||
int iRet = rng_get_bytes( buf, sizeof(buf), NULL );
|
||||
int iRet = rng_get_bytes( buf, sizeof(buf), nullptr );
|
||||
ASSERT( iRet == sizeof(buf) );
|
||||
|
||||
AddEntropy( buf, sizeof(buf) );
|
||||
|
||||
@@ -72,7 +72,7 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
// todo: Use Row1, Row2 for names? also m_sName+"Row" -aj
|
||||
m_Lines[m].m_Meter.SetName( "Row" );
|
||||
m_Lines[m].m_Meter.Load( "StepsDisplayListRow", NULL );
|
||||
m_Lines[m].m_Meter.Load( "StepsDisplayListRow", nullptr );
|
||||
this->AddChild( &m_Lines[m].m_Meter );
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -165,12 +165,12 @@ void EditMenu::Load( const RString &sType )
|
||||
this->AddChild( &m_SongTextBanner );
|
||||
|
||||
m_StepsDisplay.SetName( "StepsDisplay" );
|
||||
m_StepsDisplay.Load( "StepsDisplayEdit", NULL );
|
||||
m_StepsDisplay.Load( "StepsDisplayEdit", nullptr );
|
||||
ActorUtil::SetXY( m_StepsDisplay, sType );
|
||||
this->AddChild( &m_StepsDisplay );
|
||||
|
||||
m_StepsDisplaySource.SetName( "StepsDisplaySource" );
|
||||
m_StepsDisplaySource.Load( "StepsDisplayEdit", NULL );
|
||||
m_StepsDisplaySource.Load( "StepsDisplayEdit", nullptr );
|
||||
ActorUtil::SetXY( m_StepsDisplaySource, sType );
|
||||
this->AddChild( &m_StepsDisplaySource );
|
||||
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ namespace
|
||||
static const luaL_Reg EnumLib[] = {
|
||||
{ "GetName", GetName },
|
||||
{ "Reverse", Reverse },
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
|
||||
static void PushEnumMethodTable( lua_State *L )
|
||||
|
||||
+645
-645
File diff suppressed because it is too large
Load Diff
@@ -839,7 +839,7 @@ public:
|
||||
fadeOut = FArg(5);
|
||||
}
|
||||
}
|
||||
p->PlayMusic(musicPath, NULL, false, musicStart, musicLength,
|
||||
p->PlayMusic(musicPath, nullptr, false, musicStart, musicLength,
|
||||
fadeIn, fadeOut);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ void GrooveRadar::LoadFromNode( const XNode* pNode )
|
||||
|
||||
void GrooveRadar::SetEmpty( PlayerNumber pn )
|
||||
{
|
||||
SetFromSteps( pn, NULL );
|
||||
SetFromSteps( pn, nullptr );
|
||||
}
|
||||
|
||||
void GrooveRadar::SetFromRadarValues( PlayerNumber pn, const RadarValues &rv )
|
||||
|
||||
+1
-1
@@ -1076,7 +1076,7 @@ namespace
|
||||
LIST_METHOD( ReadFile ),
|
||||
LIST_METHOD( RunWithThreadVariables ),
|
||||
LIST_METHOD( GetThreadVariable ),
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -502,7 +502,7 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
|
||||
split( MODE_MENU_CHOICE_NAMES, ",", vsNames );
|
||||
for( unsigned i=0; i<vsNames.size(); ++i )
|
||||
{
|
||||
MusicWheelItemData wid( WheelItemDataType_Sort, NULL, "", NULL, SORT_MENU_COLOR, 0 );
|
||||
MusicWheelItemData wid( WheelItemDataType_Sort, nullptr, "", nullptr, SORT_MENU_COLOR, 0 );
|
||||
wid.m_pAction = HiddenPtr<GameCommand>( new GameCommand );
|
||||
wid.m_pAction->m_sName = vsNames[i];
|
||||
wid.m_pAction->Load( i, ParseCommands(CHOICE.GetValue(vsNames[i])) );
|
||||
@@ -676,18 +676,18 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
|
||||
// In certain situations (e.g. simulating Pump it Up), themes may
|
||||
// want to only show one group at a time.
|
||||
if( !HIDE_INACTIVE_SECTIONS )
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, sThisSection, NULL, colorSection, iSectionCount) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, nullptr, sThisSection, nullptr, colorSection, iSectionCount) );
|
||||
sLastSection = sThisSection;
|
||||
}
|
||||
}
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, NULL, SONGMAN->GetSongColor(pSong), 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Song, pSong, sLastSection, nullptr, SONGMAN->GetSongColor(pSong), 0) );
|
||||
}
|
||||
|
||||
if( so != SORT_ROULETTE )
|
||||
{
|
||||
// todo: allow themers to change the order of the items. -aj
|
||||
if( SHOW_ROULETTE )
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Roulette, NULL, "", NULL, ROULETTE_COLOR, 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Roulette, nullptr, "", nullptr, ROULETTE_COLOR, 0) );
|
||||
|
||||
// Only add WheelItemDataType_Random and WheelItemDataType_Portal if there's at least
|
||||
// one song on the list.
|
||||
@@ -697,17 +697,17 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
|
||||
bFoundAnySong = true;
|
||||
|
||||
if( SHOW_RANDOM && bFoundAnySong )
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Random, NULL, "", NULL, RANDOM_COLOR, 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Random, nullptr, "", nullptr, RANDOM_COLOR, 0) );
|
||||
|
||||
if( SHOW_PORTAL && bFoundAnySong )
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Portal, NULL, "", NULL, PORTAL_COLOR, 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Portal, nullptr, "", nullptr, PORTAL_COLOR, 0) );
|
||||
|
||||
// add custom wheel items
|
||||
vector<RString> vsNames;
|
||||
split( CUSTOM_WHEEL_ITEM_NAMES, ",", vsNames );
|
||||
for( unsigned i=0; i<vsNames.size(); ++i )
|
||||
{
|
||||
MusicWheelItemData wid( WheelItemDataType_Custom, NULL, "", NULL, CUSTOM_CHOICE_COLORS.GetValue(vsNames[i]), 0 );
|
||||
MusicWheelItemData wid( WheelItemDataType_Custom, nullptr, "", nullptr, CUSTOM_CHOICE_COLORS.GetValue(vsNames[i]), 0 );
|
||||
wid.m_pAction = HiddenPtr<GameCommand>( new GameCommand );
|
||||
wid.m_pAction->m_sName = vsNames[i];
|
||||
wid.m_pAction->Load( i, ParseCommands(CUSTOM_CHOICES.GetValue(vsNames[i])) );
|
||||
@@ -833,12 +833,12 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
|
||||
{
|
||||
RageColor c = SECTION_COLORS.GetValue(iSectionColorIndex);
|
||||
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, sThisSection, NULL, c, 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Section, nullptr, sThisSection, nullptr, c, 0) );
|
||||
sLastSection = sThisSection;
|
||||
}
|
||||
|
||||
RageColor c = ( pCourse->m_sGroupName.size() == 0 ) ? pCourse->GetColor() : SONGMAN->GetCourseColor(pCourse);
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Course, NULL, sThisSection, pCourse, c, 0) );
|
||||
arrayWheelItemDatas.push_back( new MusicWheelItemData(WheelItemDataType_Course, nullptr, sThisSection, pCourse, c, 0) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ void MusicWheel::FilterWheelItemDatas(vector<MusicWheelItemData *> &aUnFilteredD
|
||||
|
||||
// If we've filtered all items, insert a dummy.
|
||||
if( aFilteredData.empty() )
|
||||
aFilteredData.push_back( new MusicWheelItemData(WheelItemDataType_Section, NULL, EMPTY_STRING, NULL, EMPTY_COLOR, 0) );
|
||||
aFilteredData.push_back( new MusicWheelItemData(WheelItemDataType_Section, nullptr, EMPTY_STRING, nullptr, EMPTY_COLOR, 0) );
|
||||
}
|
||||
|
||||
void MusicWheel::UpdateSwitch()
|
||||
|
||||
@@ -933,7 +933,7 @@ unsigned long NetworkSyncManager::GetCurrentSMBuild( LoadingWindow* ld )
|
||||
if( 0 == stricmp(sFieldName,"X-SM-Build") )
|
||||
{
|
||||
bSuccess = true;
|
||||
uCurrentSMBuild = strtoul( sFieldValue, NULL, 10 );
|
||||
uCurrentSMBuild = strtoul( sFieldValue, nullptr, 10 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ static NoteResource *MakeNoteResource( const RString &sButton, const RString &sE
|
||||
{
|
||||
NoteResource *pRes = new NoteResource( nsap );
|
||||
|
||||
pRes->m_pActor = NOTESKIN->LoadActor( sButton, sElement, NULL, bSpriteOnly );
|
||||
pRes->m_pActor = NOTESKIN->LoadActor( sButton, sElement, nullptr, bSpriteOnly );
|
||||
ASSERT( pRes->m_pActor != nullptr );
|
||||
|
||||
g_NoteResource[nsap] = pRes;
|
||||
|
||||
@@ -328,7 +328,7 @@ int BMSSong::AllocateKeysound( RString filename, RString path )
|
||||
|
||||
if( !IsAFile(dir + normalizedFilename) )
|
||||
{
|
||||
const char *exts[] = { "oga", "ogg", "wav", "mp3", NULL }; // XXX: stop duplicating these everywhere
|
||||
const char *exts[] = { "oga", "ogg", "wav", "mp3", nullptr }; // XXX: stop duplicating these everywhere
|
||||
for( unsigned i = 0; exts[i] != nullptr; ++i )
|
||||
{
|
||||
RString fn = SetExtension( normalizedFilename, exts[i] );
|
||||
@@ -393,7 +393,7 @@ bool BMSSong::GetBackground( RString filename, RString path, RString &bgfile )
|
||||
|
||||
if( !IsAFile(dir + normalizedFilename) )
|
||||
{
|
||||
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", NULL }; // XXX: stop duplicating these everywhere
|
||||
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", nullptr }; // XXX: stop duplicating these everywhere
|
||||
for( unsigned i = 0; exts[i] != nullptr; ++i )
|
||||
{
|
||||
RString fn = SetExtension( normalizedFilename, exts[i] );
|
||||
@@ -424,7 +424,7 @@ void BMSSong::PrecacheBackgrounds(const RString &dir)
|
||||
backgroundsPrecached = true;
|
||||
vector<RString> arrayPossibleFiles;
|
||||
|
||||
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", NULL }; // XXX: stop duplicating these everywhere
|
||||
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", nullptr }; // XXX: stop duplicating these everywhere
|
||||
|
||||
for( unsigned i = 0; exts[i] != nullptr; ++i )
|
||||
{
|
||||
|
||||
@@ -169,11 +169,11 @@ void SMLoader::ProcessAttacks( AttackArray &attacks, MsdFile::value_t params )
|
||||
Trim( sBits[0] );
|
||||
|
||||
if( !sBits[0].CompareNoCase("TIME") )
|
||||
attack.fStartSecond = strtof( sBits[1], NULL );
|
||||
attack.fStartSecond = strtof( sBits[1], nullptr );
|
||||
else if( !sBits[0].CompareNoCase("LEN") )
|
||||
attack.fSecsRemaining = strtof( sBits[1], NULL );
|
||||
attack.fSecsRemaining = strtof( sBits[1], nullptr );
|
||||
else if( !sBits[0].CompareNoCase("END") )
|
||||
end = strtof( sBits[1], NULL );
|
||||
end = strtof( sBits[1], nullptr );
|
||||
else if( !sBits[0].CompareNoCase("MODS") )
|
||||
{
|
||||
Trim(sBits[1]);
|
||||
|
||||
@@ -573,7 +573,7 @@ bool RageDisplay_D3D::BeginFrame()
|
||||
}
|
||||
}
|
||||
|
||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
g_pd3dDevice->Clear( 0, nullptr, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
||||
g_pd3dDevice->BeginScene();
|
||||
|
||||
@@ -633,9 +633,9 @@ RageSurface* RageDisplay_D3D::CreateScreenshot()
|
||||
|
||||
// Copy the back buffer into a surface of a type we support.
|
||||
IDirect3DSurface9* pCopy;
|
||||
if( SUCCEEDED( g_pd3dDevice->CreateOffscreenPlainSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCopy, NULL ) ) )
|
||||
if( SUCCEEDED( g_pd3dDevice->CreateOffscreenPlainSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCopy, nullptr ) ) )
|
||||
{
|
||||
if( SUCCEEDED( D3DXLoadSurfaceFromSurface( pCopy, NULL, NULL, pSurface, NULL, NULL, D3DX_FILTER_NONE, 0) ) )
|
||||
if( SUCCEEDED( D3DXLoadSurfaceFromSurface( pCopy, nullptr, nullptr, pSurface, nullptr, nullptr, D3DX_FILTER_NONE, 0) ) )
|
||||
{
|
||||
// Update desc from the copy.
|
||||
pCopy->GetDesc( &desc );
|
||||
@@ -1029,7 +1029,7 @@ void RageDisplay_D3D::SetTexture( TextureUnit tu, unsigned iTexture )
|
||||
|
||||
if( iTexture == 0 )
|
||||
{
|
||||
g_pd3dDevice->SetTexture( tu, NULL );
|
||||
g_pd3dDevice->SetTexture( tu, nullptr );
|
||||
|
||||
/* Intentionally commented out. Don't mess with texture stage state
|
||||
* when just setting the texture. Model sets its texture modes before
|
||||
@@ -1215,7 +1215,7 @@ void RageDisplay_D3D::SetZTestMode( ZTestMode mode )
|
||||
|
||||
void RageDisplay_D3D::ClearZBuffer()
|
||||
{
|
||||
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
||||
g_pd3dDevice->Clear( 0, nullptr, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
|
||||
}
|
||||
|
||||
void RageDisplay_D3D::SetTextureWrapping( TextureUnit tu, bool b )
|
||||
@@ -1346,7 +1346,7 @@ unsigned RageDisplay_D3D::CreateTexture(
|
||||
{
|
||||
HRESULT hr;
|
||||
IDirect3DTexture9* pTex;
|
||||
hr = g_pd3dDevice->CreateTexture( power_of_two(img->w), power_of_two(img->h), 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex, NULL );
|
||||
hr = g_pd3dDevice->CreateTexture( power_of_two(img->w), power_of_two(img->h), 1, 0, D3DFORMATS[pixfmt], D3DPOOL_MANAGED, &pTex, nullptr );
|
||||
|
||||
if( FAILED(hr) )
|
||||
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
|
||||
|
||||
@@ -598,7 +598,7 @@ static void CheckPalettedTextures()
|
||||
glTexImage2D( GL_PROXY_TEXTURE_2D,
|
||||
0, glTexFormat,
|
||||
16, 16, 0,
|
||||
glImageFormat, glImageType, NULL );
|
||||
glImageFormat, glImageType, nullptr );
|
||||
GL_CHECK_ERROR( "glTexImage2D" );
|
||||
|
||||
GLuint iFormat = 0;
|
||||
@@ -662,7 +662,7 @@ static void CheckReversePackedPixels()
|
||||
glTexImage2D( GL_PROXY_TEXTURE_2D,
|
||||
0, GL_RGBA,
|
||||
16, 16, 0,
|
||||
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL );
|
||||
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, nullptr );
|
||||
|
||||
const GLenum glError = glGetError();
|
||||
if (glError == GL_NO_ERROR)
|
||||
@@ -1272,7 +1272,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
||||
DebugAssertNoGLError();
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
|
||||
DebugAssertNoGLError();
|
||||
glVertexPointer(3, GL_FLOAT, 0, NULL );
|
||||
glVertexPointer(3, GL_FLOAT, 0, nullptr );
|
||||
DebugAssertNoGLError();
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
@@ -1282,7 +1282,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
||||
DebugAssertNoGLError();
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
|
||||
DebugAssertNoGLError();
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, NULL);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, nullptr);
|
||||
DebugAssertNoGLError();
|
||||
|
||||
// TRICKY: Don't bind and send normals if lighting is disabled. This
|
||||
@@ -1301,7 +1301,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
||||
DebugAssertNoGLError();
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
|
||||
DebugAssertNoGLError();
|
||||
glNormalPointer(GL_FLOAT, 0, NULL);
|
||||
glNormalPointer(GL_FLOAT, 0, nullptr);
|
||||
DebugAssertNoGLError();
|
||||
}
|
||||
else
|
||||
@@ -1321,7 +1321,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
|
||||
DebugAssertNoGLError();
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
|
||||
DebugAssertNoGLError();
|
||||
glVertexAttribPointerARB( g_iAttribTextureMatrixScale, 2, GL_FLOAT, false, 0, NULL );
|
||||
glVertexAttribPointerARB( g_iAttribTextureMatrixScale, 2, GL_FLOAT, false, 0, nullptr );
|
||||
DebugAssertNoGLError();
|
||||
|
||||
glUseProgramObjectARB( g_bTextureMatrixShader );
|
||||
@@ -2174,7 +2174,7 @@ unsigned RageDisplay_Legacy::CreateTexture(
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0, glTexFormat,
|
||||
power_of_two(pImg->w), power_of_two(pImg->h), 0,
|
||||
glImageFormat, glImageType, NULL );
|
||||
glImageFormat, glImageType, nullptr );
|
||||
if (pImg->pixels)
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0,
|
||||
0, 0,
|
||||
@@ -2236,7 +2236,7 @@ public:
|
||||
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_iBuffer );
|
||||
|
||||
int iSize = pSurface->h * pSurface->pitch;
|
||||
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, iSize, NULL, GL_STREAM_DRAW );
|
||||
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, iSize, nullptr, GL_STREAM_DRAW );
|
||||
|
||||
void *pSurfaceMemory = glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
|
||||
pSurface->pixels = (uint8_t *) pSurfaceMemory;
|
||||
@@ -2379,7 +2379,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam ¶m, int
|
||||
internalformat = param.bWithAlpha? GL_RGBA8:GL_RGB8;
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, internalformat,
|
||||
iTextureWidth, iTextureHeight, 0, type, GL_UNSIGNED_BYTE, NULL );
|
||||
iTextureWidth, iTextureHeight, 0, type, GL_UNSIGNED_BYTE, nullptr );
|
||||
DebugAssertNoGLError();
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
|
||||
+1
-1
@@ -437,7 +437,7 @@ namespace RageFileUtil
|
||||
const luaL_Reg RageFileUtilTable[] =
|
||||
{
|
||||
LIST_METHOD( CreateRageFile ),
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
LUA_REGISTER_NAMESPACE( RageFileUtil );
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ bool RageFileDriverDirect::Move( const RString &sOldPath_, const RString &sNewPa
|
||||
}
|
||||
|
||||
FDB->DelFile( sOldPath );
|
||||
FDB->AddFile( sNewPath, size, hash, NULL );
|
||||
FDB->AddFile( sNewPath, size, hash, nullptr );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ RageSoundReader_FileReader *RageSoundReader_FileReader::OpenFile( RString filena
|
||||
if( pFile->GetFileSize() < 1024*50 )
|
||||
{
|
||||
RageFileObjMem *pMem = new RageFileObjMem;
|
||||
bool bRet = FileCopy( *pFile, *pMem, error, NULL );
|
||||
bool bRet = FileCopy( *pFile, *pMem, error, nullptr );
|
||||
if( !bRet )
|
||||
{
|
||||
delete pMem;
|
||||
|
||||
@@ -745,7 +745,7 @@ bool RageSoundReader_MP3::MADLIB_rewind()
|
||||
|
||||
mad_stream_finish(&mad->Stream);
|
||||
mad_stream_init(&mad->Stream);
|
||||
mad_stream_buffer(&mad->Stream, NULL, 0);
|
||||
mad_stream_buffer(&mad->Stream, nullptr, 0);
|
||||
mad->inbuf_filepos = 0;
|
||||
|
||||
/* Be careful. We need to leave header_bytes alone, so if we try to SetPosition_estimate
|
||||
|
||||
@@ -82,7 +82,7 @@ RageSoundReader_FileReader::OpenResult RageSoundReader_Vorbisfile::Open( RageFil
|
||||
callbacks.close_func = OggRageFile_close_func;
|
||||
callbacks.tell_func = OggRageFile_tell_func;
|
||||
|
||||
int ret = ov_open_callbacks( pFile, vf, NULL, 0, callbacks );
|
||||
int ret = ov_open_callbacks( pFile, vf, nullptr, 0, callbacks );
|
||||
if( ret < 0 )
|
||||
{
|
||||
SetError( ov_ssprintf(ret, "ov_open failed") );
|
||||
|
||||
@@ -80,7 +80,7 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
png_info *info_ptr = png_create_info_struct(png);
|
||||
if( info_ptr == nullptr )
|
||||
{
|
||||
png_destroy_read_struct( &png, NULL, NULL );
|
||||
png_destroy_read_struct( &png, nullptr, nullptr );
|
||||
sprintf( errorbuf, "creating png_create_info_struct failed");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
CHECKPOINT;
|
||||
if( setjmp(png_jmpbuf(png) ))
|
||||
{
|
||||
png_destroy_read_struct( &png, &info_ptr, NULL );
|
||||
png_destroy_read_struct( &png, &info_ptr, nullptr );
|
||||
delete img;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -101,15 +101,15 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
|
||||
png_uint_32 width, height;
|
||||
int bit_depth, color_type;
|
||||
png_get_IHDR( png, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL );
|
||||
png_get_IHDR( png, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr );
|
||||
|
||||
/* If bHeaderOnly is true, don't allocate the pixel storage space or decompress
|
||||
* the image. Just return an empty surface with only the width and height set. */
|
||||
if( bHeaderOnly )
|
||||
{
|
||||
CHECKPOINT;
|
||||
img = CreateSurfaceFrom( width, height, 32, 0, 0, 0, 0, NULL, width*4 );
|
||||
png_destroy_read_struct( &png, &info_ptr, NULL );
|
||||
img = CreateSurfaceFrom( width, height, 32, 0, 0, 0, 0, nullptr, width*4 );
|
||||
png_destroy_read_struct( &png, &info_ptr, nullptr );
|
||||
|
||||
return img;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
if( color_type == PNG_COLOR_TYPE_GRAY )
|
||||
{
|
||||
png_color_16 *trans;
|
||||
if( png_get_tRNS( png, info_ptr, NULL, NULL, &trans ) == PNG_INFO_tRNS )
|
||||
if( png_get_tRNS( png, info_ptr, nullptr, nullptr, &trans ) == PNG_INFO_tRNS )
|
||||
iColorKey = trans->gray;
|
||||
}
|
||||
else if( color_type == PNG_COLOR_TYPE_PALETTE )
|
||||
@@ -177,7 +177,7 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
|
||||
png_byte *trans = nullptr;
|
||||
int num_trans = 0;
|
||||
png_get_tRNS( png, info_ptr, &trans, &num_trans, NULL );
|
||||
png_get_tRNS( png, info_ptr, &trans, &num_trans, nullptr );
|
||||
|
||||
for( int i = 0; i < num_palette; ++i )
|
||||
{
|
||||
@@ -246,7 +246,7 @@ static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
|
||||
CHECKPOINT;
|
||||
png_read_end( png, info_ptr );
|
||||
png_destroy_read_struct( &png, &info_ptr, NULL );
|
||||
png_destroy_read_struct( &png, &info_ptr, nullptr );
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurfac
|
||||
png_info *pInfo = png_create_info_struct(pPng);
|
||||
if( pInfo == nullptr )
|
||||
{
|
||||
png_destroy_read_struct( &pPng, NULL, NULL );
|
||||
png_destroy_read_struct( &pPng, nullptr, nullptr );
|
||||
if( bDeleteImg )
|
||||
delete pImg;
|
||||
sprintf( szErrorbuf, "creating png_create_info_struct failed");
|
||||
@@ -99,7 +99,7 @@ static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurfac
|
||||
|
||||
if( setjmp(png_jmpbuf(pPng)) )
|
||||
{
|
||||
png_destroy_read_struct( &pPng, &pInfo, NULL );
|
||||
png_destroy_read_struct( &pPng, &pInfo, nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ struct ThreadSlot
|
||||
int m_iLine;
|
||||
char m_szFormattedBuf[1024];
|
||||
|
||||
ThreadCheckpoint() { Set( NULL, 0, NULL ); }
|
||||
ThreadCheckpoint() { Set( NULL, 0, nullptr ); }
|
||||
void Set( const char *szFile, int iLine, const char *szMessage = nullptr );
|
||||
const char *GetFormattedCheckpoint();
|
||||
};
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ namespace Checkpoints
|
||||
void GetLogs( char *pBuf, int iSize, const char *delim );
|
||||
};
|
||||
|
||||
#define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, NULL))
|
||||
#define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, nullptr))
|
||||
#define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m))
|
||||
|
||||
/* Mutex class that follows the behavior of Windows mutexes: if the same
|
||||
|
||||
+6
-6
@@ -149,7 +149,7 @@ namespace
|
||||
{
|
||||
LIST_METHOD( Seed ),
|
||||
LIST_METHOD( Random ),
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1347,12 +1347,12 @@ void Regex::Compile()
|
||||
{
|
||||
const char *error;
|
||||
int offset;
|
||||
m_pReg = pcre_compile( m_sPattern.c_str(), PCRE_CASELESS, &error, &offset, NULL );
|
||||
m_pReg = pcre_compile( m_sPattern.c_str(), PCRE_CASELESS, &error, &offset, nullptr );
|
||||
|
||||
if( m_pReg == nullptr )
|
||||
RageException::Throw( "Invalid regex: \"%s\" (%s).", m_sPattern.c_str(), error );
|
||||
|
||||
int iRet = pcre_fullinfo( (pcre *) m_pReg, NULL, PCRE_INFO_CAPTURECOUNT, &m_iBackrefs );
|
||||
int iRet = pcre_fullinfo( (pcre *) m_pReg, nullptr, PCRE_INFO_CAPTURECOUNT, &m_iBackrefs );
|
||||
ASSERT( iRet >= 0 );
|
||||
|
||||
++m_iBackrefs;
|
||||
@@ -1398,7 +1398,7 @@ Regex::~Regex()
|
||||
bool Regex::Compare( const RString &sStr )
|
||||
{
|
||||
int iMat[128*3];
|
||||
int iRet = pcre_exec( (pcre *) m_pReg, NULL, sStr.data(), sStr.size(), 0, 0, iMat, 128*3 );
|
||||
int iRet = pcre_exec( (pcre *) m_pReg, nullptr, sStr.data(), sStr.size(), 0, 0, iMat, 128*3 );
|
||||
|
||||
if( iRet < -1 )
|
||||
RageException::Throw( "Unexpected return from pcre_exec('%s'): %i.", m_sPattern.c_str(), iRet );
|
||||
@@ -1411,7 +1411,7 @@ bool Regex::Compare( const RString &sStr, vector<RString> &asMatches )
|
||||
asMatches.clear();
|
||||
|
||||
int iMat[128*3];
|
||||
int iRet = pcre_exec( (pcre *) m_pReg, NULL, sStr.data(), sStr.size(), 0, 0, iMat, 128*3 );
|
||||
int iRet = pcre_exec( (pcre *) m_pReg, nullptr, sStr.data(), sStr.size(), 0, 0, iMat, 128*3 );
|
||||
|
||||
if( iRet < -1 )
|
||||
RageException::Throw( "Unexpected return from pcre_exec('%s'): %i.", m_sPattern.c_str(), iRet );
|
||||
@@ -1767,7 +1767,7 @@ RString IntToString( const int &iNum )
|
||||
|
||||
float StringToFloat( const RString &sString )
|
||||
{
|
||||
float ret = strtof( sString, NULL );
|
||||
float ret = strtof( sString, nullptr );
|
||||
|
||||
if( !isfinite(ret) )
|
||||
ret = 0.0f;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/* Convert from the given codepage to UTF-8. Return true if successful. */
|
||||
static bool CodePageConvert( RString &sText, int iCodePage )
|
||||
{
|
||||
int iSize = MultiByteToWideChar( iCodePage, MB_ERR_INVALID_CHARS, sText.data(), sText.size(), NULL, 0 );
|
||||
int iSize = MultiByteToWideChar( iCodePage, MB_ERR_INVALID_CHARS, sText.data(), sText.size(), nullptr, 0 );
|
||||
if( iSize == 0 )
|
||||
{
|
||||
LOG->Trace( "%s\n", werr_ssprintf(GetLastError(), "err: ").c_str() );
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ bool RoomWheel::Select()
|
||||
return WheelBase::Select();
|
||||
if( m_iSelection == 0 )
|
||||
{
|
||||
// Since this is not actually an option outside of this wheel, NULL is a good idea.
|
||||
// Since this is not actually an option outside of this wheel, nullptr is a good idea.
|
||||
m_LastSelection = nullptr;
|
||||
ScreenTextEntry::TextEntry( SM_BackFromRoomName, ENTER_ROOM_NAME, "", 255 );
|
||||
}
|
||||
|
||||
+124
-124
@@ -549,49 +549,49 @@ static MenuDef g_MainMenu(
|
||||
"ScreenMiniMenuMainMenu",
|
||||
MenuRowDef(ScreenEdit::play_whole_song,
|
||||
"Play whole song",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::play_current_beat_to_end,
|
||||
"Play current beat to end",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::save,
|
||||
"Save",
|
||||
true, EditMode_Home, true, true, 0, NULL ),
|
||||
true, EditMode_Home, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::play_selection,
|
||||
"Play selection",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::set_selection_start,
|
||||
"Set selection start",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::set_selection_end,
|
||||
"Set selection end",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::revert_to_last_save,
|
||||
"Revert to last save",
|
||||
true, EditMode_Home, true, true, 0, NULL ),
|
||||
true, EditMode_Home, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::revert_from_disk,
|
||||
"Revert from disk",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::options,
|
||||
"Editor options",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::edit_song_info,
|
||||
"Edit song info",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::edit_steps_information,
|
||||
"Edit steps information",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::edit_timing_data,
|
||||
"Edit Timing Data",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::view_steps_data,
|
||||
"View steps data",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::play_preview_music,
|
||||
"Play preview music",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::exit,
|
||||
"Exit Edit Mode",
|
||||
true, EditMode_Practice, true, true, 0, NULL )
|
||||
true, EditMode_Practice, true, true, 0, nullptr )
|
||||
);
|
||||
|
||||
static MenuDef g_AlterMenu(
|
||||
@@ -599,12 +599,12 @@ static MenuDef g_AlterMenu(
|
||||
MenuRowDef(ScreenEdit::cut,
|
||||
"Cut",
|
||||
true,
|
||||
EditMode_Practice, true, true, 0, NULL ),
|
||||
EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::copy,
|
||||
"Copy",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::clear, "Clear area", true,
|
||||
EditMode_Practice, true, true, 0, NULL ),
|
||||
EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::quantize, "Quantize", true,
|
||||
EditMode_Practice, true, true, 0,
|
||||
"4th","8th","12th","16th","24th","32nd","48th","64th","192nd"),
|
||||
@@ -624,57 +624,57 @@ static MenuDef g_AlterMenu(
|
||||
MenuRowDef(ScreenEdit::play,
|
||||
"Play selection",
|
||||
true,
|
||||
EditMode_Practice, true, true, 0, NULL ),
|
||||
EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::record,
|
||||
"Record in selection",
|
||||
true,
|
||||
EditMode_Practice, true, true, 0, NULL ),
|
||||
EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::preview_designation,
|
||||
"Designate as Music Preview",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::convert_to_pause,
|
||||
"Convert selection to pause",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::convert_to_delay,
|
||||
"Convert selection to delay",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::convert_to_warp,
|
||||
"Convert selection to warp",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::convert_to_fake,
|
||||
"Convert selection to fake",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::convert_to_attack,
|
||||
"Convert selection to attack",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL),
|
||||
EditMode_Full, true, true, 0, nullptr),
|
||||
MenuRowDef(ScreenEdit::routine_invert_notes,
|
||||
"Invert notes' player",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::routine_mirror_1_to_2,
|
||||
"Mirror Player 1 to 2",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::routine_mirror_2_to_1,
|
||||
"Mirror Player 2 to 1",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL )
|
||||
EditMode_Full, true, true, 0, nullptr )
|
||||
);
|
||||
|
||||
static MenuDef g_AreaMenu(
|
||||
"ScreenMiniMenuAreaMenu",
|
||||
MenuRowDef(ScreenEdit::paste_at_current_beat,
|
||||
"Paste at current beat",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::paste_at_begin_marker,
|
||||
"Paste at begin marker",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::insert_and_shift,
|
||||
"Insert beat and shift down",
|
||||
true, EditMode_Practice, true, true, 0, "4th","8th","12th","16th","24th","32nd","48th","64th","192nd" ),
|
||||
@@ -690,27 +690,27 @@ static MenuDef g_AreaMenu(
|
||||
MenuRowDef(ScreenEdit::convert_pause_to_beat,
|
||||
"Convert pause to beats",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::convert_delay_to_beat,
|
||||
"Convert delay to beats",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL ),
|
||||
EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::last_second_at_beat,
|
||||
"Designate last second at current beat",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::undo,
|
||||
"Undo",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::clear_clipboard,
|
||||
"Clear clipboard",
|
||||
true,
|
||||
EditMode_Practice, true, true, 0, NULL ),
|
||||
EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::modify_attacks_at_row,
|
||||
"Modify Attacks at current beat",
|
||||
true, EditMode_CourseMods, true, true, 0, NULL),
|
||||
true, EditMode_CourseMods, true, true, 0, nullptr),
|
||||
MenuRowDef(ScreenEdit::modify_keysounds_at_row,
|
||||
"Modify Keysounds at current beat",
|
||||
true, EditMode_Full, true, true, 0, NULL)
|
||||
true, EditMode_Full, true, true, 0, nullptr)
|
||||
|
||||
);
|
||||
|
||||
@@ -718,98 +718,98 @@ static MenuDef g_StepsInformation(
|
||||
"ScreenMiniMenuStepsInformation",
|
||||
MenuRowDef(ScreenEdit::difficulty,
|
||||
"Difficulty",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::meter,
|
||||
"Meter",
|
||||
true, EditMode_Practice, true, false, 0, NULL ),
|
||||
true, EditMode_Practice, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::predict_meter,
|
||||
"Predicted Meter",
|
||||
false, EditMode_Full, true, true, 0, NULL ),
|
||||
false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::chartname,
|
||||
"Chart Name",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::description,
|
||||
"Description",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::chartstyle,
|
||||
"Chart Style",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::step_credit,
|
||||
"Step Author",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::step_display_bpm,
|
||||
"Display BPM",
|
||||
true, EditMode_Full, true, true, 0, "Actual", "Specified", "Random" ),
|
||||
MenuRowDef(ScreenEdit::step_min_bpm,
|
||||
"Min BPM",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::step_max_bpm,
|
||||
"Max BPM",
|
||||
true, EditMode_Full, true, true, 0, NULL )
|
||||
true, EditMode_Full, true, true, 0, nullptr )
|
||||
);
|
||||
|
||||
static MenuDef g_StepsData(
|
||||
"ScreenMiniMenuStepsData",
|
||||
MenuRowDef( ScreenEdit::tap_notes, "Tap Steps", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::jumps, "Jumps", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::hands, "Hands", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::quads, "Quads", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::holds, "Holds", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::mines, "Mines", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef(ScreenEdit::rolls, "Rolls", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef(ScreenEdit::lifts, "Lifts", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef(ScreenEdit::fakes, "Fakes", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::stream, "Stream", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::voltage, "Voltage", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::air, "Air", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::freeze, "Freeze", false, EditMode_Full, true, true, 0, NULL ),
|
||||
MenuRowDef( ScreenEdit::chaos, "Chaos", false, EditMode_Full, true, true, 0, NULL )
|
||||
MenuRowDef( ScreenEdit::tap_notes, "Tap Steps", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::jumps, "Jumps", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::hands, "Hands", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::quads, "Quads", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::holds, "Holds", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::mines, "Mines", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::rolls, "Rolls", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::lifts, "Lifts", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::fakes, "Fakes", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::stream, "Stream", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::voltage, "Voltage", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::air, "Air", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::freeze, "Freeze", false, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef( ScreenEdit::chaos, "Chaos", false, EditMode_Full, true, true, 0, nullptr )
|
||||
);
|
||||
|
||||
static MenuDef g_SongInformation(
|
||||
"ScreenMiniMenuSongInformation",
|
||||
MenuRowDef(ScreenEdit::main_title,
|
||||
"Main title",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::sub_title,
|
||||
"Sub title",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::artist,
|
||||
"Artist",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::genre,
|
||||
"Genre",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::credit,
|
||||
"Credit",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::main_title_transliteration,
|
||||
"Main title transliteration",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::sub_title_transliteration,
|
||||
"Sub title transliteration",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::artist_transliteration,
|
||||
"Artist transliteration",
|
||||
true, EditMode_Practice, true, true, 0, NULL ),
|
||||
true, EditMode_Practice, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::last_second_hint,
|
||||
"Last second hint",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::preview_start,
|
||||
"Preview Start",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::preview_length,
|
||||
"Preview Length",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::display_bpm,
|
||||
"Display BPM",
|
||||
true, EditMode_Full, true, true, 0, "Actual", "Specified", "Random" ),
|
||||
MenuRowDef(ScreenEdit::min_bpm,
|
||||
"Min BPM",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::max_bpm,
|
||||
"Max BPM",
|
||||
true, EditMode_Full, true, true, 0, NULL )
|
||||
true, EditMode_Full, true, true, 0, nullptr )
|
||||
);
|
||||
|
||||
|
||||
@@ -817,55 +817,55 @@ static MenuDef g_TimingDataInformation(
|
||||
"ScreenMiniMenuTimingDataInformation",
|
||||
MenuRowDef(ScreenEdit::beat_0_offset,
|
||||
"Beat 0 Offset",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::bpm,
|
||||
"Edit BPM change",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::stop,
|
||||
"Edit stop",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::delay,
|
||||
"Edit delay",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::time_signature,
|
||||
"Edit time signature",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::label,
|
||||
"Edit label",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::tickcount,
|
||||
"Edit tickcount",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::combo,
|
||||
"Edit combo",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::warp,
|
||||
"Edit warp",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::speed_percent,
|
||||
"Edit speed (percent)",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::speed_wait,
|
||||
"Edit speed (wait)",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::speed_mode,
|
||||
"Edit speed (mode)",
|
||||
true, EditMode_Full, true, true, 0, "Beats", "Seconds" ),
|
||||
MenuRowDef(ScreenEdit::scroll,
|
||||
"Edit scrolling factor",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::fake,
|
||||
"Edit fake",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::copy_full_timing,
|
||||
"Copy timing data",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::paste_full_timing,
|
||||
"Paste timing data",
|
||||
true, EditMode_Full, true, true, 0, NULL ),
|
||||
true, EditMode_Full, true, true, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::erase_step_timing,
|
||||
"Erase step timing",
|
||||
true, EditMode_Full, true, true, 0, NULL )
|
||||
true, EditMode_Full, true, true, 0, nullptr )
|
||||
);
|
||||
|
||||
// XXX: What are these enums used for?
|
||||
@@ -911,11 +911,11 @@ static MenuDef g_BackgroundChange(
|
||||
MenuRowDef(ScreenEdit::transition,
|
||||
"Force Transition",
|
||||
true,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::effect,
|
||||
"Force Effect",
|
||||
true,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::color1,
|
||||
"Force Color 1",
|
||||
true,
|
||||
@@ -936,31 +936,31 @@ static MenuDef g_BackgroundChange(
|
||||
MenuRowDef(ScreenEdit::file1_song_bganimation,
|
||||
"File1 Song BGAnimation",
|
||||
EnabledIfSet1SongBGAnimation,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file1_song_movie,
|
||||
"File1 Song Movie",
|
||||
EnabledIfSet1SongMovie,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file1_song_still,
|
||||
"File1 Song Still",
|
||||
EnabledIfSet1SongBitmap,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file1_global_bganimation,
|
||||
"File1 Global BGAnimation",
|
||||
EnabledIfSet1GlobalBGAnimation,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file1_global_movie,
|
||||
"File1 Global Movie",
|
||||
EnabledIfSet1GlobalMovie,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file1_global_movie_song_group,
|
||||
"File1 Global Movie (Group)",
|
||||
EnabledIfSet1GlobalMovieSongGroup,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file1_global_movie_song_group_and_genre,
|
||||
"File1 Global Movie (Group + Genre)",
|
||||
EnabledIfSet1GlobalMovieSongGroupAndGenre,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_type,
|
||||
"File2 Type",
|
||||
true,
|
||||
@@ -971,35 +971,35 @@ static MenuDef g_BackgroundChange(
|
||||
MenuRowDef(ScreenEdit::file2_song_bganimation,
|
||||
"File2 Song BGAnimation",
|
||||
EnabledIfSet2SongBGAnimation,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_song_movie,
|
||||
"File2 Song Movie",
|
||||
EnabledIfSet2SongMovie,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_song_still,
|
||||
"File2 Song Still",
|
||||
EnabledIfSet2SongBitmap,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_global_bganimation,
|
||||
"File2 Global BGAnimation",
|
||||
EnabledIfSet2GlobalBGAnimation,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_global_movie,
|
||||
"File2 Global Movie",
|
||||
EnabledIfSet2GlobalMovie,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_global_movie_song_group,
|
||||
"File2 Global Movie (Group)",
|
||||
EnabledIfSet2GlobalMovieSongGroup,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::file2_global_movie_song_group_and_genre,
|
||||
"File2 Global Movie (Group + Genre)",
|
||||
EnabledIfSet2GlobalMovieSongGroupAndGenre,
|
||||
EditMode_Full, true, false, 0, NULL ),
|
||||
EditMode_Full, true, false, 0, nullptr ),
|
||||
MenuRowDef(ScreenEdit::delete_change,
|
||||
"Remove Change",
|
||||
true,
|
||||
EditMode_Full, true, true, 0, NULL )
|
||||
EditMode_Full, true, true, 0, nullptr )
|
||||
);
|
||||
static bool EnabledIfSet1SongBGAnimation() { return ScreenMiniMenu::s_viLastAnswers[ScreenEdit::file1_type] == song_bganimation && !g_BackgroundChange.rows[ScreenEdit::file1_song_bganimation].choices.empty(); }
|
||||
static bool EnabledIfSet1SongMovie() { return ScreenMiniMenu::s_viLastAnswers[ScreenEdit::file1_type] == song_movie && !g_BackgroundChange.rows[ScreenEdit::file1_song_movie].choices.empty(); }
|
||||
@@ -1067,7 +1067,7 @@ static MenuDef g_InsertStepAttack(
|
||||
|
||||
static MenuDef g_CourseMode(
|
||||
"ScreenMiniMenuCourseDisplay",
|
||||
MenuRowDef( -1, "Play mods from course", true, EditMode_Practice, true, false, 0, NULL )
|
||||
MenuRowDef( -1, "Play mods from course", true, EditMode_Practice, true, false, 0, nullptr )
|
||||
);
|
||||
|
||||
// HACK: need to remember the track we're inserting on so that we can lay the
|
||||
@@ -1218,7 +1218,7 @@ void ScreenEdit::Init()
|
||||
|
||||
m_bDirty = m_NoteDataEdit.IsEmpty(); // require the usage of saving if empty.
|
||||
|
||||
m_Player->Init( "Player", GAMESTATE->m_pPlayerState[PLAYER_1], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
m_Player->Init( "Player", GAMESTATE->m_pPlayerState[PLAYER_1], nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr );
|
||||
m_Player->CacheAllUsedNoteSkins();
|
||||
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerController = PC_HUMAN;
|
||||
m_Player->SetXY( PLAYER_X, PLAYER_Y );
|
||||
@@ -5127,7 +5127,7 @@ void ScreenEdit::HandleStepsInformationChoice( StepsInformationChoice c, const v
|
||||
ScreenTextEntry::TextEntry(SM_None, ENTER_MIN_BPM,
|
||||
FloatToString(pSteps->GetMinBPM()), 20,
|
||||
ScreenTextEntry::FloatValidate,
|
||||
ChangeStepsMinBPM, NULL);
|
||||
ChangeStepsMinBPM, nullptr);
|
||||
break;
|
||||
}
|
||||
case step_max_bpm:
|
||||
@@ -5135,7 +5135,7 @@ void ScreenEdit::HandleStepsInformationChoice( StepsInformationChoice c, const v
|
||||
ScreenTextEntry::TextEntry(SM_None, ENTER_MAX_BPM,
|
||||
FloatToString(pSteps->GetMaxBPM()), 20,
|
||||
ScreenTextEntry::FloatValidate,
|
||||
ChangeStepsMaxBPM, NULL);
|
||||
ChangeStepsMaxBPM, nullptr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -5163,53 +5163,53 @@ void ScreenEdit::HandleSongInformationChoice( SongInformationChoice c, const vec
|
||||
switch( c )
|
||||
{
|
||||
case main_title:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_MAIN_TITLE, pSong->m_sMainTitle, 100, NULL, ChangeMainTitle, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_MAIN_TITLE, pSong->m_sMainTitle, 100, nullptr, ChangeMainTitle, nullptr );
|
||||
break;
|
||||
case sub_title:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_SUB_TITLE, pSong->m_sSubTitle, 100, NULL, ChangeSubTitle, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_SUB_TITLE, pSong->m_sSubTitle, 100, nullptr, ChangeSubTitle, nullptr );
|
||||
break;
|
||||
case artist:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_ARTIST, pSong->m_sArtist, 100, NULL, ChangeArtist, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_ARTIST, pSong->m_sArtist, 100, nullptr, ChangeArtist, nullptr );
|
||||
break;
|
||||
case genre:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_GENRE, pSong->m_sGenre, 100, NULL, ChangeGenre, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_GENRE, pSong->m_sGenre, 100, nullptr, ChangeGenre, nullptr );
|
||||
break;
|
||||
case credit:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_CREDIT, pSong->m_sCredit, 100, NULL, ChangeCredit, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_CREDIT, pSong->m_sCredit, 100, nullptr, ChangeCredit, nullptr );
|
||||
break;
|
||||
case main_title_transliteration:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_MAIN_TITLE_TRANSLIT, pSong->m_sMainTitleTranslit, 100, NULL, ChangeMainTitleTranslit, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_MAIN_TITLE_TRANSLIT, pSong->m_sMainTitleTranslit, 100, nullptr, ChangeMainTitleTranslit, nullptr );
|
||||
break;
|
||||
case sub_title_transliteration:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_SUB_TITLE_TRANSLIT, pSong->m_sSubTitleTranslit, 100, NULL, ChangeSubTitleTranslit, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_SUB_TITLE_TRANSLIT, pSong->m_sSubTitleTranslit, 100, nullptr, ChangeSubTitleTranslit, nullptr );
|
||||
break;
|
||||
case artist_transliteration:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_ARTIST_TRANSLIT, pSong->m_sArtistTranslit, 100, NULL, ChangeArtistTranslit, NULL );
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_ARTIST_TRANSLIT, pSong->m_sArtistTranslit, 100, nullptr, ChangeArtistTranslit, nullptr );
|
||||
break;
|
||||
case last_second_hint:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_LAST_SECOND_HINT,
|
||||
FloatToString(pSong->GetSpecifiedLastSecond()), 20,
|
||||
ScreenTextEntry::FloatValidate, ChangeLastSecondHint, NULL );
|
||||
ScreenTextEntry::FloatValidate, ChangeLastSecondHint, nullptr );
|
||||
break;
|
||||
case preview_start:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_PREVIEW_START,
|
||||
FloatToString(pSong->m_fMusicSampleStartSeconds), 20,
|
||||
ScreenTextEntry::FloatValidate, ChangePreviewStart, NULL );
|
||||
ScreenTextEntry::FloatValidate, ChangePreviewStart, nullptr );
|
||||
break;
|
||||
case preview_length:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_PREVIEW_LENGTH,
|
||||
FloatToString(pSong->m_fMusicSampleLengthSeconds), 20,
|
||||
ScreenTextEntry::FloatValidate, ChangePreviewLength, NULL );
|
||||
ScreenTextEntry::FloatValidate, ChangePreviewLength, nullptr );
|
||||
break;
|
||||
case min_bpm:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_MIN_BPM,
|
||||
FloatToString(pSong->m_fSpecifiedBPMMin), 20,
|
||||
ScreenTextEntry::FloatValidate, ChangeMinBPM, NULL );
|
||||
ScreenTextEntry::FloatValidate, ChangeMinBPM, nullptr );
|
||||
break;
|
||||
case max_bpm:
|
||||
ScreenTextEntry::TextEntry( SM_None, ENTER_MAX_BPM,
|
||||
FloatToString(pSong->m_fSpecifiedBPMMax), 20,
|
||||
ScreenTextEntry::FloatValidate, ChangeMaxBPM, NULL );
|
||||
ScreenTextEntry::FloatValidate, ChangeMaxBPM, nullptr );
|
||||
break;
|
||||
default: break;
|
||||
};
|
||||
|
||||
@@ -362,7 +362,7 @@ void ScreenInstallOverlay::Update( float fDeltaTime )
|
||||
}
|
||||
|
||||
if( playAfterLaunchInfo.bAnySongChanged )
|
||||
SONGMAN->Reload( false, NULL );
|
||||
SONGMAN->Reload( false, nullptr );
|
||||
|
||||
if( !playAfterLaunchInfo.sSongDir.empty() )
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ void ScreenNetSelectMusic::Init()
|
||||
m_DC[p] = GAMESTATE->m_PreferredDifficulty[p];
|
||||
|
||||
m_StepsDisplays[p].SetName( ssprintf("StepsDisplayP%d",p+1) );
|
||||
m_StepsDisplays[p].Load( "StepsDisplayNet", NULL );
|
||||
m_StepsDisplays[p].Load( "StepsDisplayNet", nullptr );
|
||||
LOAD_ALL_COMMANDS_AND_SET_XY( m_StepsDisplays[p] );
|
||||
this->AddChild( &m_StepsDisplays[p] );
|
||||
}
|
||||
@@ -475,7 +475,7 @@ void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn )
|
||||
if( GAMESTATE->m_pCurSong == nullptr )
|
||||
{
|
||||
m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid );
|
||||
//m_DifficultyIcon[pn].SetFromSteps( pn, NULL ); // It will blank it out
|
||||
//m_DifficultyIcon[pn].SetFromSteps( pn, nullptr ); // It will blank it out
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ void ScreenNetSelectMusic::MusicChanged()
|
||||
|
||||
SOUND->StopMusic();
|
||||
// todo: handle playing section music correctly. -aj
|
||||
// SOUND->PlayMusic( m_sSectionMusicPath, NULL, true, 0, -1 );
|
||||
// SOUND->PlayMusic( m_sSectionMusicPath, nullptr, true, 0, -1 );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ static bool CurrentCourseIsSaved()
|
||||
|
||||
static const MenuRowDef g_MenuRows[] =
|
||||
{
|
||||
MenuRowDef( -1, "Play", true, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Edit Course", true, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Shuffle", true, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Rename", CurrentCourseIsSaved, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Delete", CurrentCourseIsSaved, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Save", true, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Play", true, EditMode_Practice, true, false, 0, nullptr ),
|
||||
MenuRowDef( -1, "Edit Course", true, EditMode_Practice, true, false, 0, nullptr ),
|
||||
MenuRowDef( -1, "Shuffle", true, EditMode_Practice, true, false, 0, nullptr ),
|
||||
MenuRowDef( -1, "Rename", CurrentCourseIsSaved, EditMode_Practice, true, false, 0, nullptr ),
|
||||
MenuRowDef( -1, "Delete", CurrentCourseIsSaved, EditMode_Practice, true, false, 0, nullptr ),
|
||||
MenuRowDef( -1, "Save", true, EditMode_Practice, true, false, 0, nullptr ),
|
||||
};
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenOptionsCourseOverview );
|
||||
|
||||
@@ -152,7 +152,7 @@ void ScreenOptionsEditCourse::Init()
|
||||
|
||||
const MenuRowDef g_MenuRows[] =
|
||||
{
|
||||
MenuRowDef( -1, "Max Minutes", true, EditMode_Practice, true, false, 0, NULL ),
|
||||
MenuRowDef( -1, "Max Minutes", true, EditMode_Practice, true, false, 0, nullptr ),
|
||||
};
|
||||
|
||||
static LocalizedString EMPTY ("ScreenOptionsEditCourse","-Empty-");
|
||||
|
||||
+252
-252
@@ -1,252 +1,252 @@
|
||||
#include "global.h"
|
||||
#if !defined(WITHOUT_NETWORKING)
|
||||
#include "ScreenSMOnlineLogin.h"
|
||||
#include "RageLog.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "GameSoundManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "ScreenTextEntry.h"
|
||||
#include "ScreenPrompt.h"
|
||||
#include "GameState.h"
|
||||
#include "NetworkSyncManager.h"
|
||||
#include "Profile.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "OptionRowHandler.h"
|
||||
|
||||
REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin);
|
||||
|
||||
AutoScreenMessage( SM_SMOnlinePack );
|
||||
AutoScreenMessage( SM_PasswordDone );
|
||||
AutoScreenMessage( SM_NoProfilesDefined );
|
||||
|
||||
static LocalizedString DEFINE_A_PROFILE( "ScreenSMOnlineLogin", "You must define a Profile." );
|
||||
void ScreenSMOnlineLogin::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
m_iPlayer = 0;
|
||||
|
||||
vector<OptionRowHandler*> vHands;
|
||||
|
||||
OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull();
|
||||
|
||||
pHand->m_Def.m_sName = "Profile";
|
||||
pHand->m_Def.m_bOneChoiceForAllPlayers = false;
|
||||
pHand->m_Def.m_bAllowThemeItems = false;
|
||||
pHand->m_Def.m_vEnabledForPlayers.clear();
|
||||
|
||||
FOREACH_PlayerNumber( pn )
|
||||
pHand->m_Def.m_vEnabledForPlayers.insert( pn );
|
||||
|
||||
PROFILEMAN->GetLocalProfileDisplayNames( pHand->m_Def.m_vsChoices );
|
||||
|
||||
if( pHand->m_Def.m_vsChoices.empty() )
|
||||
{
|
||||
// Give myself a message so that I can bail out later
|
||||
PostScreenMessage(SM_NoProfilesDefined, 0);
|
||||
SAFE_DELETE(pHand);
|
||||
}
|
||||
else
|
||||
vHands.push_back( pHand );
|
||||
|
||||
InitMenu( vHands );
|
||||
SOUND->PlayMusic( THEME->GetPathS("ScreenOptionsServiceChild", "music"));
|
||||
OptionRow &row = *m_pRows.back();
|
||||
row.SetExitText("Login");
|
||||
}
|
||||
|
||||
void ScreenSMOnlineLogin::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
switch( iRow )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
vector<RString> vsProfiles;
|
||||
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
|
||||
|
||||
FOREACH_PlayerNumber( pn )
|
||||
{
|
||||
vector<RString>::iterator iter = find(vsProfiles.begin(), vsProfiles.end(), ProfileManager::m_sDefaultLocalProfileID[pn].Get() );
|
||||
if( iter != vsProfiles.end() )
|
||||
m_pRows[0]->SetOneSelection((PlayerNumber) pn, iter - vsProfiles.begin());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSMOnlineLogin::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
switch( iRow )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
vector<RString> vsProfiles;
|
||||
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
|
||||
|
||||
FOREACH_EnabledPlayer( pn )
|
||||
ProfileManager::m_sDefaultLocalProfileID[pn].Set( vsProfiles[m_pRows[0]->GetOneSelection(pn)] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static LocalizedString UNIQUE_PROFILE ( "ScreenSMOnlineLogin", "Each player needs a unique Profile." );
|
||||
static LocalizedString YOU_ARE_LOGGING_ON_AS ( "ScreenSMOnlineLogin", "You are logging on as:" );
|
||||
static LocalizedString ENTER_YOUR_PASSWORD ( "ScreenSMOnlineLogin", "Enter your password." );
|
||||
|
||||
void ScreenSMOnlineLogin::HandleScreenMessage(const ScreenMessage SM)
|
||||
{
|
||||
RString sLoginQuestion;
|
||||
// if( GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer) )
|
||||
|
||||
if( SM == SM_PasswordDone )
|
||||
{
|
||||
if(!ScreenTextEntry::s_bCancelledLast)
|
||||
SendLogin(ScreenTextEntry::s_sLastAnswer);
|
||||
else
|
||||
SCREENMAN->PostMessageToTopScreen( SM_GoToPrevScreen, 0 );
|
||||
}
|
||||
else if( SM == SM_NoProfilesDefined )
|
||||
{
|
||||
SCREENMAN->SystemMessage(DEFINE_A_PROFILE);
|
||||
SCREENMAN->SetNewScreen("ScreenOptionsManageProfiles");
|
||||
}
|
||||
else if( SM == SM_SMOnlinePack )
|
||||
{
|
||||
LOG->Trace("[ScreenSMOnlineLogin::HandleScreenMessage] SMOnlinePack");
|
||||
if(!GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer))
|
||||
{
|
||||
LOG->Warn("Invalid player number: %i", m_iPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
// This can cause problems in certain situations -aj
|
||||
sLoginQuestion = YOU_ARE_LOGGING_ON_AS.GetValue() + "\n"
|
||||
+ GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n" +
|
||||
ENTER_YOUR_PASSWORD.GetValue();
|
||||
int ResponseCode = NSMAN->m_SMOnlinePacket.Read1();
|
||||
if (ResponseCode == 0)
|
||||
{
|
||||
int Status = NSMAN->m_SMOnlinePacket.Read1();
|
||||
if(Status == 0)
|
||||
{
|
||||
NSMAN->isSMOLoggedIn[m_iPlayer] = true;
|
||||
m_iPlayer++;
|
||||
if( GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer) && m_iPlayer < NUM_PLAYERS )
|
||||
{
|
||||
ScreenTextEntry::Password(SM_PasswordDone, sLoginQuestion, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName,"NextScreen") );
|
||||
m_iPlayer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RString Response = NSMAN->m_SMOnlinePacket.ReadNT();
|
||||
ScreenTextEntry::Password( SM_PasswordDone, Response + "\n\n" + sLoginQuestion, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
LOG->Trace("[ScreenSMOnlineLogin::HandleScreenMessage] GoToNextScreen");
|
||||
vector<PlayerNumber> v;
|
||||
v.push_back( GAMESTATE->GetMasterPlayerNumber() );
|
||||
for( unsigned r=0; r<m_pRows.size(); r++ )
|
||||
ExportOptions( r, v );
|
||||
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
FOREACH_EnabledPlayer(pn)
|
||||
{
|
||||
PROFILEMAN->LoadLocalProfileFromMachine((PlayerNumber) pn);
|
||||
}
|
||||
|
||||
if(GAMESTATE->IsPlayerEnabled((PlayerNumber) 0) && GAMESTATE->IsPlayerEnabled((PlayerNumber) 1) &&
|
||||
(GAMESTATE->GetPlayerDisplayName((PlayerNumber) 0) == GAMESTATE->GetPlayerDisplayName((PlayerNumber) 1)))
|
||||
{
|
||||
SCREENMAN->SystemMessage( UNIQUE_PROFILE );
|
||||
SCREENMAN->SetNewScreen("ScreenSMOnlineLogin");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iPlayer=0;
|
||||
while(!GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer))
|
||||
++m_iPlayer;
|
||||
sLoginQuestion = YOU_ARE_LOGGING_ON_AS.GetValue() + "\n" + GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n" + ENTER_YOUR_PASSWORD.GetValue();
|
||||
ScreenTextEntry::Password(SM_PasswordDone, sLoginQuestion, NULL );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenOptions::HandleScreenMessage(SM);
|
||||
}
|
||||
|
||||
bool ScreenSMOnlineLogin::MenuStart( const InputEventPlus &input )
|
||||
{
|
||||
return ScreenOptions::MenuStart( input );
|
||||
}
|
||||
|
||||
RString ScreenSMOnlineLogin::GetSelectedProfileID()
|
||||
{
|
||||
vector<RString> vsProfiles;
|
||||
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
|
||||
|
||||
const OptionRow &row = *m_pRows[GetCurrentRow()];
|
||||
const int Selection = row.GetOneSharedSelection();
|
||||
if( !Selection )
|
||||
return RString();
|
||||
return vsProfiles[ Selection-1 ];
|
||||
}
|
||||
|
||||
void ScreenSMOnlineLogin::SendLogin( RString sPassword )
|
||||
{
|
||||
RString PlayerName = GAMESTATE->GetPlayerDisplayName( (PlayerNumber) m_iPlayer );
|
||||
|
||||
RString HashedName = NSMAN->MD5Hex( sPassword );
|
||||
|
||||
int authMethod = 0;
|
||||
if ( NSMAN->GetSMOnlineSalt() != 0 )
|
||||
{
|
||||
authMethod = 1;
|
||||
HashedName = NSMAN->MD5Hex( HashedName + ssprintf("%d", NSMAN->GetSMOnlineSalt()) );
|
||||
}
|
||||
|
||||
NSMAN->m_SMOnlinePacket.ClearPacket();
|
||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)0 ); //Login command
|
||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)m_iPlayer ); //Player
|
||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)authMethod ); //MD5 hash style
|
||||
NSMAN->m_SMOnlinePacket.WriteNT( PlayerName );
|
||||
NSMAN->m_SMOnlinePacket.WriteNT( HashedName );
|
||||
NSMAN->SendSMOnline();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2004-2005 Charles Lohr, Adam Lowman
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
#if !defined(WITHOUT_NETWORKING)
|
||||
#include "ScreenSMOnlineLogin.h"
|
||||
#include "RageLog.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "GameSoundManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "ScreenTextEntry.h"
|
||||
#include "ScreenPrompt.h"
|
||||
#include "GameState.h"
|
||||
#include "NetworkSyncManager.h"
|
||||
#include "Profile.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "OptionRowHandler.h"
|
||||
|
||||
REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin);
|
||||
|
||||
AutoScreenMessage( SM_SMOnlinePack );
|
||||
AutoScreenMessage( SM_PasswordDone );
|
||||
AutoScreenMessage( SM_NoProfilesDefined );
|
||||
|
||||
static LocalizedString DEFINE_A_PROFILE( "ScreenSMOnlineLogin", "You must define a Profile." );
|
||||
void ScreenSMOnlineLogin::Init()
|
||||
{
|
||||
ScreenOptions::Init();
|
||||
m_iPlayer = 0;
|
||||
|
||||
vector<OptionRowHandler*> vHands;
|
||||
|
||||
OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull();
|
||||
|
||||
pHand->m_Def.m_sName = "Profile";
|
||||
pHand->m_Def.m_bOneChoiceForAllPlayers = false;
|
||||
pHand->m_Def.m_bAllowThemeItems = false;
|
||||
pHand->m_Def.m_vEnabledForPlayers.clear();
|
||||
|
||||
FOREACH_PlayerNumber( pn )
|
||||
pHand->m_Def.m_vEnabledForPlayers.insert( pn );
|
||||
|
||||
PROFILEMAN->GetLocalProfileDisplayNames( pHand->m_Def.m_vsChoices );
|
||||
|
||||
if( pHand->m_Def.m_vsChoices.empty() )
|
||||
{
|
||||
// Give myself a message so that I can bail out later
|
||||
PostScreenMessage(SM_NoProfilesDefined, 0);
|
||||
SAFE_DELETE(pHand);
|
||||
}
|
||||
else
|
||||
vHands.push_back( pHand );
|
||||
|
||||
InitMenu( vHands );
|
||||
SOUND->PlayMusic( THEME->GetPathS("ScreenOptionsServiceChild", "music"));
|
||||
OptionRow &row = *m_pRows.back();
|
||||
row.SetExitText("Login");
|
||||
}
|
||||
|
||||
void ScreenSMOnlineLogin::ImportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
switch( iRow )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
vector<RString> vsProfiles;
|
||||
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
|
||||
|
||||
FOREACH_PlayerNumber( pn )
|
||||
{
|
||||
vector<RString>::iterator iter = find(vsProfiles.begin(), vsProfiles.end(), ProfileManager::m_sDefaultLocalProfileID[pn].Get() );
|
||||
if( iter != vsProfiles.end() )
|
||||
m_pRows[0]->SetOneSelection((PlayerNumber) pn, iter - vsProfiles.begin());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSMOnlineLogin::ExportOptions( int iRow, const vector<PlayerNumber> &vpns )
|
||||
{
|
||||
switch( iRow )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
vector<RString> vsProfiles;
|
||||
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
|
||||
|
||||
FOREACH_EnabledPlayer( pn )
|
||||
ProfileManager::m_sDefaultLocalProfileID[pn].Set( vsProfiles[m_pRows[0]->GetOneSelection(pn)] );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static LocalizedString UNIQUE_PROFILE ( "ScreenSMOnlineLogin", "Each player needs a unique Profile." );
|
||||
static LocalizedString YOU_ARE_LOGGING_ON_AS ( "ScreenSMOnlineLogin", "You are logging on as:" );
|
||||
static LocalizedString ENTER_YOUR_PASSWORD ( "ScreenSMOnlineLogin", "Enter your password." );
|
||||
|
||||
void ScreenSMOnlineLogin::HandleScreenMessage(const ScreenMessage SM)
|
||||
{
|
||||
RString sLoginQuestion;
|
||||
// if( GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer) )
|
||||
|
||||
if( SM == SM_PasswordDone )
|
||||
{
|
||||
if(!ScreenTextEntry::s_bCancelledLast)
|
||||
SendLogin(ScreenTextEntry::s_sLastAnswer);
|
||||
else
|
||||
SCREENMAN->PostMessageToTopScreen( SM_GoToPrevScreen, 0 );
|
||||
}
|
||||
else if( SM == SM_NoProfilesDefined )
|
||||
{
|
||||
SCREENMAN->SystemMessage(DEFINE_A_PROFILE);
|
||||
SCREENMAN->SetNewScreen("ScreenOptionsManageProfiles");
|
||||
}
|
||||
else if( SM == SM_SMOnlinePack )
|
||||
{
|
||||
LOG->Trace("[ScreenSMOnlineLogin::HandleScreenMessage] SMOnlinePack");
|
||||
if(!GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer))
|
||||
{
|
||||
LOG->Warn("Invalid player number: %i", m_iPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
// This can cause problems in certain situations -aj
|
||||
sLoginQuestion = YOU_ARE_LOGGING_ON_AS.GetValue() + "\n"
|
||||
+ GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n" +
|
||||
ENTER_YOUR_PASSWORD.GetValue();
|
||||
int ResponseCode = NSMAN->m_SMOnlinePacket.Read1();
|
||||
if (ResponseCode == 0)
|
||||
{
|
||||
int Status = NSMAN->m_SMOnlinePacket.Read1();
|
||||
if(Status == 0)
|
||||
{
|
||||
NSMAN->isSMOLoggedIn[m_iPlayer] = true;
|
||||
m_iPlayer++;
|
||||
if( GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer) && m_iPlayer < NUM_PLAYERS )
|
||||
{
|
||||
ScreenTextEntry::Password(SM_PasswordDone, sLoginQuestion, nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName,"NextScreen") );
|
||||
m_iPlayer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RString Response = NSMAN->m_SMOnlinePacket.ReadNT();
|
||||
ScreenTextEntry::Password( SM_PasswordDone, Response + "\n\n" + sLoginQuestion, nullptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( SM == SM_GoToNextScreen )
|
||||
{
|
||||
LOG->Trace("[ScreenSMOnlineLogin::HandleScreenMessage] GoToNextScreen");
|
||||
vector<PlayerNumber> v;
|
||||
v.push_back( GAMESTATE->GetMasterPlayerNumber() );
|
||||
for( unsigned r=0; r<m_pRows.size(); r++ )
|
||||
ExportOptions( r, v );
|
||||
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
FOREACH_EnabledPlayer(pn)
|
||||
{
|
||||
PROFILEMAN->LoadLocalProfileFromMachine((PlayerNumber) pn);
|
||||
}
|
||||
|
||||
if(GAMESTATE->IsPlayerEnabled((PlayerNumber) 0) && GAMESTATE->IsPlayerEnabled((PlayerNumber) 1) &&
|
||||
(GAMESTATE->GetPlayerDisplayName((PlayerNumber) 0) == GAMESTATE->GetPlayerDisplayName((PlayerNumber) 1)))
|
||||
{
|
||||
SCREENMAN->SystemMessage( UNIQUE_PROFILE );
|
||||
SCREENMAN->SetNewScreen("ScreenSMOnlineLogin");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iPlayer=0;
|
||||
while(!GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer))
|
||||
++m_iPlayer;
|
||||
sLoginQuestion = YOU_ARE_LOGGING_ON_AS.GetValue() + "\n" + GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n" + ENTER_YOUR_PASSWORD.GetValue();
|
||||
ScreenTextEntry::Password(SM_PasswordDone, sLoginQuestion, nullptr );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenOptions::HandleScreenMessage(SM);
|
||||
}
|
||||
|
||||
bool ScreenSMOnlineLogin::MenuStart( const InputEventPlus &input )
|
||||
{
|
||||
return ScreenOptions::MenuStart( input );
|
||||
}
|
||||
|
||||
RString ScreenSMOnlineLogin::GetSelectedProfileID()
|
||||
{
|
||||
vector<RString> vsProfiles;
|
||||
PROFILEMAN->GetLocalProfileIDs( vsProfiles );
|
||||
|
||||
const OptionRow &row = *m_pRows[GetCurrentRow()];
|
||||
const int Selection = row.GetOneSharedSelection();
|
||||
if( !Selection )
|
||||
return RString();
|
||||
return vsProfiles[ Selection-1 ];
|
||||
}
|
||||
|
||||
void ScreenSMOnlineLogin::SendLogin( RString sPassword )
|
||||
{
|
||||
RString PlayerName = GAMESTATE->GetPlayerDisplayName( (PlayerNumber) m_iPlayer );
|
||||
|
||||
RString HashedName = NSMAN->MD5Hex( sPassword );
|
||||
|
||||
int authMethod = 0;
|
||||
if ( NSMAN->GetSMOnlineSalt() != 0 )
|
||||
{
|
||||
authMethod = 1;
|
||||
HashedName = NSMAN->MD5Hex( HashedName + ssprintf("%d", NSMAN->GetSMOnlineSalt()) );
|
||||
}
|
||||
|
||||
NSMAN->m_SMOnlinePacket.ClearPacket();
|
||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)0 ); //Login command
|
||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)m_iPlayer ); //Player
|
||||
NSMAN->m_SMOnlinePacket.Write1( (uint8_t)authMethod ); //MD5 hash style
|
||||
NSMAN->m_SMOnlinePacket.WriteNT( PlayerName );
|
||||
NSMAN->m_SMOnlinePacket.WriteNT( HashedName );
|
||||
NSMAN->SendSMOnline();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2004-2005 Charles Lohr, Adam Lowman
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
+177
-177
@@ -1,177 +1,177 @@
|
||||
#include "global.h"
|
||||
#include "ScreenSystemLayer.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "GameState.h"
|
||||
#include "MemoryCardManager.h"
|
||||
#include "Profile.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "PlayerState.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
LocalizedString CREDITS_PRESS_START("ScreenSystemLayer","CreditsPressStart");
|
||||
LocalizedString CREDITS_INSERT_CARD("ScreenSystemLayer","CreditsInsertCard");
|
||||
LocalizedString CREDITS_CARD_TOO_LATE("ScreenSystemLayer","CreditsCardTooLate");
|
||||
LocalizedString CREDITS_CARD_NO_NAME("ScreenSystemLayer","CreditsCardNoName");
|
||||
LocalizedString CREDITS_CARD_READY("ScreenSystemLayer","CreditsCardReady");
|
||||
LocalizedString CREDITS_CARD_CHECKING("ScreenSystemLayer","CreditsCardChecking");
|
||||
LocalizedString CREDITS_CARD_REMOVED("ScreenSystemLayer","CreditsCardRemoved");
|
||||
LocalizedString CREDITS_FREE_PLAY("ScreenSystemLayer","CreditsFreePlay");
|
||||
LocalizedString CREDITS_CREDITS("ScreenSystemLayer","CreditsCredits");
|
||||
LocalizedString CREDITS_MAX("ScreenSystemLayer","CreditsMax");
|
||||
LocalizedString CREDITS_NOT_PRESENT("ScreenSystemLayer","CreditsNotPresent");
|
||||
LocalizedString CREDITS_LOAD_FAILED("ScreenSystemLayer","CreditsLoadFailed");
|
||||
LocalizedString CREDITS_LOADED_FROM_LAST_GOOD_APPEND("ScreenSystemLayer","CreditsLoadedFromLastGoodAppend");
|
||||
|
||||
ThemeMetric<bool> CREDITS_JOIN_ONLY( "ScreenSystemLayer", "CreditsJoinOnly" );
|
||||
|
||||
RString GetCreditsMessage( PlayerNumber pn )
|
||||
{
|
||||
if( (bool)CREDITS_JOIN_ONLY && !GAMESTATE->PlayersCanJoin() )
|
||||
return RString();
|
||||
|
||||
bool bShowCreditsMessage;
|
||||
if( SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == system_menu )
|
||||
bShowCreditsMessage = true;
|
||||
else if( MEMCARDMAN->GetCardLocked(pn) )
|
||||
bShowCreditsMessage = !GAMESTATE->IsPlayerEnabled( pn );
|
||||
else
|
||||
bShowCreditsMessage = !GAMESTATE->m_bSideIsJoined[pn];
|
||||
|
||||
if( !bShowCreditsMessage )
|
||||
{
|
||||
MemoryCardState mcs = MEMCARDMAN->GetCardState( pn );
|
||||
const Profile* pProfile = PROFILEMAN->GetProfile( pn );
|
||||
switch( mcs )
|
||||
{
|
||||
DEFAULT_FAIL( mcs );
|
||||
case MemoryCardState_NoCard:
|
||||
// this is a local machine profile
|
||||
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
||||
return pProfile->GetDisplayNameOrHighScoreName() + CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
|
||||
else if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) )
|
||||
return CREDITS_LOAD_FAILED.GetValue();
|
||||
// Prefer the name of the profile over the name of the card.
|
||||
else if( PROFILEMAN->IsPersistentProfile(pn) )
|
||||
return pProfile->GetDisplayNameOrHighScoreName();
|
||||
else if( GAMESTATE->PlayersCanJoin() )
|
||||
return CREDITS_INSERT_CARD.GetValue();
|
||||
else
|
||||
return RString();
|
||||
|
||||
case MemoryCardState_Error: return THEME->GetString( "ScreenSystemLayer", "CreditsCard" + MEMCARDMAN->GetCardError(pn) );
|
||||
case MemoryCardState_TooLate: return CREDITS_CARD_TOO_LATE.GetValue();
|
||||
case MemoryCardState_Checking: return CREDITS_CARD_CHECKING.GetValue();
|
||||
case MemoryCardState_Removed: return CREDITS_CARD_REMOVED.GetValue();
|
||||
case MemoryCardState_Ready:
|
||||
{
|
||||
// If the profile failed to load and there was no usable backup...
|
||||
if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) && !PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
||||
return CREDITS_LOAD_FAILED.GetValue();
|
||||
|
||||
// If there is a local profile loaded, prefer it over the name of the memory card.
|
||||
if( PROFILEMAN->IsPersistentProfile(pn) )
|
||||
{
|
||||
RString s = pProfile->GetDisplayNameOrHighScoreName();
|
||||
if( s.empty() )
|
||||
s = CREDITS_CARD_NO_NAME.GetValue();
|
||||
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
||||
s += CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
|
||||
return s;
|
||||
}
|
||||
else if( !MEMCARDMAN->IsNameAvailable(pn) )
|
||||
return CREDITS_CARD_READY.GetValue();
|
||||
else if( !MEMCARDMAN->GetName(pn).empty() )
|
||||
return MEMCARDMAN->GetName(pn);
|
||||
else
|
||||
return CREDITS_CARD_NO_NAME.GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
else // bShowCreditsMessage
|
||||
{
|
||||
CoinMode mode = GAMESTATE->GetCoinMode();
|
||||
switch( mode )
|
||||
{
|
||||
case CoinMode_Home:
|
||||
if( GAMESTATE->PlayersCanJoin() )
|
||||
return CREDITS_PRESS_START.GetValue();
|
||||
else
|
||||
return CREDITS_NOT_PRESENT.GetValue();
|
||||
|
||||
case CoinMode_Free:
|
||||
if( GAMESTATE->PlayersCanJoin() )
|
||||
return CREDITS_FREE_PLAY.GetValue();
|
||||
else
|
||||
return CREDITS_NOT_PRESENT.GetValue();
|
||||
|
||||
default:
|
||||
FAIL_M(ssprintf("Invalid CoinMode: %i", mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
int GetCreditsMessage( lua_State *L )
|
||||
{
|
||||
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
|
||||
RString sText = GetCreditsMessage( pn );
|
||||
LuaHelpers::Push( L, sText );
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg ScreenSystemLayerHelpersTable[] =
|
||||
{
|
||||
LIST_METHOD( GetCreditsMessage ),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
}
|
||||
|
||||
LUA_REGISTER_NAMESPACE( ScreenSystemLayerHelpers )
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenSystemLayer );
|
||||
void ScreenSystemLayer::Init()
|
||||
{
|
||||
Screen::Init();
|
||||
|
||||
m_sprOverlay.Load( THEME->GetPathB("ScreenSystemLayer", "overlay") );
|
||||
this->AddChild( m_sprOverlay );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "ScreenSystemLayer.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "GameState.h"
|
||||
#include "MemoryCardManager.h"
|
||||
#include "Profile.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "PlayerState.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
LocalizedString CREDITS_PRESS_START("ScreenSystemLayer","CreditsPressStart");
|
||||
LocalizedString CREDITS_INSERT_CARD("ScreenSystemLayer","CreditsInsertCard");
|
||||
LocalizedString CREDITS_CARD_TOO_LATE("ScreenSystemLayer","CreditsCardTooLate");
|
||||
LocalizedString CREDITS_CARD_NO_NAME("ScreenSystemLayer","CreditsCardNoName");
|
||||
LocalizedString CREDITS_CARD_READY("ScreenSystemLayer","CreditsCardReady");
|
||||
LocalizedString CREDITS_CARD_CHECKING("ScreenSystemLayer","CreditsCardChecking");
|
||||
LocalizedString CREDITS_CARD_REMOVED("ScreenSystemLayer","CreditsCardRemoved");
|
||||
LocalizedString CREDITS_FREE_PLAY("ScreenSystemLayer","CreditsFreePlay");
|
||||
LocalizedString CREDITS_CREDITS("ScreenSystemLayer","CreditsCredits");
|
||||
LocalizedString CREDITS_MAX("ScreenSystemLayer","CreditsMax");
|
||||
LocalizedString CREDITS_NOT_PRESENT("ScreenSystemLayer","CreditsNotPresent");
|
||||
LocalizedString CREDITS_LOAD_FAILED("ScreenSystemLayer","CreditsLoadFailed");
|
||||
LocalizedString CREDITS_LOADED_FROM_LAST_GOOD_APPEND("ScreenSystemLayer","CreditsLoadedFromLastGoodAppend");
|
||||
|
||||
ThemeMetric<bool> CREDITS_JOIN_ONLY( "ScreenSystemLayer", "CreditsJoinOnly" );
|
||||
|
||||
RString GetCreditsMessage( PlayerNumber pn )
|
||||
{
|
||||
if( (bool)CREDITS_JOIN_ONLY && !GAMESTATE->PlayersCanJoin() )
|
||||
return RString();
|
||||
|
||||
bool bShowCreditsMessage;
|
||||
if( SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == system_menu )
|
||||
bShowCreditsMessage = true;
|
||||
else if( MEMCARDMAN->GetCardLocked(pn) )
|
||||
bShowCreditsMessage = !GAMESTATE->IsPlayerEnabled( pn );
|
||||
else
|
||||
bShowCreditsMessage = !GAMESTATE->m_bSideIsJoined[pn];
|
||||
|
||||
if( !bShowCreditsMessage )
|
||||
{
|
||||
MemoryCardState mcs = MEMCARDMAN->GetCardState( pn );
|
||||
const Profile* pProfile = PROFILEMAN->GetProfile( pn );
|
||||
switch( mcs )
|
||||
{
|
||||
DEFAULT_FAIL( mcs );
|
||||
case MemoryCardState_NoCard:
|
||||
// this is a local machine profile
|
||||
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
||||
return pProfile->GetDisplayNameOrHighScoreName() + CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
|
||||
else if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) )
|
||||
return CREDITS_LOAD_FAILED.GetValue();
|
||||
// Prefer the name of the profile over the name of the card.
|
||||
else if( PROFILEMAN->IsPersistentProfile(pn) )
|
||||
return pProfile->GetDisplayNameOrHighScoreName();
|
||||
else if( GAMESTATE->PlayersCanJoin() )
|
||||
return CREDITS_INSERT_CARD.GetValue();
|
||||
else
|
||||
return RString();
|
||||
|
||||
case MemoryCardState_Error: return THEME->GetString( "ScreenSystemLayer", "CreditsCard" + MEMCARDMAN->GetCardError(pn) );
|
||||
case MemoryCardState_TooLate: return CREDITS_CARD_TOO_LATE.GetValue();
|
||||
case MemoryCardState_Checking: return CREDITS_CARD_CHECKING.GetValue();
|
||||
case MemoryCardState_Removed: return CREDITS_CARD_REMOVED.GetValue();
|
||||
case MemoryCardState_Ready:
|
||||
{
|
||||
// If the profile failed to load and there was no usable backup...
|
||||
if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) && !PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
||||
return CREDITS_LOAD_FAILED.GetValue();
|
||||
|
||||
// If there is a local profile loaded, prefer it over the name of the memory card.
|
||||
if( PROFILEMAN->IsPersistentProfile(pn) )
|
||||
{
|
||||
RString s = pProfile->GetDisplayNameOrHighScoreName();
|
||||
if( s.empty() )
|
||||
s = CREDITS_CARD_NO_NAME.GetValue();
|
||||
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
||||
s += CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
|
||||
return s;
|
||||
}
|
||||
else if( !MEMCARDMAN->IsNameAvailable(pn) )
|
||||
return CREDITS_CARD_READY.GetValue();
|
||||
else if( !MEMCARDMAN->GetName(pn).empty() )
|
||||
return MEMCARDMAN->GetName(pn);
|
||||
else
|
||||
return CREDITS_CARD_NO_NAME.GetValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
else // bShowCreditsMessage
|
||||
{
|
||||
CoinMode mode = GAMESTATE->GetCoinMode();
|
||||
switch( mode )
|
||||
{
|
||||
case CoinMode_Home:
|
||||
if( GAMESTATE->PlayersCanJoin() )
|
||||
return CREDITS_PRESS_START.GetValue();
|
||||
else
|
||||
return CREDITS_NOT_PRESENT.GetValue();
|
||||
|
||||
case CoinMode_Free:
|
||||
if( GAMESTATE->PlayersCanJoin() )
|
||||
return CREDITS_FREE_PLAY.GetValue();
|
||||
else
|
||||
return CREDITS_NOT_PRESENT.GetValue();
|
||||
|
||||
default:
|
||||
FAIL_M(ssprintf("Invalid CoinMode: %i", mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
int GetCreditsMessage( lua_State *L )
|
||||
{
|
||||
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
|
||||
RString sText = GetCreditsMessage( pn );
|
||||
LuaHelpers::Push( L, sText );
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg ScreenSystemLayerHelpersTable[] =
|
||||
{
|
||||
LIST_METHOD( GetCreditsMessage ),
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
LUA_REGISTER_NAMESPACE( ScreenSystemLayerHelpers )
|
||||
|
||||
REGISTER_SCREEN_CLASS( ScreenSystemLayer );
|
||||
void ScreenSystemLayer::Init()
|
||||
{
|
||||
Screen::Init();
|
||||
|
||||
m_sprOverlay.Load( THEME->GetPathB("ScreenSystemLayer", "overlay") );
|
||||
this->AddChild( m_sprOverlay );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
void(*OnOK)(const RString &sPassword) = nullptr,
|
||||
void(*OnCancel)() = nullptr )
|
||||
{
|
||||
TextEntry( smSendOnPop, sQuestion, "", 255, NULL, OnOK, OnCancel, true );
|
||||
TextEntry( smSendOnPop, sQuestion, "", 255, nullptr, OnOK, OnCancel, true );
|
||||
}
|
||||
|
||||
struct TextEntrySettings {
|
||||
|
||||
+3
-3
@@ -763,7 +763,7 @@ bool SongUtil::IsChartNameUnique( const Song* pSong, StepsType st, const RString
|
||||
|
||||
RString SongUtil::MakeUniqueEditDescription( const Song *pSong, StepsType st, const RString &sPreferredDescription )
|
||||
{
|
||||
if( IsEditDescriptionUnique( pSong, st, sPreferredDescription, NULL ) )
|
||||
if( IsEditDescriptionUnique( pSong, st, sPreferredDescription, nullptr ) )
|
||||
return sPreferredDescription;
|
||||
|
||||
RString sTemp;
|
||||
@@ -774,7 +774,7 @@ RString SongUtil::MakeUniqueEditDescription( const Song *pSong, StepsType st, co
|
||||
RString sNum = ssprintf("%d", i+1);
|
||||
sTemp = sPreferredDescription.Left( MAX_STEPS_DESCRIPTION_LENGTH - sNum.size() ) + sNum;
|
||||
|
||||
if( IsEditDescriptionUnique(pSong, st, sTemp, NULL) )
|
||||
if( IsEditDescriptionUnique(pSong, st, sTemp, nullptr) )
|
||||
return sTemp;
|
||||
}
|
||||
|
||||
@@ -1157,7 +1157,7 @@ namespace
|
||||
LIST_METHOD( GetPlayableSteps ),
|
||||
LIST_METHOD( IsStepsTypePlayable ),
|
||||
LIST_METHOD( IsStepsPlayable ),
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ void StepsDisplay::SetFromSteps( const Steps* pSteps )
|
||||
return;
|
||||
}
|
||||
|
||||
SetParams params = { pSteps, NULL, pSteps->GetMeter(), pSteps->m_StepsType, pSteps->GetDifficulty(), CourseType_Invalid };
|
||||
SetParams params = { pSteps, nullptr, pSteps->GetMeter(), pSteps->m_StepsType, pSteps->GetDifficulty(), CourseType_Invalid };
|
||||
SetInternal( params );
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ void StepsDisplay::Unset()
|
||||
|
||||
void StepsDisplay::SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType st, int iMeter, Difficulty dc, CourseType ct )
|
||||
{
|
||||
SetParams params = { NULL, NULL, iMeter, st, dc, ct };
|
||||
SetParams params = { NULL, nullptr, iMeter, st, dc, ct };
|
||||
SetInternal( params );
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ void StepsDisplay::SetInternal( const SetParams ¶ms )
|
||||
class LunaStepsDisplay: public Luna<StepsDisplay>
|
||||
{
|
||||
public:
|
||||
static int Load( T* p, lua_State *L ) { p->Load( SArg(1), NULL ); return 0; }
|
||||
static int Load( T* p, lua_State *L ) { p->Load( SArg(1), nullptr ); return 0; }
|
||||
static int SetFromSteps( T* p, lua_State *L )
|
||||
{
|
||||
if( lua_isnil(L,1) )
|
||||
|
||||
@@ -602,11 +602,11 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_,
|
||||
{
|
||||
// BGAnimations, Fonts, Graphics, Sounds, Other
|
||||
static const char *masks[NUM_ElementCategory][15] = {
|
||||
{ "redir", "lua", "xml", "png", "jpg", "jpeg", "bmp", "gif", "ogv", "avi", "mpg", "mpeg", "txt", "", NULL},
|
||||
{ "redir", "ini", NULL },
|
||||
{ "redir", "lua", "xml", "png", "jpg", "jpeg", "bmp", "gif", "ogv", "avi", "mpg", "mpeg", "txt", "", NULL},
|
||||
{ "redir", "lua", "mp3", "oga", "ogg", "wav", NULL },
|
||||
{ "*", NULL },
|
||||
{ "redir", "lua", "xml", "png", "jpg", "jpeg", "bmp", "gif", "ogv", "avi", "mpg", "mpeg", "txt", "", nullptr},
|
||||
{ "redir", "ini", nullptr },
|
||||
{ "redir", "lua", "xml", "png", "jpg", "jpeg", "bmp", "gif", "ogv", "avi", "mpg", "mpeg", "txt", "", nullptr},
|
||||
{ "redir", "lua", "mp3", "oga", "ogg", "wav", nullptr },
|
||||
{ "*", nullptr },
|
||||
};
|
||||
const char **asset_masks = masks[category];
|
||||
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ public:
|
||||
}
|
||||
ThemeMetric1D()
|
||||
{
|
||||
Load( RString(), NULL, 0 );
|
||||
Load( RString(), nullptr, 0 );
|
||||
}
|
||||
void Load( const RString& sGroup, MetricName1D pfn, size_t N )
|
||||
{
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ namespace
|
||||
{
|
||||
LIST_METHOD( GetNumSongs ),
|
||||
LIST_METHOD( GetTotalSeconds ),
|
||||
{ NULL, NULL }
|
||||
{ NULL, nullptr }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
}
|
||||
|
||||
size_t size;
|
||||
#define GET_PARAM( name, var ) (size = sizeof(var), sysctlbyname(name, &var, &size, NULL, 0) )
|
||||
#define GET_PARAM( name, var ) (size = sizeof(var), sysctlbyname(name, &var, &size, nullptr, 0) )
|
||||
// Get memory
|
||||
float fRam;
|
||||
char ramPower;
|
||||
@@ -285,18 +285,18 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
||||
break;
|
||||
}
|
||||
sModel = szModel;
|
||||
CFURLRef urlRef = CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR("Hardware.plist"), NULL, NULL );
|
||||
CFURLRef urlRef = CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR("Hardware.plist"), nullptr, nullptr );
|
||||
|
||||
if( urlRef == nullptr )
|
||||
break;
|
||||
CFDataRef dataRef = nullptr;
|
||||
SInt32 error;
|
||||
CFURLCreateDataAndPropertiesFromResource( NULL, urlRef, &dataRef, NULL, NULL, &error );
|
||||
CFURLCreateDataAndPropertiesFromResource( NULL, urlRef, &dataRef, nullptr, nullptr, &error );
|
||||
CFRelease( urlRef );
|
||||
if( dataRef == nullptr )
|
||||
break;
|
||||
// This also works with binary property lists for some reason.
|
||||
CFPropertyListRef plRef = CFPropertyListCreateFromXMLData( NULL, dataRef, kCFPropertyListImmutable, NULL );
|
||||
CFPropertyListRef plRef = CFPropertyListCreateFromXMLData( NULL, dataRef, kCFPropertyListImmutable, nullptr );
|
||||
CFRelease( dataRef );
|
||||
if( plRef == nullptr )
|
||||
break;
|
||||
@@ -358,8 +358,8 @@ RString ArchHooks::GetPreferredLanguage()
|
||||
bool ArchHooks_MacOSX::GoToURL( RString sUrl )
|
||||
{
|
||||
CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, (const UInt8*)sUrl.data(),
|
||||
sUrl.length(), kCFStringEncodingUTF8, NULL );
|
||||
OSStatus result = LSOpenCFURLRef( url, NULL );
|
||||
sUrl.length(), kCFStringEncodingUTF8, nullptr );
|
||||
OSStatus result = LSOpenCFURLRef( url, nullptr );
|
||||
|
||||
CFRelease( url );
|
||||
return result == 0;
|
||||
@@ -395,7 +395,7 @@ static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
char dir[PATH_MAX];
|
||||
CFURLRef dataUrl = CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR("StepMania"), CFSTR("smzip"), NULL );
|
||||
CFURLRef dataUrl = CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR("StepMania"), CFSTR("smzip"), nullptr );
|
||||
|
||||
FILEMAN->Mount( "dir", sDirOfExecutable, "/" );
|
||||
|
||||
|
||||
@@ -1,335 +1,335 @@
|
||||
#include "global.h"
|
||||
#include "ArchHooks_Unix.h"
|
||||
#include "ProductInfo.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageThreads.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "archutils/Unix/SignalHandler.h"
|
||||
#include "archutils/Unix/GetSysInfo.h"
|
||||
#include "archutils/Unix/LinuxThreadHelpers.h"
|
||||
#include "archutils/Unix/EmergencyShutdown.h"
|
||||
#include "archutils/Unix/AssertionHandler.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
#include "archutils/Unix/CrashHandler.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FFMPEG)
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool IsFatalSignal( int signal )
|
||||
{
|
||||
switch( signal )
|
||||
{
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
case SIGHUP:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool DoCleanShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
{
|
||||
if( IsFatalSignal(signal) )
|
||||
return false;
|
||||
|
||||
/* ^C. */
|
||||
ArchHooks::SetUserQuit();
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
static bool DoCrashSignalHandler( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
{
|
||||
/* Don't dump a debug file if the user just hit ^C. */
|
||||
if( !IsFatalSignal(signal) )
|
||||
return true;
|
||||
|
||||
CrashHandler::CrashSignalHandler( signal, si, uc );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool EmergencyShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
{
|
||||
if( !IsFatalSignal(signal) )
|
||||
return false;
|
||||
|
||||
DoEmergencyShutdown();
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
/* If we ran the crash handler, then die. */
|
||||
kill( getpid(), SIGKILL );
|
||||
#endif
|
||||
|
||||
/* We didn't run the crash handler. Run the default handler, so we can dump core. */
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_TLS)
|
||||
static thread_local int g_iTestTLS = 0;
|
||||
|
||||
static int TestTLSThread( void *p )
|
||||
{
|
||||
g_iTestTLS = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TestTLS()
|
||||
{
|
||||
#if defined(LINUX)
|
||||
/* TLS won't work on older threads libraries, and may crash. */
|
||||
if( !UsingNPTL() )
|
||||
return;
|
||||
#endif
|
||||
/* TLS won't work on older Linux kernels. Do a simple check. */
|
||||
g_iTestTLS = 1;
|
||||
|
||||
RageThread TestThread;
|
||||
TestThread.SetName( "TestTLS" );
|
||||
TestThread.Create( TestTLSThread, NULL );
|
||||
TestThread.Wait();
|
||||
|
||||
if( g_iTestTLS == 1 )
|
||||
RageThread::SetSupportsTLS( true );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/* If librt is available, use CLOCK_MONOTONIC to implement GetMicrosecondsSinceStart,
|
||||
* if supported, so changes to the system clock don't cause problems. */
|
||||
namespace
|
||||
{
|
||||
clockid_t g_Clock = CLOCK_REALTIME;
|
||||
|
||||
void OpenGetTime()
|
||||
{
|
||||
static bool bInitialized = false;
|
||||
if( bInitialized )
|
||||
return;
|
||||
bInitialized = true;
|
||||
|
||||
/* Check whether the clock is actually supported. */
|
||||
timespec ts;
|
||||
if( clock_getres(CLOCK_MONOTONIC, &ts) == -1 )
|
||||
return;
|
||||
|
||||
/* If the resolution is worse than a millisecond, fall back on CLOCK_REALTIME. */
|
||||
if( ts.tv_sec > 0 || ts.tv_nsec > 1000000 )
|
||||
return;
|
||||
|
||||
g_Clock = CLOCK_MONOTONIC;
|
||||
}
|
||||
};
|
||||
|
||||
clockid_t ArchHooks_Unix::GetClock()
|
||||
{
|
||||
OpenGetTime();
|
||||
return g_Clock;
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
OpenGetTime();
|
||||
|
||||
timespec ts;
|
||||
clock_gettime( g_Clock, &ts );
|
||||
|
||||
int64_t iRet = int64_t(ts.tv_sec) * 1000000 + int64_t(ts.tv_nsec)/1000;
|
||||
if( g_Clock != CLOCK_MONOTONIC )
|
||||
iRet = ArchHooks::FixupTimeIfBackwards( iRet );
|
||||
return iRet;
|
||||
}
|
||||
#else
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
|
||||
int64_t iRet = int64_t(tv.tv_sec) * 1000000 + int64_t(tv.tv_usec);
|
||||
ret = FixupTimeIfBackwards( ret );
|
||||
return iRet;
|
||||
}
|
||||
#endif
|
||||
|
||||
RString ArchHooks::GetPreferredLanguage()
|
||||
{
|
||||
RString locale;
|
||||
|
||||
if(getenv("LANG"))
|
||||
{
|
||||
locale = getenv("LANG");
|
||||
locale = locale.substr(0,2);
|
||||
}
|
||||
else
|
||||
locale = "en";
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
void ArchHooks_Unix::Init()
|
||||
{
|
||||
/* First, handle non-fatal termination signals. */
|
||||
SignalHandler::OnClose( DoCleanShutdown );
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
CrashHandler::CrashHandlerHandleArgs( g_argc, g_argv );
|
||||
CrashHandler::InitializeCrashHandler();
|
||||
SignalHandler::OnClose( DoCrashSignalHandler );
|
||||
#endif
|
||||
|
||||
/* Set up EmergencyShutdown, to try to shut down the window if we crash.
|
||||
* This might blow up, so be sure to do it after the crash handler. */
|
||||
SignalHandler::OnClose( EmergencyShutdown );
|
||||
|
||||
InstallExceptionHandler();
|
||||
|
||||
#if defined(HAVE_TLS) && !defined(BSD)
|
||||
TestTLS();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _CS_GNU_LIBC_VERSION
|
||||
#define _CS_GNU_LIBC_VERSION 2
|
||||
#endif
|
||||
|
||||
static RString LibcVersion()
|
||||
{
|
||||
char buf[1024] = "(error)";
|
||||
int ret = confstr( _CS_GNU_LIBC_VERSION, buf, sizeof(buf) );
|
||||
if( ret == -1 )
|
||||
return "(unknown)";
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void ArchHooks_Unix::DumpDebugInfo()
|
||||
{
|
||||
RString sys;
|
||||
int vers;
|
||||
GetKernel( sys, vers );
|
||||
LOG->Info( "OS: %s ver %06i", sys.c_str(), vers );
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
LOG->Info( "Crash backtrace component: %s", BACKTRACE_METHOD_TEXT );
|
||||
LOG->Info( "Crash lookup component: %s", BACKTRACE_LOOKUP_METHOD_TEXT );
|
||||
#if defined(BACKTRACE_DEMANGLE_METHOD_TEXT)
|
||||
LOG->Info( "Crash demangle component: %s", BACKTRACE_DEMANGLE_METHOD_TEXT );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LOG->Info( "Runtime library: %s", LibcVersion().c_str() );
|
||||
LOG->Info( "Threads library: %s", ThreadsVersion().c_str() );
|
||||
#if defined(HAVE_FFMPEG)
|
||||
LOG->Info( "libavcodec: %#x (%u)", avcodec_version(), avcodec_version() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArchHooks_Unix::SetTime( tm newtime )
|
||||
{
|
||||
RString sCommand = ssprintf( "date %02d%02d%02d%02d%04d.%02d",
|
||||
newtime.tm_mon+1,
|
||||
newtime.tm_mday,
|
||||
newtime.tm_hour,
|
||||
newtime.tm_min,
|
||||
newtime.tm_year+1900,
|
||||
newtime.tm_sec );
|
||||
|
||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
||||
int ret = system( sCommand );
|
||||
if( ret == -1 || ret == 127 || !WIFEXITED(ret) || WEXITSTATUS(ret) )
|
||||
LOG->Trace( "'%s' failed", sCommand.c_str() );
|
||||
|
||||
ret = system( "hwclock --systohc" );
|
||||
if( ret == -1 || ret == 127 || !WIFEXITED(ret) || WEXITSTATUS(ret) )
|
||||
LOG->Trace( "'hwclock --systohc' failed" );
|
||||
}
|
||||
|
||||
#include "RageFileManager.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
static LocalizedString COULDNT_FIND_SONGS( "ArchHooks_Unix", "Couldn't find 'Songs'" );
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
#if defined(UNIX)
|
||||
/* Mount the root filesystem, so we can read files in /proc, /etc, and so on.
|
||||
* This is /rootfs, not /root, to avoid confusion with root's home directory. */
|
||||
FILEMAN->Mount( "dir", "/", "/rootfs" );
|
||||
|
||||
/* Mount /proc, so Alsa9Buf::GetSoundCardDebugInfo() and others can access it.
|
||||
* (Deprecated; use rootfs.) */
|
||||
FILEMAN->Mount( "dir", "/proc", "/proc" );
|
||||
#endif
|
||||
|
||||
RString Root;
|
||||
struct stat st;
|
||||
if( !stat(sDirOfExecutable + "/Packages", &st) && st.st_mode&S_IFDIR )
|
||||
Root = sDirOfExecutable;
|
||||
else if( !stat(sDirOfExecutable + "/Songs", &st) && st.st_mode&S_IFDIR )
|
||||
Root = sDirOfExecutable;
|
||||
else if( !stat(RageFileManagerUtil::sInitialWorkingDirectory + "/Songs", &st) && st.st_mode&S_IFDIR )
|
||||
Root = RageFileManagerUtil::sInitialWorkingDirectory;
|
||||
else
|
||||
RageException::Throw( "%s", COULDNT_FIND_SONGS.GetValue().c_str() );
|
||||
|
||||
FILEMAN->Mount( "dir", Root, "/" );
|
||||
}
|
||||
|
||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
/* Path to write general mutable user data when not Portable
|
||||
* Lowercase the PRODUCT_ID; dotfiles and directories are almost always lowercase.
|
||||
*/
|
||||
const char *szHome = getenv( "HOME" );
|
||||
RString sUserDataPath = ssprintf( "%s/.%s", szHome? szHome:".", "stepmania-5.0" ); //call an ambulance!
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Announcers", "/Announcers" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/BGAnimations", "/BGAnimations" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/BackgroundEffects", "/BackgroundEffects" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/BackgroundTransitions", "/BackgroundTransitions" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Cache", "/Cache" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/CDTitles", "/CDTitles" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Characters", "/Characters" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Courses", "/Courses" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Logs", "/Logs" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Noteskins", "/Noteskins" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Packages", "/Packages" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Save", "/Save" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Screenshots", "/Screenshots" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Songs", "/Songs" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/RandomMovies", "/RandomMovies" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Themes", "/Themes" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "ArchHooks_Unix.h"
|
||||
#include "ProductInfo.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageThreads.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "archutils/Unix/SignalHandler.h"
|
||||
#include "archutils/Unix/GetSysInfo.h"
|
||||
#include "archutils/Unix/LinuxThreadHelpers.h"
|
||||
#include "archutils/Unix/EmergencyShutdown.h"
|
||||
#include "archutils/Unix/AssertionHandler.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
#include "archutils/Unix/CrashHandler.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FFMPEG)
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool IsFatalSignal( int signal )
|
||||
{
|
||||
switch( signal )
|
||||
{
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
case SIGHUP:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool DoCleanShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
{
|
||||
if( IsFatalSignal(signal) )
|
||||
return false;
|
||||
|
||||
/* ^C. */
|
||||
ArchHooks::SetUserQuit();
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
static bool DoCrashSignalHandler( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
{
|
||||
/* Don't dump a debug file if the user just hit ^C. */
|
||||
if( !IsFatalSignal(signal) )
|
||||
return true;
|
||||
|
||||
CrashHandler::CrashSignalHandler( signal, si, uc );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool EmergencyShutdown( int signal, siginfo_t *si, const ucontext_t *uc )
|
||||
{
|
||||
if( !IsFatalSignal(signal) )
|
||||
return false;
|
||||
|
||||
DoEmergencyShutdown();
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
/* If we ran the crash handler, then die. */
|
||||
kill( getpid(), SIGKILL );
|
||||
#endif
|
||||
|
||||
/* We didn't run the crash handler. Run the default handler, so we can dump core. */
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_TLS)
|
||||
static thread_local int g_iTestTLS = 0;
|
||||
|
||||
static int TestTLSThread( void *p )
|
||||
{
|
||||
g_iTestTLS = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TestTLS()
|
||||
{
|
||||
#if defined(LINUX)
|
||||
/* TLS won't work on older threads libraries, and may crash. */
|
||||
if( !UsingNPTL() )
|
||||
return;
|
||||
#endif
|
||||
/* TLS won't work on older Linux kernels. Do a simple check. */
|
||||
g_iTestTLS = 1;
|
||||
|
||||
RageThread TestThread;
|
||||
TestThread.SetName( "TestTLS" );
|
||||
TestThread.Create( TestTLSThread, nullptr );
|
||||
TestThread.Wait();
|
||||
|
||||
if( g_iTestTLS == 1 )
|
||||
RageThread::SetSupportsTLS( true );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/* If librt is available, use CLOCK_MONOTONIC to implement GetMicrosecondsSinceStart,
|
||||
* if supported, so changes to the system clock don't cause problems. */
|
||||
namespace
|
||||
{
|
||||
clockid_t g_Clock = CLOCK_REALTIME;
|
||||
|
||||
void OpenGetTime()
|
||||
{
|
||||
static bool bInitialized = false;
|
||||
if( bInitialized )
|
||||
return;
|
||||
bInitialized = true;
|
||||
|
||||
/* Check whether the clock is actually supported. */
|
||||
timespec ts;
|
||||
if( clock_getres(CLOCK_MONOTONIC, &ts) == -1 )
|
||||
return;
|
||||
|
||||
/* If the resolution is worse than a millisecond, fall back on CLOCK_REALTIME. */
|
||||
if( ts.tv_sec > 0 || ts.tv_nsec > 1000000 )
|
||||
return;
|
||||
|
||||
g_Clock = CLOCK_MONOTONIC;
|
||||
}
|
||||
};
|
||||
|
||||
clockid_t ArchHooks_Unix::GetClock()
|
||||
{
|
||||
OpenGetTime();
|
||||
return g_Clock;
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
OpenGetTime();
|
||||
|
||||
timespec ts;
|
||||
clock_gettime( g_Clock, &ts );
|
||||
|
||||
int64_t iRet = int64_t(ts.tv_sec) * 1000000 + int64_t(ts.tv_nsec)/1000;
|
||||
if( g_Clock != CLOCK_MONOTONIC )
|
||||
iRet = ArchHooks::FixupTimeIfBackwards( iRet );
|
||||
return iRet;
|
||||
}
|
||||
#else
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
int64_t iRet = int64_t(tv.tv_sec) * 1000000 + int64_t(tv.tv_usec);
|
||||
ret = FixupTimeIfBackwards( ret );
|
||||
return iRet;
|
||||
}
|
||||
#endif
|
||||
|
||||
RString ArchHooks::GetPreferredLanguage()
|
||||
{
|
||||
RString locale;
|
||||
|
||||
if(getenv("LANG"))
|
||||
{
|
||||
locale = getenv("LANG");
|
||||
locale = locale.substr(0,2);
|
||||
}
|
||||
else
|
||||
locale = "en";
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
void ArchHooks_Unix::Init()
|
||||
{
|
||||
/* First, handle non-fatal termination signals. */
|
||||
SignalHandler::OnClose( DoCleanShutdown );
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
CrashHandler::CrashHandlerHandleArgs( g_argc, g_argv );
|
||||
CrashHandler::InitializeCrashHandler();
|
||||
SignalHandler::OnClose( DoCrashSignalHandler );
|
||||
#endif
|
||||
|
||||
/* Set up EmergencyShutdown, to try to shut down the window if we crash.
|
||||
* This might blow up, so be sure to do it after the crash handler. */
|
||||
SignalHandler::OnClose( EmergencyShutdown );
|
||||
|
||||
InstallExceptionHandler();
|
||||
|
||||
#if defined(HAVE_TLS) && !defined(BSD)
|
||||
TestTLS();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _CS_GNU_LIBC_VERSION
|
||||
#define _CS_GNU_LIBC_VERSION 2
|
||||
#endif
|
||||
|
||||
static RString LibcVersion()
|
||||
{
|
||||
char buf[1024] = "(error)";
|
||||
int ret = confstr( _CS_GNU_LIBC_VERSION, buf, sizeof(buf) );
|
||||
if( ret == -1 )
|
||||
return "(unknown)";
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void ArchHooks_Unix::DumpDebugInfo()
|
||||
{
|
||||
RString sys;
|
||||
int vers;
|
||||
GetKernel( sys, vers );
|
||||
LOG->Info( "OS: %s ver %06i", sys.c_str(), vers );
|
||||
|
||||
#if defined(CRASH_HANDLER)
|
||||
LOG->Info( "Crash backtrace component: %s", BACKTRACE_METHOD_TEXT );
|
||||
LOG->Info( "Crash lookup component: %s", BACKTRACE_LOOKUP_METHOD_TEXT );
|
||||
#if defined(BACKTRACE_DEMANGLE_METHOD_TEXT)
|
||||
LOG->Info( "Crash demangle component: %s", BACKTRACE_DEMANGLE_METHOD_TEXT );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LOG->Info( "Runtime library: %s", LibcVersion().c_str() );
|
||||
LOG->Info( "Threads library: %s", ThreadsVersion().c_str() );
|
||||
#if defined(HAVE_FFMPEG)
|
||||
LOG->Info( "libavcodec: %#x (%u)", avcodec_version(), avcodec_version() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArchHooks_Unix::SetTime( tm newtime )
|
||||
{
|
||||
RString sCommand = ssprintf( "date %02d%02d%02d%02d%04d.%02d",
|
||||
newtime.tm_mon+1,
|
||||
newtime.tm_mday,
|
||||
newtime.tm_hour,
|
||||
newtime.tm_min,
|
||||
newtime.tm_year+1900,
|
||||
newtime.tm_sec );
|
||||
|
||||
LOG->Trace( "executing '%s'", sCommand.c_str() );
|
||||
int ret = system( sCommand );
|
||||
if( ret == -1 || ret == 127 || !WIFEXITED(ret) || WEXITSTATUS(ret) )
|
||||
LOG->Trace( "'%s' failed", sCommand.c_str() );
|
||||
|
||||
ret = system( "hwclock --systohc" );
|
||||
if( ret == -1 || ret == 127 || !WIFEXITED(ret) || WEXITSTATUS(ret) )
|
||||
LOG->Trace( "'hwclock --systohc' failed" );
|
||||
}
|
||||
|
||||
#include "RageFileManager.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
static LocalizedString COULDNT_FIND_SONGS( "ArchHooks_Unix", "Couldn't find 'Songs'" );
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
#if defined(UNIX)
|
||||
/* Mount the root filesystem, so we can read files in /proc, /etc, and so on.
|
||||
* This is /rootfs, not /root, to avoid confusion with root's home directory. */
|
||||
FILEMAN->Mount( "dir", "/", "/rootfs" );
|
||||
|
||||
/* Mount /proc, so Alsa9Buf::GetSoundCardDebugInfo() and others can access it.
|
||||
* (Deprecated; use rootfs.) */
|
||||
FILEMAN->Mount( "dir", "/proc", "/proc" );
|
||||
#endif
|
||||
|
||||
RString Root;
|
||||
struct stat st;
|
||||
if( !stat(sDirOfExecutable + "/Packages", &st) && st.st_mode&S_IFDIR )
|
||||
Root = sDirOfExecutable;
|
||||
else if( !stat(sDirOfExecutable + "/Songs", &st) && st.st_mode&S_IFDIR )
|
||||
Root = sDirOfExecutable;
|
||||
else if( !stat(RageFileManagerUtil::sInitialWorkingDirectory + "/Songs", &st) && st.st_mode&S_IFDIR )
|
||||
Root = RageFileManagerUtil::sInitialWorkingDirectory;
|
||||
else
|
||||
RageException::Throw( "%s", COULDNT_FIND_SONGS.GetValue().c_str() );
|
||||
|
||||
FILEMAN->Mount( "dir", Root, "/" );
|
||||
}
|
||||
|
||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
/* Path to write general mutable user data when not Portable
|
||||
* Lowercase the PRODUCT_ID; dotfiles and directories are almost always lowercase.
|
||||
*/
|
||||
const char *szHome = getenv( "HOME" );
|
||||
RString sUserDataPath = ssprintf( "%s/.%s", szHome? szHome:".", "stepmania-5.0" ); //call an ambulance!
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Announcers", "/Announcers" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/BGAnimations", "/BGAnimations" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/BackgroundEffects", "/BackgroundEffects" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/BackgroundTransitions", "/BackgroundTransitions" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Cache", "/Cache" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/CDTitles", "/CDTitles" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Characters", "/Characters" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Courses", "/Courses" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Logs", "/Logs" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Noteskins", "/Noteskins" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Packages", "/Packages" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Save", "/Save" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Screenshots", "/Screenshots" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Songs", "/Songs" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/RandomMovies", "/RandomMovies" );
|
||||
FILEMAN->Mount( "dir", sUserDataPath + "/Themes", "/Themes" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -100,7 +100,7 @@ bool ArchHooks_Win32::CheckForMultipleInstances(int argc, char* argv[])
|
||||
/* Search for the existing window. Prefer to use the class name, which is less likely to
|
||||
* have a false match, and will match the gameplay window. If that fails, try the window
|
||||
* name, which should match the loading window. */
|
||||
HWND hWnd = FindWindow( PRODUCT_ID, NULL );
|
||||
HWND hWnd = FindWindow( PRODUCT_ID, nullptr );
|
||||
if( hWnd == nullptr )
|
||||
hWnd = FindWindow( NULL, PRODUCT_ID );
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ static CFOptionFlags ShowAlert( CFOptionFlags flags, const RString& sMessage, CF
|
||||
DEBUG_ASSERT_M( false, error );
|
||||
return kCFUserNotificationDefaultResponse; // Is this better than displaying an "unknown error" message?
|
||||
}
|
||||
CFUserNotificationDisplayAlert( 0.0, flags, NULL, NULL, NULL, CFSTR(PRODUCT_FAMILY),
|
||||
CFUserNotificationDisplayAlert( 0.0, flags, nullptr, nullptr, nullptr, CFSTR(PRODUCT_FAMILY),
|
||||
text, OK, alt, other, &result );
|
||||
CFRelease( text );
|
||||
|
||||
@@ -36,7 +36,7 @@ static CFOptionFlags ShowAlert( CFOptionFlags flags, const RString& sMessage, CF
|
||||
return result;
|
||||
}
|
||||
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), NULL, CFSTR("Localizable") )
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), nullptr, CFSTR("Localizable") )
|
||||
|
||||
void DialogDriver_MacOSX::OK( RString sMessage, RString sID )
|
||||
{
|
||||
|
||||
@@ -222,7 +222,7 @@ void DialogDriver_Win32::Error( RString sError, RString sID )
|
||||
|
||||
// throw up a pretty error dialog
|
||||
AppInstance handle;
|
||||
DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG), NULL, ErrorWndProc );
|
||||
DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG), nullptr, ErrorWndProc );
|
||||
#else
|
||||
::AfxMessageBox( ConvertUTF8ToACP(sError).c_str(), MB_OK, 0 );
|
||||
#endif
|
||||
|
||||
@@ -104,23 +104,23 @@ InputHandler_DInput::InputHandler_DInput()
|
||||
g_iNumJoysticks = 0;
|
||||
|
||||
AppInstance inst;
|
||||
HRESULT hr = DirectInput8Create(inst.Get(), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID *) &g_dinput, NULL);
|
||||
HRESULT hr = DirectInput8Create(inst.Get(), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID *) &g_dinput, nullptr);
|
||||
if( hr != DI_OK )
|
||||
RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: DirectInputCreate") );
|
||||
|
||||
LOG->Trace( "InputHandler_DInput: IDirectInput::EnumDevices(DIDEVTYPE_KEYBOARD)" );
|
||||
hr = g_dinput->EnumDevices( DI8DEVTYPE_KEYBOARD, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY );
|
||||
hr = g_dinput->EnumDevices( DI8DEVTYPE_KEYBOARD, EnumDevicesCallback, nullptr, DIEDFL_ATTACHEDONLY );
|
||||
if( hr != DI_OK )
|
||||
RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: IDirectInput::EnumDevices") );
|
||||
|
||||
LOG->Trace( "InputHandler_DInput: IDirectInput::EnumDevices(DIDEVTYPE_JOYSTICK)" );
|
||||
hr = g_dinput->EnumDevices( DI8DEVTYPE_JOYSTICK, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY );
|
||||
hr = g_dinput->EnumDevices( DI8DEVTYPE_JOYSTICK, EnumDevicesCallback, nullptr, DIEDFL_ATTACHEDONLY );
|
||||
if( hr != DI_OK )
|
||||
RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: IDirectInput::EnumDevices") );
|
||||
|
||||
// mouse
|
||||
LOG->Trace( "InputHandler_DInput: IDirectInput::EnumDevices(DIDEVTYPE_MOUSE)" );
|
||||
hr = g_dinput->EnumDevices( DI8DEVTYPE_MOUSE, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY );
|
||||
hr = g_dinput->EnumDevices( DI8DEVTYPE_MOUSE, EnumDevicesCallback, nullptr, DIEDFL_ATTACHEDONLY );
|
||||
if( hr != DI_OK )
|
||||
RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: IDirectInput::EnumDevices") );
|
||||
|
||||
@@ -731,7 +731,7 @@ void InputHandler_DInput::InputThreadMain()
|
||||
SetThreadPriorityBoost( GetCurrentThread(), FALSE );
|
||||
|
||||
vector<DIDevice*> BufferedDevices;
|
||||
HANDLE Handle = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
HANDLE Handle = CreateEvent( NULL, FALSE, FALSE, nullptr );
|
||||
for( unsigned i = 0; i < Devices.size(); ++i )
|
||||
{
|
||||
if( !Devices[i].buffered )
|
||||
|
||||
@@ -37,7 +37,7 @@ bool DIDevice::Open()
|
||||
LPDIRECTINPUTDEVICE8 tmpdevice;
|
||||
|
||||
// load joystick
|
||||
HRESULT hr = g_dinput->CreateDevice( JoystickInst.guidInstance, &tmpdevice, NULL );
|
||||
HRESULT hr = g_dinput->CreateDevice( JoystickInst.guidInstance, &tmpdevice, nullptr );
|
||||
if ( hr != DI_OK )
|
||||
{
|
||||
LOG->Info( hr_ssprintf(hr, "OpenDevice: IDirectInput_CreateDevice") );
|
||||
|
||||
@@ -355,7 +355,7 @@ void InputHandler_Linux_Event::InputThread()
|
||||
break;
|
||||
|
||||
struct timeval zero = {0,100000};
|
||||
if( select(iMaxFD+1, &fdset, NULL, NULL, &zero) <= 0 )
|
||||
if( select(iMaxFD+1, &fdset, nullptr, nullptr, &zero) <= 0 )
|
||||
continue;
|
||||
RageTimer now;
|
||||
|
||||
|
||||
@@ -1,225 +1,225 @@
|
||||
#include "global.h"
|
||||
#include "InputHandler_Linux_Joystick.h"
|
||||
#include "InputHandler_Linux_Event.h" // for m_bFoundAnyJoysticks
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/joystick.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
REGISTER_INPUT_HANDLER_CLASS2( Joystick, Linux_Joystick );
|
||||
|
||||
static const char *Paths[InputHandler_Linux_Joystick::NUM_JOYSTICKS] =
|
||||
{
|
||||
"/dev/js0",
|
||||
"/dev/js1",
|
||||
"/dev/input/js0",
|
||||
"/dev/input/js1",
|
||||
};
|
||||
|
||||
InputHandler_Linux_Joystick::InputHandler_Linux_Joystick()
|
||||
{
|
||||
LOG->Trace( "InputHandler_Linux_Joystick::InputHandler_Linux_Joystick" );
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
fds[i] = -1;
|
||||
|
||||
if( InputHandler_Linux_Event::m_bFoundAnyJoysticks )
|
||||
{
|
||||
LOG->Trace( "InputHandler_Linux_Joystick disabled (joystick driver already loaded)" );
|
||||
return;
|
||||
}
|
||||
|
||||
/* We check both eg. /dev/js0 and /dev/input/js0. If both exist, they're probably
|
||||
* the same device; keep track of device IDs so we don't open the same joystick
|
||||
* twice. */
|
||||
set< pair<int,int> > devices;
|
||||
bool bFoundAnyJoysticks = false;
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
struct stat st;
|
||||
if( stat( Paths[i], &st ) == -1 )
|
||||
{
|
||||
if( errno != ENOENT )
|
||||
LOG->Warn( "Couldn't stat %s: %s", Paths[i], strerror(errno) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !S_ISCHR( st.st_mode ) )
|
||||
{
|
||||
LOG->Warn( "Ignoring %s: not a character device", Paths[i] );
|
||||
continue;
|
||||
}
|
||||
|
||||
pair<int,int> dev( major(st.st_rdev), minor(st.st_rdev) );
|
||||
if( devices.find(dev) != devices.end() )
|
||||
continue; /* dupe */
|
||||
devices.insert( dev );
|
||||
|
||||
fds[i] = open( Paths[i], O_RDONLY );
|
||||
|
||||
if(fds[i] != -1)
|
||||
{
|
||||
char szName[1024];
|
||||
ZERO( szName );
|
||||
if( ioctl(fds[i], JSIOCGNAME(sizeof(szName)), szName) < 0 )
|
||||
m_sDescription[i] = ssprintf( "Unknown joystick at %s", Paths[i] );
|
||||
else
|
||||
m_sDescription[i] = szName;
|
||||
|
||||
LOG->Info("Opened %s", Paths[i]);
|
||||
bFoundAnyJoysticks = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_bShutdown = false;
|
||||
|
||||
if( bFoundAnyJoysticks )
|
||||
{
|
||||
m_InputThread.SetName( "Joystick thread" );
|
||||
m_InputThread.Create( InputThread_Start, this );
|
||||
InputHandler_Linux_Event::m_bFoundAnyJoysticks = true;
|
||||
}
|
||||
}
|
||||
|
||||
InputHandler_Linux_Joystick::~InputHandler_Linux_Joystick()
|
||||
{
|
||||
if( m_InputThread.IsCreated() )
|
||||
{
|
||||
m_bShutdown = true;
|
||||
LOG->Trace( "Shutting down joystick thread ..." );
|
||||
m_InputThread.Wait();
|
||||
LOG->Trace( "Joystick thread shut down." );
|
||||
}
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
if(fds[i] != -1) close(fds[i]);
|
||||
}
|
||||
|
||||
int InputHandler_Linux_Joystick::InputThread_Start( void *p )
|
||||
{
|
||||
((InputHandler_Linux_Joystick *) p)->InputThread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InputHandler_Linux_Joystick::InputThread()
|
||||
{
|
||||
while( !m_bShutdown )
|
||||
{
|
||||
fd_set fdset;
|
||||
FD_ZERO(&fdset);
|
||||
int max_fd = -1;
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
if (fds[i] < 0)
|
||||
continue;
|
||||
|
||||
FD_SET(fds[i], &fdset);
|
||||
max_fd = max(max_fd, fds[i]);
|
||||
}
|
||||
|
||||
if(max_fd == -1)
|
||||
break;
|
||||
|
||||
struct timeval zero = {0,100000};
|
||||
if( select(max_fd+1, &fdset, NULL, NULL, &zero) <= 0 )
|
||||
continue;
|
||||
RageTimer now;
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
if( fds[i] == -1 )
|
||||
continue;
|
||||
|
||||
if(!FD_ISSET(fds[i], &fdset))
|
||||
continue;
|
||||
|
||||
js_event event;
|
||||
int ret = read(fds[i], &event, sizeof(event));
|
||||
if(ret != sizeof(event))
|
||||
{
|
||||
LOG->Warn("Unexpected packet (size %i != %i) from joystick %i; disabled", ret, (int)sizeof(event), i);
|
||||
close(fds[i]);
|
||||
fds[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
InputDevice id = InputDevice(DEVICE_JOY1 + i);
|
||||
|
||||
event.type &= ~JS_EVENT_INIT;
|
||||
switch (event.type) {
|
||||
case JS_EVENT_BUTTON: {
|
||||
int iNum = event.number;
|
||||
// In 2.6.11 using an EMS USB2, the event number for P1 Tri (the first button)
|
||||
// is being reported as 32 instead of 0. Correct for this.
|
||||
wrap( iNum, 32 ); // max number of joystick buttons. Make this a constant?
|
||||
ButtonPressed( DeviceInput(id, enum_add2(JOY_BUTTON_1, iNum), event.value, now) );
|
||||
break;
|
||||
}
|
||||
|
||||
case JS_EVENT_AXIS: {
|
||||
DeviceButton neg = enum_add2(JOY_LEFT, 2*event.number);
|
||||
DeviceButton pos = enum_add2(JOY_RIGHT, 2*event.number);
|
||||
float l = SCALE( int(event.value), 0.0f, 32767, 0.0f, 1.0f );
|
||||
ButtonPressed( DeviceInput(id, neg, max(-l,0), now) );
|
||||
ButtonPressed( DeviceInput(id, pos, max(+l,0), now) );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
LOG->Warn("Unexpected packet (type %i) from joystick %i; disabled", event.type, i);
|
||||
close(fds[i]);
|
||||
fds[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
|
||||
void InputHandler_Linux_Joystick::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
|
||||
{
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
if (fds[i] < 0)
|
||||
continue;
|
||||
|
||||
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i), m_sDescription[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "InputHandler_Linux_Joystick.h"
|
||||
#include "InputHandler_Linux_Event.h" // for m_bFoundAnyJoysticks
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/joystick.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
REGISTER_INPUT_HANDLER_CLASS2( Joystick, Linux_Joystick );
|
||||
|
||||
static const char *Paths[InputHandler_Linux_Joystick::NUM_JOYSTICKS] =
|
||||
{
|
||||
"/dev/js0",
|
||||
"/dev/js1",
|
||||
"/dev/input/js0",
|
||||
"/dev/input/js1",
|
||||
};
|
||||
|
||||
InputHandler_Linux_Joystick::InputHandler_Linux_Joystick()
|
||||
{
|
||||
LOG->Trace( "InputHandler_Linux_Joystick::InputHandler_Linux_Joystick" );
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
fds[i] = -1;
|
||||
|
||||
if( InputHandler_Linux_Event::m_bFoundAnyJoysticks )
|
||||
{
|
||||
LOG->Trace( "InputHandler_Linux_Joystick disabled (joystick driver already loaded)" );
|
||||
return;
|
||||
}
|
||||
|
||||
/* We check both eg. /dev/js0 and /dev/input/js0. If both exist, they're probably
|
||||
* the same device; keep track of device IDs so we don't open the same joystick
|
||||
* twice. */
|
||||
set< pair<int,int> > devices;
|
||||
bool bFoundAnyJoysticks = false;
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
struct stat st;
|
||||
if( stat( Paths[i], &st ) == -1 )
|
||||
{
|
||||
if( errno != ENOENT )
|
||||
LOG->Warn( "Couldn't stat %s: %s", Paths[i], strerror(errno) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !S_ISCHR( st.st_mode ) )
|
||||
{
|
||||
LOG->Warn( "Ignoring %s: not a character device", Paths[i] );
|
||||
continue;
|
||||
}
|
||||
|
||||
pair<int,int> dev( major(st.st_rdev), minor(st.st_rdev) );
|
||||
if( devices.find(dev) != devices.end() )
|
||||
continue; /* dupe */
|
||||
devices.insert( dev );
|
||||
|
||||
fds[i] = open( Paths[i], O_RDONLY );
|
||||
|
||||
if(fds[i] != -1)
|
||||
{
|
||||
char szName[1024];
|
||||
ZERO( szName );
|
||||
if( ioctl(fds[i], JSIOCGNAME(sizeof(szName)), szName) < 0 )
|
||||
m_sDescription[i] = ssprintf( "Unknown joystick at %s", Paths[i] );
|
||||
else
|
||||
m_sDescription[i] = szName;
|
||||
|
||||
LOG->Info("Opened %s", Paths[i]);
|
||||
bFoundAnyJoysticks = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_bShutdown = false;
|
||||
|
||||
if( bFoundAnyJoysticks )
|
||||
{
|
||||
m_InputThread.SetName( "Joystick thread" );
|
||||
m_InputThread.Create( InputThread_Start, this );
|
||||
InputHandler_Linux_Event::m_bFoundAnyJoysticks = true;
|
||||
}
|
||||
}
|
||||
|
||||
InputHandler_Linux_Joystick::~InputHandler_Linux_Joystick()
|
||||
{
|
||||
if( m_InputThread.IsCreated() )
|
||||
{
|
||||
m_bShutdown = true;
|
||||
LOG->Trace( "Shutting down joystick thread ..." );
|
||||
m_InputThread.Wait();
|
||||
LOG->Trace( "Joystick thread shut down." );
|
||||
}
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
if(fds[i] != -1) close(fds[i]);
|
||||
}
|
||||
|
||||
int InputHandler_Linux_Joystick::InputThread_Start( void *p )
|
||||
{
|
||||
((InputHandler_Linux_Joystick *) p)->InputThread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InputHandler_Linux_Joystick::InputThread()
|
||||
{
|
||||
while( !m_bShutdown )
|
||||
{
|
||||
fd_set fdset;
|
||||
FD_ZERO(&fdset);
|
||||
int max_fd = -1;
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
if (fds[i] < 0)
|
||||
continue;
|
||||
|
||||
FD_SET(fds[i], &fdset);
|
||||
max_fd = max(max_fd, fds[i]);
|
||||
}
|
||||
|
||||
if(max_fd == -1)
|
||||
break;
|
||||
|
||||
struct timeval zero = {0,100000};
|
||||
if( select(max_fd+1, &fdset, nullptr, nullptr, &zero) <= 0 )
|
||||
continue;
|
||||
RageTimer now;
|
||||
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
if( fds[i] == -1 )
|
||||
continue;
|
||||
|
||||
if(!FD_ISSET(fds[i], &fdset))
|
||||
continue;
|
||||
|
||||
js_event event;
|
||||
int ret = read(fds[i], &event, sizeof(event));
|
||||
if(ret != sizeof(event))
|
||||
{
|
||||
LOG->Warn("Unexpected packet (size %i != %i) from joystick %i; disabled", ret, (int)sizeof(event), i);
|
||||
close(fds[i]);
|
||||
fds[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
InputDevice id = InputDevice(DEVICE_JOY1 + i);
|
||||
|
||||
event.type &= ~JS_EVENT_INIT;
|
||||
switch (event.type) {
|
||||
case JS_EVENT_BUTTON: {
|
||||
int iNum = event.number;
|
||||
// In 2.6.11 using an EMS USB2, the event number for P1 Tri (the first button)
|
||||
// is being reported as 32 instead of 0. Correct for this.
|
||||
wrap( iNum, 32 ); // max number of joystick buttons. Make this a constant?
|
||||
ButtonPressed( DeviceInput(id, enum_add2(JOY_BUTTON_1, iNum), event.value, now) );
|
||||
break;
|
||||
}
|
||||
|
||||
case JS_EVENT_AXIS: {
|
||||
DeviceButton neg = enum_add2(JOY_LEFT, 2*event.number);
|
||||
DeviceButton pos = enum_add2(JOY_RIGHT, 2*event.number);
|
||||
float l = SCALE( int(event.value), 0.0f, 32767, 0.0f, 1.0f );
|
||||
ButtonPressed( DeviceInput(id, neg, max(-l,0), now) );
|
||||
ButtonPressed( DeviceInput(id, pos, max(+l,0), now) );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
LOG->Warn("Unexpected packet (type %i) from joystick %i; disabled", event.type, i);
|
||||
close(fds[i]);
|
||||
fds[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
|
||||
void InputHandler_Linux_Joystick::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
|
||||
{
|
||||
for(int i = 0; i < NUM_JOYSTICKS; ++i)
|
||||
{
|
||||
if (fds[i] < 0)
|
||||
continue;
|
||||
|
||||
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i), m_sDescription[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -171,7 +171,7 @@ void InputHandler_Linux_tty::Update()
|
||||
FD_SET(fd, &fdset);
|
||||
|
||||
struct timeval zero = {0,0};
|
||||
if ( select(fd+1, &fdset, NULL, NULL, &zero) <= 0 )
|
||||
if ( select(fd+1, &fdset, nullptr, nullptr, &zero) <= 0 )
|
||||
return;
|
||||
|
||||
unsigned char keybuf[BUFSIZ];
|
||||
|
||||
@@ -65,7 +65,7 @@ int InputHandler_MacOSX_HID::Run( void *data )
|
||||
{
|
||||
/* The function copies the information out of the structure, so the memory
|
||||
* pointed to by context does not need to persist beyond the function call. */
|
||||
CFRunLoopObserverContext context = { 0, &This->m_Sem, NULL, NULL, NULL };
|
||||
CFRunLoopObserverContext context = { 0, &This->m_Sem, nullptr, nullptr, nullptr };
|
||||
CFRunLoopObserverRef o = CFRunLoopObserverCreate( kCFAllocatorDefault, kCFRunLoopEntry,
|
||||
false, 0, RunLoopStarted, &context);
|
||||
CFRunLoopAddObserver( This->m_LoopRef, o, kCFRunLoopDefaultMode );
|
||||
@@ -82,7 +82,7 @@ int InputHandler_MacOSX_HID::Run( void *data )
|
||||
void *info = This->m_LoopRef;
|
||||
void (*perform)(void *) = (void (*)(void *))CFRunLoopStop;
|
||||
// { version, info, retain, release, copyDescription, equal, hash, schedule, cancel, perform }
|
||||
CFRunLoopSourceContext context = { 0, info, NULL, NULL, NULL, NULL, NULL, NULL, NULL, perform };
|
||||
CFRunLoopSourceContext context = { 0, info, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, perform };
|
||||
|
||||
// Pass 1 so that it is called after all inputs have been handled (they will have order = 0)
|
||||
This->m_SourceRef = CFRunLoopSourceCreate( kCFAllocatorDefault, 1, &context );
|
||||
|
||||
@@ -1,190 +1,190 @@
|
||||
#include "global.h"
|
||||
#include "InputHandler_Win32_Pump.h"
|
||||
|
||||
#include "PrefsManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageInputDevice.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
#include "archutils/Win32/USB.h"
|
||||
|
||||
REGISTER_INPUT_HANDLER_CLASS2( Pump, Win32_Pump );
|
||||
|
||||
InputHandler_Win32_Pump::InputHandler_Win32_Pump()
|
||||
{
|
||||
m_bShutdown = false;
|
||||
const int pump_usb_vid = 0x0d2f;
|
||||
const int pump_usb_pids[2] = {
|
||||
0x0001 /* older model */,
|
||||
0x0003 /* shipped with Exceed */
|
||||
};
|
||||
|
||||
m_pDevice = new USBDevice[NUM_PUMPS];
|
||||
|
||||
int iNumFound = 0;
|
||||
for( int p = 0; p < ARRAYSIZE(pump_usb_pids); ++p )
|
||||
{
|
||||
const int pump_usb_pid = pump_usb_pids[p];
|
||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||
{
|
||||
if( m_pDevice[i].Open(pump_usb_vid, pump_usb_pid, sizeof(long), i, NULL) )
|
||||
{
|
||||
iNumFound++;
|
||||
LOG->Info( "Found Pump pad %i", iNumFound );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't start a thread if we have no pads. */
|
||||
if( iNumFound > 0 && PREFSMAN->m_bThreadedInput )
|
||||
{
|
||||
InputThread.SetName( "Pump thread" );
|
||||
InputThread.Create( InputThread_Start, this );
|
||||
}
|
||||
}
|
||||
|
||||
InputHandler_Win32_Pump::~InputHandler_Win32_Pump()
|
||||
{
|
||||
if( InputThread.IsCreated() )
|
||||
{
|
||||
m_bShutdown = true;
|
||||
LOG->Trace( "Shutting down Pump thread ..." );
|
||||
InputThread.Wait();
|
||||
LOG->Trace( "Pump thread shut down." );
|
||||
}
|
||||
|
||||
delete[] m_pDevice;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::HandleInput( int iDevice, int iEvent )
|
||||
{
|
||||
static const int bits[] = {
|
||||
/* P1 */ (1<<9), (1<<12), (1<<13), (1<<11), (1<<10),
|
||||
/* ESC */ (1<<16),
|
||||
/* P1 */ (1<<17), (1<<20), (1<<21), (1<<19), (1<<18),
|
||||
};
|
||||
|
||||
InputDevice id = InputDevice( DEVICE_PUMP1 + iDevice );
|
||||
|
||||
for( int iButton = 0; iButton < ARRAYLEN(bits); ++iButton )
|
||||
{
|
||||
DeviceInput di( id, enum_add2(JOY_BUTTON_1, iButton), !(iEvent & bits[iButton]) );
|
||||
|
||||
/* If we're in a thread, our timestamp is accurate. */
|
||||
if( InputThread.IsCreated() )
|
||||
di.ts.Touch();
|
||||
|
||||
ButtonPressed( di );
|
||||
}
|
||||
}
|
||||
|
||||
RString InputHandler_Win32_Pump::GetDeviceSpecificInputString( const DeviceInput &di )
|
||||
{
|
||||
switch( di.button )
|
||||
{
|
||||
case JOY_BUTTON_1: return "UL";
|
||||
case JOY_BUTTON_2: return "UR";
|
||||
case JOY_BUTTON_3: return "MID";
|
||||
case JOY_BUTTON_4: return "DL";
|
||||
case JOY_BUTTON_5: return "DR";
|
||||
case JOY_BUTTON_6: return "Esc";
|
||||
case JOY_BUTTON_7: return "P2 UL";
|
||||
case JOY_BUTTON_8: return "P2 UR";
|
||||
case JOY_BUTTON_9: return "P2 MID";
|
||||
case JOY_BUTTON_10: return "P2 DL";
|
||||
case JOY_BUTTON_11: return "P2 DR";
|
||||
}
|
||||
|
||||
return InputHandler::GetDeviceSpecificInputString( di );
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
|
||||
{
|
||||
for(int i = 0; i < NUM_PUMPS; ++i)
|
||||
{
|
||||
if( m_pDevice[i].IsOpen() )
|
||||
{
|
||||
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_PUMP1+i),"Pump USB") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int InputHandler_Win32_Pump::InputThread_Start( void *p )
|
||||
{
|
||||
((InputHandler_Win32_Pump *) p)->InputThreadMain();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::InputThreadMain()
|
||||
{
|
||||
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) )
|
||||
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set Pump thread priority") );
|
||||
|
||||
/* Enable priority boosting. */
|
||||
SetThreadPriorityBoost( GetCurrentThread(), FALSE );
|
||||
|
||||
vector<WindowsFileIO *> apSources;
|
||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||
{
|
||||
if( m_pDevice[i].m_IO.IsOpen() )
|
||||
apSources.push_back( &m_pDevice[i].m_IO );
|
||||
}
|
||||
|
||||
while( !m_bShutdown )
|
||||
{
|
||||
CHECKPOINT;
|
||||
int iActual = 0, iVal = 0;
|
||||
int iRet = WindowsFileIO::read_several( apSources, &iVal, iActual, 0.100f );
|
||||
|
||||
CHECKPOINT;
|
||||
if( iRet <= 0 )
|
||||
continue; /* no event */
|
||||
|
||||
HandleInput( iActual, iVal );
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
CHECKPOINT;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::Update()
|
||||
{
|
||||
if( !InputThread.IsCreated() )
|
||||
{
|
||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||
{
|
||||
int iRet = m_pDevice[i].GetPadEvent();
|
||||
|
||||
if( iRet == -1 )
|
||||
continue; /* no event */
|
||||
|
||||
HandleInput( i, iRet );
|
||||
}
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "InputHandler_Win32_Pump.h"
|
||||
|
||||
#include "PrefsManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageInputDevice.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
#include "archutils/Win32/USB.h"
|
||||
|
||||
REGISTER_INPUT_HANDLER_CLASS2( Pump, Win32_Pump );
|
||||
|
||||
InputHandler_Win32_Pump::InputHandler_Win32_Pump()
|
||||
{
|
||||
m_bShutdown = false;
|
||||
const int pump_usb_vid = 0x0d2f;
|
||||
const int pump_usb_pids[2] = {
|
||||
0x0001 /* older model */,
|
||||
0x0003 /* shipped with Exceed */
|
||||
};
|
||||
|
||||
m_pDevice = new USBDevice[NUM_PUMPS];
|
||||
|
||||
int iNumFound = 0;
|
||||
for( int p = 0; p < ARRAYSIZE(pump_usb_pids); ++p )
|
||||
{
|
||||
const int pump_usb_pid = pump_usb_pids[p];
|
||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||
{
|
||||
if( m_pDevice[i].Open(pump_usb_vid, pump_usb_pid, sizeof(long), i, nullptr) )
|
||||
{
|
||||
iNumFound++;
|
||||
LOG->Info( "Found Pump pad %i", iNumFound );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't start a thread if we have no pads. */
|
||||
if( iNumFound > 0 && PREFSMAN->m_bThreadedInput )
|
||||
{
|
||||
InputThread.SetName( "Pump thread" );
|
||||
InputThread.Create( InputThread_Start, this );
|
||||
}
|
||||
}
|
||||
|
||||
InputHandler_Win32_Pump::~InputHandler_Win32_Pump()
|
||||
{
|
||||
if( InputThread.IsCreated() )
|
||||
{
|
||||
m_bShutdown = true;
|
||||
LOG->Trace( "Shutting down Pump thread ..." );
|
||||
InputThread.Wait();
|
||||
LOG->Trace( "Pump thread shut down." );
|
||||
}
|
||||
|
||||
delete[] m_pDevice;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::HandleInput( int iDevice, int iEvent )
|
||||
{
|
||||
static const int bits[] = {
|
||||
/* P1 */ (1<<9), (1<<12), (1<<13), (1<<11), (1<<10),
|
||||
/* ESC */ (1<<16),
|
||||
/* P1 */ (1<<17), (1<<20), (1<<21), (1<<19), (1<<18),
|
||||
};
|
||||
|
||||
InputDevice id = InputDevice( DEVICE_PUMP1 + iDevice );
|
||||
|
||||
for( int iButton = 0; iButton < ARRAYLEN(bits); ++iButton )
|
||||
{
|
||||
DeviceInput di( id, enum_add2(JOY_BUTTON_1, iButton), !(iEvent & bits[iButton]) );
|
||||
|
||||
/* If we're in a thread, our timestamp is accurate. */
|
||||
if( InputThread.IsCreated() )
|
||||
di.ts.Touch();
|
||||
|
||||
ButtonPressed( di );
|
||||
}
|
||||
}
|
||||
|
||||
RString InputHandler_Win32_Pump::GetDeviceSpecificInputString( const DeviceInput &di )
|
||||
{
|
||||
switch( di.button )
|
||||
{
|
||||
case JOY_BUTTON_1: return "UL";
|
||||
case JOY_BUTTON_2: return "UR";
|
||||
case JOY_BUTTON_3: return "MID";
|
||||
case JOY_BUTTON_4: return "DL";
|
||||
case JOY_BUTTON_5: return "DR";
|
||||
case JOY_BUTTON_6: return "Esc";
|
||||
case JOY_BUTTON_7: return "P2 UL";
|
||||
case JOY_BUTTON_8: return "P2 UR";
|
||||
case JOY_BUTTON_9: return "P2 MID";
|
||||
case JOY_BUTTON_10: return "P2 DL";
|
||||
case JOY_BUTTON_11: return "P2 DR";
|
||||
}
|
||||
|
||||
return InputHandler::GetDeviceSpecificInputString( di );
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
|
||||
{
|
||||
for(int i = 0; i < NUM_PUMPS; ++i)
|
||||
{
|
||||
if( m_pDevice[i].IsOpen() )
|
||||
{
|
||||
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_PUMP1+i),"Pump USB") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int InputHandler_Win32_Pump::InputThread_Start( void *p )
|
||||
{
|
||||
((InputHandler_Win32_Pump *) p)->InputThreadMain();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::InputThreadMain()
|
||||
{
|
||||
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) )
|
||||
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set Pump thread priority") );
|
||||
|
||||
/* Enable priority boosting. */
|
||||
SetThreadPriorityBoost( GetCurrentThread(), FALSE );
|
||||
|
||||
vector<WindowsFileIO *> apSources;
|
||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||
{
|
||||
if( m_pDevice[i].m_IO.IsOpen() )
|
||||
apSources.push_back( &m_pDevice[i].m_IO );
|
||||
}
|
||||
|
||||
while( !m_bShutdown )
|
||||
{
|
||||
CHECKPOINT;
|
||||
int iActual = 0, iVal = 0;
|
||||
int iRet = WindowsFileIO::read_several( apSources, &iVal, iActual, 0.100f );
|
||||
|
||||
CHECKPOINT;
|
||||
if( iRet <= 0 )
|
||||
continue; /* no event */
|
||||
|
||||
HandleInput( iActual, iVal );
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
CHECKPOINT;
|
||||
}
|
||||
|
||||
void InputHandler_Win32_Pump::Update()
|
||||
{
|
||||
if( !InputThread.IsCreated() )
|
||||
{
|
||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||
{
|
||||
int iRet = m_pDevice[i].GetPadEvent();
|
||||
|
||||
if( iRet == -1 )
|
||||
continue; /* no event */
|
||||
|
||||
HandleInput( i, iRet );
|
||||
}
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
|
||||
RageSurfaceUtils::Blit( pSrc, pSurface , -1, -1 );
|
||||
|
||||
GdkPixbuf *pBuf = gdk_pixbuf_new_from_data( pSurface->pixels, GDK_COLORSPACE_RGB,
|
||||
true, 8, pSurface->w, pSurface->h , pSurface->pitch, DeletePixels, NULL);
|
||||
true, 8, pSurface->w, pSurface->h , pSurface->pitch, DeletePixels, nullptr);
|
||||
|
||||
if( pBuf != nullptr )
|
||||
pSurface->pixels_owned = false;
|
||||
|
||||
@@ -60,7 +60,7 @@ static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject( BitmapDC, NULL );
|
||||
SelectObject( BitmapDC, nullptr );
|
||||
DeleteObject( BitmapDC );
|
||||
|
||||
ReleaseDC( NULL, hScreen );
|
||||
@@ -144,7 +144,7 @@ void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash )
|
||||
LoadingWindow_Win32::LoadingWindow_Win32()
|
||||
{
|
||||
m_hIcon = nullptr;
|
||||
hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), NULL, WndProc );
|
||||
hwnd = CreateDialog( handle.Get(), MAKEINTRESOURCE(IDD_LOADING_DIALOG), nullptr, WndProc );
|
||||
for( unsigned i = 0; i < 3; ++i )
|
||||
text[i] = "ABC"; /* always set on first call */
|
||||
SetText( "" );
|
||||
|
||||
@@ -255,7 +255,7 @@ void RenderTarget_MacOSX::Create( const RenderTargetParam ¶m, int &iTextureW
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, param.bWithAlpha? GL_RGBA8:GL_RGB8,
|
||||
iTextureWidth, iTextureHeight, 0, param.bWithAlpha? GL_RGBA:GL_RGB,
|
||||
GL_UNSIGNED_BYTE, NULL );
|
||||
GL_UNSIGNED_BYTE, nullptr );
|
||||
GLenum error = glGetError();
|
||||
ASSERT_M(error == GL_NO_ERROR, RageDisplay_Legacy_Helpers::GLToString(error));
|
||||
|
||||
@@ -483,10 +483,10 @@ int LowLevelWindow_MacOSX::ChangeDisplayMode( const VideoModeParams& p )
|
||||
}
|
||||
|
||||
if( p.rate == REFRESH_DEFAULT )
|
||||
newMode = CGDisplayBestModeForParameters( kCGDirectMainDisplay, p.bpp, p.width, p.height, NULL );
|
||||
newMode = CGDisplayBestModeForParameters( kCGDirectMainDisplay, p.bpp, p.width, p.height, nullptr );
|
||||
else
|
||||
newMode = CGDisplayBestModeForParametersAndRefreshRate( kCGDirectMainDisplay, p.bpp,
|
||||
p.width, p.height, p.rate, NULL );
|
||||
p.width, p.height, p.rate, nullptr );
|
||||
|
||||
|
||||
err = CGDisplaySwitchToMode( kCGDirectMainDisplay, newMode );
|
||||
|
||||
@@ -20,7 +20,7 @@ static void DestroyGraphicsWindowAndOpenGLContext()
|
||||
{
|
||||
if( g_HGLRC != nullptr )
|
||||
{
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
wglMakeCurrent( NULL, nullptr );
|
||||
wglDeleteContext( g_HGLRC );
|
||||
g_HGLRC = nullptr;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ RString LowLevelWindow_Win32::TryVideoMode( const VideoModeParams &p, bool &bNew
|
||||
LOG->Trace( "Mode requires new pixel format, and we've already set one; resetting OpenGL context" );
|
||||
if( g_HGLRC != nullptr )
|
||||
{
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
wglMakeCurrent( NULL, nullptr );
|
||||
wglDeleteContext( g_HGLRC );
|
||||
g_HGLRC = nullptr;
|
||||
wglDeleteContext( g_HGLRC_Background );
|
||||
@@ -262,7 +262,7 @@ void LowLevelWindow_Win32::BeginConcurrentRendering()
|
||||
|
||||
void LowLevelWindow_Win32::EndConcurrentRendering()
|
||||
{
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
wglMakeCurrent( NULL, nullptr );
|
||||
}
|
||||
|
||||
static LocalizedString OPENGL_NOT_AVAILABLE( "LowLevelWindow_Win32", "OpenGL hardware acceleration is not available." );
|
||||
@@ -357,7 +357,7 @@ void RenderTarget_Win32::Create(const RenderTargetParam ¶m, int &iTextureWid
|
||||
internalformat = param.bWithAlpha? GL_RGBA8:GL_RGB8;
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, iTextureWidth,
|
||||
iTextureHeight, 0, type, GL_UNSIGNED_BYTE, NULL);
|
||||
iTextureHeight, 0, type, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
||||
|
||||
@@ -151,7 +151,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
||||
glXDestroyContext( Dpy, g_pContext );
|
||||
if( g_pBackgroundContext )
|
||||
glXDestroyContext( Dpy, g_pBackgroundContext );
|
||||
g_pContext = glXCreateContext( Dpy, xvi, NULL, True );
|
||||
g_pContext = glXCreateContext( Dpy, xvi, nullptr, True );
|
||||
g_pBackgroundContext = glXCreateContext( Dpy, xvi, g_pContext, True );
|
||||
|
||||
glXMakeCurrent( Dpy, Win, g_pContext );
|
||||
@@ -459,7 +459,7 @@ void RenderTarget_X11::Create( const RenderTargetParam ¶m, int &iTextureWidt
|
||||
iTextureHeightOut = iTextureHeight;
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, param.bWithAlpha? GL_RGBA8:GL_RGB8,
|
||||
iTextureWidth, iTextureHeight, 0, param.bWithAlpha? GL_RGBA:GL_RGB, GL_UNSIGNED_BYTE, NULL );
|
||||
iTextureWidth, iTextureHeight, 0, param.bWithAlpha? GL_RGBA:GL_RGB, GL_UNSIGNED_BYTE, nullptr );
|
||||
GLenum error = glGetError();
|
||||
ASSERT_M( error == GL_NO_ERROR, GLToString(error) );
|
||||
|
||||
@@ -505,7 +505,7 @@ bool LowLevelWindow_X11::SupportsRenderToTexture() const
|
||||
{
|
||||
// Server must support pbuffers:
|
||||
const int iScreen = DefaultScreen( Dpy );
|
||||
float fVersion = strtof( glXQueryServerString(Dpy, iScreen, GLX_VERSION), NULL );
|
||||
float fVersion = strtof( glXQueryServerString(Dpy, iScreen, GLX_VERSION), nullptr );
|
||||
if( fVersion < 1.3f )
|
||||
return false;
|
||||
|
||||
@@ -540,7 +540,7 @@ void LowLevelWindow_X11::BeginConcurrentRendering()
|
||||
|
||||
void LowLevelWindow_X11::EndConcurrentRendering()
|
||||
{
|
||||
bool b = glXMakeCurrent( Dpy, None, NULL );
|
||||
bool b = glXMakeCurrent( Dpy, None, nullptr );
|
||||
ASSERT(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ bool MemoryCardDriverThreaded_MacOSX::USBStorageDevicesChanged()
|
||||
|
||||
static int GetIntProperty( io_registry_entry_t entry, CFStringRef key )
|
||||
{
|
||||
CFTypeRef t = IORegistryEntryCreateCFProperty( entry, key, NULL, 0 );
|
||||
CFTypeRef t = IORegistryEntryCreateCFProperty( entry, key, nullptr, 0 );
|
||||
|
||||
if( !t )
|
||||
return -1;
|
||||
@@ -100,7 +100,7 @@ static int GetIntProperty( io_registry_entry_t entry, CFStringRef key )
|
||||
|
||||
static RString GetStringProperty( io_registry_entry_t entry, CFStringRef key )
|
||||
{
|
||||
CFTypeRef t = IORegistryEntryCreateCFProperty( entry, key, NULL, 0 );
|
||||
CFTypeRef t = IORegistryEntryCreateCFProperty( entry, key, nullptr, 0 );
|
||||
|
||||
if( !t )
|
||||
return RString();
|
||||
|
||||
@@ -47,7 +47,7 @@ bool MemoryCardDriverThreaded_Windows::TestWrite( UsbStorageDevice* pDevice )
|
||||
{
|
||||
HANDLE hFile = CreateFile( ssprintf( "%stmp%i", pDevice->sOsMountDir.c_str(), RandomInt(100000)),
|
||||
GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL );
|
||||
NULL, CREATE_NEW, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, nullptr );
|
||||
|
||||
if( hFile == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
@@ -193,7 +193,7 @@ void MemoryCardDriverThreaded_Windows::Unmount( UsbStorageDevice* pDevice )
|
||||
/* Try to flush the device before returning. This requires administrator priviliges. */
|
||||
HANDLE hDevice = CreateFile( pDevice->sDevice, GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
|
||||
|
||||
if( hDevice == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
|
||||
@@ -345,7 +345,7 @@ RString MovieTexture_DShow::Create()
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not CoInitialize") );
|
||||
|
||||
// Create the filter graph
|
||||
if( FAILED( hr=m_pGB.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC) ) )
|
||||
if( FAILED( hr=m_pGB.CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC) ) )
|
||||
RageException::Throw( hr_ssprintf(hr, "Could not create CLSID_FilterGraph!") );
|
||||
|
||||
// Create the Texture Renderer object
|
||||
|
||||
@@ -13,7 +13,7 @@ struct __declspec(uuid("{71771540-2017-11cf-ae26-0020afd79767}")) CLSID_TextureR
|
||||
static HRESULT CBV_ret;
|
||||
CTextureRenderer::CTextureRenderer():
|
||||
CBaseVideoRenderer(__uuidof(CLSID_TextureRenderer),
|
||||
NAME("Texture Renderer"), NULL, &CBV_ret),
|
||||
NAME("Texture Renderer"), nullptr, &CBV_ret),
|
||||
m_OneFrameDecoded( "m_OneFrameDecoded", 0 )
|
||||
{
|
||||
if( FAILED(CBV_ret) )
|
||||
|
||||
@@ -547,7 +547,7 @@ void MovieDecoder_FFMpeg::GetFrame( RageSurface *pSurface )
|
||||
m_swsctx = avcodec::sws_getCachedContext( m_swsctx,
|
||||
GetWidth(), GetHeight(), m_pStream->codec->pix_fmt,
|
||||
GetWidth(), GetHeight(), m_AVTexfmt,
|
||||
sws_flags, NULL, NULL, NULL );
|
||||
sws_flags, nullptr, nullptr, nullptr );
|
||||
if( m_swsctx == nullptr )
|
||||
{
|
||||
LOG->Warn("Cannot initialize sws conversion context for (%d,%d) %d->%d", GetWidth(), GetHeight(), m_pStream->codec->pix_fmt, m_AVTexfmt);
|
||||
@@ -631,17 +631,17 @@ RString MovieDecoder_FFMpeg::Open( RString sFile )
|
||||
}
|
||||
|
||||
m_buffer = (unsigned char *)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE);
|
||||
m_avioContext = avcodec::avio_alloc_context(m_buffer, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, NULL, AVIORageFile_Seek);
|
||||
m_avioContext = avcodec::avio_alloc_context(m_buffer, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, nullptr, AVIORageFile_Seek);
|
||||
m_fctx->pb = m_avioContext;
|
||||
int ret = avcodec::avformat_open_input( &m_fctx, sFile.c_str(), NULL, NULL );
|
||||
int ret = avcodec::avformat_open_input( &m_fctx, sFile.c_str(), nullptr, nullptr );
|
||||
if( ret < 0 )
|
||||
return RString( averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", sFile.c_str()) );
|
||||
|
||||
ret = avcodec::avformat_find_stream_info( m_fctx, NULL );
|
||||
ret = avcodec::avformat_find_stream_info( m_fctx, nullptr );
|
||||
if( ret < 0 )
|
||||
return RString( averr_ssprintf(ret, "AVCodec (%s): Couldn't find codec parameters", sFile.c_str()) );
|
||||
|
||||
int stream_idx = avcodec::av_find_best_stream( m_fctx, avcodec::AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0 );
|
||||
int stream_idx = avcodec::av_find_best_stream( m_fctx, avcodec::AVMEDIA_TYPE_VIDEO, -1, -1, nullptr, 0 );
|
||||
if ( stream_idx < 0 ||
|
||||
static_cast<unsigned int>(stream_idx) >= m_fctx->nb_streams ||
|
||||
m_fctx->streams[stream_idx] == nullptr )
|
||||
@@ -682,7 +682,7 @@ RString MovieDecoder_FFMpeg::OpenCodec()
|
||||
|
||||
LOG->Trace("Opening codec %s", pCodec->name );
|
||||
|
||||
int ret = avcodec::avcodec_open2( m_pStream->codec, pCodec, NULL );
|
||||
int ret = avcodec::avcodec_open2( m_pStream->codec, pCodec, nullptr );
|
||||
if( ret < 0 )
|
||||
return RString( averr_ssprintf(ret, "Couldn't open codec \"%s\"", pCodec->name) );
|
||||
ASSERT( m_pStream->codec->codec != nullptr );
|
||||
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
m_SurfaceFormat.Mask[0],
|
||||
m_SurfaceFormat.Mask[1],
|
||||
m_SurfaceFormat.Mask[2],
|
||||
m_SurfaceFormat.Mask[3], NULL, 1 );
|
||||
m_SurfaceFormat.Mask[3], nullptr, 1 );
|
||||
|
||||
m_uTexHandle = DISPLAY->CreateTexture( m_PixFmt, pSurface, false );
|
||||
delete pSurface;
|
||||
|
||||
@@ -46,7 +46,7 @@ void DSound::SetPrimaryBufferMode()
|
||||
format.lpwfxFormat = nullptr;
|
||||
|
||||
IDirectSoundBuffer *pBuffer;
|
||||
HRESULT hr = this->GetDS()->CreateSoundBuffer( &format, &pBuffer, NULL );
|
||||
HRESULT hr = this->GetDS()->CreateSoundBuffer( &format, &pBuffer, nullptr );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
LOG->Warn(hr_ssprintf(hr, "Couldn't create primary buffer"));
|
||||
@@ -106,7 +106,7 @@ DSound::DSound()
|
||||
RString DSound::Init()
|
||||
{
|
||||
HRESULT hr;
|
||||
if( FAILED( hr = DirectSoundCreate(NULL, &m_pDS, NULL) ) )
|
||||
if( FAILED( hr = DirectSoundCreate(NULL, &m_pDS, nullptr) ) )
|
||||
return hr_ssprintf( hr, "DirectSoundCreate" );
|
||||
|
||||
static bool bShownInfo = false;
|
||||
@@ -228,7 +228,7 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware,
|
||||
|
||||
format.lpwfxFormat = &waveformat;
|
||||
|
||||
HRESULT hr = ds.GetDS()->CreateSoundBuffer( &format, &m_pBuffer, NULL );
|
||||
HRESULT hr = ds.GetDS()->CreateSoundBuffer( &format, &m_pBuffer, nullptr );
|
||||
if( FAILED(hr) )
|
||||
return hr_ssprintf( hr, "CreateSoundBuffer failed (%i hz)", m_iSampleBits );
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
return;
|
||||
|
||||
if( (error = AudioDeviceGetPropertyInfo(OutputDevice, 0, false, kAudioDevicePropertyAvailableNominalSampleRates,
|
||||
&size, NULL)) )
|
||||
&size, nullptr)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't get available nominal sample rates info", error) );
|
||||
return;
|
||||
@@ -114,7 +114,7 @@ static void SetSampleRate( AudioUnit au, Float64 desiredRate )
|
||||
if( bestRate == 0.0 )
|
||||
return;
|
||||
|
||||
if( (error = AudioDeviceSetProperty(OutputDevice, NULL, 0, false, kAudioDevicePropertyNominalSampleRate,
|
||||
if( (error = AudioDeviceSetProperty(OutputDevice, nullptr, 0, false, kAudioDevicePropertyNominalSampleRate,
|
||||
sizeof(Float64), &bestRate)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Couldn't set the device's sample rate", error) );
|
||||
@@ -204,7 +204,7 @@ RString RageSoundDriver_AU::Init()
|
||||
{
|
||||
CFRunLoopObserverRef observerRef;
|
||||
CFRunLoopRef runLoopRef;
|
||||
CFRunLoopObserverContext context = { 0, this, NULL, NULL, NULL };
|
||||
CFRunLoopObserverContext context = { 0, this, nullptr, nullptr, nullptr };
|
||||
UInt32 size = sizeof( CFRunLoopRef );
|
||||
|
||||
if( (error = AudioHardwareGetProperty(kAudioHardwarePropertyRunLoop, &size, &runLoopRef)) )
|
||||
@@ -300,7 +300,7 @@ float RageSoundDriver_AU::GetPlayLatency() const
|
||||
size = sizeof( UInt32 );
|
||||
|
||||
do {
|
||||
if( (error = AudioDeviceGetPropertyInfo(OutputDevice, 0, false, kAudioDevicePropertyStreams, &size, NULL)) )
|
||||
if( (error = AudioDeviceGetPropertyInfo(OutputDevice, 0, false, kAudioDevicePropertyStreams, &size, nullptr)) )
|
||||
{
|
||||
LOG->Warn( WERROR("Device has no streams", error) );
|
||||
break;
|
||||
|
||||
@@ -54,7 +54,7 @@ void RageSoundDriver_OSS::MixerThread()
|
||||
usleep( 10000 );
|
||||
|
||||
struct timeval tv = { 0, 10000 };
|
||||
select(fd+1, NULL, &f, NULL, &tv);
|
||||
select(fd+1, nullptr, &f, nullptr, &tv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ RString RageSoundDriver_PulseAudio::Init()
|
||||
pa_context_set_state_callback(m_PulseCtx, StaticCtxStateCb, this);
|
||||
|
||||
LOG->Trace("Pulse: pa_context_connect()...");
|
||||
error = pa_context_connect(m_PulseCtx, NULL, (pa_context_flags_t)0, NULL);
|
||||
error = pa_context_connect(m_PulseCtx, nullptr, (pa_context_flags_t)0, nullptr);
|
||||
|
||||
if(error < 0)
|
||||
{
|
||||
@@ -224,8 +224,8 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
||||
|
||||
/* connect the stream for playback */
|
||||
LOG->Trace("Pulse: pa_stream_connect_playback()...");
|
||||
error = pa_stream_connect_playback(m_PulseStream, NULL, &attr,
|
||||
PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL);
|
||||
error = pa_stream_connect_playback(m_PulseStream, nullptr, &attr,
|
||||
PA_STREAM_AUTO_TIMING_UPDATE, nullptr, nullptr);
|
||||
if(error < 0)
|
||||
{
|
||||
if(asprintf(&m_Error, "pa_stream_connect_playback(): %s",
|
||||
@@ -316,7 +316,7 @@ void RageSoundDriver_PulseAudio::StreamWriteCb(pa_stream *s, size_t length)
|
||||
int64_t pos1 = m_LastPosition;
|
||||
int64_t pos2 = pos1 + nbframes/2; /* Mix() position in stereo frames */
|
||||
this->Mix( buf, pos2-pos1, pos1, pos2);
|
||||
if(pa_stream_write(m_PulseStream, buf, length, NULL, 0, PA_SEEK_RELATIVE) < 0)
|
||||
if(pa_stream_write(m_PulseStream, buf, length, nullptr, 0, PA_SEEK_RELATIVE) < 0)
|
||||
{
|
||||
RageException::Throw("Pulse: pa_stream_write()");
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ static bool WdmSyncIoctl(
|
||||
|
||||
OVERLAPPED overlapped;
|
||||
memset( &overlapped, 0, sizeof(overlapped) );
|
||||
overlapped.hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
overlapped.hEvent = CreateEvent( NULL, FALSE, FALSE, nullptr );
|
||||
if( !overlapped.hEvent )
|
||||
{
|
||||
sError = werr_ssprintf( GetLastError(), "CreateEvent" );
|
||||
@@ -201,7 +201,7 @@ static bool WdmGetPropertySimple( HANDLE hHandle, const GUID *pGuidPropertySet,
|
||||
if( pInstance )
|
||||
memcpy( &ksProperty[1], pInstance, iInstanceSize );
|
||||
|
||||
return WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, ksProperty, iPropertySize, pValue, iValueSize, NULL, sError );
|
||||
return WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, ksProperty, iPropertySize, pValue, iValueSize, nullptr, sError );
|
||||
}
|
||||
|
||||
static bool WdmSetPropertySimple(
|
||||
@@ -222,7 +222,7 @@ static bool WdmSetPropertySimple(
|
||||
if( instance )
|
||||
memcpy( ((char*)ksProperty + sizeof(KSPROPERTY)), instance, iInstanceSize );
|
||||
|
||||
return WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, ksProperty, iPropertySize, pValue, iValueSize, NULL, sError );
|
||||
return WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, ksProperty, iPropertySize, pValue, iValueSize, nullptr, sError );
|
||||
}
|
||||
|
||||
static bool WdmGetPinPropertySimple( HANDLE hHandle, unsigned long iPinId, const GUID *pGuidPropertySet, unsigned long iProperty,
|
||||
@@ -235,7 +235,7 @@ static bool WdmGetPinPropertySimple( HANDLE hHandle, unsigned long iPinId, const
|
||||
ksPProp.PinId = iPinId;
|
||||
ksPProp.Reserved = 0;
|
||||
|
||||
return WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, &ksPProp, sizeof(KSP_PIN), pValue, iInstanceSize, NULL, sError );
|
||||
return WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, &ksPProp, sizeof(KSP_PIN), pValue, iInstanceSize, nullptr, sError );
|
||||
}
|
||||
|
||||
static bool WdmGetPinPropertyMulti(
|
||||
@@ -255,13 +255,13 @@ static bool WdmGetPinPropertyMulti(
|
||||
ksPProp.Reserved = 0;
|
||||
|
||||
unsigned long multipleItemSize = 0;
|
||||
if( !WdmSyncIoctl(hHandle, IOCTL_KS_PROPERTY, &ksPProp.Property, sizeof(KSP_PIN), NULL, 0, &multipleItemSize, sError) )
|
||||
if( !WdmSyncIoctl(hHandle, IOCTL_KS_PROPERTY, &ksPProp.Property, sizeof(KSP_PIN), nullptr, 0, &multipleItemSize, sError) )
|
||||
return false;
|
||||
|
||||
*ksMultipleItem = (KSMULTIPLE_ITEM*) malloc( multipleItemSize );
|
||||
ASSERT( *ksMultipleItem != nullptr );
|
||||
|
||||
if( !WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, &ksPProp, sizeof(KSP_PIN), (void*)*ksMultipleItem, multipleItemSize, NULL, sError) )
|
||||
if( !WdmSyncIoctl( hHandle, IOCTL_KS_PROPERTY, &ksPProp, sizeof(KSP_PIN), (void*)*ksMultipleItem, multipleItemSize, nullptr, sError) )
|
||||
{
|
||||
free( ksMultipleItem );
|
||||
return false;
|
||||
@@ -442,7 +442,7 @@ bool WinWdmPin::SetState( KSSTATE state, RString &sError )
|
||||
{
|
||||
ASSERT( m_hHandle != nullptr );
|
||||
return WdmSetPropertySimple( m_hHandle, &KSPROPSETID_Connection, KSPROPERTY_CONNECTION_STATE,
|
||||
&state, sizeof(state), NULL, 0, sError );
|
||||
&state, sizeof(state), nullptr, 0, sError );
|
||||
}
|
||||
|
||||
bool WinWdmPin::Instantiate( const WAVEFORMATEX *pFormat, RString &sError )
|
||||
@@ -587,7 +587,7 @@ bool WinWdmFilter::Use( RString &sError )
|
||||
{
|
||||
/* Open the filter */
|
||||
m_hHandle = CreateFile( m_sFilterName, GENERIC_READ | GENERIC_WRITE, 0,
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, nullptr );
|
||||
|
||||
if( m_hHandle == nullptr )
|
||||
{
|
||||
@@ -804,7 +804,7 @@ static bool GetDevicePath( HANDLE hHandle, SP_DEVICE_INTERFACE_DATA *pInterfaceD
|
||||
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||
devInfoData.Reserved = 0;
|
||||
|
||||
if( !SetupDiGetDeviceInterfaceDetail(hHandle, pInterfaceData, devInterfaceDetails, sizeInterface, NULL, &devInfoData) )
|
||||
if( !SetupDiGetDeviceInterfaceDetail(hHandle, pInterfaceData, devInterfaceDetails, sizeInterface, nullptr, &devInfoData) )
|
||||
return false;
|
||||
sPath = devInterfaceDetails->DevicePath;
|
||||
return true;
|
||||
@@ -816,7 +816,7 @@ static bool BuildFilterList( vector<WinWdmFilter*> &aFilters, RString &sError )
|
||||
const GUID *pCategoryGuid = (GUID*) &KSCATEGORY_RENDER;
|
||||
|
||||
/* Open a handle to search for devices (filters) */
|
||||
HDEVINFO hHandle = SetupDiGetClassDevs( pCategoryGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE );
|
||||
HDEVINFO hHandle = SetupDiGetClassDevs( pCategoryGuid, nullptr, nullptr, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE );
|
||||
if( hHandle == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
sError = werr_ssprintf( GetLastError(), "SetupDiGetClassDevs" );
|
||||
@@ -831,7 +831,7 @@ static bool BuildFilterList( vector<WinWdmFilter*> &aFilters, RString &sError )
|
||||
SP_DEVICE_INTERFACE_DATA interfaceData;
|
||||
interfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
interfaceData.Reserved = 0;
|
||||
if( !SetupDiEnumDeviceInterfaces(hHandle, NULL, pCategoryGuid, device, &interfaceData) )
|
||||
if( !SetupDiEnumDeviceInterfaces(hHandle, nullptr, pCategoryGuid, device, &interfaceData) )
|
||||
break; /* No more devices */
|
||||
if( !interfaceData.Flags || (interfaceData.Flags & SPINT_REMOVED) )
|
||||
continue;
|
||||
@@ -899,7 +899,7 @@ struct WinWdmStream
|
||||
{
|
||||
memset( this, 0, sizeof(*this) );
|
||||
for( int i = 0; i < MAX_CHUNKS; ++i )
|
||||
m_Signal[i].hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
m_Signal[i].hEvent = CreateEvent( NULL, FALSE, FALSE, nullptr );
|
||||
m_pPlaybackPin = nullptr;
|
||||
}
|
||||
|
||||
@@ -969,12 +969,12 @@ bool WinWdmStream::Open( WinWdmFilter *pFilter,
|
||||
KSALLOCATOR_FRAMING ksaf;
|
||||
KSALLOCATOR_FRAMING_EX ksafex;
|
||||
if( WdmGetPropertySimple(m_pPlaybackPin->m_hHandle, &KSPROPSETID_Connection, KSPROPERTY_CONNECTION_ALLOCATORFRAMING,
|
||||
&ksaf, sizeof(ksaf), NULL, 0, sError) )
|
||||
&ksaf, sizeof(ksaf), nullptr, 0, sError) )
|
||||
{
|
||||
iFrameSize = ksaf.FrameSize;
|
||||
}
|
||||
else if( WdmGetPropertySimple(m_pPlaybackPin->m_hHandle, &KSPROPSETID_Connection, KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX,
|
||||
&ksafex, sizeof(ksafex), NULL, 0, sError) )
|
||||
&ksafex, sizeof(ksafex), nullptr, 0, sError) )
|
||||
{
|
||||
iFrameSize = ksafex.FramingItem[0].FramingRange.Range.MinFrameSize;
|
||||
}
|
||||
@@ -1021,8 +1021,8 @@ error:
|
||||
bool WinWdmStream::SubmitPacket( int iPacket, RString &sError )
|
||||
{
|
||||
KSSTREAM_HEADER *p = &m_Packets[iPacket];
|
||||
int iRet = DeviceIoControl( m_pPlaybackPin->m_hHandle, IOCTL_KS_WRITE_STREAM, NULL, 0,
|
||||
p, p->Size, NULL, &m_Signal[iPacket] );
|
||||
int iRet = DeviceIoControl( m_pPlaybackPin->m_hHandle, IOCTL_KS_WRITE_STREAM, nullptr, 0,
|
||||
p, p->Size, nullptr, &m_Signal[iPacket] );
|
||||
ASSERT_M( iRet == 0, "DeviceIoControl" );
|
||||
|
||||
DWORD iError = GetLastError();
|
||||
@@ -1254,7 +1254,7 @@ int64_t RageSoundDriver_WDMKS::GetPosition() const
|
||||
|
||||
RString sError;
|
||||
WdmGetPropertySimple( m_pStream->m_pPlaybackPin->m_hHandle, &KSPROPSETID_Audio, KSPROPERTY_AUDIO_POSITION,
|
||||
&pos, sizeof(pos), NULL, 0, sError );
|
||||
&pos, sizeof(pos), nullptr, 0, sError );
|
||||
ASSERT_M( sError == "", sError );
|
||||
|
||||
pos.PlayOffset /= m_pStream->m_iBytesPerOutputSample * m_pStream->m_iDeviceOutputChannels;
|
||||
@@ -1267,7 +1267,7 @@ RageSoundDriver_WDMKS::RageSoundDriver_WDMKS()
|
||||
m_pFilter = nullptr;
|
||||
m_bShutdown = false;
|
||||
m_iLastCursorPos = 0;
|
||||
m_hSignal = CreateEvent( NULL, FALSE, FALSE, NULL ); /* abort event */
|
||||
m_hSignal = CreateEvent( NULL, FALSE, FALSE, nullptr ); /* abort event */
|
||||
}
|
||||
|
||||
RString RageSoundDriver_WDMKS::Init()
|
||||
|
||||
@@ -104,7 +104,7 @@ RageSoundDriver_WaveOut::RageSoundDriver_WaveOut()
|
||||
m_bShutdown = false;
|
||||
m_iLastCursorPos = 0;
|
||||
|
||||
m_hSoundEvent = CreateEvent( NULL, false, true, NULL );
|
||||
m_hSoundEvent = CreateEvent( NULL, false, true, nullptr );
|
||||
|
||||
m_hWaveOut = nullptr;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
|
||||
thread->m_StartFinishedSem = new SemaImpl_Pthreads( 0 );
|
||||
|
||||
int ret = pthread_create( &thread->thread, NULL, StartThread, thread );
|
||||
int ret = pthread_create( &thread->thread, nullptr, StartThread, thread );
|
||||
ASSERT_M( ret == 0, ssprintf( "MakeThread: pthread_create: %s", strerror(errno)) );
|
||||
|
||||
// Don't return until StartThread sets m_piThreadID.
|
||||
@@ -94,7 +94,7 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
MutexImpl_Pthreads::MutexImpl_Pthreads( RageMutex *pParent ):
|
||||
MutexImpl( pParent )
|
||||
{
|
||||
pthread_mutex_init( &mutex, NULL );
|
||||
pthread_mutex_init( &mutex, nullptr );
|
||||
}
|
||||
|
||||
MutexImpl_Pthreads::~MutexImpl_Pthreads()
|
||||
@@ -129,7 +129,7 @@ bool MutexImpl_Pthreads::Lock()
|
||||
/* Wait for ten seconds. If it takes longer than that, we're
|
||||
* probably deadlocked. */
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
timespec ts;
|
||||
ts.tv_sec = tv.tv_sec + len;
|
||||
@@ -327,7 +327,7 @@ bool EventImpl_Pthreads::Wait( RageTimer *pTimeout )
|
||||
{
|
||||
// The RageTimer clock is different than the wait clock; convert it.
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
RageTimer timeofday( tv.tv_sec, tv.tv_usec );
|
||||
|
||||
@@ -427,9 +427,9 @@ bool SemaImpl_Pthreads::TryWait()
|
||||
// Use conditions, to work around OS X "forgetting" to implement semaphores.
|
||||
SemaImpl_Pthreads::SemaImpl_Pthreads( int iInitialValue )
|
||||
{
|
||||
int ret = pthread_cond_init( &m_Cond, NULL );
|
||||
int ret = pthread_cond_init( &m_Cond, nullptr );
|
||||
ASSERT_M( ret == 0, ssprintf( "SemaImpl_Pthreads: pthread_cond_init: %s", strerror(errno)) );
|
||||
ret = pthread_mutex_init( &m_Mutex, NULL );
|
||||
ret = pthread_mutex_init( &m_Mutex, nullptr );
|
||||
ASSERT_M( ret == 0, ssprintf( "SemaImpl_Pthreads: pthread_mutex_init: %s", strerror(errno)) );
|
||||
|
||||
m_iValue = iInitialValue;
|
||||
@@ -456,7 +456,7 @@ bool SemaImpl_Pthreads::Wait()
|
||||
if( UseTimedlock() )
|
||||
{
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
/* Wait for ten seconds. If it takes longer than that, we're probably deadlocked. */
|
||||
timespec ts;
|
||||
|
||||
@@ -174,7 +174,7 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
MutexImpl_Win32::MutexImpl_Win32( RageMutex *pParent ):
|
||||
MutexImpl( pParent )
|
||||
{
|
||||
mutex = CreateMutex( NULL, false, NULL );
|
||||
mutex = CreateMutex( NULL, false, nullptr );
|
||||
ASSERT_M( mutex != nullptr, werr_ssprintf(GetLastError(), "CreateMutex") );
|
||||
}
|
||||
|
||||
@@ -263,9 +263,9 @@ EventImpl_Win32::EventImpl_Win32( MutexImpl_Win32 *pParent )
|
||||
{
|
||||
m_pParent = pParent;
|
||||
m_iNumWaiting = 0;
|
||||
m_WakeupSema = CreateSemaphore( NULL, 0, 0x7fffffff, NULL );
|
||||
m_WakeupSema = CreateSemaphore( NULL, 0, 0x7fffffff, nullptr );
|
||||
InitializeCriticalSection( &m_iNumWaitingLock );
|
||||
m_WaitersDone = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
m_WaitersDone = CreateEvent( NULL, FALSE, FALSE, nullptr );
|
||||
}
|
||||
|
||||
EventImpl_Win32::~EventImpl_Win32()
|
||||
@@ -432,7 +432,7 @@ EventImpl *MakeEvent( MutexImpl *pMutex )
|
||||
|
||||
SemaImpl_Win32::SemaImpl_Win32( int iInitialValue )
|
||||
{
|
||||
sem = CreateSemaphore( NULL, iInitialValue, 999999999, NULL );
|
||||
sem = CreateSemaphore( NULL, iInitialValue, 999999999, nullptr );
|
||||
m_iCounter = iInitialValue;
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ SemaImpl_Win32::~SemaImpl_Win32()
|
||||
void SemaImpl_Win32::Post()
|
||||
{
|
||||
++m_iCounter;
|
||||
ReleaseSemaphore( sem, 1, NULL );
|
||||
ReleaseSemaphore( sem, 1, nullptr );
|
||||
}
|
||||
|
||||
bool SemaImpl_Win32::Wait()
|
||||
|
||||
@@ -21,7 +21,7 @@ RString CrashHandler::GetLogsDirectory()
|
||||
}
|
||||
|
||||
// XXX Can we use LocalizedString here instead?
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), NULL, CFSTR("Localizable") )
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), nullptr, CFSTR("Localizable") )
|
||||
|
||||
void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
{
|
||||
@@ -38,12 +38,12 @@ void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
CFStringRef sFormat = LSTRING( bundle, PRODUCT_FAMILY " has crashed. "
|
||||
"Debugging information has been output to\n\n%s\n\n"
|
||||
"Please file a bug report at\n\n%s" );
|
||||
CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, NULL, sFormat,
|
||||
CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, nullptr, sFormat,
|
||||
sPath.c_str(), REPORT_BUG_URL );
|
||||
CFOptionFlags response = kCFUserNotificationCancelResponse;
|
||||
CFTimeInterval timeout = 0.0; // Should we ever time out?
|
||||
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, nullptr, nullptr, nullptr,
|
||||
sTitle, sBody, sDefault, sAlternate, sOther, &response );
|
||||
|
||||
switch( response )
|
||||
@@ -83,7 +83,7 @@ bool CrashHandler::IsDebuggerPresent()
|
||||
|
||||
// Call sysctl.
|
||||
size = sizeof( info );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, NULL, 0 );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, nullptr, 0 );
|
||||
|
||||
// We're being debugged if the P_TRACED flag is set.
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ protected:
|
||||
// Perform a synchronous set report on the HID interface.
|
||||
inline IOReturn SetReport( IOHIDReportType type, UInt32 reportID, void *buffer, UInt32 size, UInt32 timeoutMS )
|
||||
{
|
||||
return CALL( m_Interface, setReport, type, reportID, buffer, size, timeoutMS, NULL, NULL, NULL );
|
||||
return CALL( m_Interface, setReport, type, reportID, buffer, size, timeoutMS, nullptr, nullptr, nullptr );
|
||||
}
|
||||
public:
|
||||
HIDDevice();
|
||||
|
||||
@@ -10,7 +10,7 @@ bool Vector::CheckForVector()
|
||||
int32_t result = 0;
|
||||
size_t size = 4;
|
||||
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, NULL, 0 ) && result;
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, nullptr, 0 ) && result;
|
||||
}
|
||||
|
||||
/* for( unsigned pos = 0; pos < size; ++pos )
|
||||
|
||||
@@ -42,7 +42,7 @@ void BacktraceNames::Demangle()
|
||||
return;
|
||||
|
||||
int status = 0;
|
||||
char *name = abi::__cxa_demangle( Symbol, NULL, NULL, &status );
|
||||
char *name = abi::__cxa_demangle( Symbol, nullptr, nullptr, &status );
|
||||
if( name )
|
||||
{
|
||||
Symbol = name;
|
||||
@@ -375,7 +375,7 @@ void BacktraceNames::FromAddr( const void *p )
|
||||
char *p;
|
||||
asprintf(&p, "%d", ppid);
|
||||
|
||||
execl("/usr/bin/atos", "/usr/bin/atos", "-p", p, addy, NULL);
|
||||
execl("/usr/bin/atos", "/usr/bin/atos", "-p", p, addy, nullptr);
|
||||
|
||||
fprintf(stderr, "execl(atos) failed: %s\n", strerror(errno));
|
||||
free(addy);
|
||||
|
||||
@@ -80,13 +80,13 @@ static void NORETURN spawn_child_process( int from_parent )
|
||||
strncpy( magic, CHILD_MAGIC_PARAMETER, sizeof(magic) );
|
||||
|
||||
/* Use execve; it's the lowest-level of the exec calls. The others may allocate. */
|
||||
char *argv[3] = { path, magic, NULL };
|
||||
char *argv[3] = { path, magic, nullptr };
|
||||
char *envp[1] = { NULL };
|
||||
execve( path, argv, envp );
|
||||
|
||||
/* If we got here, the exec failed. We can't call strerror. */
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", NULL);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", NULL );
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", nullptr);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@@ -108,13 +108,13 @@ static bool parent_write( int to_child, const void *p, size_t size )
|
||||
int ret = retried_write( to_child, p, size );
|
||||
if( ret == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( size_t(ret) != size )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
{
|
||||
if( g_pCrashHandlerArgv0 == nullptr )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -213,9 +213,9 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
struct sigaction sa;
|
||||
memset( &sa, 0, sizeof(sa) );
|
||||
sa.sa_handler = SIG_IGN;
|
||||
if( sigaction( SIGPIPE, &sa, NULL ) != 0 )
|
||||
if( sigaction( SIGPIPE, &sa, nullptr ) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), NULL );
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), nullptr );
|
||||
/* non-fatal */
|
||||
}
|
||||
|
||||
@@ -229,22 +229,22 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
switch( crash->type )
|
||||
{
|
||||
case CrashData::SIGNAL:
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", NULL );
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", nullptr );
|
||||
break;
|
||||
|
||||
case CrashData::FORCE_CRASH:
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", nullptr );
|
||||
break;
|
||||
|
||||
default:
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", nullptr );
|
||||
break;
|
||||
}
|
||||
|
||||
if( active == 1 )
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", NULL);
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", nullptr);
|
||||
else if( active == 2 )
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", NULL);
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", nullptr);
|
||||
|
||||
_exit( 1 );
|
||||
}
|
||||
@@ -259,14 +259,14 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
int fds[2];
|
||||
if( pipe(fds) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", nullptr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
pid_t childpid = fork();
|
||||
if( childpid == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
RageThread::ResumeAllThreads();
|
||||
|
||||
if( WIFSIGNALED(status) )
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
strncpy( crash.reason, reason, sizeof(crash.reason) );
|
||||
crash.reason[ sizeof(crash.reason)-1 ] = 0;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
RunCrashHandler( &crash );
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
|
||||
crash.type = CrashData::FORCE_CRASH;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
if( iID == GetInvalidThreadId() )
|
||||
{
|
||||
@@ -376,7 +376,7 @@ void CrashHandler::CrashSignalHandler( int signal, siginfo_t *si, const ucontext
|
||||
static volatile bool bInCrashSignalHandler = false;
|
||||
if( bInCrashSignalHandler )
|
||||
{
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", NULL );
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ static void child_process()
|
||||
|
||||
FD_ZERO( &rs );
|
||||
FD_SET( 3, &rs );
|
||||
int ret = select( 4, &rs, NULL, NULL, &timeout );
|
||||
int ret = select( 4, &rs, nullptr, nullptr, &timeout );
|
||||
|
||||
if( ret == 0 )
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ static int waittid( int ThreadID, int *status, int options )
|
||||
static int PtraceAttach( int ThreadID )
|
||||
{
|
||||
int ret;
|
||||
ret = ptrace( PTRACE_ATTACH, ThreadID, NULL, NULL );
|
||||
ret = ptrace( PTRACE_ATTACH, ThreadID, nullptr, nullptr );
|
||||
if( ret == -1 )
|
||||
{
|
||||
printf("ptrace failed: %s\n", strerror(errno) );
|
||||
@@ -114,7 +114,7 @@ static int PtraceAttach( int ThreadID )
|
||||
|
||||
static int PtraceDetach( int ThreadID )
|
||||
{
|
||||
return ptrace( PTRACE_DETACH, ThreadID, NULL, NULL );
|
||||
return ptrace( PTRACE_DETACH, ThreadID, nullptr, nullptr );
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx )
|
||||
|
||||
#if defined(CPU_X86_64) || defined(CPU_X86)
|
||||
user_regs_struct regs;
|
||||
if( ptrace( PTRACE_GETREGS, pid_t(ThreadID), NULL, ®s ) == -1 )
|
||||
if( ptrace( PTRACE_GETREGS, pid_t(ThreadID), nullptr, ®s ) == -1 )
|
||||
return false;
|
||||
|
||||
ctx->pid = pid_t(ThreadID);
|
||||
|
||||
@@ -57,7 +57,7 @@ SaveSignals::SaveSignals()
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigaction( signals[i], NULL, &sa );
|
||||
sigaction( signals[i], nullptr, &sa );
|
||||
old_handlers.push_back( sa );
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ SaveSignals::~SaveSignals()
|
||||
{
|
||||
/* Restore the old signal handlers. */
|
||||
for( unsigned i = 0; i < old_handlers.size(); ++i )
|
||||
sigaction( signals[i], &old_handlers[i], NULL );
|
||||
sigaction( signals[i], &old_handlers[i], nullptr );
|
||||
}
|
||||
|
||||
static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
@@ -86,7 +86,7 @@ static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
struct sigaction old;
|
||||
sigaction( signal, &sa, &old );
|
||||
raise( signal );
|
||||
sigaction( signal, &old, NULL );
|
||||
sigaction( signal, &old, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ void SignalHandler::OnClose( handler h )
|
||||
ss.ss_sp = (char*)p; /* cast for Darwin */
|
||||
ss.ss_size = AltStackSize;
|
||||
ss.ss_flags = 0;
|
||||
if( sigaltstack( &ss, NULL ) == -1 )
|
||||
if( sigaltstack( &ss, nullptr ) == -1 )
|
||||
{
|
||||
LOG->Info( "sigaltstack failed: %s", strerror(errno) );
|
||||
p = nullptr; /* no SA_ONSTACK */
|
||||
@@ -185,11 +185,11 @@ void SignalHandler::OnClose( handler h )
|
||||
/* Set up our signal handlers. */
|
||||
sa.sa_sigaction = SigHandler;
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
sigaction( signals[i], &sa, NULL );
|
||||
sigaction( signals[i], &sa, nullptr );
|
||||
|
||||
/* Block SIGPIPE, so we get EPIPE. */
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction( SIGPIPE, &sa, NULL );
|
||||
sigaction( SIGPIPE, &sa, nullptr );
|
||||
}
|
||||
handlers.push_back(h);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void WriteToChild( HANDLE hPipe, const void *pData, size_t iSize )
|
||||
while( iSize )
|
||||
{
|
||||
DWORD iActual;
|
||||
if( !WriteFile(hPipe, pData, iSize, &iActual, NULL) )
|
||||
if( !WriteFile(hPipe, pData, iSize, &iActual, nullptr) )
|
||||
return;
|
||||
iSize -= iActual;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void RunChild()
|
||||
* since GetModuleFileNameEx might not be available. Run the requests here. */
|
||||
HMODULE hMod;
|
||||
DWORD iActual;
|
||||
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, NULL) )
|
||||
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, nullptr) )
|
||||
break;
|
||||
|
||||
TCHAR szName[MAX_PATH];
|
||||
@@ -331,7 +331,7 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||
/* Now things get more risky. If we're fullscreen, the window will obscure
|
||||
* the crash dialog. Try to hide the window. Things might blow up here; do
|
||||
* this after DoSave, so we always write a crash dump. */
|
||||
if( GetWindowThreadProcessId( g_hForegroundWnd, NULL ) == GetCurrentThreadId() )
|
||||
if( GetWindowThreadProcessId( g_hForegroundWnd, nullptr ) == GetCurrentThreadId() )
|
||||
{
|
||||
/* The thread that crashed was the thread that created the main window.
|
||||
* Hide the window. This will also restore the video mode, if necessary. */
|
||||
@@ -445,7 +445,7 @@ static bool PointsToValidCall( unsigned long ptr )
|
||||
|
||||
memset( buf, 0, sizeof(buf) );
|
||||
|
||||
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, NULL))
|
||||
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, nullptr))
|
||||
--len;
|
||||
|
||||
return IsValidCall(buf+7, len);
|
||||
@@ -521,7 +521,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
break;
|
||||
|
||||
lpAddr += 4;
|
||||
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, NULL));
|
||||
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, nullptr));
|
||||
|
||||
*buf = nullptr;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace VDDebugInfo
|
||||
GetVDIPath( pctx->sFilename, ARRAYLEN(pctx->sFilename) );
|
||||
pctx->sError = RString();
|
||||
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
|
||||
if( h == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
pctx->sError = werr_ssprintf( GetLastError(), "CreateFile failed" );
|
||||
@@ -131,7 +131,7 @@ namespace VDDebugInfo
|
||||
}
|
||||
|
||||
do {
|
||||
DWORD dwFileSize = GetFileSize( h, NULL );
|
||||
DWORD dwFileSize = GetFileSize( h, nullptr );
|
||||
if( dwFileSize == INVALID_FILE_SIZE )
|
||||
break;
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace VDDebugInfo
|
||||
break;
|
||||
|
||||
DWORD dwActual;
|
||||
int iRet = ReadFile(h, pBuf, dwFileSize, &dwActual, NULL);
|
||||
int iRet = ReadFile(h, pBuf, dwFileSize, &dwActual, nullptr);
|
||||
CloseHandle(h);
|
||||
pctx->sRawBlock.ReleaseBuffer( dwActual );
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace SymbolLookup
|
||||
{
|
||||
SymSetOptions( SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS );
|
||||
|
||||
if( !SymInitialize(g_hParent, NULL, TRUE) )
|
||||
if( !SymInitialize(g_hParent, nullptr, TRUE) )
|
||||
return false;
|
||||
|
||||
bInitted = true;
|
||||
@@ -745,7 +745,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
|
||||
m_pPost->Start( CRASH_REPORT_HOST, CRASH_REPORT_PORT, CRASH_REPORT_PATH );
|
||||
|
||||
SetTimer( hDlg, 0, 100, NULL );
|
||||
SetTimer( hDlg, 0, 100, nullptr );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -174,7 +174,7 @@ NetworkStream_Win32::NetworkStream_Win32():
|
||||
#if defined(WINDOWS)
|
||||
m_hResolve = nullptr;
|
||||
m_hResolveHwnd = nullptr;
|
||||
m_hCompletionEvent = CreateEvent( NULL, true, false, NULL );
|
||||
m_hCompletionEvent = CreateEvent( NULL, true, false, nullptr );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
#include "global.h"
|
||||
#include "ErrorStrings.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
RString werr_ssprintf( int err, const char *fmt, ... )
|
||||
{
|
||||
char buf[1024] = "";
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0, err, 0, buf, sizeof(buf), NULL);
|
||||
|
||||
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
||||
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
||||
RString text = buf;
|
||||
text.Replace( "\n", "" );
|
||||
text.Replace( "\r", " " ); // foo\r\nbar -> foo bar
|
||||
TrimRight( text ); // "foo\r\n" -> "foo"
|
||||
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
RString s = vssprintf( fmt, va );
|
||||
va_end(va);
|
||||
|
||||
return s += ssprintf( " (%s)", text.c_str() );
|
||||
}
|
||||
|
||||
RString ConvertWstringToCodepage( wstring s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return RString();
|
||||
|
||||
int iBytes = WideCharToMultiByte( iCodePage, 0, s.data(), s.size(),
|
||||
NULL, 0, NULL, FALSE );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
|
||||
|
||||
RString ret;
|
||||
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
|
||||
ret.GetBuffer( iBytes ), iBytes, NULL, FALSE );
|
||||
ret.ReleaseBuffer( iBytes );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RString ConvertUTF8ToACP( const RString &s )
|
||||
{
|
||||
return ConvertWstringToCodepage( RStringToWstring(s), CP_ACP );
|
||||
}
|
||||
|
||||
wstring ConvertCodepageToWString( RString s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return wstring();
|
||||
|
||||
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), NULL, 0 );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "MultiByteToWideChar" ).c_str() );
|
||||
|
||||
wchar_t *pTemp = new wchar_t[iBytes];
|
||||
MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), pTemp, iBytes );
|
||||
wstring sRet( pTemp, iBytes );
|
||||
delete [] pTemp;
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
RString ConvertACPToUTF8( const RString &s )
|
||||
{
|
||||
return WStringToRString( ConvertCodepageToWString(s, CP_ACP) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "ErrorStrings.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
RString werr_ssprintf( int err, const char *fmt, ... )
|
||||
{
|
||||
char buf[1024] = "";
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0, err, 0, buf, sizeof(buf), nullptr);
|
||||
|
||||
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
||||
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
||||
RString text = buf;
|
||||
text.Replace( "\n", "" );
|
||||
text.Replace( "\r", " " ); // foo\r\nbar -> foo bar
|
||||
TrimRight( text ); // "foo\r\n" -> "foo"
|
||||
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
RString s = vssprintf( fmt, va );
|
||||
va_end(va);
|
||||
|
||||
return s += ssprintf( " (%s)", text.c_str() );
|
||||
}
|
||||
|
||||
RString ConvertWstringToCodepage( wstring s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return RString();
|
||||
|
||||
int iBytes = WideCharToMultiByte( iCodePage, 0, s.data(), s.size(),
|
||||
NULL, 0, nullptr, FALSE );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
|
||||
|
||||
RString ret;
|
||||
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
|
||||
ret.GetBuffer( iBytes ), iBytes, nullptr, FALSE );
|
||||
ret.ReleaseBuffer( iBytes );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RString ConvertUTF8ToACP( const RString &s )
|
||||
{
|
||||
return ConvertWstringToCodepage( RStringToWstring(s), CP_ACP );
|
||||
}
|
||||
|
||||
wstring ConvertCodepageToWString( RString s, int iCodePage )
|
||||
{
|
||||
if( s.empty() )
|
||||
return wstring();
|
||||
|
||||
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), nullptr, 0 );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "MultiByteToWideChar" ).c_str() );
|
||||
|
||||
wchar_t *pTemp = new wchar_t[iBytes];
|
||||
MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), pTemp, iBytes );
|
||||
wstring sRet( pTemp, iBytes );
|
||||
delete [] pTemp;
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
RString ConvertACPToUTF8( const RString &s )
|
||||
{
|
||||
return WStringToRString( ConvertCodepageToWString(s, CP_ACP) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2005 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata )
|
||||
bool GotoURL( RString sUrl )
|
||||
{
|
||||
// First try ShellExecute()
|
||||
int iRet = (int) ShellExecute( NULL, "open", sUrl, NULL, NULL, SW_SHOWDEFAULT );
|
||||
int iRet = (int) ShellExecute( NULL, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT );
|
||||
|
||||
// If it failed, get the .htm regkey and lookup the program
|
||||
if( iRet > 32 )
|
||||
|
||||
@@ -283,7 +283,7 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
|
||||
AppInstance inst;
|
||||
HWND hWnd = CreateWindow( g_sClassName, "app", iWindowStyle,
|
||||
0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
if( hWnd == nullptr )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
|
||||
|
||||
@@ -363,9 +363,9 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
* If we don't do this, then starting up in a D3D fullscreen window may
|
||||
* cause all other windows on the system to be resized. */
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
@@ -399,10 +399,10 @@ void GraphicsWindow::DestroyGraphicsWindow()
|
||||
CHECKPOINT;
|
||||
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
CHECKPOINT;
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
CHECKPOINT;
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
@@ -487,9 +487,9 @@ const VideoModeParams &GraphicsWindow::GetParams()
|
||||
void GraphicsWindow::Update()
|
||||
{
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ MessageWindow::MessageWindow( const RString &sClassName )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "RegisterClass" ).c_str() );
|
||||
|
||||
// XXX: on 2k/XP, use HWND_MESSAGE as parent
|
||||
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
ASSERT( m_hWnd != nullptr );
|
||||
|
||||
SetProp( m_hWnd, "MessageWindow", this );
|
||||
|
||||
@@ -66,7 +66,7 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RSt
|
||||
char sBuffer[MAX_PATH];
|
||||
DWORD iSize = sizeof(sBuffer);
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE)sBuffer, &iSize );
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE)sBuffer, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
@@ -92,7 +92,7 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int
|
||||
DWORD iValue;
|
||||
DWORD iSize = sizeof(iValue);
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE) &iValue, &iSize );
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE) &iValue, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
@@ -126,7 +126,7 @@ bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, c
|
||||
FILETIME ft;
|
||||
char szBuffer[MAX_PATH];
|
||||
DWORD iSize = sizeof(szBuffer);
|
||||
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, NULL, NULL, NULL, &ft);
|
||||
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, nullptr, nullptr, nullptr, &ft);
|
||||
if( iRet == ERROR_NO_MORE_ITEMS )
|
||||
break;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ static RString GetUSBDevicePath( int iNum )
|
||||
GUID guid;
|
||||
HidD_GetHidGuid( &guid );
|
||||
|
||||
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
|
||||
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, nullptr, nullptr, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
|
||||
|
||||
SP_DEVICE_INTERFACE_DATA DeviceInterface;
|
||||
DeviceInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
@@ -33,14 +33,14 @@ static RString GetUSBDevicePath( int iNum )
|
||||
}
|
||||
|
||||
unsigned long iSize;
|
||||
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, NULL, 0, &iSize, 0 );
|
||||
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, nullptr, 0, &iSize, 0 );
|
||||
|
||||
PSP_INTERFACE_DEVICE_DETAIL_DATA DeviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc( iSize );
|
||||
DeviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
|
||||
|
||||
RString sRet;
|
||||
if( SetupDiGetDeviceInterfaceDetail(DeviceInfo, &DeviceInterface,
|
||||
DeviceDetail, iSize, &iSize, NULL) )
|
||||
DeviceDetail, iSize, &iSize, nullptr) )
|
||||
sRet = DeviceDetail->DevicePath;
|
||||
free( DeviceDetail );
|
||||
|
||||
@@ -56,7 +56,7 @@ bool USBDevice::Open( int iVID, int iPID, int iBlockSize, int iNum, void (*pfnIn
|
||||
while( (path = GetUSBDevicePath(iIndex++)) != "" )
|
||||
{
|
||||
HANDLE h = CreateFile( path, GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr );
|
||||
|
||||
if( h == INVALID_HANDLE_VALUE )
|
||||
continue;
|
||||
@@ -138,7 +138,7 @@ bool WindowsFileIO::Open( RString path, int iBlockSize )
|
||||
CloseHandle( m_Handle );
|
||||
|
||||
m_Handle = CreateFile( path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL );
|
||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr );
|
||||
|
||||
if( m_Handle == INVALID_HANDLE_VALUE )
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,7 @@ void WindowsDialogBox::Run( int iDialog )
|
||||
GetModuleFileName( NULL, szFullAppPath, MAX_PATH );
|
||||
HINSTANCE hHandle = LoadLibrary( szFullAppPath );
|
||||
|
||||
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), NULL, DlgProc, (LPARAM) this );
|
||||
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), nullptr, DlgProc, (LPARAM) this );
|
||||
}
|
||||
|
||||
BOOL APIENTRY WindowsDialogBox::DlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
|
||||
+2
-2
@@ -201,7 +201,7 @@ bool EzSockets::IsError()
|
||||
FD_ZERO(scks);
|
||||
FD_SET((unsigned)sock, scks);
|
||||
|
||||
if (select(sock+1, NULL, NULL, scks, times) >=0 )
|
||||
if (select(sock+1, nullptr, nullptr, scks, times) >=0 )
|
||||
return false;
|
||||
|
||||
state = skERROR;
|
||||
@@ -213,7 +213,7 @@ bool EzSockets::CanWrite()
|
||||
FD_ZERO(scks);
|
||||
FD_SET((unsigned)sock, scks);
|
||||
|
||||
return select(sock+1, NULL, scks, NULL, times) > 0;
|
||||
return select(sock+1, nullptr, scks, nullptr, times) > 0;
|
||||
}
|
||||
|
||||
void EzSockets::update()
|
||||
|
||||
+285
-285
@@ -1,285 +1,285 @@
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
/** @brief This macro is for INT8_MIN, etc. */
|
||||
#define __STDC_LIMIT_MACROS
|
||||
/** @brief This macro is for INT64_C, etc. */
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
/* Platform-specific fixes. */
|
||||
#if defined(WIN32)
|
||||
#include "archutils/Win32/arch_setup.h"
|
||||
#elif defined(PBBUILD)
|
||||
#include "archutils/Darwin/arch_setup.h"
|
||||
#elif defined(UNIX)
|
||||
#include "archutils/Unix/arch_setup.h"
|
||||
#endif
|
||||
|
||||
/* Set one of these in arch_setup.h. (Don't bother trying to fall back on BYTE_ORDER
|
||||
* if it was already set; too many systems are missing endian.h.) */
|
||||
#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
|
||||
#error Neither ENDIAN_LITTLE nor ENDIAN_BIG defined
|
||||
#endif
|
||||
|
||||
/* Define standard endianness macros, if they're missing. */
|
||||
#if defined(HAVE_ENDIAN_H)
|
||||
#include <endian.h>
|
||||
#elif defined(HAVE_MACHINE_ENDIAN_H)
|
||||
#include <machine/endian.h>
|
||||
#else
|
||||
/** @brief The macro for little endian order. */
|
||||
#define LITTLE_ENDIAN 1234
|
||||
/** @brief The macro for big endian order. */
|
||||
#define BIG_ENDIAN 4321
|
||||
#if defined(ENDIAN_LITTLE)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#elif defined(ENDIAN_BIG)
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Make sure everyone has min and max: */
|
||||
#include <algorithm>
|
||||
|
||||
/* Everything will need string for one reason or another: */
|
||||
#include <string>
|
||||
|
||||
/* And vector: */
|
||||
#include <vector>
|
||||
|
||||
#if !defined(MISSING_STDINT_H) /* need to define int64_t if so */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/* Branch optimizations: */
|
||||
#if defined(__GNUC__)
|
||||
#define likely(x) (__builtin_expect(!!(x), 1))
|
||||
#define unlikely(x) (__builtin_expect(!!(x), 0))
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
#if defined(NEED_CSTDLIB_WORKAROUND)
|
||||
#define llabs ::llabs
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef ASSERT
|
||||
#undef ASSERT
|
||||
#endif
|
||||
|
||||
/** @brief RageThreads defines (don't pull in all of RageThreads.h here) */
|
||||
namespace Checkpoints
|
||||
{
|
||||
void SetCheckpoint( const char *file, int line, const char *message );
|
||||
}
|
||||
/** @brief Set a checkpoint with no message. */
|
||||
#define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, NULL))
|
||||
/** @brief Set a checkpoint with a specified message. */
|
||||
#define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m))
|
||||
|
||||
|
||||
/**
|
||||
* @brief Define a macro to tell the compiler that a function doesn't return.
|
||||
*
|
||||
* This just improves compiler warnings. This should be placed near the
|
||||
* beginning of the function prototype (although it looks better near the end,
|
||||
* VC only accepts it at the beginning). */
|
||||
#if defined(_MSC_VER)
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
|
||||
#define NORETURN __attribute__ ((__noreturn__))
|
||||
#else
|
||||
#define NORETURN
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A crash has occured, and we're not getting out of it easily.
|
||||
*
|
||||
* For most users, this will result in a crashinfo.txt file being generated.
|
||||
* For anyone that is using a debug build, a debug break will be thrown to
|
||||
* allow viewing the current process.
|
||||
* @param reason the crash reason as determined by prior function calls.
|
||||
* @return nothing: there is no escape without quitting the program.
|
||||
*/
|
||||
void NORETURN sm_crash( const char *reason = "Internal error" );
|
||||
|
||||
/**
|
||||
* @brief Assertion that sets an optional message and brings up the crash
|
||||
* handler, so we get a backtrace.
|
||||
*
|
||||
* This should probably be used instead of throwing an exception in most
|
||||
* cases we expect never to happen (but not in cases that we do expect,
|
||||
* such as DSound init failure.) */
|
||||
#define FAIL_M(MESSAGE) do { CHECKPOINT_M(MESSAGE); sm_crash(MESSAGE); } while(0)
|
||||
#define ASSERT_M(COND, MESSAGE) do { if(unlikely(!(COND))) { FAIL_M(MESSAGE); } } while(0)
|
||||
|
||||
|
||||
#if !defined(CO_EXIST_WITH_MFC)
|
||||
#define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed")
|
||||
#endif
|
||||
|
||||
/** @brief Use this to catch switching on invalid values */
|
||||
#define DEFAULT_FAIL(i) default: FAIL_M( ssprintf("%s = %i", #i, (i)) )
|
||||
|
||||
void ShowWarningOrTrace( const char *file, int line, const char *message, bool bWarning ); // don't pull in LOG here
|
||||
#define WARN(MESSAGE) (ShowWarningOrTrace(__FILE__, __LINE__, MESSAGE, true))
|
||||
#if !defined(CO_EXIST_WITH_MFC)
|
||||
#define TRACE(MESSAGE) (ShowWarningOrTrace(__FILE__, __LINE__, MESSAGE, false))
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_ASSERT(x) ASSERT(x)
|
||||
#define DEBUG_ASSERT_M(x,y) ASSERT_M(x,y)
|
||||
#else
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define DEBUG_ASSERT(x)
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define DEBUG_ASSERT_M(x,y)
|
||||
#endif
|
||||
|
||||
/* Use UNIQUE_NAME to get the line number concatenated to x. This is useful for
|
||||
* generating unique identifiers in other macros. */
|
||||
/* XXX: VC2003 expanding __LINE__ to nothing in the first version. Investigate why. -Chris */
|
||||
//#define UNIQUE_NAME3(x,line) x##line
|
||||
//#define UNIQUE_NAME2(x,line) UNIQUE_NAME3(x, line)
|
||||
//#define UNIQUE_NAME(x) UNIQUE_NAME2(x, __LINE__)
|
||||
#define UNIQUE_NAME3(x) x
|
||||
#define UNIQUE_NAME2(x) UNIQUE_NAME3(x)
|
||||
#define UNIQUE_NAME(x) UNIQUE_NAME2(x)
|
||||
|
||||
template <bool> struct CompileAssert;
|
||||
template <> struct CompileAssert<true> { };
|
||||
template<int> struct CompileAssertDecl { };
|
||||
#define COMPILE_ASSERT(COND) typedef CompileAssertDecl< sizeof(CompileAssert<!!(COND)>) > CompileAssertInst
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/** @brief Define a macro to tell the compiler that a function has printf()
|
||||
* semantics, to aid warning output. */
|
||||
#define PRINTF(a,b) __attribute__((format(__printf__,a,b)))
|
||||
#define CONST_FUNCTION __attribute__((const))
|
||||
#else
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define PRINTF(a,b)
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define CONST_FUNCTION
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define SM_ALIGN(n) __attribute__((aligned(n)))
|
||||
#else
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define SM_ALIGN(n)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "StdString.h"
|
||||
/** @brief Use RStrings throughout the program. */
|
||||
typedef StdString::CStdString RString;
|
||||
|
||||
#if !defined(WIN32)
|
||||
/** @brief Define stricmp to be strcasecmp. */
|
||||
#define stricmp strcasecmp
|
||||
/** @brief Define strnicmp to be strncasecmp. */
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
#include "RageException.h"
|
||||
|
||||
/* Define a few functions if necessary */
|
||||
#include <cmath>
|
||||
|
||||
#ifndef M_PI
|
||||
/** @brief Define Pi to many digits. */
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
|
||||
#ifdef NEED_POWF
|
||||
inline float powf( float x, float y ) CONST_FUNCTION;
|
||||
float powf( float x, float y ) { return float( pow(double(x), double(y)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SQRTF
|
||||
inline float sqrtf( float x ) CONST_FUNCTION;
|
||||
float sqrtf( float x ) { return float( sqrt(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SINF
|
||||
inline float sinf( float x ) CONST_FUNCTION;
|
||||
float sinf( float x ) { return float( sin(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_TANF
|
||||
inline float tanf( float x ) CONST_FUNCTION;
|
||||
float tanf( float x ) { return float( tan(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_COSF
|
||||
inline float cosf( float x ) CONST_FUNCTION;
|
||||
float cosf( float x ){ return float( cos(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_ACOSF
|
||||
inline float acosf( float x ) CONST_FUNCTION;
|
||||
float acosf( float x ) { return float( acos(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_TRUNCF
|
||||
inline float truncf( float f ) CONST_FUNCTION;
|
||||
float truncf( float f ) { return float( int(f) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_ROUNDF
|
||||
inline float roundf( float f ) CONST_FUNCTION;
|
||||
float roundf( float f ) { if( f < 0.0f ) return truncf( f-0.5f ); return truncf( f+0.5f ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_STRTOF
|
||||
inline float strtof( const char *s, char **se ) { return (float) strtod( s, se ); }
|
||||
#endif
|
||||
|
||||
/* Don't include our own headers here, since they tend to change often. */
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Chris Danford, Glenn Maynard (c) 2001-2004
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
/** @brief This macro is for INT8_MIN, etc. */
|
||||
#define __STDC_LIMIT_MACROS
|
||||
/** @brief This macro is for INT64_C, etc. */
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
/* Platform-specific fixes. */
|
||||
#if defined(WIN32)
|
||||
#include "archutils/Win32/arch_setup.h"
|
||||
#elif defined(PBBUILD)
|
||||
#include "archutils/Darwin/arch_setup.h"
|
||||
#elif defined(UNIX)
|
||||
#include "archutils/Unix/arch_setup.h"
|
||||
#endif
|
||||
|
||||
/* Set one of these in arch_setup.h. (Don't bother trying to fall back on BYTE_ORDER
|
||||
* if it was already set; too many systems are missing endian.h.) */
|
||||
#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
|
||||
#error Neither ENDIAN_LITTLE nor ENDIAN_BIG defined
|
||||
#endif
|
||||
|
||||
/* Define standard endianness macros, if they're missing. */
|
||||
#if defined(HAVE_ENDIAN_H)
|
||||
#include <endian.h>
|
||||
#elif defined(HAVE_MACHINE_ENDIAN_H)
|
||||
#include <machine/endian.h>
|
||||
#else
|
||||
/** @brief The macro for little endian order. */
|
||||
#define LITTLE_ENDIAN 1234
|
||||
/** @brief The macro for big endian order. */
|
||||
#define BIG_ENDIAN 4321
|
||||
#if defined(ENDIAN_LITTLE)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#elif defined(ENDIAN_BIG)
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Make sure everyone has min and max: */
|
||||
#include <algorithm>
|
||||
|
||||
/* Everything will need string for one reason or another: */
|
||||
#include <string>
|
||||
|
||||
/* And vector: */
|
||||
#include <vector>
|
||||
|
||||
#if !defined(MISSING_STDINT_H) /* need to define int64_t if so */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#if defined(HAVE_INTTYPES_H)
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
/* Branch optimizations: */
|
||||
#if defined(__GNUC__)
|
||||
#define likely(x) (__builtin_expect(!!(x), 1))
|
||||
#define unlikely(x) (__builtin_expect(!!(x), 0))
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
#if defined(NEED_CSTDLIB_WORKAROUND)
|
||||
#define llabs ::llabs
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef ASSERT
|
||||
#undef ASSERT
|
||||
#endif
|
||||
|
||||
/** @brief RageThreads defines (don't pull in all of RageThreads.h here) */
|
||||
namespace Checkpoints
|
||||
{
|
||||
void SetCheckpoint( const char *file, int line, const char *message );
|
||||
}
|
||||
/** @brief Set a checkpoint with no message. */
|
||||
#define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, nullptr))
|
||||
/** @brief Set a checkpoint with a specified message. */
|
||||
#define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m))
|
||||
|
||||
|
||||
/**
|
||||
* @brief Define a macro to tell the compiler that a function doesn't return.
|
||||
*
|
||||
* This just improves compiler warnings. This should be placed near the
|
||||
* beginning of the function prototype (although it looks better near the end,
|
||||
* VC only accepts it at the beginning). */
|
||||
#if defined(_MSC_VER)
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
|
||||
#define NORETURN __attribute__ ((__noreturn__))
|
||||
#else
|
||||
#define NORETURN
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A crash has occured, and we're not getting out of it easily.
|
||||
*
|
||||
* For most users, this will result in a crashinfo.txt file being generated.
|
||||
* For anyone that is using a debug build, a debug break will be thrown to
|
||||
* allow viewing the current process.
|
||||
* @param reason the crash reason as determined by prior function calls.
|
||||
* @return nothing: there is no escape without quitting the program.
|
||||
*/
|
||||
void NORETURN sm_crash( const char *reason = "Internal error" );
|
||||
|
||||
/**
|
||||
* @brief Assertion that sets an optional message and brings up the crash
|
||||
* handler, so we get a backtrace.
|
||||
*
|
||||
* This should probably be used instead of throwing an exception in most
|
||||
* cases we expect never to happen (but not in cases that we do expect,
|
||||
* such as DSound init failure.) */
|
||||
#define FAIL_M(MESSAGE) do { CHECKPOINT_M(MESSAGE); sm_crash(MESSAGE); } while(0)
|
||||
#define ASSERT_M(COND, MESSAGE) do { if(unlikely(!(COND))) { FAIL_M(MESSAGE); } } while(0)
|
||||
|
||||
|
||||
#if !defined(CO_EXIST_WITH_MFC)
|
||||
#define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed")
|
||||
#endif
|
||||
|
||||
/** @brief Use this to catch switching on invalid values */
|
||||
#define DEFAULT_FAIL(i) default: FAIL_M( ssprintf("%s = %i", #i, (i)) )
|
||||
|
||||
void ShowWarningOrTrace( const char *file, int line, const char *message, bool bWarning ); // don't pull in LOG here
|
||||
#define WARN(MESSAGE) (ShowWarningOrTrace(__FILE__, __LINE__, MESSAGE, true))
|
||||
#if !defined(CO_EXIST_WITH_MFC)
|
||||
#define TRACE(MESSAGE) (ShowWarningOrTrace(__FILE__, __LINE__, MESSAGE, false))
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_ASSERT(x) ASSERT(x)
|
||||
#define DEBUG_ASSERT_M(x,y) ASSERT_M(x,y)
|
||||
#else
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define DEBUG_ASSERT(x)
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define DEBUG_ASSERT_M(x,y)
|
||||
#endif
|
||||
|
||||
/* Use UNIQUE_NAME to get the line number concatenated to x. This is useful for
|
||||
* generating unique identifiers in other macros. */
|
||||
/* XXX: VC2003 expanding __LINE__ to nothing in the first version. Investigate why. -Chris */
|
||||
//#define UNIQUE_NAME3(x,line) x##line
|
||||
//#define UNIQUE_NAME2(x,line) UNIQUE_NAME3(x, line)
|
||||
//#define UNIQUE_NAME(x) UNIQUE_NAME2(x, __LINE__)
|
||||
#define UNIQUE_NAME3(x) x
|
||||
#define UNIQUE_NAME2(x) UNIQUE_NAME3(x)
|
||||
#define UNIQUE_NAME(x) UNIQUE_NAME2(x)
|
||||
|
||||
template <bool> struct CompileAssert;
|
||||
template <> struct CompileAssert<true> { };
|
||||
template<int> struct CompileAssertDecl { };
|
||||
#define COMPILE_ASSERT(COND) typedef CompileAssertDecl< sizeof(CompileAssert<!!(COND)>) > CompileAssertInst
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/** @brief Define a macro to tell the compiler that a function has printf()
|
||||
* semantics, to aid warning output. */
|
||||
#define PRINTF(a,b) __attribute__((format(__printf__,a,b)))
|
||||
#define CONST_FUNCTION __attribute__((const))
|
||||
#else
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define PRINTF(a,b)
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define CONST_FUNCTION
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define SM_ALIGN(n) __attribute__((aligned(n)))
|
||||
#else
|
||||
/** @brief A dummy define to keep things going smoothly. */
|
||||
#define SM_ALIGN(n)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "StdString.h"
|
||||
/** @brief Use RStrings throughout the program. */
|
||||
typedef StdString::CStdString RString;
|
||||
|
||||
#if !defined(WIN32)
|
||||
/** @brief Define stricmp to be strcasecmp. */
|
||||
#define stricmp strcasecmp
|
||||
/** @brief Define strnicmp to be strncasecmp. */
|
||||
#define strnicmp strncasecmp
|
||||
#endif
|
||||
|
||||
#include "RageException.h"
|
||||
|
||||
/* Define a few functions if necessary */
|
||||
#include <cmath>
|
||||
|
||||
#ifndef M_PI
|
||||
/** @brief Define Pi to many digits. */
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
|
||||
#ifdef NEED_POWF
|
||||
inline float powf( float x, float y ) CONST_FUNCTION;
|
||||
float powf( float x, float y ) { return float( pow(double(x), double(y)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SQRTF
|
||||
inline float sqrtf( float x ) CONST_FUNCTION;
|
||||
float sqrtf( float x ) { return float( sqrt(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SINF
|
||||
inline float sinf( float x ) CONST_FUNCTION;
|
||||
float sinf( float x ) { return float( sin(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_TANF
|
||||
inline float tanf( float x ) CONST_FUNCTION;
|
||||
float tanf( float x ) { return float( tan(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_COSF
|
||||
inline float cosf( float x ) CONST_FUNCTION;
|
||||
float cosf( float x ){ return float( cos(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_ACOSF
|
||||
inline float acosf( float x ) CONST_FUNCTION;
|
||||
float acosf( float x ) { return float( acos(double(x)) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_TRUNCF
|
||||
inline float truncf( float f ) CONST_FUNCTION;
|
||||
float truncf( float f ) { return float( int(f) ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_ROUNDF
|
||||
inline float roundf( float f ) CONST_FUNCTION;
|
||||
float roundf( float f ) { if( f < 0.0f ) return truncf( f-0.5f ); return truncf( f+0.5f ); }
|
||||
#endif
|
||||
|
||||
#ifdef NEED_STRTOF
|
||||
inline float strtof( const char *s, char **se ) { return (float) strtod( s, se ); }
|
||||
#endif
|
||||
|
||||
/* Don't include our own headers here, since they tend to change often. */
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @author Chris Danford, Glenn Maynard (c) 2001-2004
|
||||
* @section LICENSE
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user