Merge branch 'feature/bonusmalus-timers'

feature/prepare-cross-merge
Nuno 4 years ago committed by kaetemi
parent ca543ce9b6
commit 4401db3dc7
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -158,9 +158,13 @@ void CAuraRootEffect::createEffectOnEntity(CEntityBase *entity, CEntityBase *cre
if (effect) if (effect)
{ {
effect->setIsFromConsumable(_IsFromConsumable); effect->setIsFromConsumable(_IsFromConsumable);
effect->setEffectDisabledEndDate( CTickEventHandler::getGameCycle() + _TargetDisableTime ); effect->setEffectDisabledEndDate( _ActivationDate + _TargetDisableTime );
entity->addSabrinaEffect(effect); entity->addSabrinaEffect(effect);
character->useAura(_PowerType, CTickEventHandler::getGameCycle(), CTickEventHandler::getGameCycle() + _TargetDisableTime, creator->getId()); character->useAura(_PowerType, _ActivationDate, _ActivationDate + _TargetDisableTime, creator->getId());
// CAuraBaseEffect has short (~2sec) AurasUpdateFrequency timer as it needs to update in-range players.
// Send (our) CAuraRootEffect timer to client instead
character->updateEffectInDB(effect->getEffectIndexInDB(), EFFECT_FAMILIES::isEffectABonus(effect->getFamily()), getEndDate());
//send message to newly affected entity //send message to newly affected entity
SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type); SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type);
@ -274,7 +278,7 @@ void CAuraBaseEffect::removed()
if (_IsFromConsumable) if (_IsFromConsumable)
player->removeEffectInDB((uint8)_EffectIndexInDB, true); player->removeEffectInDB((uint8)_EffectIndexInDB, true);
else else
player->disableEffectInDB( (uint8)_EffectIndexInDB,true, _DisabledEndDate); player->disableEffectInDB( (uint8)_EffectIndexInDB,true, getAssociatedSheetId(), _DisabledEndDate);
} }
} // removed // } // removed //

@ -50,6 +50,7 @@ public:
{ {
_AffectGuild = affectGuild; _AffectGuild = affectGuild;
_IsFromConsumable = false; _IsFromConsumable = false;
_ActivationDate = CTickEventHandler::getGameCycle();
#ifdef NL_DEBUG #ifdef NL_DEBUG
_LastUpdateDate = CTickEventHandler::getGameCycle(); _LastUpdateDate = CTickEventHandler::getGameCycle();
#endif #endif
@ -97,6 +98,8 @@ private:
bool _IsFromConsumable; bool _IsFromConsumable;
NLMISC::TGameCycle _ActivationDate;
#ifdef NL_DEBUG #ifdef NL_DEBUG
NLMISC::TGameCycle _LastUpdateDate; NLMISC::TGameCycle _LastUpdateDate;
#endif #endif

@ -212,6 +212,9 @@ public:
inline void setIsFromConsumable(bool fromConsumable) { _IsFromConsumable = fromConsumable; } inline void setIsFromConsumable(bool fromConsumable) { _IsFromConsumable = fromConsumable; }
inline bool getIsFromConsumable() { return _IsFromConsumable; } inline bool getIsFromConsumable() { return _IsFromConsumable; }
///
inline NLMISC::TGameCycle getEndTime() const { return _EndTimer.getTime(); }
protected: protected:
/// send chat message for effect begin /// send chat message for effect begin

@ -10369,10 +10369,10 @@ void CCharacter::setDatabase()
CBankAccessor_PLR::getFAME().setCIV_ALLEGIANCE(_PropertyDatabase, _DeclaredCiv); CBankAccessor_PLR::getFAME().setCIV_ALLEGIANCE(_PropertyDatabase, _DeclaredCiv);
// activate effects active on character // activate effects active on character
_PersistentEffects.activate(); _PersistentEffects.activate();
// activate forbid power end date, infective aura end date and consumable overdose timer // cleanup expired forbid power, infective aura, and consumable overdose timer
_ForbidPowerDates.activate(); _ForbidPowerDates.cleanVector();
_IneffectiveAuras.activate(); _IneffectiveAuras.cleanVector();
_ConsumableOverdoseEndDates.activate(); _ConsumableOverdoseEndDates.cleanVector();
// init the RRPs // init the RRPs
// RingRewardPoints.initDb(); // RingRewardPoints.initDb();
} // setDatabase // } // setDatabase //
@ -16951,7 +16951,7 @@ void CCharacter::setPowerFlagDates()
{ {
uint32 flag = BRICK_FLAGS::powerTypeToFlag((*it).PowerType) - BRICK_FLAGS::BeginPowerFlags; uint32 flag = BRICK_FLAGS::powerTypeToFlag((*it).PowerType) - BRICK_FLAGS::BeginPowerFlags;
if ((*it).ActivationDate <= time && _ForbidPowerDates.doNotClear == false) if ((*it).ActivationDate <= time)
{ {
// erase returns an iterator that designates the first element remaining beyond any elements removed, or // erase returns an iterator that designates the first element remaining beyond any elements removed, or
// end() if no such element exists. // end() if no such element exists.
@ -17211,7 +17211,7 @@ bool CCharacter::addSabrinaEffect(CSEffect* effect)
if (sheet != CSheetId::Unknown) if (sheet != CSheetId::Unknown)
{ {
effect->setEffectIndexInDB(addEffectInDB(sheet, EFFECT_FAMILIES::isEffectABonus(effect->getFamily()))); effect->setEffectIndexInDB(addEffectInDB(sheet, EFFECT_FAMILIES::isEffectABonus(effect->getFamily()), effect->getEndTime()));
} }
return true; return true;
@ -22949,9 +22949,9 @@ void CCharacter::incParryModifier(sint32 inc)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
sint8 CCharacter::addEffectInDB(const NLMISC::CSheetId &sheetId, bool bonus) sint8 CCharacter::addEffectInDB(const NLMISC::CSheetId &sheetId, bool bonus, NLMISC::TGameCycle endTime)
{ {
return _ModifiersInDB.addEffect(sheetId, bonus, _PropertyDatabase); return _ModifiersInDB.addEffect(sheetId, bonus, endTime, _PropertyDatabase);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -22963,9 +22963,16 @@ void CCharacter::removeEffectInDB(uint8 index, bool bonus)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void CCharacter::disableEffectInDB(uint8 index, bool bonus, NLMISC::TGameCycle activationDate) void CCharacter::disableEffectInDB(uint8 index, bool bonus, const NLMISC::CSheetId &sheetId, NLMISC::TGameCycle activationDate)
{ {
_ModifiersInDB.disableEffect(index, bonus, activationDate, _PropertyDatabase); _ModifiersInDB.disableEffect(index, bonus, sheetId, activationDate, _PropertyDatabase);
}
//------------------------------------------------------------------------------
void CCharacter::updateEffectInDB(uint8 index, bool bonus, NLMISC::TGameCycle activationDate)
{
_ModifiersInDB.updateEffect(index, bonus, activationDate, _PropertyDatabase);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -2022,15 +2022,19 @@ public:
* add a bonus effect and write it in DB * add a bonus effect and write it in DB
* \param sheetId sheetId of the effect brick * \param sheetId sheetId of the effect brick
* \param bonus true of the effectis a bonus * \param bonus true of the effectis a bonus
* \param endDate game cycle when effect ends
* \return index in Db, or -1 if DB full * \return index in Db, or -1 if DB full
*/ */
sint8 addEffectInDB(const NLMISC::CSheetId &sheetId, bool bonus = true); sint8 addEffectInDB(const NLMISC::CSheetId &sheetId, bool bonus = true, NLMISC::TGameCycle endDate = 0);
/// remove bonus effect /// remove bonus effect
void removeEffectInDB(uint8 index, bool bonus = true); void removeEffectInDB(uint8 index, bool bonus = true);
/// disable effect /// disable effect
void disableEffectInDB(uint8 index, bool bonus, NLMISC::TGameCycle activationDate); void disableEffectInDB(uint8 index, bool bonus, const NLMISC::CSheetId &sheetId, NLMISC::TGameCycle activationDate);
/// update effect activation date
void updateEffectInDB(uint8 index, bool bonus, NLMISC::TGameCycle activationDate);
// return the carried weight // return the carried weight
uint32 getCarriedWeight(); uint32 getCarriedWeight();

@ -101,6 +101,7 @@ void CModifiersInDB::writeInDatabase(CCDBSynchronised &database)
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setSHEET(database, Bonus[i].SheetId); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setSHEET(database, Bonus[i].SheetId);
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[i], 1); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[i], 1);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setDISABLED(database, true); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setDISABLED(database, true);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setDISABLED_TIME(database, Bonus[i].ActivationDate);
} }
} }
for (uint i = 0 ; i < NbMalusModifiers ; ++i) for (uint i = 0 ; i < NbMalusModifiers ; ++i)
@ -111,6 +112,7 @@ void CModifiersInDB::writeInDatabase(CCDBSynchronised &database)
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setSHEET(database, Malus[i].SheetId); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setSHEET(database, Malus[i].SheetId);
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[i], 1); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[i], 1);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setDISABLED(database, true); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setDISABLED(database, true);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setDISABLED_TIME(database, Malus[i].ActivationDate);
} }
} }
} }
@ -126,6 +128,7 @@ void CModifiersInDB::update(CCDBSynchronised &database)
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setSHEET(database, CSheetId::Unknown); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setSHEET(database, CSheetId::Unknown);
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[i], 0); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[i], 0);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setDISABLED(database, false); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setDISABLED(database, false);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(i).setDISABLED_TIME(database, 0);
Bonus[i].init(); Bonus[i].init();
} }
} }
@ -137,12 +140,13 @@ void CModifiersInDB::update(CCDBSynchronised &database)
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setSHEET(database, CSheetId::Unknown); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setSHEET(database, CSheetId::Unknown);
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[i], 0); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[i], 0);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setDISABLED(database, false); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setDISABLED(database, false);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(i).setDISABLED_TIME(database, 0);
Malus[i].init(); Malus[i].init();
} }
} }
} }
sint8 CModifiersInDB::addEffect(const NLMISC::CSheetId &sheetId, bool bonus, CCDBSynchronised &database) sint8 CModifiersInDB::addEffect(const NLMISC::CSheetId &sheetId, bool bonus, NLMISC::TGameCycle endTime, CCDBSynchronised &database)
{ {
if (sheetId == NLMISC::CSheetId::Unknown) if (sheetId == NLMISC::CSheetId::Unknown)
return (sint8)-1; return (sint8)-1;
@ -167,12 +171,14 @@ sint8 CModifiersInDB::addEffect(const NLMISC::CSheetId &sheetId, bool bonus, CCD
if (freeSlot != -1) if (freeSlot != -1)
{ {
modifiers[freeSlot].SheetId = sheetId; modifiers[freeSlot].SheetId = sheetId;
modifiers[freeSlot].ActivationDate = endTime;
if(bonus) if(bonus)
{ {
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Sheet[freeSlot], sheetId.asInt() ); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Sheet[freeSlot], sheetId.asInt() );
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(freeSlot).setSHEET(database, sheetId ); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(freeSlot).setSHEET(database, sheetId );
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[freeSlot], 0); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[freeSlot], 0);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(freeSlot).setDISABLED(database, false); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(freeSlot).setDISABLED(database, false);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(freeSlot).setDISABLED_TIME(database, endTime);
} }
else else
{ {
@ -180,6 +186,7 @@ sint8 CModifiersInDB::addEffect(const NLMISC::CSheetId &sheetId, bool bonus, CCD
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(freeSlot).setSHEET(database, sheetId ); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(freeSlot).setSHEET(database, sheetId );
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[freeSlot], 0); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[freeSlot], 0);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(freeSlot).setDISABLED(database, false); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(freeSlot).setDISABLED(database, false);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(freeSlot).setDISABLED_TIME(database, endTime);
} }
} }
@ -200,6 +207,7 @@ void CModifiersInDB::removeEffect(uint8 index, bool bonus, CCDBSynchronised &dat
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setSHEET(database, CSheetId::Unknown ); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setSHEET(database, CSheetId::Unknown );
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[index], 0); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Bonus.Disable[index], 0);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setDISABLED(database, false); CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setDISABLED(database, false);
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setDISABLED_TIME(database, 0);
} }
else else
{ {
@ -207,16 +215,16 @@ void CModifiersInDB::removeEffect(uint8 index, bool bonus, CCDBSynchronised &dat
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setSHEET(database, CSheetId::Unknown); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setSHEET(database, CSheetId::Unknown);
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[index], 0); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.Disable[index], 0);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setDISABLED(database, false); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setDISABLED(database, false);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setDISABLED_TIME(database, 0);
} }
} }
void CModifiersInDB::disableEffect(uint8 index, bool bonus, NLMISC::TGameCycle activationDate, CCDBSynchronised &database) void CModifiersInDB::disableEffect(uint8 index, bool bonus, const NLMISC::CSheetId &sheetId, NLMISC::TGameCycle activationDate, CCDBSynchronised &database)
{ {
if ( (bonus && index >= NbBonusModifiers) || (!bonus && index >= NbMalusModifiers) ) if ( (bonus && index >= NbBonusModifiers) || (!bonus && index >= NbMalusModifiers) )
return; return;
std::vector<CModifierInDB> &modifiers = bonus ? Bonus : Malus; std::vector<CModifierInDB> &modifiers = bonus ? Bonus : Malus;
const std::string type = bonus ? "BONUS:" : "MALUS:";
modifiers[index].Disabled = true; modifiers[index].Disabled = true;
modifiers[index].ActivationDate = activationDate; modifiers[index].ActivationDate = activationDate;
@ -235,6 +243,31 @@ void CModifiersInDB::disableEffect(uint8 index, bool bonus, NLMISC::TGameCycle a
// database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.DisableTime[index], activationDate); // database.setProp( CCharacter::getDataIndexReminder()->Modifiers.Malus.DisableTime[index], activationDate);
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setDISABLED_TIME(database, activationDate); CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setDISABLED_TIME(database, activationDate);
} }
// update sheetId only when needed
if (modifiers[index].SheetId == CSheetId::Unknown)
{
modifiers[index].SheetId = sheetId;
if (bonus)
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setSHEET(database, sheetId);
else
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setSHEET(database, sheetId);
}
}
void CModifiersInDB::updateEffect(uint8 index, bool bonus, NLMISC::TGameCycle activationDate, CCDBSynchronised &database)
{
if ( (bonus && index >= NbBonusModifiers) || (!bonus && index >= NbMalusModifiers) )
return;
std::vector<CModifierInDB> &modifiers = bonus ? Bonus : Malus;
modifiers[index].ActivationDate = activationDate;
if(bonus)
CBankAccessor_PLR::getMODIFIERS().getBONUS().getArray(index).setDISABLED_TIME(database, activationDate);
else
CBankAccessor_PLR::getMODIFIERS().getMALUS().getArray(index).setDISABLED_TIME(database, activationDate);
} }
void CModifiersInDB::_addBonus(const CModifierInDB& bonus) void CModifiersInDB::_addBonus(const CModifierInDB& bonus)

@ -74,13 +74,16 @@ struct CModifiersInDB
void update(CCDBSynchronised &database); void update(CCDBSynchronised &database);
/// add an active effect /// add an active effect
sint8 addEffect(const NLMISC::CSheetId &sheetId, bool bonus, CCDBSynchronised &database); sint8 addEffect(const NLMISC::CSheetId &sheetId, bool bonus, NLMISC::TGameCycle endTime, CCDBSynchronised &database);
/// remove an effect /// remove an effect
void removeEffect(uint8 index, bool bonus, CCDBSynchronised &database); void removeEffect(uint8 index, bool bonus, CCDBSynchronised &database);
/// disable an effect /// disable an effect
void disableEffect(uint8 index, bool bonus, NLMISC::TGameCycle activationDate, CCDBSynchronised &database); void disableEffect(uint8 index, bool bonus, const NLMISC::CSheetId &sheetId, NLMISC::TGameCycle activationDate, CCDBSynchronised &database);
/// update an effect activation date
void updateEffect(uint8 index, bool bonus, NLMISC::TGameCycle activationDate, CCDBSynchronised &database);
private: private:
void _addBonus(const CModifierInDB& bonus); void _addBonus(const CModifierInDB& bonus);

@ -796,8 +796,8 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
#define PERSISTENT_CLASS CPowerActivationDate #define PERSISTENT_CLASS CPowerActivationDate
#define PERSISTENT_DATA\ #define PERSISTENT_DATA\
PROP2(DeactivationDate, NLMISC::TGameCycle, CTickEventHandler::getGameCycle() - DeactivationDate, DeactivationDate = val)\ PROP_GAME_CYCLE(DeactivationDate)\
PROP2(ActivationDate, NLMISC::TGameCycle, ActivationDate - CTickEventHandler::getGameCycle(), ActivationDate = val)\ PROP_GAME_CYCLE(ActivationDate)\
PROP(uint16, ConsumableFamilyId)\ PROP(uint16, ConsumableFamilyId)\
PROP2(PowerType,string,POWERS::toString(PowerType),PowerType=POWERS::toPowerType(val))\ PROP2(PowerType,string,POWERS::toString(PowerType),PowerType=POWERS::toPowerType(val))\
@ -829,7 +829,7 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
#define PERSISTENT_CLASS CConsumableOverdoseTimer #define PERSISTENT_CLASS CConsumableOverdoseTimer
#define PERSISTENT_DATA\ #define PERSISTENT_DATA\
LPROP2(ActivationDate, NLMISC::TGameCycle, if(ActivationDate >= CTickEventHandler::getGameCycle()), ActivationDate - CTickEventHandler::getGameCycle(), ActivationDate = val)\ PROP_GAME_CYCLE(ActivationDate)\
PROP2(Family,string, CConsumable::getFamilyName(Family), Family=CConsumable::getFamilyIndex(val))\ PROP2(Family,string, CConsumable::getFamilyName(Family), Family=CConsumable::getFamilyIndex(val))\
//#pragma message( PERSISTENT_GENERATION_MESSAGE ) //#pragma message( PERSISTENT_GENERATION_MESSAGE )

@ -137,7 +137,7 @@ void CPowerActivationDateVector::writeUsablePowerFlags( uint32 &usablePowerFlags
std::vector <CPowerActivationDate>::iterator it = PowerActivationDates.begin(); std::vector <CPowerActivationDate>::iterator it = PowerActivationDates.begin();
while (it != PowerActivationDates.end()) while (it != PowerActivationDates.end())
{ {
if ( (*it).ActivationDate <= time && doNotClear == false ) if ( (*it).ActivationDate <= time )
{ {
// erase returns an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists. // erase returns an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
it = PowerActivationDates.erase(it); it = PowerActivationDates.erase(it);
@ -150,37 +150,6 @@ void CPowerActivationDateVector::writeUsablePowerFlags( uint32 &usablePowerFlags
} }
} }
//-----------------------------------------------------------------------------
void CPowerActivationDateVector::activate()
{
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
std::vector <CPowerActivationDate>::iterator it = PowerActivationDates.begin();
while (it != PowerActivationDates.end())
{
if ( ((*it).DeactivationDate >= 0) && ((*it).DeactivationDate < MAX_DEACTIVATION_DATE) )
{
(*it).DeactivationDate = time - (*it).DeactivationDate; // the value saved is time length since deactivation, here we transform length into a date
}
else
{
nlinfo("POWER_AURA_CONTROL : Bad Deactivation date : %d", (*it).DeactivationDate);
(*it).DeactivationDate = time - MAX_DEACTIVATION_DATE;
}
if ((*it).ActivationDate < MAX_ACTIVATION_DATE)
{
(*it).ActivationDate += time;
}
else
{
nlinfo("POWER_AURA_CONTROL : Bad Activation date : %d", (*it).ActivationDate);
(*it).ActivationDate = time;
}
++it;
}
doNotClear = false;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// CAuraActivationDateVector // CAuraActivationDateVector
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -268,29 +237,6 @@ bool CAuraActivationDateVector::isAuraEffective(POWERS::TPowerType type, const N
return result; return result;
} }
//-----------------------------------------------------------------------------
void CAuraActivationDateVector::activate()
{
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
std::vector <CPowerActivationDate>::iterator it = _AuraActivationDates.begin();
while (it != _AuraActivationDates.end())
{
(*it).DeactivationDate = time - (*it).DeactivationDate; // the value saved is time length since deactivation, here we transform length into a date
if ((*it).ActivationDate < MAX_ACTIVATION_DATE)
{
(*it).ActivationDate += time;
}
else
{
nlinfo("POWER_AURA_CONTROL : Bad Activation date : %d", (*it).ActivationDate);
(*it).ActivationDate = time;
}
++it;
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// CConsumableOverdoseTimerVector // CConsumableOverdoseTimerVector
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -340,24 +286,3 @@ bool CConsumableOverdoseTimerVector::canConsume(uint16 family, NLMISC::TGameCycl
return result; return result;
} }
//-----------------------------------------------------------------------------
void CConsumableOverdoseTimerVector::activate()
{
const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();
std::vector <CConsumableOverdoseTimer>::iterator it = Dates.begin();
while (it != Dates.end())
{
if ((*it).ActivationDate < MAX_ACTIVATION_DATE)
{
(*it).ActivationDate += time;
}
else
{
nlinfo("POWER_AURA_CONTROL : Bad Activation date : %d", (*it).ActivationDate);
(*it).ActivationDate = time;
}
++it;
}
}

@ -61,9 +61,6 @@ struct CPowerActivationDateVector
DECLARE_PERSISTENCE_METHODS DECLARE_PERSISTENCE_METHODS
std::vector <CPowerActivationDate> PowerActivationDates; std::vector <CPowerActivationDate> PowerActivationDates;
bool doNotClear;
CPowerActivationDateVector() { doNotClear = true; }
void clear(); void clear();
@ -79,8 +76,6 @@ struct CPowerActivationDateVector
bool isPowerAllowed(POWERS::TPowerType type, uint16 consumableFamilyId, NLMISC::TGameCycle &endDate); bool isPowerAllowed(POWERS::TPowerType type, uint16 consumableFamilyId, NLMISC::TGameCycle &endDate);
void writeUsablePowerFlags( uint32 &usablePowerFlags); void writeUsablePowerFlags( uint32 &usablePowerFlags);
void activate();
}; };
/************************************************************************/ /************************************************************************/
@ -116,8 +111,6 @@ public:
void cleanVector(); void cleanVector();
bool isAuraEffective(POWERS::TPowerType type, const NLMISC::CEntityId &user, NLMISC::TGameCycle &endDate); bool isAuraEffective(POWERS::TPowerType type, const NLMISC::CEntityId &user, NLMISC::TGameCycle &endDate);
void activate();
}; };
/************************************************************************/ /************************************************************************/
@ -170,8 +163,6 @@ struct CConsumableOverdoseTimerVector
/// can consume this family ? also clean the vector /// can consume this family ? also clean the vector
bool canConsume(uint16 family, NLMISC::TGameCycle &endDate); bool canConsume(uint16 family, NLMISC::TGameCycle &endDate);
void activate();
}; };

Loading…
Cancel
Save