diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 8fb5c13ab..ccb0b74d7 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -366,7 +366,7 @@ void LocalPlayer::updateInventory(bool forceUpdate) MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player); - for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) + for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++) { MWWorld::ContainerStoreIterator it = invStore.getSlot(slot); if (it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), EquipedItem(slot)->refid)) @@ -659,6 +659,26 @@ void LocalPlayer::setClass() } } +void LocalPlayer::setInventory() +{ + MWWorld::Ptr ptrPlayer = GetPlayerPtr(); + + MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer); + ptrInventory.clear(); + + for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++) + { + mwmp::Item *currentItem = EquipedItem(slot); + + //printf("Setting currentItem: %s in slot %i\n", currentItem->refid, slot); + + if (!currentItem->refid.empty()) + { + ptrInventory.equip(slot, ptrInventory.ContainerStore::add(EquipedItem(slot)->refid.c_str(), 1, ptrPlayer), ptrPlayer); + } + } +} + void LocalPlayer::sendClass() { MWBase::World *world = MWBase::Environment::get().getWorld(); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 6ca222f80..30eeb37c3 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -42,6 +42,7 @@ namespace mwmp void setPosition(); void setCell(); void setClass(); + void setInventory(); void sendClass(); void sendAttack(char type); diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index d727079d5..a69c39e2a 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -259,8 +259,15 @@ void Networking::ReceiveMessage(RakNet::Packet *packet) { if (id == myid) { - getLocalPlayer()->updateInventory(true); - myPacket->Send(getLocalPlayer(), serverAddr); + if (packet->length == myPacket->headerSize()) + { + getLocalPlayer()->updateInventory(true); + } + else + { + myPacket->Packet(&bsIn, getLocalPlayer(), false); + getLocalPlayer()->setInventory(); + } } else if (pl != 0) {