优化[生物血量扩展]区分生物guid,以分别显示生物血量
This commit is contained in:
parent
eea532a204
commit
cee073896d
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>
|
||||
*/
|
||||
|
||||
// 声明您现有的脚本加载函数
|
||||
void AddMod_RuneSystemScripts();
|
||||
|
||||
// 新API要求的加载函数
|
||||
void Addmod_rune_systemScripts()
|
||||
{
|
||||
AddMod_RuneSystemScripts();
|
||||
}
|
||||
///*
|
||||
// * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>
|
||||
// */
|
||||
//
|
||||
//// 声明您现有的脚本加载函数
|
||||
//void Addmod_Creature_MultiLifeMultiplierScripts();
|
||||
//
|
||||
//// 新API要求的加载函数
|
||||
//void Addmod_Creature_MultiLifeMultiplierScripts()
|
||||
//{
|
||||
// Addmod_Creature_MultiLifeMultiplierScripts();
|
||||
//}
|
||||
|
||||
@ -54,7 +54,7 @@ void CreatureMultiHealthMgr::LoadCreatureHealthData()
|
||||
} while (result->NextRow());
|
||||
|
||||
_needsInstanceUpdate = true;
|
||||
LOG_INFO("server.loading", ">> 加载生物多倍血量数据 {} 条,用时 {} 毫秒", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outMessage("server", LogLevel::LOG_LEVEL_INFO, ">> 读取自定义功能数据表【__sm_生物血量扩展------】,共{}条数据读取加载,用时{}毫秒", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +109,12 @@ void CreatureMultiHealthMgr::UpdateNearbyPlayers(Creature* creature, uint64 curr
|
||||
if (!creature || !creature->GetMap())
|
||||
return;
|
||||
|
||||
std::string healthData = std::to_string(creature->GetEntry()) + "," +
|
||||
uint32 CreatureEntry = creature->GetEntry();
|
||||
uint64 CreatureLowGUID = creature->GetGUID().GetCounter(); // 获取GUID的Low部分
|
||||
|
||||
std::string healthData =
|
||||
std::to_string(CreatureEntry) + "," +
|
||||
std::to_string(CreatureLowGUID) + "," +
|
||||
std::to_string(currentHealth) + "," +
|
||||
std::to_string(maxHealth);
|
||||
|
||||
@ -193,7 +198,9 @@ void CreatureMultiHealthMgr::SendCustomCreatureHealthData(Player* player)
|
||||
|
||||
for (const auto& entry : _creatureHealthTemplates)
|
||||
{
|
||||
std::string data = std::to_string(entry.first) + "," + std::to_string(entry.second.maxHealth);
|
||||
std::string data =
|
||||
std::to_string(entry.first) + "," +
|
||||
std::to_string(entry.second.maxHealth);
|
||||
// 保留原始的客户端通信方式
|
||||
sGCAddon->SendPacketTo(player, "SM_S_CUSTOM_CREATURE_HEALTH_DATA", data);
|
||||
}
|
||||
@ -256,31 +263,6 @@ void CreatureMultiHealthMgr::OnCreatureRemove(Creature* creature)
|
||||
_creatureHealthInstances.erase(creature->GetGUID());
|
||||
}
|
||||
|
||||
void CreatureMultiHealthMgr::CleanupCache()
|
||||
{
|
||||
for (auto it = _creatureHealthInstances.begin(); it != _creatureHealthInstances.end();)
|
||||
{
|
||||
// 通过任意一个在世界中的对象来查找生物
|
||||
// 这里我们可以简化逻辑,直接检查GUID是否有效
|
||||
bool found = false;
|
||||
|
||||
// 遍历所有地图来查找生物是否仍然存在
|
||||
// 这是一个简化的检查方式
|
||||
if (it->first.IsCreature()) {
|
||||
// 如果GUID格式正确,我们假设生物可能仍然存在
|
||||
// 实际的清理可以通过其他方式触发,比如生物死亡或移除时
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
it = _creatureHealthInstances.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MultiLifeMultiplierPlayerScript : public PlayerScript
|
||||
{
|
||||
public:
|
||||
@ -354,15 +336,15 @@ public:
|
||||
|
||||
void OnAllCreatureUpdate(Creature* creature, uint32 diff) override
|
||||
{
|
||||
uint32 currentTime = getMSTime();
|
||||
//uint32 currentTime = getMSTime();
|
||||
|
||||
// 优化的清理机制
|
||||
if (currentTime - _lastCleanupTime > CACHE_CLEANUP_INTERVAL) {
|
||||
// 基于活跃生物列表进行精确清理
|
||||
sCreatureMultiHealthMgr->CleanupCacheBasedOnActiveCreatures(_processedCreatures);
|
||||
_processedCreatures.clear(); // 重置活跃列表
|
||||
_lastCleanupTime = currentTime;
|
||||
}
|
||||
//// 优化的清理机制
|
||||
//if (currentTime - _lastCleanupTime > CACHE_CLEANUP_INTERVAL) {
|
||||
// // 基于活跃生物列表进行精确清理
|
||||
// sCreatureMultiHealthMgr->CleanupCacheBasedOnActiveCreatures(_processedCreatures);
|
||||
// _processedCreatures.clear(); // 重置活跃列表
|
||||
// _lastCleanupTime = currentTime;
|
||||
//}
|
||||
|
||||
// 快速过滤
|
||||
if (!creature || creature->IsPet() || creature->IsTotem() || creature->isDead())
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
|
||||
CreatureMultiHealthInfo* GetCreatureHealthInfo(ObjectGuid guid);
|
||||
bool HasExtendedHealth(uint32 entry) const;
|
||||
void CleanupCache();
|
||||
|
||||
void CleanupCacheBasedOnActiveCreatures(const std::unordered_set<ObjectGuid>& activeCreatures);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user