BACKEND: fixed missing lock of member

this is not really needed - but still better (as there is no other access before or during init())
master
Martin Gerhardy 2021-01-23 14:36:18 +01:00
parent d05bc273ad
commit 3b789e6482
2 changed files with 6 additions and 4 deletions

View File

@ -62,11 +62,11 @@ protected:
* @brief called in the zone update to add new @c AI instances.
*
* @note Make sure to also call @c removeAI whenever you despawn the given @c AI instance
* @note This doesn't lock the zone - but because @c Zone::update already does it
* @note This doesn't lock the zone - because @c Zone::update already does it
*/
bool doAddAI(const AIPtr& ai);
/**
* @note This doesn't lock the zone - but only because @c Zone::update already does it
* @note This doesn't lock the zone - because @c Zone::update already does it
*/
bool doRemoveAI(const ai::CharacterId& id);
/**
@ -74,7 +74,7 @@ protected:
*
* @note That means, that this can be called in case the attached @c ICharacter instances or the @c AI instance itself is
* already invalid.
* @note This doesn't lock the zone - but because @c Zone::update already does it
* @note This doesn't lock the zone - because @c Zone::update already does it
*/
bool doDestroyAI(const ai::CharacterId& id);

View File

@ -3,6 +3,7 @@
*/
#include "UserCooldownMgr.h"
#include "core/concurrent/Lock.h"
#include "persistence/DBHandler.h"
#include "persistence/PersistenceMgr.h"
#include "core/Log.h"
@ -25,8 +26,9 @@ bool UserCooldownMgr::init() {
const cooldown::Type type = (cooldown::Type)id;
const uint64_t millis = model.starttime().millis();
const cooldown::CooldownPtr& c = createCooldown(type, millis);
_cooldowns.put(type, c);
if (c->running()) {
core::ScopedWriteLock scoped(_lock);
_cooldowns.put(type, c);
_queue.push(c);
}
})) {