1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-25 00:23:50 +00:00
openmw-tes3mp/apps/openmw/mwmp/processors/player/ProcessorPlayerQuickKeys.hpp
David Cernat 3bd8aa82fe [General] Reduce inventory-sending hooks to just 2 in ContainerStore
Whenever an item is added to or removed from the player's ContainerStore, that player sends a PlayerInventory packet with just that addition or removal.

This eliminates all the unnecessary packet spam related to oversized PlayerInventory packets that had existed in one form or another since the initial implementation of inventory sync in 1b259e2d33

Additionally, move booleans from BasePlayer to LocalPlayer when they are only needed on the client, and make the usage of the isReceivingQuickKeys boolean consistent with the new isReceivingInventory boolean by having them both in the processors of their associated packets.
2018-08-28 05:01:52 +03:00

39 lines
1.1 KiB
C++

#ifndef OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
#define OPENMW_PROCESSORPLAYERQUICKKEYS_HPP
#include "../PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerQuickKeys : public PlayerProcessor
{
public:
ProcessorPlayerQuickKeys()
{
BPP_INIT(ID_PLAYER_QUICKKEYS)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (!isLocal()) return;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_QUICKKEYS about LocalPlayer from server");
if (!isRequest())
{
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
// Because we send PlayerQuickKeys packets from the same OpenMW methods that we use to set the
// quick keys received, we need to set a boolean to prevent resending the keys set here
localPlayer.isReceivingQuickKeys = true;
localPlayer.setQuickKeys();
localPlayer.isReceivingQuickKeys = false;
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERQUICKKEYS_HPP