From f47896f5b83ebf4f0c5a8eb0c2ef8eaa08eff380 Mon Sep 17 00:00:00 2001 From: Emagi Date: Fri, 23 May 2025 17:11:57 -0400 Subject: [PATCH] Added support for the spawn_anim to be converted and accurate for earlier clients like KoS and DoF, when spawning skeletons, zombies so on their animation is now present --- source/WorldServer/Spawn.cpp | 14 ++++++++++++-- source/WorldServer/VisualStates.h | 27 ++++++++++++++++++++++++++- source/WorldServer/WorldDatabase.cpp | 2 +- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/source/WorldServer/Spawn.cpp b/source/WorldServer/Spawn.cpp index edfa05f..de6a0e1 100644 --- a/source/WorldServer/Spawn.cpp +++ b/source/WorldServer/Spawn.cpp @@ -221,10 +221,20 @@ void Spawn::InitializeHeaderPacketData(Player* player, PacketStruct* header, int header->setDataByName("index", index); if (GetSpawnAnim() > 0 && Timer::GetCurrentTime2() < (GetAddedToWorldTimestamp() + GetSpawnAnimLeeway())) { + int32 spawn_anim = GetSpawnAnim(); + if (header->GetVersion() <= 561) { // spell's spell_visual field is based on newer clients, DoF has to convert + Emote* spellVisualEmote = visual_states.FindEmoteByID(spawn_anim, 60085); + if (spellVisualEmote != nullptr && spellVisualEmote->GetMessageString().size() > 0) { + spellVisualEmote = visual_states.FindEmote(spellVisualEmote->GetMessageString(), header->GetVersion()); + if (spellVisualEmote) { + spawn_anim = (int32)spellVisualEmote->GetVisualState(); + } + } + } if (header->GetVersion() >= 57080) - header->setDataByName("spawn_anim", GetSpawnAnim()); + header->setDataByName("spawn_anim", spawn_anim); else - header->setDataByName("spawn_anim", (int16)GetSpawnAnim()); + header->setDataByName("spawn_anim", (int16)spawn_anim); } else { if (header->GetVersion() >= 57080) diff --git a/source/WorldServer/VisualStates.h b/source/WorldServer/VisualStates.h index 40672d2..b4e4094 100644 --- a/source/WorldServer/VisualStates.h +++ b/source/WorldServer/VisualStates.h @@ -172,6 +172,7 @@ public: for(map_list = emoteMap.begin(); map_list != emoteMap.end(); map_list++ ) safe_delete(map_list->second); emoteMap.clear(); + emoteMapID.clear(); } void ClearVisualStates(){ @@ -191,8 +192,9 @@ public: return 0; } - void InsertEmoteRange(EmoteVersionRange* emote) { + void InsertEmoteRange(EmoteVersionRange* emote, int32 animation_id) { emoteMap[emote->GetName()] = emote; + emoteMapID[animation_id] = emote; } EmoteVersionRange* FindEmoteRange(string var) { @@ -217,6 +219,28 @@ public: return 0; } + EmoteVersionRange* FindEmoteRangeByID(int32 id) { + if (emoteMapID.count(id) > 0) + { + return emoteMapID[id]; + } + return 0; + } + + Emote* FindEmoteByID(int32 visual_id, int32 version){ + if (emoteMapID.count(visual_id) > 0) + { + map::iterator itr = emoteMapID[visual_id]->FindEmoteVersion(version); + + if (itr != emoteMapID[visual_id]->GetRangeEnd()) + { + Emote* emote = itr->second; + return emote; + } + } + return 0; + } + void InsertSpellVisualRange(EmoteVersionRange* emote, int32 spell_visual_id) { spellMap[emote->GetName()] = emote; spellMapID[spell_visual_id] = emote; @@ -276,6 +300,7 @@ public: private: map visualStateMap; map emoteMap; + map emoteMapID; map spellMap; map spellMapID; }; diff --git a/source/WorldServer/WorldDatabase.cpp b/source/WorldServer/WorldDatabase.cpp index 8b0280e..f119256 100644 --- a/source/WorldServer/WorldDatabase.cpp +++ b/source/WorldServer/WorldDatabase.cpp @@ -460,7 +460,7 @@ void WorldDatabase::LoadVisualStates() if ((range = visual_states.FindEmoteRange(string(row2[0]))) == NULL) { range = new EmoteVersionRange(row2[0]); - visual_states.InsertEmoteRange(range); + visual_states.InsertEmoteRange(range, atoul(row2[1])); } range->AddVersionRange(atoul(row2[4]),atoul(row2[5]), row2[0], atoul(row2[1]), row2[2], row2[3]);