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
+37 -35
View File
@@ -25,7 +25,7 @@
#include "CharacterManager.h"
ProfileManager* PROFILEMAN = NULL; // global and accessible from anywhere in our program
ProfileManager* PROFILEMAN = nullptr; // global and accessible from anywhere in our program
#define ID_DIGITS 8
#define ID_DIGITS_STR "8"
@@ -124,12 +124,12 @@ void ProfileManager::Init()
{
RString sCharacterID = FIXED_PROFILE_CHARACTER_ID( i );
Character *pCharacter = CHARMAN->GetCharacterFromID( sCharacterID );
ASSERT_M( pCharacter != NULL, sCharacterID );
ASSERT_M( pCharacter != nullptr, sCharacterID );
RString sProfileID;
bool b = CreateLocalProfile( pCharacter->GetDisplayName(), sProfileID );
ASSERT( b );
Profile* pProfile = GetLocalProfile( sProfileID );
ASSERT_M( pProfile != NULL, sProfileID );
ASSERT_M( pProfile != nullptr, sProfileID );
pProfile->m_sCharacterID = sCharacterID;
SaveLocalProfile( sProfileID );
}
@@ -216,7 +216,7 @@ bool ProfileManager::LoadLocalProfileFromMachine( PlayerNumber pn )
m_bWasLoadedFromMemoryCard[pn] = false;
m_bLastLoadWasFromLastGood[pn] = false;
if( GetLocalProfile(sProfileID) == NULL )
if( GetLocalProfile(sProfileID) == nullptr )
{
m_sProfileDir[pn] = "";
return false;
@@ -364,7 +364,7 @@ bool ProfileManager::SaveProfile( PlayerNumber pn ) const
bool ProfileManager::SaveLocalProfile( RString sProfileID )
{
const Profile *pProfile = GetLocalProfile( sProfileID );
ASSERT( pProfile != NULL );
ASSERT( pProfile != nullptr );
RString sDir = LocalProfileIDToDir( sProfileID );
bool b = pProfile->SaveAllToDir( sDir, PREFSMAN->m_bSignProfileData );
return b;
@@ -444,10 +444,10 @@ void ProfileManager::RefreshLocalProfilesFromDisk()
// The type data for a profile is in its own file so that loading isn't
// slowed down by copying temporary profiles around to make sure the list
// is sorted. The profiles are loaded at the end. -Kyz
FOREACH_CONST(RString, profile_ids, id)
for (RString const &id : profile_ids)
{
DirAndProfile derp;
derp.sDir= *id + "/";
derp.sDir= id + "/";
derp.profile.LoadTypeFromDir(derp.sDir);
map<ProfileType, vector<DirAndProfile> >::iterator category=
categorized_profiles.find(derp.profile.m_Type);
@@ -458,7 +458,7 @@ void ProfileManager::RefreshLocalProfilesFromDisk()
else
{
bool inserted= false;
FOREACH(DirAndProfile, category->second, curr)
for (auto curr = g_vLocalProfile.begin(); curr != g_vLocalProfile.end(); ++curr)
{
if(curr->profile.m_ListPriority > derp.profile.m_ListPriority)
{
@@ -476,23 +476,23 @@ void ProfileManager::RefreshLocalProfilesFromDisk()
add_category_to_global_list(categorized_profiles[ProfileType_Guest]);
add_category_to_global_list(categorized_profiles[ProfileType_Normal]);
add_category_to_global_list(categorized_profiles[ProfileType_Test]);
FOREACH(DirAndProfile, g_vLocalProfile, curr)
for (DirAndProfile &curr : g_vLocalProfile)
{
curr->profile.LoadAllFromDir(curr->sDir, PREFSMAN->m_bSignProfileData);
curr.profile.LoadAllFromDir(curr.sDir, PREFSMAN->m_bSignProfileData);
}
}
const Profile *ProfileManager::GetLocalProfile( const RString &sProfileID ) const
{
RString sDir = LocalProfileIDToDir( sProfileID );
FOREACH_CONST( DirAndProfile, g_vLocalProfile, dap )
for (DirAndProfile const &dap : g_vLocalProfile)
{
const RString &sOther = dap->sDir;
const RString &sOther = dap.sDir;
if( sOther == sDir )
return &dap->profile;
return &dap.profile;
}
return NULL;
return nullptr;
}
bool ProfileManager::CreateLocalProfile( RString sName, RString &sProfileIDOut )
@@ -510,7 +510,7 @@ bool ProfileManager::CreateLocalProfile( RString sName, RString &sProfileIDOut )
int first_free_number= 0;
vector<RString> profile_ids;
GetLocalProfileIDs(profile_ids);
FOREACH_CONST(RString, profile_ids, id)
for (std::vector<RString>::const_iterator id = profile_ids.begin(); id != profile_ids.end(); ++id)
{
int tmp= 0;
if((*id) >> tmp)
@@ -536,7 +536,7 @@ bool ProfileManager::CreateLocalProfile( RString sName, RString &sProfileIDOut )
RString profile_id = ssprintf( "%0" ID_DIGITS_STR "d", profile_number );
// make sure this id doesn't already exist
ASSERT_M(GetLocalProfile(profile_id) == NULL,
ASSERT_M(GetLocalProfile(profile_id) == nullptr,
ssprintf("creating profile with ID \"%s\" that already exists",
profile_id.c_str()));
@@ -564,7 +564,7 @@ static void InsertProfileIntoList(DirAndProfile& derp)
{
bool inserted= false;
derp.profile.m_ListPriority= 0;
FOREACH(DirAndProfile, g_vLocalProfile, curr)
for (auto curr = g_vLocalProfile.begin(); curr != g_vLocalProfile.end(); ++curr)
{
if(curr->profile.m_Type > derp.profile.m_Type)
{
@@ -588,7 +588,7 @@ static void InsertProfileIntoList(DirAndProfile& derp)
void ProfileManager::AddLocalProfileByID( Profile *pProfile, RString sProfileID )
{
// make sure this id doesn't already exist
ASSERT_M( GetLocalProfile(sProfileID) == NULL,
ASSERT_M( GetLocalProfile(sProfileID) == nullptr,
ssprintf("creating \"%s\" \"%s\" that already exists",
pProfile->m_sDisplayName.c_str(), sProfileID.c_str()) );
@@ -603,7 +603,7 @@ bool ProfileManager::RenameLocalProfile( RString sProfileID, RString sNewName )
ASSERT( !sProfileID.empty() );
Profile *pProfile = ProfileManager::GetLocalProfile( sProfileID );
ASSERT( pProfile != NULL );
ASSERT( pProfile != nullptr );
pProfile->m_sDisplayName = sNewName;
RString sProfileDir = LocalProfileIDToDir( sProfileID );
@@ -613,13 +613,13 @@ bool ProfileManager::RenameLocalProfile( RString sProfileID, RString sNewName )
bool ProfileManager::DeleteLocalProfile( RString sProfileID )
{
Profile *pProfile = ProfileManager::GetLocalProfile( sProfileID );
ASSERT( pProfile != NULL );
ASSERT( pProfile != nullptr );
RString sProfileDir = LocalProfileIDToDir( sProfileID );
// flush directory cache in an attempt to get this working
FILEMAN->FlushDirCache( sProfileDir );
FOREACH( DirAndProfile, g_vLocalProfile, i )
for (vector<DirAndProfile>::iterator i = g_vLocalProfile.begin(); i != g_vLocalProfile.end(); ++i)
{
if( i->sDir == sProfileDir )
{
@@ -628,10 +628,10 @@ bool ProfileManager::DeleteLocalProfile( RString sProfileID )
g_vLocalProfile.erase( i );
// Delete all references to this profileID
FOREACH_CONST( Preference<RString>*, m_sDefaultLocalProfileID.m_v, j )
for (Preference<RString> *j : m_sDefaultLocalProfileID.m_v)
{
if( (*j)->Get() == sProfileID )
(*j)->Set( "" );
if( j->Get() == sProfileID )
j->Set( "" );
}
return true;
}
@@ -746,7 +746,7 @@ void ProfileManager::MergeLocalProfiles(RString const& from_id, RString const& t
{
Profile* from= GetLocalProfile(from_id);
Profile* to= GetLocalProfile(to_id);
if(from == NULL || to == NULL)
if(from == nullptr || to == nullptr)
{
return;
}
@@ -757,7 +757,7 @@ void ProfileManager::MergeLocalProfiles(RString const& from_id, RString const& t
void ProfileManager::MergeLocalProfileIntoMachine(RString const& from_id, bool skip_totals)
{
Profile* from= GetLocalProfile(from_id);
if(from == NULL)
if(from == nullptr)
{
return;
}
@@ -975,9 +975,9 @@ bool ProfileManager::IsPersistentProfile( ProfileSlot slot ) const
void ProfileManager::GetLocalProfileIDs( vector<RString> &vsProfileIDsOut ) const
{
vsProfileIDsOut.clear();
FOREACH_CONST( DirAndProfile, g_vLocalProfile, i)
for (DirAndProfile const &i : g_vLocalProfile)
{
RString sID = LocalProfileDirToID( i->sDir );
RString sID = LocalProfileDirToID( i.sDir );
vsProfileIDsOut.push_back( sID );
}
}
@@ -985,17 +985,19 @@ void ProfileManager::GetLocalProfileIDs( vector<RString> &vsProfileIDsOut ) cons
void ProfileManager::GetLocalProfileDisplayNames( vector<RString> &vsProfileDisplayNamesOut ) const
{
vsProfileDisplayNamesOut.clear();
FOREACH_CONST( DirAndProfile, g_vLocalProfile, i)
vsProfileDisplayNamesOut.push_back( i->profile.m_sDisplayName );
for (DirAndProfile const &i : g_vLocalProfile)
vsProfileDisplayNamesOut.push_back( i.profile.m_sDisplayName );
}
int ProfileManager::GetLocalProfileIndexFromID( RString sProfileID ) const
{
RString sDir = LocalProfileIDToDir( sProfileID );
FOREACH_CONST( DirAndProfile, g_vLocalProfile, i )
int j = 0;
for (DirAndProfile const &i : g_vLocalProfile)
{
if( i->sDir == sDir )
return i - g_vLocalProfile.begin();
if( i.sDir == sDir )
return j;
++j;
}
return -1;
}
@@ -1053,7 +1055,7 @@ public:
COMMON_RETURN_SELF;
}
static int IsPersistentProfile( T* p, lua_State *L ) { lua_pushboolean(L, p->IsPersistentProfile(Enum::Check<PlayerNumber>(L, 1)) ); return 1; }
static int GetProfile( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1); Profile* pP = p->GetProfile(pn); ASSERT(pP != NULL); pP->PushSelf(L); return 1; }
static int GetProfile( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1); Profile* pP = p->GetProfile(pn); ASSERT(pP != nullptr); pP->PushSelf(L); return 1; }
static int GetMachineProfile( T* p, lua_State *L ) { p->GetMachineProfile()->PushSelf(L); return 1; }
static int SaveMachineProfile( T* p, lua_State * ) { p->SaveMachineProfile(); return 0; }
static int GetLocalProfile( T* p, lua_State *L )
@@ -1073,7 +1075,7 @@ public:
luaL_error(L, "Profile index %d out of range.", index);
}
Profile *pProfile = p->GetLocalProfileFromIndex(index);
if(pProfile == NULL)
if(pProfile == nullptr)
{
luaL_error(L, "No profile at index %d.", index);
}