1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-07-02 23:51:35 +00:00

[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.
This commit is contained in:
David Cernat 2019-11-27 11:21:29 +02:00
parent b352983348
commit bbf9f20053
3 changed files with 3 additions and 41 deletions

View file

@ -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)

View file

@ -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<char>& imageData)
{
mapTiles.clear();

View file

@ -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<char>& imageData);
void sendWeather(std::string region, int currentWeather, int nextWeather, int queuedWeather, float transitionFactor);