diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index c691de081..833780504 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -106,13 +106,14 @@ set(PROCESSORS_PLAYER processors/player/ProcessorPlayerDeath.hpp processors/player/ProcessorPlayerDisposition.hpp processors/player/ProcessorPlayerEquipment.hpp processors/player/ProcessorPlayerFaction.hpp processors/player/ProcessorPlayerInput.hpp processors/player/ProcessorPlayerInventory.hpp - processors/player/ProcessorPlayerJournal.hpp processors/player/ProcessorWorldKillCount.hpp - processors/player/ProcessorPlayerLevel.hpp processors/player/ProcessorPlayerMiscellaneous.hpp - processors/player/ProcessorPlayerPosition.hpp processors/player/ProcessorPlayerQuickKeys.hpp - processors/player/ProcessorPlayerRest.hpp processors/player/ProcessorPlayerResurrect.hpp - processors/player/ProcessorPlayerShapeshift.hpp processors/player/ProcessorPlayerSkill.hpp - processors/player/ProcessorPlayerSpeech.hpp processors/player/ProcessorPlayerSpellbook.hpp - processors/player/ProcessorPlayerStatsDynamic.hpp processors/player/ProcessorPlayerTopic.hpp + processors/player/ProcessorPlayerItemUse.hpp processors/player/ProcessorPlayerJournal.hpp + processors/player/ProcessorWorldKillCount.hpp processors/player/ProcessorPlayerLevel.hpp + processors/player/ProcessorPlayerMiscellaneous.hpp processors/player/ProcessorPlayerPosition.hpp + processors/player/ProcessorPlayerQuickKeys.hpp processors/player/ProcessorPlayerRest.hpp + processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerShapeshift.hpp + processors/player/ProcessorPlayerSkill.hpp processors/player/ProcessorPlayerSpeech.hpp + processors/player/ProcessorPlayerSpellbook.hpp processors/player/ProcessorPlayerStatsDynamic.hpp + processors/player/ProcessorPlayerTopic.hpp ) source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER}) diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index 0fa9fee00..93f998b5f 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -173,6 +173,46 @@ const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int return player->inventoryChanges.items.at(index).soul.c_str(); } +const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ""); + + return player->usedItem.refId.c_str(); +} + +int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->usedItem.count; +} + +int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->usedItem.charge; +} + +double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->usedItem.enchantmentCharge; +} + +const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ""); + + return player->usedItem.soul.c_str(); +} + void ItemFunctions::SendEquipment(unsigned short pid) noexcept { Player *player; @@ -200,3 +240,14 @@ void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPla if (sendToOtherPlayers) packet->Send(true); } + +void ItemFunctions::SendItemUse(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ITEM_USE); + packet->setPlayer(player); + + packet->Send(false); +} diff --git a/apps/openmw-mp/Script/Functions/Items.hpp b/apps/openmw-mp/Script/Functions/Items.hpp index 6a819ec0d..4735a4675 100644 --- a/apps/openmw-mp/Script/Functions/Items.hpp +++ b/apps/openmw-mp/Script/Functions/Items.hpp @@ -26,8 +26,15 @@ {"GetInventoryItemEnchantmentCharge", ItemFunctions::GetInventoryItemEnchantmentCharge},\ {"GetInventoryItemSoul", ItemFunctions::GetInventoryItemSoul},\ \ + {"GetUsedItemRefId", ItemFunctions::GetUsedItemRefId},\ + {"GetUsedItemCount", ItemFunctions::GetUsedItemCount},\ + {"GetUsedItemCharge", ItemFunctions::GetUsedItemCharge},\ + {"GetUsedItemEnchantmentCharge", ItemFunctions::GetUsedItemEnchantmentCharge},\ + {"GetUsedItemSoul", ItemFunctions::GetUsedItemSoul},\ + \ {"SendEquipment", ItemFunctions::SendEquipment},\ - {"SendInventoryChanges", ItemFunctions::SendInventoryChanges} + {"SendInventoryChanges", ItemFunctions::SendInventoryChanges},\ + {"SendItemUse", ItemFunctions::SendItemUse} class ItemFunctions { @@ -206,6 +213,46 @@ public: */ static const char *GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept; + /** + * \brief Get the refId of the item last used by a player. + * + * \param pid The player ID. + * \return The refId. + */ + static const char *GetUsedItemRefId(unsigned short pid) noexcept; + + /** + * \brief Get the count of the item last used by a player. + * + * \param pid The player ID. + * \return The item count. + */ + static int GetUsedItemCount(unsigned short pid) noexcept; + + /** + * \brief Get the charge of the item last used by a player. + * + * \param pid The player ID. + * \return The charge. + */ + static int GetUsedItemCharge(unsigned short pid) noexcept; + + /** + * \brief Get the enchantment charge of the item last used by a player. + * + * \param pid The player ID. + * \return The enchantment charge. + */ + static double GetUsedItemEnchantmentCharge(unsigned short pid) noexcept; + + /** + * \brief Get the soul of the item last used by a player. + * + * \param pid The player ID. + * \return The soul. + */ + static const char *GetUsedItemSoul(unsigned short pid) noexcept; + /** * \brief Send a PlayerEquipment packet with a player's equipment. * @@ -227,6 +274,15 @@ public: * \return void */ static void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + + /** + * \brief Send a PlayerItemUse causing a player to use their recorded usedItem. + * + * \param pid The player ID affected. + * \return void + */ + static void SendItemUse(unsigned short pid) noexcept; + private: }; diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index e5d8e799c..298ff647e 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -174,6 +174,7 @@ public: {"OnPlayerTopic", Function()}, {"OnPlayerDisposition", Function()}, {"OnPlayerBook", Function()}, + {"OnPlayerItemUse", Function()}, {"OnPlayerMiscellaneous", Function()}, {"OnPlayerInput", Function()}, {"OnPlayerRest", Function()}, diff --git a/apps/openmw-mp/processors/ProcessorInitializer.cpp b/apps/openmw-mp/processors/ProcessorInitializer.cpp index ffb9490a8..15562b054 100644 --- a/apps/openmw-mp/processors/ProcessorInitializer.cpp +++ b/apps/openmw-mp/processors/ProcessorInitializer.cpp @@ -21,6 +21,7 @@ #include "player/ProcessorPlayerEquipment.hpp" #include "player/ProcessorPlayerFaction.hpp" #include "player/ProcessorPlayerInventory.hpp" +#include "player/ProcessorPlayerItemUse.hpp" #include "player/ProcessorPlayerJournal.hpp" #include "player/ProcessorWorldKillCount.hpp" #include "player/ProcessorPlayerInput.hpp" @@ -99,6 +100,7 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorPlayerEquipment()); PlayerProcessor::AddProcessor(new ProcessorPlayerFaction()); PlayerProcessor::AddProcessor(new ProcessorPlayerInventory()); + PlayerProcessor::AddProcessor(new ProcessorPlayerItemUse()); PlayerProcessor::AddProcessor(new ProcessorPlayerJournal()); PlayerProcessor::AddProcessor(new ProcessorWorldKillCount()); PlayerProcessor::AddProcessor(new ProcessorPlayerInput()); diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerItemUse.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerItemUse.hpp new file mode 100644 index 000000000..ec1e607d8 --- /dev/null +++ b/apps/openmw-mp/processors/player/ProcessorPlayerItemUse.hpp @@ -0,0 +1,25 @@ +#ifndef OPENMW_PROCESSORPLAYERITEMUSE_HPP +#define OPENMW_PROCESSORPLAYERITEMUSE_HPP + +#include "../PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerItemUse : public PlayerProcessor + { + public: + ProcessorPlayerItemUse() + { + BPP_INIT(ID_PLAYER_ITEM_USE) + } + + void Do(PlayerPacket &packet, Player &player) override + { + DEBUG_PRINTF(strPacketID.c_str()); + + Script::Call(player.getId()); + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERITEMUSE_HPP diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f6a94e9a1..5efdd917e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -116,8 +116,8 @@ add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageB ProcessorPlayerAttack ProcessorPlayerAttribute ProcessorPlayerBaseInfo ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerInput - ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal ProcessorWorldKillCount ProcessorPlayerLevel - ProcessorPlayerMiscellaneous ProcessorPlayerMomentum ProcessorPlayerPosition ProcessorPlayerQuickKeys + ProcessorPlayerInventory ProcessorPlayerItemUse ProcessorPlayerJail ProcessorPlayerJournal ProcessorWorldKillCount + ProcessorPlayerLevel ProcessorPlayerMiscellaneous ProcessorPlayerMomentum ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerResurrect ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic ) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index f6423cf35..0e56087bc 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -567,7 +567,17 @@ namespace MWGui ptr = mDragAndDrop->mSourceModel->moveItem(mDragAndDrop->mItem, mDragAndDrop->mDraggedCount, mTradeModel); } - useItem(ptr); + /* + Start of tes3mp change (major) + + Instead of unilaterally using an item, send an ID_PLAYER_ITEM_USE packet and let the server + decide if the item actually gets used + */ + //useItem(ptr); + mwmp::Main::get().getLocalPlayer()->sendItemUse(ptr); + /* + End of tes3mp change (major) + */ // If item is ingredient or potion don't stop drag and drop to simplify action of taking more than one 1 item if ((ptr.getTypeName() == typeid(ESM::Potion).name() || @@ -792,7 +802,17 @@ namespace MWGui if (!found || selected == cycled) return; - useItem(model.getItem(cycled).mBase); + /* + Start of tes3mp change (major) + + Instead of unilaterally using an item, send an ID_PLAYER_ITEM_USE packet and let the server + decide if the item actually gets used + */ + //useItem(model.getItem(cycled).mBase); + mwmp::Main::get().getLocalPlayer()->sendItemUse(model.getItem(cycled).mBase); + /* + End of tes3mp change (major) + */ } void InventoryWindow::rebuildAvatar() diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 04acfbb55..46d44cedb 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1618,6 +1618,18 @@ void LocalPlayer::sendSelectedSpell(const std::string& newSelectedSpellId) getNetworking()->getPlayerPacket(ID_PLAYER_MISCELLANEOUS)->Send(); } +void LocalPlayer::sendItemUse(const MWWorld::Ptr& itemPtr) +{ + usedItem.refId = itemPtr.getCellRef().getRefId(); + usedItem.count = itemPtr.getRefData().getCount(); + usedItem.charge = itemPtr.getCellRef().getCharge(); + usedItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge(); + usedItem.soul = itemPtr.getCellRef().getSoul(); + + getNetworking()->getPlayerPacket(ID_PLAYER_ITEM_USE)->setPlayer(this); + getNetworking()->getPlayerPacket(ID_PLAYER_ITEM_USE)->Send(); +} + void LocalPlayer::clearCellStates() { cellStateChanges.cellStates.clear(); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 39937fb6b..a96fa0c4c 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -87,6 +87,7 @@ namespace mwmp void sendWerewolfState(bool isWerewolf); void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition); void sendSelectedSpell(const std::string& newSelectedSpellId); + void sendItemUse(const MWWorld::Ptr& itemPtr); void clearCellStates(); void clearCurrentContainer(); diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index 29efe858d..7e143ecfd 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -360,3 +360,18 @@ void MechanicsHelper::unequipItemsByEffect(const MWWorld::Ptr& ptr, short enchan } } } + +MWWorld::Ptr MechanicsHelper::getItemPtrFromStore(const mwmp::Item& item, MWWorld::ContainerStore& store) +{ + for (MWWorld::ContainerStoreIterator storeIterator = store.begin(); storeIterator != store.end(); ++storeIterator) + { + if (Misc::StringUtils::ciEqual(item.refId, storeIterator->getCellRef().getRefId()) && + item.count == storeIterator->getRefData().getCount() && + item.charge == storeIterator->getCellRef().getCharge() && + item.enchantmentCharge == storeIterator->getCellRef().getEnchantmentCharge() && + Misc::StringUtils::ciEqual(item.soul, storeIterator->getCellRef().getSoul())) + { + return *storeIterator; + } + } +} diff --git a/apps/openmw/mwmp/MechanicsHelper.hpp b/apps/openmw/mwmp/MechanicsHelper.hpp index 86c6024bf..d2e5edf1d 100644 --- a/apps/openmw/mwmp/MechanicsHelper.hpp +++ b/apps/openmw/mwmp/MechanicsHelper.hpp @@ -3,6 +3,8 @@ #include +#include "../mwworld/containerstore.hpp" + #include @@ -30,6 +32,8 @@ namespace MechanicsHelper bool doesEffectListContainEffect(const ESM::EffectList& effectList, short effectId, short attributeId = -1, short skillId = -1); void unequipItemsByEffect(const MWWorld::Ptr& ptr, short enchantmentType, short effectId, short attributeId = -1, short skillId = -1); + + MWWorld::Ptr getItemPtrFromStore(const mwmp::Item& item, MWWorld::ContainerStore& store); } diff --git a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp index 56b2d49b6..30b4acdca 100644 --- a/apps/openmw/mwmp/processors/ProcessorInitializer.cpp +++ b/apps/openmw/mwmp/processors/ProcessorInitializer.cpp @@ -24,6 +24,7 @@ #include "player/ProcessorPlayerFaction.hpp" #include "player/ProcessorPlayerInput.hpp" #include "player/ProcessorPlayerInventory.hpp" +#include "player/ProcessorPlayerItemUse.hpp" #include "player/ProcessorPlayerJail.hpp" #include "player/ProcessorPlayerJournal.hpp" #include "player/ProcessorWorldKillCount.hpp" @@ -123,6 +124,7 @@ void ProcessorInitializer() PlayerProcessor::AddProcessor(new ProcessorPlayerFaction()); PlayerProcessor::AddProcessor(new ProcessorPlayerInput()); PlayerProcessor::AddProcessor(new ProcessorPlayerInventory()); + PlayerProcessor::AddProcessor(new ProcessorPlayerItemUse()); PlayerProcessor::AddProcessor(new ProcessorPlayerJail()); PlayerProcessor::AddProcessor(new ProcessorPlayerJournal()); PlayerProcessor::AddProcessor(new ProcessorWorldKillCount()); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerItemUse.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerItemUse.hpp new file mode 100644 index 000000000..32b3fbc26 --- /dev/null +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerItemUse.hpp @@ -0,0 +1,44 @@ +#ifndef OPENMW_PROCESSORPLAYERITEMUSE_HPP +#define OPENMW_PROCESSORPLAYERITEMUSE_HPP + +#include "apps/openmw/mwbase/environment.hpp" +#include "apps/openmw/mwgui/inventorywindow.hpp" +#include "apps/openmw/mwgui/windowmanagerimp.hpp" +#include "apps/openmw/mwworld/inventorystore.hpp" + +#include "../MechanicsHelper.hpp" +#include "../PlayerProcessor.hpp" + +namespace mwmp +{ + class ProcessorPlayerItemUse : public PlayerProcessor + { + public: + ProcessorPlayerItemUse() + { + BPP_INIT(ID_PLAYER_ITEM_USE) + } + + virtual void Do(PlayerPacket &packet, BasePlayer *player) + { + if (!isLocal()) return; + + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_ITEM_USE about LocalPlayer from server"); + + if (!isRequest()) + { + LOG_APPEND(Log::LOG_INFO, "- refId: %s, count: %i, charge: %f, enchantmentCharge: %f, soul: %s", + player->usedItem.refId.c_str(), player->usedItem.count, player->usedItem.charge, + player->usedItem.enchantmentCharge, player->usedItem.soul.c_str()); + + MWWorld::Ptr &playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + MWWorld::InventoryStore &inventoryStore = playerPtr.getClass().getInventoryStore(playerPtr); + + MWWorld::Ptr &itemPtr = MechanicsHelper::getItemPtrFromStore(player->usedItem, inventoryStore); + MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(itemPtr); + } + } + }; +} + +#endif //OPENMW_PROCESSORPLAYERITEMUSE_HPP diff --git a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp index 5b2b056f6..a4398d4b6 100644 --- a/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp +++ b/apps/openmw/mwmp/processors/worldstate/ProcessorWorldTime.hpp @@ -1,9 +1,9 @@ #ifndef OPENMW_PROCESSORWORLDTIME_HPP #define OPENMW_PROCESSORWORLDTIME_HPP - #include #include + #include "../WorldstateProcessor.hpp" namespace mwmp diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index cf9d43ae1..c022098dd 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -181,10 +181,11 @@ add_component_dir (openmw-mp/Packets/Player PacketPlayerBaseInfo PacketPlayerCharGen PacketPlayerActiveSkills PacketPlayerAnimFlags PacketPlayerAnimPlay PacketPlayerAttack PacketPlayerAttribute PacketPlayerBehavior PacketPlayerBook PacketPlayerBounty PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment - PacketPlayerFaction PacketPlayerInput PacketPlayerInventory PacketPlayerJail PacketPlayerJournal - PacketWorldKillCount PacketPlayerLevel PacketPlayerMiscellaneous PacketPlayerMomentum PacketPlayerPosition - PacketPlayerQuickKeys PacketPlayerReputation PacketPlayerRest PacketPlayerResurrect PacketPlayerShapeshift - PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerTopic + PacketPlayerFaction PacketPlayerInput PacketPlayerInventory PacketPlayerItemUse PacketPlayerJail + PacketPlayerJournal PacketWorldKillCount PacketPlayerLevel PacketPlayerMiscellaneous PacketPlayerMomentum + PacketPlayerPosition PacketPlayerQuickKeys PacketPlayerReputation PacketPlayerRest PacketPlayerResurrect + PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic + PacketPlayerTopic ) add_component_dir (openmw-mp/Packets/Object diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index d08de8034..4392e39c2 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -324,6 +324,8 @@ namespace mwmp ESM::Position markPosition; std::string selectedSpellId; + mwmp::Item usedItem; + bool isReceivingQuickKeys; bool isPlayingAnimation; bool diedSinceArrestAttempt; diff --git a/components/openmw-mp/Controllers/PlayerPacketController.cpp b/components/openmw-mp/Controllers/PlayerPacketController.cpp index 085779ef9..29c70e789 100644 --- a/components/openmw-mp/Controllers/PlayerPacketController.cpp +++ b/components/openmw-mp/Controllers/PlayerPacketController.cpp @@ -22,6 +22,7 @@ #include "../Packets/Player/PacketPlayerFaction.hpp" #include "../Packets/Player/PacketPlayerInput.hpp" #include "../Packets/Player/PacketPlayerInventory.hpp" +#include "../Packets/Player/PacketPlayerItemUse.hpp" #include "../Packets/Player/PacketPlayerJail.hpp" #include "../Packets/Player/PacketPlayerJournal.hpp" #include "../Packets/Player/PacketWorldKillCount.hpp" @@ -77,6 +78,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); + AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); AddPacket(&packets, peer); diff --git a/components/openmw-mp/NetworkMessages.hpp b/components/openmw-mp/NetworkMessages.hpp index 5c0f655bd..b886dd067 100644 --- a/components/openmw-mp/NetworkMessages.hpp +++ b/components/openmw-mp/NetworkMessages.hpp @@ -109,7 +109,9 @@ enum GameMessages ID_WORLD_COLLISION_OVERRIDE, ID_WORLD_MAP, ID_WORLD_TIME, - ID_WORLD_WEATHER + ID_WORLD_WEATHER, + + ID_PLAYER_ITEM_USE }; enum OrderingChannel diff --git a/components/openmw-mp/Packets/Player/PacketPlayerItemUse.cpp b/components/openmw-mp/Packets/Player/PacketPlayerItemUse.cpp new file mode 100644 index 000000000..c0ff9e479 --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketPlayerItemUse.cpp @@ -0,0 +1,21 @@ +#include "PacketPlayerItemUse.hpp" +#include + +using namespace mwmp; + +PacketPlayerItemUse::PacketPlayerItemUse(RakNet::RakPeerInterface *peer) : PlayerPacket(peer) +{ + packetID = ID_PLAYER_ITEM_USE; +} + +void PacketPlayerItemUse::Packet(RakNet::BitStream *bs, bool send) +{ + PlayerPacket::Packet(bs, send); + + + RW(player->usedItem.refId, send, true); + RW(player->usedItem.count, send); + RW(player->usedItem.charge, send); + RW(player->usedItem.enchantmentCharge, send); + RW(player->usedItem.soul, send, true); +} diff --git a/components/openmw-mp/Packets/Player/PacketPlayerItemUse.hpp b/components/openmw-mp/Packets/Player/PacketPlayerItemUse.hpp new file mode 100644 index 000000000..ef726d1ce --- /dev/null +++ b/components/openmw-mp/Packets/Player/PacketPlayerItemUse.hpp @@ -0,0 +1,17 @@ +#ifndef OPENMW_PACKETPLAYERITEMUSE_HPP +#define OPENMW_PACKETPLAYERITEMUSE_HPP + +#include + +namespace mwmp +{ + class PacketPlayerItemUse : public PlayerPacket + { + public: + PacketPlayerItemUse(RakNet::RakPeerInterface *peer); + + virtual void Packet(RakNet::BitStream *bs, bool send); + }; +} + +#endif //OPENMW_PACKETPLAYERITEMUSE_HPP