mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-26 13:13:50 +00:00
refactor(game): extract EntityController from GameHandler (step 1.3)
Moves entity lifecycle, name/creature/game-object caches, transport GUID tracking, and the entire update-object pipeline out of GameHandler into a new EntityController class (friend-class pattern, same as CombatHandler et al.). What moved: - applyUpdateObjectBlock() — 1,520-line core of all entity creation, field updates, and movement application - processOutOfRangeObjects() / finalizeUpdateObjectBatch() - handleUpdateObject() / handleCompressedUpdateObject() / handleDestroyObject() - handleNameQueryResponse() / handleCreatureQueryResponse() - handleGameObjectQueryResponse() / handleGameObjectPageText() - handlePageTextQueryResponse() - enqueueUpdateObjectWork() / processPendingUpdateObjectWork() - playerNameCache, playerClassRaceCache_, pendingNameQueries - creatureInfoCache, pendingCreatureQueries - gameObjectInfoCache_, pendingGameObjectQueries_ - transportGuids_, serverUpdatedTransportGuids_ - EntityManager (accessed by other handlers via getEntityManager()) 8 opcodes re-registered by EntityController::registerOpcodes(): SMSG_UPDATE_OBJECT, SMSG_COMPRESSED_UPDATE_OBJECT, SMSG_DESTROY_OBJECT, SMSG_NAME_QUERY_RESPONSE, SMSG_CREATURE_QUERY_RESPONSE, SMSG_GAMEOBJECT_QUERY_RESPONSE, SMSG_GAMEOBJECT_PAGETEXT, SMSG_PAGE_TEXT_QUERY_RESPONSE Other handler files (combat, movement, social, spell, inventory, quest, chat) updated to access EntityManager via getEntityManager() and the name cache via getPlayerNameCache() — no logic changes. Also included: - .clang-tidy: add modernize-use-nodiscard, modernize-use-designated-initializers; set -std=c++20 in ExtraArgs - test.sh: prepend clang's own resource include dir before GCC's to silence xmmintrin.h / ia32intrin.h conflicts during clang-tidy runs Line counts: entity_controller.hpp 147 lines (new) entity_controller.cpp 2172 lines (new) game_handler.cpp 8095 lines (was 10143, −2048) Build: 0 errors, 0 warnings.
This commit is contained in:
parent
4f2a4e5520
commit
f5757aca83
15 changed files with 2497 additions and 2260 deletions
|
|
@ -504,7 +504,7 @@ void QuestHandler::registerOpcodes(DispatchTable& table) {
|
|||
}
|
||||
// Re-query all nearby quest giver NPCs so markers refresh
|
||||
if (owner_.socket) {
|
||||
for (const auto& [guid, entity] : owner_.entityManager.getEntities()) {
|
||||
for (const auto& [guid, entity] : owner_.getEntityManager().getEntities()) {
|
||||
if (entity->getType() != ObjectType::UNIT) continue;
|
||||
auto unit = std::static_pointer_cast<Unit>(entity);
|
||||
if (unit->getNpcFlags() & 0x02) {
|
||||
|
|
@ -1557,7 +1557,7 @@ void QuestHandler::handleGossipMessage(network::Packet& packet) {
|
|||
|
||||
// Play NPC greeting voice
|
||||
if (owner_.npcGreetingCallback_ && currentGossip_.npcGuid != 0) {
|
||||
auto entity = owner_.entityManager.getEntity(currentGossip_.npcGuid);
|
||||
auto entity = owner_.getEntityManager().getEntity(currentGossip_.npcGuid);
|
||||
if (entity) {
|
||||
glm::vec3 npcPos(entity->getX(), entity->getY(), entity->getZ());
|
||||
owner_.npcGreetingCallback_(currentGossip_.npcGuid, npcPos);
|
||||
|
|
@ -1654,7 +1654,7 @@ void QuestHandler::handleGossipComplete(network::Packet& packet) {
|
|||
|
||||
// Play farewell sound before closing
|
||||
if (owner_.npcFarewellCallback_ && currentGossip_.npcGuid != 0) {
|
||||
auto entity = owner_.entityManager.getEntity(currentGossip_.npcGuid);
|
||||
auto entity = owner_.getEntityManager().getEntity(currentGossip_.npcGuid);
|
||||
if (entity && entity->getType() == ObjectType::UNIT) {
|
||||
glm::vec3 pos(entity->getX(), entity->getY(), entity->getZ());
|
||||
owner_.npcFarewellCallback_(currentGossip_.npcGuid, pos);
|
||||
|
|
@ -1865,13 +1865,13 @@ void QuestHandler::handleQuestConfirmAccept(network::Packet& packet) {
|
|||
}
|
||||
|
||||
sharedQuestSharerName_.clear();
|
||||
auto entity = owner_.entityManager.getEntity(sharedQuestSharerGuid_);
|
||||
auto entity = owner_.getEntityManager().getEntity(sharedQuestSharerGuid_);
|
||||
if (auto* unit = dynamic_cast<Unit*>(entity.get())) {
|
||||
sharedQuestSharerName_ = unit->getName();
|
||||
}
|
||||
if (sharedQuestSharerName_.empty()) {
|
||||
auto nit = owner_.playerNameCache.find(sharedQuestSharerGuid_);
|
||||
if (nit != owner_.playerNameCache.end())
|
||||
auto nit = owner_.getPlayerNameCache().find(sharedQuestSharerGuid_);
|
||||
if (nit != owner_.getPlayerNameCache().end())
|
||||
sharedQuestSharerName_ = nit->second;
|
||||
}
|
||||
if (sharedQuestSharerName_.empty()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue