diff --git a/apps/openmw-mp/Inventory.cpp b/apps/openmw-mp/Inventory.cpp index f3391d084..78628a106 100644 --- a/apps/openmw-mp/Inventory.cpp +++ b/apps/openmw-mp/Inventory.cpp @@ -97,7 +97,7 @@ int Inventory::getChangesSize() const return netActor->getNetCreature()->inventoryChanges.items.size(); } -void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, int enchantmentCharge) +void Inventory::equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, double enchantmentCharge) { netActor->getNetCreature()->equipmentItems[slot].refId = refId; netActor->getNetCreature()->equipmentItems[slot].count = count; @@ -119,7 +119,7 @@ void Inventory::unequipItem( unsigned short slot) } -void Inventory::addItem(const std::string &refId, unsigned int count, int charge, int enchantmentCharge) +void Inventory::addItem(const std::string &refId, unsigned int count, int charge, double enchantmentCharge) { if (inventoryChanged == mwmp::InventoryChanges::Type::Remove) return; @@ -165,13 +165,13 @@ bool Inventory::hasItemEquipped(const std::string &refId) const return false; } -std::tuple Inventory::getEquipmentItem(unsigned short slot) const +std::tuple Inventory::getEquipmentItem(unsigned short slot) const { const auto &item = netActor->getNetCreature()->equipmentItems[slot]; return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge); } -std::tuple Inventory::getInventoryItem(unsigned int slot) const +std::tuple Inventory::getInventoryItem(unsigned int slot) const { const auto &item = netActor->getNetCreature()->inventoryChanges.items.at(slot); return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge); diff --git a/apps/openmw-mp/Inventory.hpp b/apps/openmw-mp/Inventory.hpp index da3ee3046..f6fb4a404 100644 --- a/apps/openmw-mp/Inventory.hpp +++ b/apps/openmw-mp/Inventory.hpp @@ -25,7 +25,7 @@ public: //inventory int getChangesSize() const; - void addItem(const std::string& refId, unsigned int count, int charge, int enchantmentCharge); + void addItem(const std::string& refId, unsigned int count, int charge, double enchantmentCharge); void removeItem(const std::string& refId, unsigned short count); /** @@ -33,11 +33,11 @@ public: * @param slot * @return refid, count, charge, enchantmentCharge */ - std::tuple getInventoryItem(unsigned int slot) const; + std::tuple getInventoryItem(unsigned int slot) const; // equipment - void equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, int enchantmentCharge); + void equipItem(unsigned short slot, const std::string& refId, unsigned int count, int charge, double enchantmentCharge); void unequipItem(unsigned short slot); bool hasItemEquipped(const std::string& refId) const; @@ -47,7 +47,7 @@ public: * @param slot * @return refid, count, charge, enchantmentCharge */ - std::tuple getEquipmentItem(unsigned short slot) const; + std::tuple getEquipmentItem(unsigned short slot) const; private: diff --git a/apps/openmw-mp/Object.cpp b/apps/openmw-mp/Object.cpp index ff6b1a0b2..36701b521 100644 --- a/apps/openmw-mp/Object.cpp +++ b/apps/openmw-mp/Object.cpp @@ -147,12 +147,12 @@ void Object::setCharge(int charge) } -int Object::getEnchantmentCharge() const +double Object::getEnchantmentCharge() const { return object.enchantmentCharge; } -void Object::setEnchantmentCharge(int enchantmentCharge) +void Object::setEnchantmentCharge(double enchantmentCharge) { changedObjectPlace = true; object.enchantmentCharge = enchantmentCharge; @@ -245,13 +245,13 @@ Container::Container() } -tuple Container::getItem(int i) const +tuple Container::getItem(int i) const { auto &item = object.containerItems.at(i); return make_tuple(item.refId, item.count, item.charge, item.enchantmentCharge); } -void Container::setItem(int i, const string &refId, int count, int charge, int enchantmentCharge) +void Container::setItem(int i, const string &refId, int count, int charge, double enchantmentCharge) { auto &item = object.containerItems.at(i); item.refId = refId; @@ -261,7 +261,7 @@ void Container::setItem(int i, const string &refId, int count, int charge, int e changed = true; } -void Container::addItem(const string &refId, int count, int charge, int enchantmentCharge) +void Container::addItem(const string &refId, int count, int charge, double enchantmentCharge) { mwmp::ContainerItem item; item.refId = refId; diff --git a/apps/openmw-mp/Object.hpp b/apps/openmw-mp/Object.hpp index 6537b6d97..bfcfdcdf9 100644 --- a/apps/openmw-mp/Object.hpp +++ b/apps/openmw-mp/Object.hpp @@ -66,8 +66,8 @@ public: int getCharge() const; void setCharge(int charge); - int getEnchantmentCharge() const; - void setEnchantmentCharge(int enchantmentCharge); + double getEnchantmentCharge() const; + void setEnchantmentCharge(double enchantmentCharge); int getGoldValue() const; void setGoldValue(int gold); @@ -98,10 +98,10 @@ public: public: Container(); - std::tuple getItem(int i) const; - void addItem(const std::string &refId, int count, int charge, int enchantmentCharge); + std::tuple getItem(int i) const; + void addItem(const std::string &refId, int count, int charge, double enchantmentCharge); - void setItem(int i, const std::string &refId, int count, int charge, int enchantmentCharge); + void setItem(int i, const std::string &refId, int count, int charge, double enchantmentCharge); int getActionCount(int i) const; size_t size() const; diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 500115f83..5557e7b0d 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -97,7 +97,7 @@ namespace MWGui Include a messagebox notifying players that player-made potions are not synced yet */ - MWBase::Environment::get().getWindowManager()->messageBox("Player-made potions are not synchronized in multiplayer yet and they will not show up for other players."); + MWBase::Environment::get().getWindowManager()->messageBox("Player-made potions are not synchronized in multiplayer yet and they will not show up for the server or other players."); /* End of tes3mp addition */ diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 221286a0c..4a66bd0e5 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -127,6 +127,7 @@ namespace MWGui containerItem.refId =itemPtr.getCellRef().getRefId(); containerItem.count = itemPtr.getRefData().getCount(); containerItem.charge = itemPtr.getCellRef().getCharge(); + containerItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge(); containerItem.actionCount = count; LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", @@ -176,6 +177,7 @@ namespace MWGui containerItem.count = mDragAndDrop->mDraggedCount; containerItem.charge = itemPtr.getCellRef().getCharge(); + containerItem.enchantmentCharge = itemPtr.getCellRef().getEnchantmentCharge(); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_CONTAINER about\n- Ptr cellRef: %s, %i\n- cell: %s\n- item: %s, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldEvent->cell.getDescription().c_str(), diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index efd24e381..ef13a95b3 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -302,8 +302,8 @@ void Networking::connect(const std::string &ip, unsigned short port, std::vector } case ID_INVALID_PASSWORD: { - errmsg = "Connection failed.\n" - "The client or server is outdated."; + errmsg = "Version mismatch!\nYour client is on version " TES3MP_VERSION "\n" + "Please make sure the server is on the same version."; queue = false; break; } diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index 66b701b0d..a1ee01f17 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -75,6 +75,9 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore) MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr(); for (const auto &containerItem : worldObject.containerItems) { + if (containerItem.refId.find("$dynamic") != string::npos) + continue; + if (action == BaseEvent::Action::Add || action == BaseEvent::Action::Set) { // Create a ManualRef to be able to set item charge @@ -152,6 +155,10 @@ void WorldEvent::placeObjects(MWWorld::CellStore* cellStore) LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i, count: %i, charge: %i, enchantmentCharge: %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum, worldObject.count, worldObject.charge, worldObject.enchantmentCharge); + // Ignore generic dynamic refIds because they could be anything on other clients + if (worldObject.refId.find("$dynamic") != string::npos) + continue; + MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); // Only create this object if it doesn't already exist @@ -187,6 +194,10 @@ void WorldEvent::spawnObjects(MWWorld::CellStore* cellStore) LOG_APPEND(Log::LOG_VERBOSE, "- cellRef: %s, %i, %i", worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.mpNum); + // Ignore generic dynamic refIds because they could be anything on other clients + if (worldObject.refId.find("$dynamic") != string::npos) + continue; + MWWorld::Ptr ptrFound = cellStore->searchExact(0, worldObject.mpNum); // Only create this object if it doesn't already exist @@ -591,6 +602,12 @@ void WorldEvent::playVideo() void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr) { + if (ptr.getCellRef().getRefId().find("$dynamic") != string::npos) + { + MWBase::Environment::get().getWindowManager()->messageBox("You're trying to place a custom item, but those are not synchronized in multiplayer yet."); + return; + } + cell = *ptr.getCell()->getCell(); mwmp::WorldObject worldObject; @@ -616,6 +633,12 @@ void WorldEvent::addObjectPlace(const MWWorld::Ptr& ptr) void WorldEvent::addObjectSpawn(const MWWorld::Ptr& ptr) { + if (ptr.getCellRef().getRefId().find("$dynamic") != string::npos) + { + MWBase::Environment::get().getWindowManager()->messageBox("You're trying to spawn a custom object, but those are not synchronized in multiplayer yet."); + return; + } + cell = *ptr.getCell()->getCell(); mwmp::WorldObject worldObject; @@ -813,6 +836,9 @@ void WorldEvent::addScriptGlobalShort(std::string varName, int shortVal) void WorldEvent::sendObjectPlace() { + if (worldObjects.size() == 0) + return; + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE about %s", cell.getDescription().c_str()); for (const auto &worldObject : worldObjects) @@ -824,6 +850,9 @@ void WorldEvent::sendObjectPlace() void WorldEvent::sendObjectSpawn() { + if (worldObjects.size() == 0) + return; + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_SPAWN about %s", cell.getDescription().c_str()); for (const auto &worldObject : worldObjects) diff --git a/components/openmw-mp/Base/BaseEvent.hpp b/components/openmw-mp/Base/BaseEvent.hpp index 47f90c234..ef44176bb 100644 --- a/components/openmw-mp/Base/BaseEvent.hpp +++ b/components/openmw-mp/Base/BaseEvent.hpp @@ -12,7 +12,7 @@ namespace mwmp std::string refId; int count; int charge; - int enchantmentCharge; + double enchantmentCharge; int actionCount; @@ -29,7 +29,7 @@ namespace mwmp unsigned mpNum; int count; int charge; - int enchantmentCharge; + double enchantmentCharge; int goldValue; ESM::Position position; diff --git a/components/openmw-mp/Base/BaseStructs.hpp b/components/openmw-mp/Base/BaseStructs.hpp index 5a3290c52..cc57c274d 100644 --- a/components/openmw-mp/Base/BaseStructs.hpp +++ b/components/openmw-mp/Base/BaseStructs.hpp @@ -12,7 +12,7 @@ namespace mwmp std::string refId; int count; int charge; - int enchantmentCharge; + double enchantmentCharge; inline bool operator==(const Item& rhs) { diff --git a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp index f3c2b8069..63d7a0b1f 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerEquipment.cpp @@ -31,5 +31,6 @@ void PacketPlayerEquipment::Packet(RakNet::BitStream *bs, bool send) RW(player->equipmentItems[equipmentIndex].refId, send); RW(player->equipmentItems[equipmentIndex].count, send); RW(player->equipmentItems[equipmentIndex].charge, send); + RW(player->equipmentItems[equipmentIndex].enchantmentCharge, send); } }