Integrate C++11 branch into 5_1-new

This commit is contained in:
teejusb
2019-06-22 12:35:38 -07:00
444 changed files with 19503 additions and 21007 deletions
+68 -69
View File
@@ -14,7 +14,6 @@
#include "PrefsManager.h"
#include "Game.h"
#include "Style.h"
#include "Foreach.h"
#include "GameSoundManager.h"
#include "PlayerState.h"
#include "SongManager.h"
@@ -36,7 +35,7 @@ void GameCommand::Init()
m_bInvalid = true;
m_iIndex = -1;
m_MultiPlayer = MultiPlayer_Invalid;
m_pStyle = NULL;
m_pStyle = nullptr;
m_pm = PlayMode_Invalid;
m_dc = Difficulty_Invalid;
m_CourseDifficulty = Difficulty_Invalid;
@@ -45,11 +44,11 @@ void GameCommand::Init()
m_sAnnouncer = "";
m_sScreen = "";
m_LuaFunction.Unset();
m_pSong = NULL;
m_pSteps = NULL;
m_pCourse = NULL;
m_pTrail = NULL;
m_pCharacter = NULL;
m_pSong = nullptr;
m_pSteps = nullptr;
m_pCourse = nullptr;
m_pTrail = nullptr;
m_pCharacter = nullptr;
m_SortOrder = SortOrder_Invalid;
m_sSoundPath = "";
m_vsScreensToPrepare.clear();
@@ -90,7 +89,7 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const
// HACK: don't compare m_dc if m_pSteps is set. This causes problems
// in ScreenSelectOptionsMaster::ImportOptions if m_PreferredDifficulty
// doesn't match the difficulty of m_pCurSteps.
if( m_pSteps == NULL && m_dc != Difficulty_Invalid )
if( m_pSteps == nullptr && m_dc != Difficulty_Invalid )
{
// Why is this checking for all players?
FOREACH_HumanPlayer( human )
@@ -158,8 +157,8 @@ void GameCommand::Load( int iIndex, const Commands& cmds )
m_bInvalid = false;
m_Commands = cmds;
FOREACH_CONST( Command, cmds.v, cmd )
LoadOne( *cmd );
for (Command const &cmd : cmds.v)
LoadOne( cmd );
}
void GameCommand::LoadOne( const Command& cmd )
@@ -197,7 +196,7 @@ void GameCommand::LoadOne( const Command& cmd )
if( sName == "style" )
{
const Style* style = GAMEMAN->GameAndStringToStyle( GAMESTATE->m_pCurGame, sValue );
CHECK_INVALID_VALUE(m_pStyle, style, NULL, style);
CHECK_INVALID_VALUE(m_pStyle, style, nullptr, style);
}
else if( sName == "playmode" )
@@ -278,7 +277,7 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "song" )
{
CHECK_INVALID_COND(m_pSong, SONGMAN->FindSong(sValue),
(SONGMAN->FindSong(sValue) == NULL),
(SONGMAN->FindSong(sValue) == nullptr),
(ssprintf("Song \"%s\" not found", sValue.c_str())));
}
@@ -289,9 +288,9 @@ void GameCommand::LoadOne( const Command& cmd )
// This must be processed after "song" and "style" commands.
if( !m_bInvalid )
{
Song *pSong = (m_pSong != NULL)? m_pSong:GAMESTATE->m_pCurSong;
Song *pSong = (m_pSong != nullptr)? m_pSong:GAMESTATE->m_pCurSong;
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
if( pSong == NULL || pStyle == NULL )
if( pSong == nullptr || pStyle == nullptr )
{
MAKE_INVALID("Must set Song and Style to set Steps.");
}
@@ -307,7 +306,7 @@ void GameCommand::LoadOne( const Command& cmd )
{
st = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps );
}
CHECK_INVALID_COND(m_pSteps, st, (st == NULL),
CHECK_INVALID_COND(m_pSteps, st, (st == nullptr),
(ssprintf("Steps \"%s\" not found", sSteps.c_str())));
}
}
@@ -316,7 +315,7 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "course" )
{
CHECK_INVALID_COND(m_pCourse, SONGMAN->FindCourse("", sValue),
(SONGMAN->FindCourse("", sValue) == NULL),
(SONGMAN->FindCourse("", sValue) == nullptr),
(ssprintf( "Course \"%s\" not found", sValue.c_str())));
}
@@ -327,9 +326,9 @@ void GameCommand::LoadOne( const Command& cmd )
// This must be processed after "course" and "style" commands.
if( !m_bInvalid )
{
Course *pCourse = (m_pCourse != NULL)? m_pCourse:GAMESTATE->m_pCurCourse;
Course *pCourse = (m_pCourse != nullptr)? m_pCourse:GAMESTATE->m_pCurCourse;
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
if( pCourse == NULL || pStyle == NULL )
if( pCourse == nullptr || pStyle == nullptr )
{
MAKE_INVALID("Must set Course and Style to set Trail.");
}
@@ -343,7 +342,7 @@ void GameCommand::LoadOne( const Command& cmd )
else
{
Trail* tr = pCourse->GetTrail(pStyle->m_StepsType, cd);
CHECK_INVALID_COND(m_pTrail, tr, (tr == NULL),
CHECK_INVALID_COND(m_pTrail, tr, (tr == nullptr),
("Trail \"" + sTrail + "\" not found."));
}
}
@@ -378,12 +377,12 @@ void GameCommand::LoadOne( const Command& cmd )
else if( sName == "weight" )
{
m_iWeightPounds = StringToInt( sValue );
m_iWeightPounds = std::stoi( sValue );
}
else if( sName == "goalcalories" )
{
m_iGoalCalories = StringToInt( sValue );
m_iGoalCalories = std::stoi( sValue );
}
else if( sName == "goaltype" )
@@ -450,7 +449,7 @@ void GameCommand::LoadOne( const Command& cmd )
{
for(size_t i= 1; i < cmd.m_vsArgs.size(); i+= 2)
{
if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == NULL)
if(IPreference::GetPreferenceByName(cmd.m_vsArgs[i]) == nullptr)
{
MAKE_INVALID("Unknown preference \"" + cmd.m_vsArgs[i] + "\".");
}
@@ -526,7 +525,7 @@ int GetCreditsRequiredToPlayStyle( const Style *style )
static bool AreStyleAndPlayModeCompatible( const Style *style, PlayMode pm )
{
if( style == NULL || pm == PlayMode_Invalid )
if( style == nullptr || pm == PlayMode_Invalid )
return true;
switch( pm )
@@ -596,10 +595,10 @@ bool GameCommand::IsPlayable( RString *why ) const
/* Don't allow a PlayMode that's incompatible with our current Style (if set),
* and vice versa. */
if( m_pm != PlayMode_Invalid || m_pStyle != NULL )
if( m_pm != PlayMode_Invalid || m_pStyle != nullptr )
{
const PlayMode pm = (m_pm != PlayMode_Invalid) ? m_pm : GAMESTATE->m_PlayMode;
const Style *style = (m_pStyle != NULL)? m_pStyle: GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
const Style *style = (m_pStyle != nullptr)? m_pStyle: GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber());
if( !AreStyleAndPlayModeCompatible( style, pm ) )
{
if( why )
@@ -680,12 +679,12 @@ void GameCommand::Apply( const vector<PlayerNumber> &vpns ) const
if( m_Commands.v.size() )
{
// We were filled using a GameCommand from metrics. Apply the options in order.
FOREACH_CONST( Command, m_Commands.v, cmd )
for (Command const &cmd : m_Commands.v)
{
GameCommand gc;
gc.m_bInvalid = false;
gc.m_bApplyCommitsScreens = m_bApplyCommitsScreens;
gc.LoadOne( *cmd );
gc.LoadOne( cmd );
gc.ApplySelf( vpns );
}
}
@@ -704,7 +703,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_pm != PlayMode_Invalid )
GAMESTATE->m_PlayMode.Set( m_pm );
if( m_pStyle != NULL )
if( m_pStyle != nullptr )
{
GAMESTATE->SetCurrentStyle( m_pStyle, GAMESTATE->GetMasterPlayerNumber() );
@@ -720,8 +719,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
LOG->Trace( "Deducted %i coins, %i remaining",
iNumCreditsOwed * PREFSMAN->m_iCoinsPerCredit, GAMESTATE->m_iCoins.Get() );
//Credit Used, make sure to update CoinsFile
BOOKKEEPER->WriteCoinsFile(GAMESTATE->m_iCoins.Get());
//Credit Used, make sure to update CoinsFile
BOOKKEEPER->WriteCoinsFile(GAMESTATE->m_iCoins.Get());
}
// If only one side is joined and we picked a style that requires both
@@ -743,25 +742,25 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
}
}
if( m_dc != Difficulty_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->m_PreferredDifficulty[*pn].Set( m_dc );
for (PlayerNumber const &pn : vpns)
GAMESTATE->m_PreferredDifficulty[pn].Set( m_dc );
if( m_sAnnouncer != "" )
ANNOUNCER->SwitchAnnouncer( m_sAnnouncer );
if( m_sPreferredModifiers != "" )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->ApplyPreferredModifiers( *pn, m_sPreferredModifiers );
for (PlayerNumber const &pn : vpns)
GAMESTATE->ApplyPreferredModifiers( pn, m_sPreferredModifiers );
if( m_sStageModifiers != "" )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->ApplyStageModifiers( *pn, m_sStageModifiers );
for (PlayerNumber const &pn : vpns)
GAMESTATE->ApplyStageModifiers( pn, m_sStageModifiers );
if( m_LuaFunction.IsSet() && !m_LuaFunction.IsNil() )
{
Lua *L = LUA->Get();
FOREACH_CONST( PlayerNumber, vpns, pn )
for (PlayerNumber const &pn : vpns)
{
m_LuaFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
lua_pushnumber( L, *pn ); // 1st parameter
lua_pushnumber( L, pn ); // 1st parameter
RString error= "Lua GameCommand error: ";
LuaHelpers::RunScriptOnStack(L, error, 1, 0, true);
}
@@ -775,22 +774,22 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
GAMESTATE->m_pPreferredSong = m_pSong;
}
if( m_pSteps )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->m_pCurSteps[*pn].Set( m_pSteps );
for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurSteps[pn].Set( m_pSteps );
if( m_pCourse )
{
GAMESTATE->m_pCurCourse.Set( m_pCourse );
GAMESTATE->m_pPreferredCourse = m_pCourse;
}
if( m_pTrail )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->m_pCurTrail[*pn].Set( m_pTrail );
for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurTrail[pn].Set( m_pTrail );
if( m_CourseDifficulty != Difficulty_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->ChangePreferredCourseDifficulty( *pn, m_CourseDifficulty );
for (PlayerNumber const &pn : vpns)
GAMESTATE->ChangePreferredCourseDifficulty( pn, m_CourseDifficulty );
if( m_pCharacter )
FOREACH_CONST( PlayerNumber, vpns, pn )
GAMESTATE->m_pCurCharacters[*pn] = m_pCharacter;
for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurCharacters[pn] = m_pCharacter;
for( map<RString,RString>::const_iterator i = m_SetEnv.begin(); i != m_SetEnv.end(); i++ )
{
Lua *L = LUA->Get();
@@ -804,7 +803,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
for(map<RString,RString>::const_iterator setting= m_SetPref.begin(); setting != m_SetPref.end(); ++setting)
{
IPreference* pref= IPreference::GetPreferenceByName(setting->first);
if(pref != NULL)
if(pref != nullptr)
{
pref->FromString(setting->second);
}
@@ -816,17 +815,17 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_sSoundPath != "" )
SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) );
if( m_iWeightPounds != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn )
PROFILEMAN->GetProfile(*pn)->m_iWeightPounds = m_iWeightPounds;
for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(pn)->m_iWeightPounds = m_iWeightPounds;
if( m_iGoalCalories != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn )
PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories;
for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(pn)->m_iGoalCalories = m_iGoalCalories;
if( m_GoalType != GoalType_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn )
PROFILEMAN->GetProfile(*pn)->m_GoalType = m_GoalType;
for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(pn)->m_GoalType = m_GoalType;
if( !m_sProfileID.empty() )
FOREACH_CONST( PlayerNumber, vpns, pn )
ProfileManager::m_sDefaultLocalProfileID[*pn].Set( m_sProfileID );
for (PlayerNumber const &pn : vpns)
ProfileManager::m_sDefaultLocalProfileID[pn].Set( m_sProfileID );
if( !m_sUrl.empty() )
{
if( HOOKS->GoToURL( m_sUrl ) )
@@ -845,8 +844,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_bFadeMusic )
SOUND->DimMusic(m_fMusicFadeOutVolume, m_fMusicFadeOutSeconds);
FOREACH_CONST( RString, m_vsScreensToPrepare, s )
SCREENMAN->PrepareScreen( *s );
for (RString const &s : m_vsScreensToPrepare)
SCREENMAN->PrepareScreen( s );
if( m_bInsertCredit )
{
@@ -886,16 +885,16 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
bool GameCommand::IsZero() const
{
if( m_pm != PlayMode_Invalid ||
m_pStyle != NULL ||
m_pStyle != nullptr ||
m_dc != Difficulty_Invalid ||
m_sAnnouncer != "" ||
m_sPreferredModifiers != "" ||
m_sStageModifiers != "" ||
m_pSong != NULL ||
m_pSteps != NULL ||
m_pCourse != NULL ||
m_pTrail != NULL ||
m_pCharacter != NULL ||
m_pSong != nullptr ||
m_pSteps != nullptr ||
m_pCourse != nullptr ||
m_pTrail != nullptr ||
m_pCharacter != nullptr ||
m_CourseDifficulty != Difficulty_Invalid ||
!m_sSongGroup.empty() ||
m_SortOrder != SortOrder_Invalid ||
@@ -923,14 +922,14 @@ public:
static int GetText( T* p, lua_State *L ) { lua_pushstring(L, p->m_sText ); return 1; }
static int GetIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iIndex ); return 1; }
static int GetMultiPlayer( T* p, lua_State *L ) { lua_pushnumber(L, p->m_MultiPlayer); return 1; }
static int GetStyle( T* p, lua_State *L ) { if(p->m_pStyle==NULL) lua_pushnil(L); else {Style *pStyle = (Style*)p->m_pStyle; pStyle->PushSelf(L);} return 1; }
static int GetStyle( T* p, lua_State *L ) { if(p->m_pStyle== nullptr) lua_pushnil(L); else {Style *pStyle = (Style*)p->m_pStyle; pStyle->PushSelf(L);} return 1; }
static int GetScreen( T* p, lua_State *L ) { lua_pushstring(L, p->m_sScreen ); return 1; }
static int GetProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sProfileID ); return 1; }
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong==NULL) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps==NULL) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; }
static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse==NULL) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; }
static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail==NULL) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; }
static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter==NULL) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; }
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong== nullptr) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
static int GetSteps( T* p, lua_State *L ) { if(p->m_pSteps== nullptr) lua_pushnil(L); else p->m_pSteps->PushSelf(L); return 1; }
static int GetCourse( T* p, lua_State *L ) { if(p->m_pCourse== nullptr) lua_pushnil(L); else p->m_pCourse->PushSelf(L); return 1; }
static int GetTrail( T* p, lua_State *L ) { if(p->m_pTrail== nullptr) lua_pushnil(L); else p->m_pTrail->PushSelf(L); return 1; }
static int GetCharacter( T* p, lua_State *L ) { if(p->m_pCharacter== nullptr) lua_pushnil(L); else p->m_pCharacter->PushSelf(L); return 1; }
static int GetSongGroup( T* p, lua_State *L ) { lua_pushstring(L, p->m_sSongGroup ); return 1; }
static int GetUrl( T* p, lua_State *L ) { lua_pushstring(L, p->m_sUrl ); return 1; }
static int GetAnnouncer( T* p, lua_State *L ) { lua_pushstring(L, p->m_sAnnouncer ); return 1; }