From bbf9f200532837806582c548b480964a1ce4671b Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 27 Nov 2019 11:21:29 +0200 Subject: [PATCH] [Client] Stop sending WorldKillCount packets or incrementing local kills This means the server scripts are now required to send a WorldKillCount packet as a reply to ActorDeath packets sent by clients. This gives the server full control over which kills are counted, while also solving the previous problem of kills being counted only for actors that had finished their death animations. --- apps/openmw/mwmechanics/actors.cpp | 27 +++------------------------ apps/openmw/mwmp/Worldstate.cpp | 16 ---------------- apps/openmw/mwmp/Worldstate.hpp | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 5e891ef5c..7cb8be156 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1995,34 +1995,13 @@ namespace MWMechanics /* Start of tes3mp change (major) - Only increment death count for an actor if we are its authority, to avoid - situations where we increment it locally after having already received an - ID_WORLD_KILL_COUNT packet about it + Don't increment the kill count and expect the server to send a packet to increment + it for us instead */ - bool isLocalActor = mwmp::Main::get().getCellController()->isLocalActor(actor); - - if (isLocalActor) - ++mDeathCount[Misc::StringUtils::lowerCase(actor.getCellRef().getRefId())]; + //++mDeathCount[Misc::StringUtils::lowerCase(actor.getCellRef().getRefId())]; /* End of tes3mp change (major) */ - - /* - Start of tes3mp addition - - Send an ID_WORLD_KILL_COUNT packet every time the kill count changes, - as long as we are the authority over the actor's cell - */ - if (isLocalActor) - { - std::string refId = Misc::StringUtils::lowerCase(actor.getCellRef().getRefId()); - int number = mDeathCount[refId]; - - mwmp::Main::get().getNetworking()->getWorldstate()->sendKill(refId, number); - } - /* - End of tes3mp addition - */ } void Actors::resurrect(const MWWorld::Ptr &ptr) diff --git a/apps/openmw/mwmp/Worldstate.cpp b/apps/openmw/mwmp/Worldstate.cpp index 8e0d413cb..2483b1676 100644 --- a/apps/openmw/mwmp/Worldstate.cpp +++ b/apps/openmw/mwmp/Worldstate.cpp @@ -380,22 +380,6 @@ void Worldstate::setWeather() weather.queuedWeather, weather.transitionFactor, forceWeather); } -void Worldstate::sendKill(const std::string& refId, int number) -{ - killChanges.clear(); - - mwmp::Kill killChange; - killChange.refId = refId; - killChange.number = number; - - LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_WORLD_KILL_COUNT with refId %s, number %i", refId.c_str(), number); - - killChanges.push_back(killChange); - - getNetworking()->getWorldstatePacket(ID_WORLD_KILL_COUNT)->setWorldstate(this); - getNetworking()->getWorldstatePacket(ID_WORLD_KILL_COUNT)->Send(); -} - void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector& imageData) { mapTiles.clear(); diff --git a/apps/openmw/mwmp/Worldstate.hpp b/apps/openmw/mwmp/Worldstate.hpp index b608943fe..1f7064a0c 100644 --- a/apps/openmw/mwmp/Worldstate.hpp +++ b/apps/openmw/mwmp/Worldstate.hpp @@ -22,7 +22,6 @@ namespace mwmp void setMapExplored(); void setWeather(); - void sendKill(const std::string& refId, int number); void sendMapExplored(int cellX, int cellY, const std::vector& imageData); void sendWeather(std::string region, int currentWeather, int nextWeather, int queuedWeather, float transitionFactor);