Remove AUTO_VAR macro and _toString function (#592)

This commit is contained in:
void_17
2026-03-06 02:11:18 +07:00
committed by GitHub
parent 7d6658fe5b
commit 55231bb8d3
294 changed files with 5067 additions and 5773 deletions

View File

@@ -23,9 +23,8 @@ bool AreaTask::isCompleted()
case eAreaTaskCompletion_CompleteOnConstraintsSatisfied:
{
bool allSatisfied = true;
for(AUTO_VAR(it, constraints.begin()); it != constraints.end(); ++it)
for( auto& constraint : constraints )
{
TutorialConstraint *constraint = *it;
if(!constraint->isConstraintSatisfied(tutorial->getPad()))
{
allSatisfied = false;

View File

@@ -53,15 +53,15 @@ bool ControllerTask::isCompleted()
if(m_bHasSouthpaw && app.GetGameSettings(pMinecraft->player->GetXboxPad(),eGameSetting_ControlSouthPaw))
{
for(AUTO_VAR(it, southpawCompletedMappings.begin()); it != southpawCompletedMappings.end(); ++it)
for (auto& it : southpawCompletedMappings )
{
bool current = (*it).second;
bool current = it.second;
if(!current)
{
// TODO Use a different pad
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 )
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0 )
{
(*it).second = true;
it.second = true;
m_uiCompletionMask|=1<<iCurrent;
}
else
@@ -78,15 +78,15 @@ bool ControllerTask::isCompleted()
}
else
{
for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
for (auto& it : completedMappings )
{
bool current = (*it).second;
bool current = it.second;
if(!current)
{
// TODO Use a different pad
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 )
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0 )
{
(*it).second = true;
it.second = true;
m_uiCompletionMask|=1<<iCurrent;
}
else

View File

@@ -37,7 +37,7 @@ bool InfoTask::isCompleted()
return false;
bool bAllComplete = true;
Minecraft *pMinecraft = Minecraft::GetInstance();
// If the player is under water then allow all keypresses so they can jump out
@@ -47,9 +47,9 @@ bool InfoTask::isCompleted()
{
// If a menu is displayed, then we use the handleUIInput to complete the task
bAllComplete = true;
for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
for( auto& it : completedMappings )
{
bool current = (*it).second;
bool current = it.second;
if(!current)
{
bAllComplete = false;
@@ -61,18 +61,18 @@ bool InfoTask::isCompleted()
{
int iCurrent=0;
for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
for( auto& it : completedMappings )
{
bool current = (*it).second;
bool current = it.second;
if(!current)
{
#ifdef _WINDOWS64
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0 || g_KBMInput.IsKeyDown(VK_SPACE))
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0 || g_KBMInput.IsKeyDown(VK_SPACE))
#else
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), (*it).first) > 0)
if( InputManager.GetValue(pMinecraft->player->GetXboxPad(), it.first) > 0)
#endif
{
(*it).second = true;
it.second = true;
bAllComplete=true;
}
else
@@ -111,11 +111,11 @@ void InfoTask::handleUIInput(int iAction)
{
if(bHasBeenActivated)
{
for(AUTO_VAR(it, completedMappings.begin()); it != completedMappings.end(); ++it)
for( auto& it : completedMappings )
{
if( iAction == (*it).first )
if( iAction == it.first )
{
(*it).second = true;
it.second = true;
}
}
}

View File

@@ -3,8 +3,8 @@
ProcedureCompoundTask::~ProcedureCompoundTask()
{
for(AUTO_VAR(it, m_taskSequence.begin()); it < m_taskSequence.end(); ++it)
{
for (auto it = m_taskSequence.begin(); it < m_taskSequence.end(); ++it)
{
delete (*it);
}
}
@@ -24,10 +24,8 @@ int ProcedureCompoundTask::getDescriptionId()
// Return the id of the first task not completed
int descriptionId = -1;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
{
TutorialTask *task = *it;
for (auto& task : m_taskSequence)
{
if(!task->isCompleted())
{
task->setAsCurrentTask(true);
@@ -50,10 +48,8 @@ int ProcedureCompoundTask::getPromptId()
// Return the id of the first task not completed
int promptId = -1;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(!task->isCompleted())
{
promptId = task->getPromptId();
@@ -69,11 +65,8 @@ bool ProcedureCompoundTask::isCompleted()
bool allCompleted = true;
bool isCurrentTask = true;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(allCompleted && isCurrentTask)
{
if(task->isCompleted())
@@ -99,11 +92,9 @@ bool ProcedureCompoundTask::isCompleted()
if(allCompleted)
{
//Disable all constraints
itEnd = m_taskSequence.end();
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
// Disable all constraints
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
task->enableConstraints(false);
}
}
@@ -113,20 +104,16 @@ bool ProcedureCompoundTask::isCompleted()
void ProcedureCompoundTask::onCrafted(shared_ptr<ItemInstance> item)
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
task->onCrafted(item);
}
}
void ProcedureCompoundTask::handleUIInput(int iAction)
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto task : m_taskSequence)
{
TutorialTask *task = *it;
task->handleUIInput(iAction);
}
}
@@ -135,10 +122,8 @@ void ProcedureCompoundTask::handleUIInput(int iAction)
void ProcedureCompoundTask::setAsCurrentTask(bool active /*= true*/)
{
bool allCompleted = true;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(allCompleted && !task->isCompleted())
{
task->setAsCurrentTask(true);
@@ -157,10 +142,8 @@ bool ProcedureCompoundTask::ShowMinimumTime()
return false;
bool showMinimumTime = false;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(!task->isCompleted())
{
showMinimumTime = task->ShowMinimumTime();
@@ -176,10 +159,8 @@ bool ProcedureCompoundTask::hasBeenActivated()
return true;
bool hasBeenActivated = false;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(!task->isCompleted())
{
hasBeenActivated = task->hasBeenActivated();
@@ -191,10 +172,8 @@ bool ProcedureCompoundTask::hasBeenActivated()
void ProcedureCompoundTask::setShownForMinimumTime()
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(!task->isCompleted())
{
task->setShownForMinimumTime();
@@ -209,10 +188,8 @@ bool ProcedureCompoundTask::AllowFade()
return true;
bool allowFade = true;
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
if(!task->isCompleted())
{
allowFade = task->AllowFade();
@@ -224,40 +201,32 @@ bool ProcedureCompoundTask::AllowFade()
void ProcedureCompoundTask::useItemOn(Level *level, shared_ptr<ItemInstance> item, int x, int y, int z,bool bTestUseOnly)
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
task->useItemOn(level, item, x, y, z, bTestUseOnly);
}
}
void ProcedureCompoundTask::useItem(shared_ptr<ItemInstance> item, bool bTestUseOnly)
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
task->useItem(item, bTestUseOnly);
}
}
void ProcedureCompoundTask::onTake(shared_ptr<ItemInstance> item, unsigned int invItemCountAnyAux, unsigned int invItemCountThisAux)
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
task->onTake(item, invItemCountAnyAux, invItemCountThisAux);
}
}
void ProcedureCompoundTask::onStateChange(eTutorial_State newState)
{
AUTO_VAR(itEnd, m_taskSequence.end());
for(AUTO_VAR(it, m_taskSequence.begin()); it < itEnd; ++it)
for(auto& task : m_taskSequence)
{
TutorialTask *task = *it;
task->onStateChange(newState);
}
}

View File

@@ -41,7 +41,7 @@ bool Tutorial::PopupMessageDetails::isSameContent(PopupMessageDetails *other)
void Tutorial::staticCtor()
{
//
//
/*
*****
*****
@@ -72,7 +72,7 @@ void Tutorial::staticCtor()
s_completableTasks.push_back( e_Tutorial_State_Enchanting );
s_completableTasks.push_back( e_Tutorial_Hint_Hold_To_Mine );
s_completableTasks.push_back( e_Tutorial_Hint_Tool_Damaged );
s_completableTasks.push_back( e_Tutorial_Hint_Tool_Damaged );
s_completableTasks.push_back( e_Tutorial_Hint_Swim_Up );
s_completableTasks.push_back( e_Tutorial_Hint_Unused_2 );
@@ -164,7 +164,7 @@ void Tutorial::staticCtor()
s_completableTasks.push_back( e_Tutorial_Hint_Thin_Glass );
s_completableTasks.push_back( e_Tutorial_Hint_Melon );
s_completableTasks.push_back( e_Tutorial_Hint_Vine );
s_completableTasks.push_back( e_Tutorial_Hint_Fence_Gate );
s_completableTasks.push_back( e_Tutorial_Hint_Fence_Gate );
s_completableTasks.push_back( e_Tutorial_Hint_Mycel );
s_completableTasks.push_back( e_Tutorial_Hint_Water_Lily );
s_completableTasks.push_back( e_Tutorial_Hint_Nether_Brick );
@@ -319,7 +319,7 @@ void Tutorial::staticCtor()
s_completableTasks.push_back( e_Tutorial_State_Enderchests );
s_completableTasks.push_back( e_Tutorial_State_Horse_Menu );
s_completableTasks.push_back( e_Tutorial_State_Hopper_Menu );
s_completableTasks.push_back( e_Tutorial_Hint_Wither );
s_completableTasks.push_back( e_Tutorial_Hint_Witch );
s_completableTasks.push_back( e_Tutorial_Hint_Bat );
@@ -470,7 +470,7 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
if(!isHintCompleted(e_Tutorial_Hint_Detector_Rail)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Detector_Rail, this, detectorRailItems, 1 ) );
int tallGrassItems[] = {Tile::tallgrass_Id};
if(!isHintCompleted(e_Tutorial_Hint_Tall_Grass))
if(!isHintCompleted(e_Tutorial_Hint_Tall_Grass))
{
addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Tall_Grass, this, tallGrassItems, 1, -1, TallGrass::DEAD_SHRUB ) );
addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Tall_Grass, this, tallGrassItems, 1, -1, TallGrass::TALL_GRASS ) );
@@ -753,46 +753,46 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
int potatoItems[] = {Tile::potatoes_Id};
if(!isHintCompleted(e_Tutorial_Hint_Potato)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Potato, this, potatoItems, 1, -1, -1, 7 ) );
int carrotItems[] = {Tile::carrots_Id};
if(!isHintCompleted(e_Tutorial_Hint_Carrot)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Carrot, this, carrotItems, 1, -1, -1, 7 ) );
int commandBlockItems[] = {Tile::commandBlock_Id};
if(!isHintCompleted(e_Tutorial_Hint_CommandBlock)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_CommandBlock, this, commandBlockItems, 1 ) );
int beaconItems[] = {Tile::beacon_Id};
if(!isHintCompleted(e_Tutorial_Hint_Beacon)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Beacon, this, beaconItems, 1 ) );
int activatorRailItems[] = {Tile::activatorRail_Id};
if(!isHintCompleted(e_Tutorial_Hint_Activator_Rail)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Activator_Rail, this, activatorRailItems, 1 ) );
int redstoneBlockItems[] = {Tile::redstoneBlock_Id};
if(!isHintCompleted(e_Tutorial_Hint_RedstoneBlock)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_RedstoneBlock, this, redstoneBlockItems, 1 ) );
int daylightDetectorItems[] = {Tile::daylightDetector_Id};
if(!isHintCompleted(e_Tutorial_Hint_DaylightDetector)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_DaylightDetector, this, daylightDetectorItems, 1 ) );
int dropperItems[] = {Tile::dropper_Id};
if(!isHintCompleted(e_Tutorial_Hint_Dropper)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Dropper, this, dropperItems, 1 ) );
int hopperItems[] = {Tile::hopper_Id};
if(!isHintCompleted(e_Tutorial_Hint_Hopper)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Hopper, this, hopperItems, 1 ) );
int comparatorItems[] = {Tile::comparator_off_Id, Tile::comparator_on_Id};
if(!isHintCompleted(e_Tutorial_Hint_Comparator)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_Comparator, this, comparatorItems, 2, Item::comparator_Id ) );
int trappedChestItems[] = {Tile::chest_trap_Id};
if(!isHintCompleted(e_Tutorial_Hint_ChestTrap)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_ChestTrap, this, trappedChestItems, 1 ) );
int hayBlockItems[] = {Tile::hayBlock_Id};
if(!isHintCompleted(e_Tutorial_Hint_HayBlock)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_HayBlock, this, hayBlockItems, 1 ) );
int clayHardenedItems[] = {Tile::clayHardened_Id};
if(!isHintCompleted(e_Tutorial_Hint_ClayHardened)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_ClayHardened, this, clayHardenedItems, 1 ) );
int clayHardenedColoredItems[] = {Tile::clayHardened_colored_Id};
if(!isHintCompleted(e_Tutorial_Hint_ClayHardenedColored)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_ClayHardenedColored, this, clayHardenedColoredItems, 1 ) );
int coalBlockItems[] = {Tile::coalBlock_Id};
if(!isHintCompleted(e_Tutorial_Hint_CoalBlock)) addHint(e_Tutorial_State_Gameplay, new LookAtTileHint(e_Tutorial_Hint_CoalBlock, this, coalBlockItems, 1 ) );
@@ -1000,9 +1000,9 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
* HORSE ENCOUNTER
*
*/
if(isFullTutorial || !isStateCompleted(e_Tutorial_State_Horse) )
if(isFullTutorial || !isStateCompleted(e_Tutorial_State_Horse) )
{
addTask(e_Tutorial_State_Horse,
addTask(e_Tutorial_State_Horse,
new HorseChoiceTask(this, IDS_TUTORIAL_TASK_HORSE_OVERVIEW, IDS_TUTORIAL_TASK_DONKEY_OVERVIEW, IDS_TUTORIAL_TASK_MULE_OVERVIEW, IDS_TUTORIAL_PROMPT_HORSE_OVERVIEW,
true, ACTION_MENU_A, ACTION_MENU_B, e_Tutorial_Completion_Complete_State_Gameplay_Constraints, eTelemetryTutorial_Horse) );
@@ -1144,23 +1144,23 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad( iPad )
Tutorial::~Tutorial()
{
for(AUTO_VAR(it, m_globalConstraints.begin()); it != m_globalConstraints.end(); ++it)
for(auto& it : m_globalConstraints)
{
delete (*it);
delete it;
}
for(unordered_map<int, TutorialMessage *>::iterator it = messages.begin(); it != messages.end(); ++it)
for(auto& message : messages)
{
delete (*it).second;
delete message.second;
}
for(unsigned int i = 0; i < e_Tutorial_State_Max; ++i)
{
for(AUTO_VAR(it, activeTasks[i].begin()); it < activeTasks[i].end(); ++it)
for(auto& it : activeTasks[i])
{
delete (*it);
delete it;
}
for(AUTO_VAR(it, hints[i].begin()); it < hints[i].end(); ++it)
for(auto& it : hints[i])
{
delete (*it);
delete it;
}
currentTask[i] = NULL;
@@ -1188,10 +1188,10 @@ void Tutorial::setCompleted( int completableId )
int completableIndex = -1;
for( AUTO_VAR(it, s_completableTasks.begin()); it < s_completableTasks.end(); ++it)
{
for (int task : s_completableTasks)
{
++completableIndex;
if( *it == completableId )
if( task == completableId )
{
break;
}
@@ -1220,10 +1220,10 @@ bool Tutorial::getCompleted( int completableId )
//}
int completableIndex = -1;
for( AUTO_VAR(it, s_completableTasks.begin()); it < s_completableTasks.end(); ++it)
{
for (int it : s_completableTasks)
{
++completableIndex;
if( *it == completableId )
if( it == completableId )
{
break;
}
@@ -1318,8 +1318,8 @@ void Tutorial::tick()
for(unsigned int state = 0; state < e_Tutorial_State_Max; ++state)
{
AUTO_VAR(it, constraintsToRemove[state].begin());
while(it < constraintsToRemove[state].end() )
auto it = constraintsToRemove[state].begin();
while(it != constraintsToRemove[state].end() )
{
++(*it).second;
if( (*it).second > m_iTutorialConstraintDelayRemoveTicks )
@@ -1361,7 +1361,7 @@ void Tutorial::tick()
}
if(!m_allowShow)
{
{
if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
{
uiTempDisabled = true;
@@ -1397,7 +1397,7 @@ void Tutorial::tick()
app.TutorialSceneNavigateBack(m_iPad);
m_bSceneIsSplitscreen=app.GetLocalPlayerCount()>1;
if(m_bSceneIsSplitscreen)
{
{
app.NavigateToScene(m_iPad, eUIComponent_TutorialPopup,(void *)this, false, false, &m_hTutorialScene);
}
else
@@ -1427,9 +1427,8 @@ void Tutorial::tick()
}
// Check constraints
for(AUTO_VAR(it, m_globalConstraints.begin()); it < m_globalConstraints.end(); ++it)
{
TutorialConstraint *constraint = *it;
for (auto& constraint : m_globalConstraints)
{
constraint->tick(m_iPad);
}
@@ -1443,9 +1442,8 @@ void Tutorial::tick()
if(hintsOn)
{
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
{
TutorialHint *hint = *it;
for (auto& hint : hints[m_CurrentState])
{
hintNeeded = hint->tick();
if(hintNeeded >= 0)
{
@@ -1469,9 +1467,8 @@ void Tutorial::tick()
constraintChanged = true;
currentFailedConstraint[m_CurrentState] = NULL;
}
for(AUTO_VAR(it, constraints[m_CurrentState].begin()); it < constraints[m_CurrentState].end(); ++it)
{
TutorialConstraint *constraint = *it;
for (auto& constraint : constraints[m_CurrentState])
{
if( !constraint->isConstraintSatisfied(m_iPad) && constraint->isConstraintRestrictive(m_iPad) )
{
constraintChanged = true;
@@ -1484,15 +1481,15 @@ void Tutorial::tick()
{
// Update tasks
bool isCurrentTask = true;
AUTO_VAR(it, activeTasks[m_CurrentState].begin());
while(activeTasks[m_CurrentState].size() > 0 && it < activeTasks[m_CurrentState].end())
auto it = activeTasks[m_CurrentState].begin();
while(activeTasks[m_CurrentState].size() > 0 && it != activeTasks[m_CurrentState].end())
{
TutorialTask *task = *it;
if( isCurrentTask || task->isPreCompletionEnabled() )
{
isCurrentTask = false;
if(
( !task->ShowMinimumTime() || ( task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime ) < GetTickCount() ) )
( !task->ShowMinimumTime() || ( task->hasBeenActivated() && (lastMessageTime + m_iTutorialMinimumDisplayMessageTime ) < GetTickCount() ) )
&& task->isCompleted()
)
{
@@ -1509,8 +1506,8 @@ void Tutorial::tick()
{
// 4J Stu - Move the delayed constraints to the gameplay state so that they are in
// effect for a bit longer
AUTO_VAR(itCon, constraintsToRemove[m_CurrentState].begin());
while(itCon != constraintsToRemove[m_CurrentState].end() )
auto itCon = constraintsToRemove[m_CurrentState].begin();
while(itCon != constraintsToRemove[m_CurrentState].end() )
{
constraints[e_Tutorial_State_Gameplay].push_back(itCon->first);
constraintsToRemove[e_Tutorial_State_Gameplay].push_back( pair<TutorialConstraint *, unsigned char>(itCon->first, itCon->second) );
@@ -1521,9 +1518,9 @@ void Tutorial::tick()
}
// Fall through the the normal complete state
case e_Tutorial_Completion_Complete_State:
for(AUTO_VAR(itRem, activeTasks[m_CurrentState].begin()); itRem < activeTasks[m_CurrentState].end(); ++itRem)
{
delete (*itRem);
for (auto& itRem : activeTasks[m_CurrentState])
{
delete itRem;
}
activeTasks[m_CurrentState].clear();
break;
@@ -1531,9 +1528,9 @@ void Tutorial::tick()
{
TutorialTask *lastTask = activeTasks[m_CurrentState].at( activeTasks[m_CurrentState].size() - 1 );
activeTasks[m_CurrentState].pop_back();
for(AUTO_VAR(itRem, activeTasks[m_CurrentState].begin()); itRem < activeTasks[m_CurrentState].end(); ++itRem)
for(auto& itRem : activeTasks[m_CurrentState])
{
delete (*itRem);
delete itRem;
}
activeTasks[m_CurrentState].clear();
activeTasks[m_CurrentState].push_back( lastTask );
@@ -1636,7 +1633,7 @@ void Tutorial::tick()
message->m_promptId = currentTask[m_CurrentState]->getPromptId();
message->m_allowFade = currentTask[m_CurrentState]->AllowFade();
setMessage( message );
currentTask[m_CurrentState]->TaskReminders()? m_iTaskReminders = 1 : m_iTaskReminders = 0;
currentTask[m_CurrentState]->TaskReminders()? m_iTaskReminders = 1 : m_iTaskReminders = 0;
}
else
{
@@ -1697,8 +1694,8 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
}
else
{
AUTO_VAR(it, messages.find(message->m_messageId));
if( it != messages.end() && it->second != NULL )
auto it = messages.find(message->m_messageId);
if( it != messages.end() && it->second != NULL )
{
TutorialMessage *messageString = it->second;
text = wstring( messageString->getMessageForDisplay() );
@@ -1727,8 +1724,8 @@ bool Tutorial::setMessage(PopupMessageDetails *message)
}
else if(message->m_promptId >= 0)
{
AUTO_VAR(it, messages.find(message->m_promptId));
if(it != messages.end() && it->second != NULL)
auto it = messages.find(message->m_promptId);
if(it != messages.end() && it->second != NULL)
{
TutorialMessage *prompt = it->second;
text.append( prompt->getMessageForDisplay() );
@@ -1781,7 +1778,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message)
bool messageShown = false;
DWORD time = GetTickCount();
if(message != NULL && (message->m_forceDisplay || hintsOn) &&
(!message->m_delay ||
(!message->m_delay ||
(
(m_hintDisplayed && (time - m_lastHintDisplayedTime) > m_iTutorialHintDelayTime ) ||
(!m_hintDisplayed && (time - lastMessageTime) > m_iTutorialMinimumDisplayMessageTime )
@@ -1793,7 +1790,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message)
if(messageShown)
{
m_lastHintDisplayedTime = time;
m_lastHintDisplayedTime = time;
m_hintDisplayed = true;
if(hint!=NULL) setHintCompleted( hint );
}
@@ -1817,7 +1814,7 @@ void Tutorial::showTutorialPopup(bool show)
m_allowShow = show;
if(!show)
{
{
if( currentTask[m_CurrentState] != NULL && (!currentTask[m_CurrentState]->AllowFade() || (lastMessageTime + m_iTutorialDisplayMessageTime ) > GetTickCount() ) )
{
uiTempDisabled = true;
@@ -1828,36 +1825,32 @@ void Tutorial::showTutorialPopup(bool show)
void Tutorial::useItemOn(Level *level, shared_ptr<ItemInstance> item, int x, int y, int z, bool bTestUseOnly)
{
for(AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it < activeTasks[m_CurrentState].end(); ++it)
for(auto& task : activeTasks[m_CurrentState])
{
TutorialTask *task = *it;
task->useItemOn(level, item, x, y, z, bTestUseOnly);
}
}
void Tutorial::useItemOn(shared_ptr<ItemInstance> item, bool bTestUseOnly)
{
for(AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it < activeTasks[m_CurrentState].end(); ++it)
for(auto& task : activeTasks[m_CurrentState])
{
TutorialTask *task = *it;
task->useItem(item, bTestUseOnly);
}
}
void Tutorial::completeUsingItem(shared_ptr<ItemInstance> item)
{
for(AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it < activeTasks[m_CurrentState].end(); ++it)
for(auto task : activeTasks[m_CurrentState])
{
TutorialTask *task = *it;
task->completeUsingItem(item);
}
// Fix for #46922 - TU5: UI: Player receives a reminder that he is hungry while "hunger bar" is full (triggered in split-screen mode)
if(m_CurrentState != e_Tutorial_State_Gameplay)
{
for(AUTO_VAR(it, activeTasks[e_Tutorial_State_Gameplay].begin()); it < activeTasks[e_Tutorial_State_Gameplay].end(); ++it)
for(auto task : activeTasks[e_Tutorial_State_Gameplay])
{
TutorialTask *task = *it;
task->completeUsingItem(item);
}
}
@@ -1866,9 +1859,8 @@ void Tutorial::completeUsingItem(shared_ptr<ItemInstance> item)
void Tutorial::startDestroyBlock(shared_ptr<ItemInstance> item, Tile *tile)
{
int hintNeeded = -1;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->startDestroyBlock(item, tile);
if(hintNeeded >= 0)
{
@@ -1877,16 +1869,14 @@ void Tutorial::startDestroyBlock(shared_ptr<ItemInstance> item, Tile *tile)
setMessage( hint, message );
break;
}
}
}
void Tutorial::destroyBlock(Tile *tile)
{
int hintNeeded = -1;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->destroyBlock(tile);
if(hintNeeded >= 0)
{
@@ -1895,16 +1885,14 @@ void Tutorial::destroyBlock(Tile *tile)
setMessage( hint, message );
break;
}
}
}
void Tutorial::attack(shared_ptr<Player> player, shared_ptr<Entity> entity)
{
int hintNeeded = -1;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->attack(player->inventory->getSelected(), entity);
if(hintNeeded >= 0)
{
@@ -1920,9 +1908,8 @@ void Tutorial::attack(shared_ptr<Player> player, shared_ptr<Entity> entity)
void Tutorial::itemDamaged(shared_ptr<ItemInstance> item)
{
int hintNeeded = -1;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->itemDamaged(item);
if(hintNeeded >= 0)
{
@@ -1939,11 +1926,6 @@ void Tutorial::handleUIInput(int iAction)
{
if( m_hintDisplayed ) return;
//for(AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it < activeTasks[m_CurrentState].end(); ++it)
//{
// TutorialTask *task = *it;
// task->handleUIInput(iAction);
//}
if(currentTask[m_CurrentState] != NULL)
currentTask[m_CurrentState]->handleUIInput(iAction);
}
@@ -1951,9 +1933,8 @@ void Tutorial::handleUIInput(int iAction)
void Tutorial::createItemSelected(shared_ptr<ItemInstance> item, bool canMake)
{
int hintNeeded = -1;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->createItemSelected(item, canMake);
if(hintNeeded >= 0)
{
@@ -1968,11 +1949,10 @@ void Tutorial::createItemSelected(shared_ptr<ItemInstance> item, bool canMake)
void Tutorial::onCrafted(shared_ptr<ItemInstance> item)
{
for(unsigned int state = 0; state < e_Tutorial_State_Max; ++state)
for(auto& subtasks : activeTasks)
{
for(AUTO_VAR(it, activeTasks[state].begin()); it < activeTasks[state].end(); ++it)
for(auto& task : subtasks)
{
TutorialTask *task = *it;
task->onCrafted(item);
}
}
@@ -1983,23 +1963,20 @@ void Tutorial::onTake(shared_ptr<ItemInstance> item, unsigned int invItemCountAn
if( !m_hintDisplayed )
{
bool hintNeeded = false;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->onTake(item);
if(hintNeeded)
{
break;
}
}
}
for(unsigned int state = 0; state < e_Tutorial_State_Max; ++state)
for(auto& subtasks : activeTasks)
{
for(AUTO_VAR(it, activeTasks[state].begin()); it < activeTasks[state].end(); ++it)
for(auto& task : subtasks)
{
TutorialTask *task = *it;
task->onTake(item, invItemCountAnyAux, invItemCountThisAux);
}
}
@@ -2035,9 +2012,8 @@ void Tutorial::onLookAt(int id, int iData)
if( m_hintDisplayed ) return;
bool hintNeeded = false;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->onLookAt(id, iData);
if(hintNeeded)
{
@@ -2066,9 +2042,8 @@ void Tutorial::onLookAtEntity(shared_ptr<Entity> entity)
if( m_hintDisplayed ) return;
bool hintNeeded = false;
for(AUTO_VAR(it, hints[m_CurrentState].begin()); it < hints[m_CurrentState].end(); ++it)
for(auto& hint : hints[m_CurrentState])
{
TutorialHint *hint = *it;
hintNeeded = hint->onLookAtEntity(entity->GetType());
if(hintNeeded)
{
@@ -2081,9 +2056,9 @@ void Tutorial::onLookAtEntity(shared_ptr<Entity> entity)
changeTutorialState(e_Tutorial_State_Horse);
}
for (AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it != activeTasks[m_CurrentState].end(); ++it)
for (auto& it : activeTasks[m_CurrentState])
{
(*it)->onLookAtEntity(entity);
it->onLookAtEntity(entity);
}
}
@@ -2098,17 +2073,16 @@ void Tutorial::onRideEntity(shared_ptr<Entity> entity)
}
}
for (AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it != activeTasks[m_CurrentState].end(); ++it)
for (auto& it : activeTasks[m_CurrentState])
{
(*it)->onRideEntity(entity);
it->onRideEntity(entity);
}
}
void Tutorial::onEffectChanged(MobEffect *effect, bool bRemoved)
{
for(AUTO_VAR(it, activeTasks[m_CurrentState].begin()); it < activeTasks[m_CurrentState].end(); ++it)
for(auto& task : activeTasks[m_CurrentState])
{
TutorialTask *task = *it;
task->onEffectChanged(effect,bRemoved);
}
}
@@ -2116,9 +2090,8 @@ void Tutorial::onEffectChanged(MobEffect *effect, bool bRemoved)
bool Tutorial::canMoveToPosition(double xo, double yo, double zo, double xt, double yt, double zt)
{
bool allowed = true;
for(AUTO_VAR(it, constraints[m_CurrentState].begin()); it < constraints[m_CurrentState].end(); ++it)
for(auto& constraint : constraints[m_CurrentState])
{
TutorialConstraint *constraint = *it;
if( !constraint->isConstraintSatisfied(m_iPad) && !constraint->canMoveToPosition(xo,yo,zo,xt,yt,zt) )
{
allowed = false;
@@ -2136,9 +2109,8 @@ bool Tutorial::isInputAllowed(int mapping)
if( Minecraft::GetInstance()->localplayers[m_iPad]->isUnderLiquid(Material::water) ) return true;
bool allowed = true;
for(AUTO_VAR(it, constraints[m_CurrentState].begin()); it < constraints[m_CurrentState].end(); ++it)
for(auto& constraint : constraints[m_CurrentState])
{
TutorialConstraint *constraint = *it;
if( constraint->isMappingConstrained( m_iPad, mapping ) )
{
allowed = false;
@@ -2156,9 +2128,9 @@ vector<TutorialTask *> *Tutorial::getTasks()
unsigned int Tutorial::getCurrentTaskIndex()
{
unsigned int index = 0;
for(AUTO_VAR(it, tasks.begin()); it < tasks.end(); ++it)
for(const auto& task : tasks)
{
if(*it == currentTask[e_Tutorial_State_Gameplay])
if(task == currentTask[e_Tutorial_State_Gameplay])
break;
++index;
@@ -2184,11 +2156,11 @@ void Tutorial::RemoveConstraint(TutorialConstraint *c, bool delayedRemove /*= fa
if( c->getQueuedForRemoval() )
{
// If it is already queued for removal, remove it on the next tick
/*for(AUTO_VAR(it, constraintsToRemove[m_CurrentState].begin()); it < constraintsToRemove[m_CurrentState].end(); ++it)
/*for(auto& it : constraintsToRemove[m_CurrentState])
{
if( it->first == c )
if( it.first == c )
{
it->second = m_iTutorialConstraintDelayRemoveTicks;
it.second = m_iTutorialConstraintDelayRemoveTicks;
break;
}
}*/
@@ -2196,12 +2168,12 @@ void Tutorial::RemoveConstraint(TutorialConstraint *c, bool delayedRemove /*= fa
else if(delayedRemove)
{
c->setQueuedForRemoval(true);
constraintsToRemove[m_CurrentState].push_back( pair<TutorialConstraint *, unsigned char>(c, 0) );
constraintsToRemove[m_CurrentState].emplace_back(c, 0);
}
else
{
for( AUTO_VAR(it, constraintsToRemove[m_CurrentState].begin()); it < constraintsToRemove[m_CurrentState].end(); ++it)
{
for (auto it = constraintsToRemove[m_CurrentState].begin(); it != constraintsToRemove[m_CurrentState].end(); ++it)
{
if( it->first == c )
{
constraintsToRemove[m_CurrentState].erase( it );
@@ -2209,8 +2181,8 @@ void Tutorial::RemoveConstraint(TutorialConstraint *c, bool delayedRemove /*= fa
}
}
AUTO_VAR(it, find( constraints[m_CurrentState].begin(), constraints[m_CurrentState].end(), c));
if( it != constraints[m_CurrentState].end() ) constraints[m_CurrentState].erase( find( constraints[m_CurrentState].begin(), constraints[m_CurrentState].end(), c) );
auto it = find(constraints[m_CurrentState].begin(), constraints[m_CurrentState].end(), c);
if( it != constraints[m_CurrentState].end() ) constraints[m_CurrentState].erase( find( constraints[m_CurrentState].begin(), constraints[m_CurrentState].end(), c) );
// It may be in the gameplay list, so remove it from there if it is
it = find( constraints[e_Tutorial_State_Gameplay].begin(), constraints[e_Tutorial_State_Gameplay].end(), c);
@@ -2271,7 +2243,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() )
{
activeTasks[m_CurrentState].erase( find( activeTasks[m_CurrentState].begin(), activeTasks[m_CurrentState].end(), currentTask[m_CurrentState]) );
activeTasks[m_CurrentState].erase( find( activeTasks[m_CurrentState].begin(), activeTasks[m_CurrentState].end(), currentTask[m_CurrentState]) );
if( activeTasks[m_CurrentState].size() > 0 )
{
@@ -2304,9 +2276,8 @@ void Tutorial::changeTutorialState(eTutorial_State newState, UIScene *scene /*=
if( m_CurrentState != newState )
{
for(AUTO_VAR(it, activeTasks[newState].begin()); it < activeTasks[newState].end(); ++it)
{
TutorialTask *task = *it;
for (auto& task : activeTasks[newState] )
{
task->onStateChange(newState);
}
m_CurrentState = newState;

View File

@@ -3,7 +3,7 @@
#include "TutorialConstraints.h"
#include "TutorialTask.h"
TutorialTask::TutorialTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, vector<TutorialConstraint *> *inConstraints,
TutorialTask::TutorialTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, vector<TutorialConstraint *> *inConstraints,
bool bShowMinimumTime, bool bAllowFade, bool bTaskReminders)
: tutorial( tutorial ), descriptionId( descriptionId ), m_promptId( -1 ), enablePreCompletion( enablePreCompletion ),
areConstraintsEnabled( false ), bIsCompleted( false ), bHasBeenActivated( false ),
@@ -11,9 +11,8 @@ TutorialTask::TutorialTask(Tutorial *tutorial, int descriptionId, bool enablePre
{
if(inConstraints != NULL)
{
for(AUTO_VAR(it, inConstraints->begin()); it < inConstraints->end(); ++it)
for(auto& constraint : *inConstraints)
{
TutorialConstraint *constraint = *it;
constraints.push_back( constraint );
}
delete inConstraints;
@@ -26,10 +25,8 @@ TutorialTask::~TutorialTask()
{
enableConstraints(false);
for(AUTO_VAR(it, constraints.begin()); it < constraints.end(); ++it)
for(auto& constraint : constraints)
{
TutorialConstraint *constraint = *it;
if( constraint->getQueuedForRemoval() )
{
constraint->setDeleteOnDeactivate(true);
@@ -52,9 +49,8 @@ void TutorialTask::enableConstraints(bool enable, bool delayRemove /*= false*/)
if( !enable && (areConstraintsEnabled || !delayRemove) )
{
// Remove
for(AUTO_VAR(it, constraints.begin()); it != constraints.end(); ++it)
for(auto& constraint : constraints)
{
TutorialConstraint *constraint = *it;
//app.DebugPrintf(">>>>>>>> %i\n", constraints.size());
tutorial->RemoveConstraint( constraint, delayRemove );
}
@@ -63,9 +59,8 @@ void TutorialTask::enableConstraints(bool enable, bool delayRemove /*= false*/)
else if( !areConstraintsEnabled && enable )
{
// Add
for(AUTO_VAR(it, constraints.begin()); it != constraints.end(); ++it)
for(auto& constraint : constraints)
{
TutorialConstraint *constraint = *it;
tutorial->AddConstraint( constraint );
}
areConstraintsEnabled = true;