Project modernization (#630)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "TutorialTasks.h"
|
||||
#include "TutorialConstraints.h"
|
||||
#include "TutorialHints.h"
|
||||
#include "Common/UI/UI.h"
|
||||
|
||||
vector<int> Tutorial::s_completableTasks;
|
||||
|
||||
@@ -31,7 +32,7 @@ int Tutorial::m_iTutorialFreezeTimeValue = 8000;
|
||||
|
||||
bool Tutorial::PopupMessageDetails::isSameContent(PopupMessageDetails *other)
|
||||
{
|
||||
if(other == NULL) return false;
|
||||
if(other == nullptr) return false;
|
||||
|
||||
bool textTheSame = (m_messageId == other->m_messageId) && (m_messageString.compare(other->m_messageString) == 0);
|
||||
bool titleTheSame = (m_titleId == other->m_titleId) && (m_titleString.compare(other->m_titleString) == 0);
|
||||
@@ -360,12 +361,12 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
|
||||
m_hintDisplayed = false;
|
||||
m_freezeTime = false;
|
||||
m_timeFrozen = false;
|
||||
m_UIScene = NULL;
|
||||
m_UIScene = nullptr;
|
||||
m_allowShow = true;
|
||||
m_bHasTickedOnce = false;
|
||||
m_firstTickTime = 0;
|
||||
|
||||
m_lastMessage = NULL;
|
||||
m_lastMessage = nullptr;
|
||||
|
||||
lastMessageTime = 0;
|
||||
m_iTaskReminders = 0;
|
||||
@@ -374,13 +375,13 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
|
||||
m_CurrentState = e_Tutorial_State_Gameplay;
|
||||
m_hasStateChanged = false;
|
||||
#ifdef _XBOX
|
||||
m_hTutorialScene=NULL;
|
||||
m_hTutorialScene=nullptr;
|
||||
#endif
|
||||
|
||||
for(unsigned int i = 0; i < e_Tutorial_State_Max; ++i)
|
||||
{
|
||||
currentTask[i] = NULL;
|
||||
currentFailedConstraint[i] = NULL;
|
||||
currentTask[i] = nullptr;
|
||||
currentFailedConstraint[i] = nullptr;
|
||||
}
|
||||
|
||||
// DEFAULT TASKS THAT ALL TUTORIALS SHARE
|
||||
@@ -1012,7 +1013,7 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
|
||||
addTask(e_Tutorial_State_Horse, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_TAMING2, IDS_TUTORIAL_PROMPT_PRESS_A_TO_CONTINUE, true, ACTION_MENU_A) );
|
||||
|
||||
// 4J-JEV: Only force the RideEntityTask if we're on the full-tutorial.
|
||||
if (isFullTutorial) addTask(e_Tutorial_State_Horse, new RideEntityTask(eTYPE_HORSE, this, IDS_TUTORIAL_TASK_HORSE_RIDE, true, NULL, false, false, false) );
|
||||
if (isFullTutorial) addTask(e_Tutorial_State_Horse, new RideEntityTask(eTYPE_HORSE, this, IDS_TUTORIAL_TASK_HORSE_RIDE, true, nullptr, false, false, false) );
|
||||
else addTask(e_Tutorial_State_Horse, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_RIDE, IDS_TUTORIAL_PROMPT_PRESS_A_TO_CONTINUE, true, ACTION_MENU_A) );
|
||||
|
||||
addTask(e_Tutorial_State_Horse, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_SADDLES, IDS_TUTORIAL_PROMPT_PRESS_A_TO_CONTINUE, true, ACTION_MENU_A) );
|
||||
@@ -1163,8 +1164,8 @@ Tutorial::~Tutorial()
|
||||
delete it;
|
||||
}
|
||||
|
||||
currentTask[i] = NULL;
|
||||
currentFailedConstraint[i] = NULL;
|
||||
currentTask[i] = nullptr;
|
||||
currentFailedConstraint[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,7 +1174,7 @@ void Tutorial::debugResetPlayerSavedProgress(int iPad)
|
||||
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(iPad);
|
||||
#else
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(iPad);
|
||||
GAME_SETTINGS *pGameSettings = static_cast<GAME_SETTINGS *>(ProfileManager.GetGameDefinedProfileData(iPad));
|
||||
#endif
|
||||
ZeroMemory( pGameSettings->ucTutorialCompletion, TUTORIAL_PROFILE_STORAGE_BYTES );
|
||||
pGameSettings->uiSpecialTutorialBitmask = 0;
|
||||
@@ -1202,7 +1203,7 @@ void Tutorial::setCompleted( int completableId )
|
||||
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(m_iPad);
|
||||
#else
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(m_iPad);
|
||||
GAME_SETTINGS *pGameSettings = static_cast<GAME_SETTINGS *>(ProfileManager.GetGameDefinedProfileData(m_iPad));
|
||||
#endif
|
||||
int arrayIndex = completableIndex >> 3;
|
||||
int bitIndex = 7 - (completableIndex % 8);
|
||||
@@ -1235,7 +1236,7 @@ bool Tutorial::getCompleted( int completableId )
|
||||
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)StorageManager.GetGameDefinedProfileData(m_iPad);
|
||||
#else
|
||||
GAME_SETTINGS *pGameSettings = (GAME_SETTINGS *)ProfileManager.GetGameDefinedProfileData(m_iPad);
|
||||
GAME_SETTINGS *pGameSettings = static_cast<GAME_SETTINGS *>(ProfileManager.GetGameDefinedProfileData(m_iPad));
|
||||
#endif
|
||||
int arrayIndex = completableIndex >> 3;
|
||||
int bitIndex = 7 - (completableIndex % 8);
|
||||
@@ -1362,7 +1363,7 @@ void Tutorial::tick()
|
||||
|
||||
if(!m_allowShow)
|
||||
{
|
||||
if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
|
||||
if( currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
|
||||
{
|
||||
uiTempDisabled = true;
|
||||
}
|
||||
@@ -1412,7 +1413,7 @@ void Tutorial::tick()
|
||||
|
||||
if(ui.IsPauseMenuDisplayed( m_iPad ) )
|
||||
{
|
||||
if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
|
||||
if( currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
|
||||
{
|
||||
uiTempDisabled = true;
|
||||
}
|
||||
@@ -1460,12 +1461,12 @@ void Tutorial::tick()
|
||||
|
||||
// Check constraints
|
||||
// Only need to update these if we aren't already failing something
|
||||
if( !m_allTutorialsComplete && (currentFailedConstraint[m_CurrentState] == NULL || currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad)) )
|
||||
if( !m_allTutorialsComplete && (currentFailedConstraint[m_CurrentState] == nullptr || currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad)) )
|
||||
{
|
||||
if( currentFailedConstraint[m_CurrentState] != NULL && currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad) )
|
||||
if( currentFailedConstraint[m_CurrentState] != nullptr && currentFailedConstraint[m_CurrentState]->isConstraintSatisfied(m_iPad) )
|
||||
{
|
||||
constraintChanged = true;
|
||||
currentFailedConstraint[m_CurrentState] = NULL;
|
||||
currentFailedConstraint[m_CurrentState] = nullptr;
|
||||
}
|
||||
for (auto& constraint : constraints[m_CurrentState])
|
||||
{
|
||||
@@ -1477,7 +1478,7 @@ void Tutorial::tick()
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_allTutorialsComplete && currentFailedConstraint[m_CurrentState] == NULL )
|
||||
if( !m_allTutorialsComplete && currentFailedConstraint[m_CurrentState] == nullptr )
|
||||
{
|
||||
// Update tasks
|
||||
bool isCurrentTask = true;
|
||||
@@ -1496,7 +1497,7 @@ void Tutorial::tick()
|
||||
eTutorial_CompletionAction compAction = task->getCompletionAction();
|
||||
it = activeTasks[m_CurrentState].erase( it );
|
||||
delete task;
|
||||
task = NULL;
|
||||
task = nullptr;
|
||||
|
||||
if( activeTasks[m_CurrentState].size() > 0 )
|
||||
{
|
||||
@@ -1552,12 +1553,12 @@ void Tutorial::tick()
|
||||
{
|
||||
setStateCompleted( m_CurrentState );
|
||||
|
||||
currentTask[m_CurrentState] = NULL;
|
||||
currentTask[m_CurrentState] = nullptr;
|
||||
}
|
||||
taskChanged = true;
|
||||
|
||||
// If we can complete this early, check if we can complete it right now
|
||||
if( currentTask[m_CurrentState] != NULL && currentTask[m_CurrentState]->isPreCompletionEnabled() )
|
||||
if( currentTask[m_CurrentState] != nullptr && currentTask[m_CurrentState]->isPreCompletionEnabled() )
|
||||
{
|
||||
isCurrentTask = true;
|
||||
}
|
||||
@@ -1566,7 +1567,7 @@ void Tutorial::tick()
|
||||
{
|
||||
++it;
|
||||
}
|
||||
if( task != NULL && task->ShowMinimumTime() && task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime ) < GetTickCount() )
|
||||
if( task != nullptr && task->ShowMinimumTime() && task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime ) < GetTickCount() )
|
||||
{
|
||||
task->setShownForMinimumTime();
|
||||
|
||||
@@ -1587,7 +1588,7 @@ void Tutorial::tick()
|
||||
}
|
||||
}
|
||||
|
||||
if( currentTask[m_CurrentState] == NULL && activeTasks[m_CurrentState].size() > 0 )
|
||||
if( currentTask[m_CurrentState] == nullptr && activeTasks[m_CurrentState].size() > 0 )
|
||||
{
|
||||
currentTask[m_CurrentState] = activeTasks[m_CurrentState][0];
|
||||
currentTask[m_CurrentState]->setAsCurrentTask();
|
||||
@@ -1616,17 +1617,17 @@ void Tutorial::tick()
|
||||
}
|
||||
|
||||
if( constraintChanged || taskChanged || m_hasStateChanged ||
|
||||
(currentFailedConstraint[m_CurrentState] == NULL && currentTask[m_CurrentState] != NULL && (m_lastMessage == NULL || currentTask[m_CurrentState]->getDescriptionId() != m_lastMessage->m_messageId) && !m_hintDisplayed)
|
||||
(currentFailedConstraint[m_CurrentState] == nullptr && currentTask[m_CurrentState] != nullptr && (m_lastMessage == nullptr || currentTask[m_CurrentState]->getDescriptionId() != m_lastMessage->m_messageId) && !m_hintDisplayed)
|
||||
)
|
||||
{
|
||||
if( currentFailedConstraint[m_CurrentState] != NULL )
|
||||
if( currentFailedConstraint[m_CurrentState] != nullptr )
|
||||
{
|
||||
PopupMessageDetails *message = new PopupMessageDetails();
|
||||
message->m_messageId = currentFailedConstraint[m_CurrentState]->getDescriptionId();
|
||||
message->m_allowFade = false;
|
||||
setMessage( message );
|
||||
}
|
||||
else if( currentTask[m_CurrentState] != NULL )
|
||||
else if( currentTask[m_CurrentState] != nullptr )
|
||||
{
|
||||
PopupMessageDetails *message = new PopupMessageDetails();
|
||||
message->m_messageId = currentTask[m_CurrentState]->getDescriptionId();
|
||||
@@ -1637,7 +1638,7 @@ void Tutorial::tick()
|
||||
}
|
||||
else
|
||||
{
|
||||
setMessage( NULL );
|
||||
setMessage( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1646,7 +1647,7 @@ void Tutorial::tick()
|
||||
m_hintDisplayed = false;
|
||||
}
|
||||
|
||||
if( currentFailedConstraint[m_CurrentState] == NULL && currentTask[m_CurrentState] != NULL && (m_iTaskReminders!=0) && (lastMessageTime + (m_iTaskReminders * m_iTutorialReminderTime) ) < GetTickCount() )
|
||||
if( currentFailedConstraint[m_CurrentState] == nullptr && currentTask[m_CurrentState] != nullptr && (m_iTaskReminders!=0) && (lastMessageTime + (m_iTaskReminders * m_iTutorialReminderTime) ) < GetTickCount() )
|
||||
{
|
||||
// Reminder
|
||||
PopupMessageDetails *message = new PopupMessageDetails();
|
||||
@@ -1671,7 +1672,7 @@ void Tutorial::tick()
|
||||
|
||||
bool Tutorial::setMessage(PopupMessageDetails *message)
|
||||
{
|
||||
if(message != NULL && !message->m_forceDisplay &&
|
||||
if(message != nullptr && !message->m_forceDisplay &&
|
||||
m_lastMessageState == m_CurrentState &&
|
||||
message->isSameContent(m_lastMessage) &&
|
||||
( !message->m_isReminder || ( (lastMessageTime + m_iTutorialReminderTime ) > GetTickCount() && message->m_isReminder ) )
|
||||
@@ -1681,7 +1682,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(message != NULL && (message->m_messageId > 0 || !message->m_messageString.empty()) )
|
||||
if(message != nullptr && (message->m_messageId > 0 || !message->m_messageString.empty()) )
|
||||
{
|
||||
m_lastMessageState = m_CurrentState;
|
||||
|
||||
@@ -1695,7 +1696,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
|
||||
else
|
||||
{
|
||||
auto it = messages.find(message->m_messageId);
|
||||
if( it != messages.end() && it->second != NULL )
|
||||
if( it != messages.end() && it->second != nullptr )
|
||||
{
|
||||
TutorialMessage *messageString = it->second;
|
||||
text = wstring( messageString->getMessageForDisplay() );
|
||||
@@ -1725,7 +1726,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
|
||||
else if(message->m_promptId >= 0)
|
||||
{
|
||||
auto it = messages.find(message->m_promptId);
|
||||
if(it != messages.end() && it->second != NULL)
|
||||
if(it != messages.end() && it->second != nullptr)
|
||||
{
|
||||
TutorialMessage *prompt = it->second;
|
||||
text.append( prompt->getMessageForDisplay() );
|
||||
@@ -1754,7 +1755,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
|
||||
ui.SetTutorialDescription( m_iPad, &popupInfo );
|
||||
}
|
||||
}
|
||||
else if( (m_lastMessage != NULL && m_lastMessage->m_messageId != -1) ) //&& (lastMessageTime + m_iTutorialReminderTime ) > GetTickCount() )
|
||||
else if( (m_lastMessage != nullptr && m_lastMessage->m_messageId != -1) ) //&& (lastMessageTime + m_iTutorialReminderTime ) > GetTickCount() )
|
||||
{
|
||||
// This should cause the popup to dissappear
|
||||
TutorialPopupInfo popupInfo;
|
||||
@@ -1763,7 +1764,7 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
|
||||
ui.SetTutorialDescription( m_iPad, &popupInfo );
|
||||
}
|
||||
|
||||
if(m_lastMessage != NULL) delete m_lastMessage;
|
||||
if(m_lastMessage != nullptr) delete m_lastMessage;
|
||||
m_lastMessage = message;
|
||||
|
||||
return true;
|
||||
@@ -1777,7 +1778,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message)
|
||||
|
||||
bool messageShown = false;
|
||||
DWORD time = GetTickCount();
|
||||
if(message != NULL && (message->m_forceDisplay || hintsOn) &&
|
||||
if(message != nullptr && (message->m_forceDisplay || hintsOn) &&
|
||||
(!message->m_delay ||
|
||||
(
|
||||
(m_hintDisplayed && (time - m_lastHintDisplayedTime) > m_iTutorialHintDelayTime ) ||
|
||||
@@ -1792,7 +1793,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message)
|
||||
{
|
||||
m_lastHintDisplayedTime = time;
|
||||
m_hintDisplayed = true;
|
||||
if(hint!=NULL) setHintCompleted( hint );
|
||||
if(hint!=nullptr) setHintCompleted( hint );
|
||||
}
|
||||
}
|
||||
return messageShown;
|
||||
@@ -1815,7 +1816,7 @@ void Tutorial::showTutorialPopup(bool show)
|
||||
|
||||
if(!show)
|
||||
{
|
||||
if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
|
||||
if( currentTask[m_CurrentState] != nullptr && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
|
||||
{
|
||||
uiTempDisabled = true;
|
||||
}
|
||||
@@ -1926,7 +1927,7 @@ void Tutorial::handleUIInput(int iAction)
|
||||
{
|
||||
if( m_hintDisplayed ) return;
|
||||
|
||||
if(currentTask[m_CurrentState] != NULL)
|
||||
if(currentTask[m_CurrentState] != nullptr)
|
||||
currentTask[m_CurrentState]->handleUIInput(iAction);
|
||||
}
|
||||
|
||||
@@ -1988,7 +1989,7 @@ void Tutorial::onSelectedItemChanged(shared_ptr<ItemInstance> item)
|
||||
// Menus and states like riding in a minecart will NOT allow this
|
||||
if( isSelectedItemState() )
|
||||
{
|
||||
if(item != NULL)
|
||||
if(item != nullptr)
|
||||
{
|
||||
switch(item->id)
|
||||
{
|
||||
@@ -2151,7 +2152,7 @@ void Tutorial::AddConstraint(TutorialConstraint *c)
|
||||
void Tutorial::RemoveConstraint(TutorialConstraint *c, bool delayedRemove /*= false*/)
|
||||
{
|
||||
if( currentFailedConstraint[m_CurrentState] == c )
|
||||
currentFailedConstraint[m_CurrentState] = NULL;
|
||||
currentFailedConstraint[m_CurrentState] = nullptr;
|
||||
|
||||
if( c->getQueuedForRemoval() )
|
||||
{
|
||||
@@ -2211,16 +2212,16 @@ void Tutorial::addMessage(int messageId, bool limitRepeats /*= false*/, unsigned
|
||||
}
|
||||
|
||||
#ifdef _XBOX
|
||||
void Tutorial::changeTutorialState(eTutorial_State newState, CXuiScene *scene /*= NULL*/)
|
||||
void Tutorial::changeTutorialState(eTutorial_State newState, CXuiScene *scene /*= nullptr*/)
|
||||
#else
|
||||
void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*= NULL*/)
|
||||
void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*= nullptr*/)
|
||||
#endif
|
||||
{
|
||||
if(newState == m_CurrentState)
|
||||
{
|
||||
// If clearing the scene, make sure that the tutorial popup has its reference to this scene removed
|
||||
#ifndef _XBOX
|
||||
if( scene == NULL )
|
||||
if( scene == nullptr )
|
||||
{
|
||||
ui.RemoveInteractSceneReference(m_iPad, m_UIScene);
|
||||
}
|
||||
@@ -2241,7 +2242,7 @@ void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*=
|
||||
}
|
||||
|
||||
// The action that caused the change of state may also have completed the current task
|
||||
if( currentTask[m_CurrentState] != NULL && currentTask[m_CurrentState]->isCompleted() )
|
||||
if( currentTask[m_CurrentState] != nullptr && currentTask[m_CurrentState]->isCompleted() )
|
||||
{
|
||||
activeTasks[m_CurrentState].erase( find( activeTasks[m_CurrentState].begin(), activeTasks[m_CurrentState].end(), currentTask[m_CurrentState]) );
|
||||
|
||||
@@ -2252,21 +2253,21 @@ void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*=
|
||||
}
|
||||
else
|
||||
{
|
||||
currentTask[m_CurrentState] = NULL;
|
||||
currentTask[m_CurrentState] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if( currentTask[m_CurrentState] != NULL )
|
||||
if( currentTask[m_CurrentState] != nullptr )
|
||||
{
|
||||
currentTask[m_CurrentState]->onStateChange(newState);
|
||||
}
|
||||
|
||||
// Make sure that the current message is cleared
|
||||
setMessage( NULL );
|
||||
setMessage( nullptr );
|
||||
|
||||
// If clearing the scene, make sure that the tutorial popup has its reference to this scene removed
|
||||
#ifndef _XBOX
|
||||
if( scene == NULL )
|
||||
if( scene == nullptr )
|
||||
{
|
||||
ui.RemoveInteractSceneReference(m_iPad, m_UIScene);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user