From 53081a6a6f6f4ec7c0a0c741fabc7428bd4acaf0 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 18 Apr 2017 12:38:26 +0300 Subject: [PATCH] [Client] Clean up more checks by using PlayerList::isDedicatedPlayer() --- apps/openmw/mwmechanics/actors.cpp | 15 +++++++--- apps/openmw/mwmechanics/character.cpp | 16 +++++++---- .../mwmechanics/mechanicsmanagerimp.cpp | 22 +++++++++++++-- apps/openmw/mwworld/inventorystore.cpp | 28 +++++++++++++++---- 4 files changed, 63 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 8019aad9b..2d2f664e2 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -869,11 +869,18 @@ namespace MWMechanics * Automatically equip NPCs torches at night and unequip them at day */ - // tes3mp needs player-controlled NPCs to not automatically unequip - // their light-emitting items, so a 2nd condition has been added - // that should return false only for them - if (!isPlayer && ptr.getBase()->canChangeCell) + /* + Start of tes3mp change (major) + + We need player-controlled NPCs to not automatically unequip + their light-emitting items, so a 2nd condition has been added + for them + */ + if (!isPlayer && !mwmp::PlayerList::isDedicatedPlayer(ptr)) { + /* + End of tes3mp change (major) + */ MWWorld::ContainerStoreIterator torch = inventoryStore.end(); for (MWWorld::ContainerStoreIterator it = inventoryStore.begin(); it != inventoryStore.end(); ++it) { diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index cc7daf622..da358ad75 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -37,6 +37,7 @@ #include "../mwmp/CellController.hpp" #include "../mwmp/LocalPlayer.hpp" #include "../mwmp/LocalActor.hpp" +#include "../mwmp/DedicatedPlayer.hpp" /* End of tes3mp addition */ @@ -1345,11 +1346,16 @@ bool CharacterController::updateWeaponState() mAttackType = "shoot"; else { - // tes3mp needs player-controlled NPCs to not have their attacks - // cancelled here, so a 2nd condition has been added that should - // return true only for them - - if(mPtr == getPlayer() || !mPtr.getBase()->canChangeCell) + /* + Start of tes3mp change (major) + + We need player-controlled NPCs to not have their attacks + cancelled here, so a 2nd condition has been added for them + */ + if(mPtr == getPlayer() || mwmp::PlayerList::isDedicatedPlayer(mPtr)) + /* + End of tes3mp change (major) + */ { if (isWeapon) { diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 27a34fb88..3cbce9f93 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -9,6 +9,16 @@ #include +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ +#include "../mwmp/DedicatedPlayer.hpp" +/* + End of tes3mp addition +*/ + #include "../mwworld/esmstore.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/class.hpp" @@ -1026,10 +1036,16 @@ namespace MWMechanics if (playerFollowers.find(*it) != playerFollowers.end()) continue; - // tes3mp needs player-controlled NPCs to not report crimes committed by other players, - // so a condition has been added that should be true only for them - if (!it->getBase()->canChangeCell) + /* + Start of tes3mp addition + + We need player-controlled NPCs to not report crimes committed by other players + */ + if (mwmp::PlayerList::isDedicatedPlayer(*it)) continue; + /* + End of tes3mp addition + */ if (type == OT_Theft || type == OT_Pickpocket) MWBase::Environment::get().getDialogueManager()->say(*it, "thief"); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index f60d630e5..b0e9232a9 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -8,6 +8,16 @@ #include #include +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ +#include "../mwmp/DedicatedPlayer.hpp" +/* + End of tes3mp addition +*/ + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -212,6 +222,18 @@ bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const if (!Settings::Manager::getBool("prevent merchant equipping", "Game")) return true; + /* + Start of tes3mp addition + + We need player-controlled NPCs to wear whatever their players are + actually wearing, so don't autoequip for them + */ + if (mwmp::PlayerList::isDedicatedPlayer(actor)) + return false; + /* + End of tes3mp addition + */ + // Only autoEquip if we are the original owner of the item. // This stops merchants from auto equipping anything you sell to them. // ...unless this is a companion, he should always equip items given to him. @@ -224,12 +246,6 @@ bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const return false; } - // tes3mp needs player-controlled NPCs to wear whatever their players are - // actually wearing, so a condition has been added that should return - // false only for them - else if (!actor.getBase()->canChangeCell) - return false; - return true; }