mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 17:49:42 +00:00
[Client] Make ActiveSpells::removeSpellByTimestamp() return a boolean
Add logging to LocalPlayer::removeSpellsActive() to track when a player's active spell hasn't been removed due to an invalid timestamp.
This commit is contained in:
parent
ed9a85f13b
commit
f2d95dc84d
3 changed files with 15 additions and 4 deletions
|
@ -308,8 +308,10 @@ namespace MWMechanics
|
|||
|
||||
Remove the spell with a certain ID and a certain timestamp, useful
|
||||
when there are stacked spells with the same ID
|
||||
|
||||
Returns a boolean that indicates whether the corresponding spell was found
|
||||
*/
|
||||
void ActiveSpells::removeSpellByTimestamp(const std::string& id, MWWorld::TimeStamp timestamp)
|
||||
bool ActiveSpells::removeSpellByTimestamp(const std::string& id, MWWorld::TimeStamp timestamp)
|
||||
{
|
||||
for (TContainer::iterator spell = mSpells.begin(); spell != mSpells.end(); ++spell)
|
||||
{
|
||||
|
@ -319,10 +321,12 @@ namespace MWMechanics
|
|||
{
|
||||
spell->second.mEffects.clear();
|
||||
mSpellsChanged = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace MWMechanics
|
|||
Remove the spell with a certain ID and a certain timestamp, useful
|
||||
when there are stacked spells with the same ID
|
||||
*/
|
||||
void removeSpellByTimestamp(const std::string& id, MWWorld::TimeStamp timestamp);
|
||||
bool removeSpellByTimestamp(const std::string& id, MWWorld::TimeStamp timestamp);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -824,11 +824,18 @@ void LocalPlayer::removeSpellsActive()
|
|||
|
||||
for (const auto& activeSpell : spellsActiveChanges.activeSpells)
|
||||
{
|
||||
LOG_APPEND(TimedLog::LOG_INFO, "- removing %sstacking active spell %s", activeSpell.isStackingSpell ? "" : "non-", activeSpell.id.c_str());
|
||||
|
||||
// Remove stacking spells based on their timestamps
|
||||
if (activeSpell.isStackingSpell)
|
||||
{
|
||||
MWWorld::TimeStamp timestamp = MWWorld::TimeStamp(activeSpell.timestampHour, activeSpell.timestampDay);
|
||||
activeSpells.removeSpellByTimestamp(activeSpell.id, timestamp);
|
||||
bool foundSpell = activeSpells.removeSpellByTimestamp(activeSpell.id, timestamp);
|
||||
|
||||
if (!foundSpell)
|
||||
{
|
||||
LOG_APPEND(TimedLog::LOG_INFO, "-- spell with this ID and timestamp could not be found!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue