From 6316f1e5909543d164215c990362967c9e36d1c0 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 12 Jul 2018 20:48:47 +0300 Subject: [PATCH] [Client] Add ActorList methods for sending ActorAI packets Additionally, use consistent capitalization for AI-related methods. --- apps/openmw/mwmp/ActorList.cpp | 15 +++++++++++++++ apps/openmw/mwmp/ActorList.hpp | 3 +++ apps/openmw/mwmp/Cell.cpp | 4 ++-- apps/openmw/mwmp/Cell.hpp | 2 +- apps/openmw/mwmp/CellController.cpp | 4 ++-- apps/openmw/mwmp/CellController.hpp | 2 +- apps/openmw/mwmp/DedicatedActor.cpp | 2 +- apps/openmw/mwmp/DedicatedActor.hpp | 2 +- .../mwmp/processors/actor/ProcessorActorAI.hpp | 2 +- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmp/ActorList.cpp b/apps/openmw/mwmp/ActorList.cpp index 62b1c8d47..b20d49f15 100644 --- a/apps/openmw/mwmp/ActorList.cpp +++ b/apps/openmw/mwmp/ActorList.cpp @@ -79,6 +79,11 @@ void ActorList::addEquipmentActor(BaseActor baseActor) equipmentActors.push_back(baseActor); } +void ActorList::addAiActor(BaseActor baseActor) +{ + aiActors.push_back(baseActor); +} + void ActorList::addAttackActor(BaseActor baseActor) { attackActors.push_back(baseActor); @@ -159,6 +164,16 @@ void ActorList::sendEquipmentActors() } } +void ActorList::sendAiActors() +{ + if (aiActors.size() > 0) + { + baseActors = aiActors; + Main::get().getNetworking()->getActorPacket(ID_ACTOR_AI)->setActorList(this); + Main::get().getNetworking()->getActorPacket(ID_ACTOR_AI)->Send(); + } +} + void ActorList::sendAttackActors() { if (attackActors.size() > 0) diff --git a/apps/openmw/mwmp/ActorList.hpp b/apps/openmw/mwmp/ActorList.hpp index ab8288286..ed1b3bf96 100644 --- a/apps/openmw/mwmp/ActorList.hpp +++ b/apps/openmw/mwmp/ActorList.hpp @@ -27,6 +27,7 @@ namespace mwmp void addStatsDynamicActor(BaseActor baseActor); void addDeathActor(BaseActor baseActor); void addEquipmentActor(BaseActor baseActor); + void addAiActor(BaseActor baseActor); void addAttackActor(BaseActor baseActor); void addCellChangeActor(BaseActor baseActor); @@ -37,6 +38,7 @@ namespace mwmp void sendStatsDynamicActors(); void sendDeathActors(); void sendEquipmentActors(); + void sendAiActors(); void sendAttackActors(); void sendCellChangeActors(); @@ -52,6 +54,7 @@ namespace mwmp std::vector statsDynamicActors; std::vector deathActors; std::vector equipmentActors; + std::vector aiActors; std::vector attackActors; std::vector cellChangeActors; }; diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index 0c18aa616..c4c16afe9 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -245,7 +245,7 @@ void Cell::readSpeech(ActorList& actorList) } } -void Cell::readAI(ActorList& actorList) +void Cell::readAi(ActorList& actorList) { initializeDedicatedActors(actorList); @@ -263,7 +263,7 @@ void Cell::readAI(ActorList& actorList) actor->aiCoordinates = baseActor.aiCoordinates; actor->hasAiTarget = baseActor.hasAiTarget; actor->aiTarget = baseActor.aiTarget; - actor->setAI(); + actor->setAi(); } } } diff --git a/apps/openmw/mwmp/Cell.hpp b/apps/openmw/mwmp/Cell.hpp index f54589747..ab81c9030 100644 --- a/apps/openmw/mwmp/Cell.hpp +++ b/apps/openmw/mwmp/Cell.hpp @@ -24,7 +24,7 @@ namespace mwmp void readStatsDynamic(ActorList& actorList); void readEquipment(ActorList& actorList); void readSpeech(ActorList& actorList); - void readAI(ActorList& actorList); + void readAi(ActorList& actorList); void readAttack(ActorList& actorList); void readCellChange(ActorList& actorList); diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index f66f77d3e..f861752a9 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -154,7 +154,7 @@ void CellController::readSpeech(ActorList& actorList) cellsInitialized[mapIndex]->readSpeech(actorList); } -void CellController::readAI(ActorList& actorList) +void CellController::readAi(ActorList& actorList) { std::string mapIndex = actorList.cell.getDescription(); @@ -162,7 +162,7 @@ void CellController::readAI(ActorList& actorList) // If this now exists, send it the data if (cellsInitialized.count(mapIndex) > 0) - cellsInitialized[mapIndex]->readAI(actorList); + cellsInitialized[mapIndex]->readAi(actorList); } void CellController::readAttack(ActorList& actorList) diff --git a/apps/openmw/mwmp/CellController.hpp b/apps/openmw/mwmp/CellController.hpp index 2e21eb306..b6af44a0e 100644 --- a/apps/openmw/mwmp/CellController.hpp +++ b/apps/openmw/mwmp/CellController.hpp @@ -27,7 +27,7 @@ namespace mwmp void readStatsDynamic(mwmp::ActorList& actorList); void readEquipment(mwmp::ActorList& actorList); void readSpeech(mwmp::ActorList& actorList); - void readAI(mwmp::ActorList& actorList); + void readAi(mwmp::ActorList& actorList); void readAttack(mwmp::ActorList& actorList); void readCellChange(mwmp::ActorList& actorList); diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index d2065630d..641e446e9 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -211,7 +211,7 @@ void DedicatedActor::setEquipment() } } -void DedicatedActor::setAI() +void DedicatedActor::setAi() { MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0); diff --git a/apps/openmw/mwmp/DedicatedActor.hpp b/apps/openmw/mwmp/DedicatedActor.hpp index 3b952f3c4..438d79d34 100644 --- a/apps/openmw/mwmp/DedicatedActor.hpp +++ b/apps/openmw/mwmp/DedicatedActor.hpp @@ -22,7 +22,7 @@ namespace mwmp void setAnimFlags(); void setStatsDynamic(); void setEquipment(); - void setAI(); + void setAi(); void playAnimation(); void playSound(); diff --git a/apps/openmw/mwmp/processors/actor/ProcessorActorAI.hpp b/apps/openmw/mwmp/processors/actor/ProcessorActorAI.hpp index d065131f9..414e22312 100644 --- a/apps/openmw/mwmp/processors/actor/ProcessorActorAI.hpp +++ b/apps/openmw/mwmp/processors/actor/ProcessorActorAI.hpp @@ -19,7 +19,7 @@ namespace mwmp { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str()); - Main::get().getCellController()->readAI(actorList); + Main::get().getCellController()->readAi(actorList); } }; }