From ecc456fea9bd6e0b3120b6c9e518c82f1c53eb5a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 5 Feb 2017 13:45:12 +0200 Subject: [PATCH] [General] Include charge int in WorldObject & send it w/ ID_OBJECT_PLACE --- apps/openmw-mp/Script/Functions/World.cpp | 11 +++++++++++ apps/openmw-mp/Script/Functions/World.hpp | 4 ++++ apps/openmw/mwgui/hud.cpp | 1 + apps/openmw/mwmp/LocalEvent.cpp | 1 + apps/openmw/mwscript/transformationextensions.cpp | 1 + components/openmw-mp/Base/WorldEvent.hpp | 3 ++- .../openmw-mp/Packets/World/PacketObjectPlace.cpp | 1 + 7 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index 8e4a05a77..aa0126e82 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -33,6 +33,7 @@ void WorldFunctions::AddWorldObject() noexcept WorldObject worldObject; worldObject.refId = tempWorldObject.refId; worldObject.refNumIndex = tempWorldObject.refNumIndex; + worldObject.charge = tempWorldObject.charge; worldObject.count = tempWorldObject.count; worldObject.goldValue = tempWorldObject.goldValue; worldObject.scale = tempWorldObject.scale; @@ -76,6 +77,11 @@ void WorldFunctions::SetObjectRefNumIndex(int refNumIndex) noexcept tempWorldObject.refNumIndex = refNumIndex; } +void WorldFunctions::SetObjectCharge(int charge) noexcept +{ + tempWorldObject.charge = charge; +} + void WorldFunctions::SetObjectCount(int count) noexcept { tempWorldObject.count = count; @@ -130,6 +136,11 @@ int WorldFunctions::GetObjectRefNumIndex(unsigned int i) noexcept return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).refNumIndex; } +int WorldFunctions::GetObjectCharge(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).charge; +} + int WorldFunctions::GetObjectCount(unsigned int i) noexcept { return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).count; diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/World.hpp index d3a4ed106..3876d7f56 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -9,6 +9,7 @@ \ {"SetObjectRefId", WorldFunctions::SetObjectRefId},\ {"SetObjectRefNumIndex", WorldFunctions::SetObjectRefNumIndex},\ + {"SetObjectCharge", WorldFunctions::SetObjectCharge},\ {"SetObjectCount", WorldFunctions::SetObjectCount},\ {"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\ {"SetObjectScale", WorldFunctions::SetObjectScale},\ @@ -21,6 +22,7 @@ \ {"GetObjectRefId", WorldFunctions::GetObjectRefId},\ {"GetObjectRefNumIndex", WorldFunctions::GetObjectRefNumIndex},\ + {"GetObjectCharge", WorldFunctions::GetObjectCharge},\ {"GetObjectCount", WorldFunctions::GetObjectCount},\ {"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\ {"GetObjectScale", WorldFunctions::GetObjectScale},\ @@ -55,6 +57,7 @@ public: static void SetObjectRefId(const char* refId) noexcept; static void SetObjectRefNumIndex(int refNumIndex) noexcept; + static void SetObjectCharge(int charge) noexcept; static void SetObjectCount(int count) noexcept; static void SetObjectGoldValue(int goldValue) noexcept; static void SetObjectScale(double scale) noexcept; @@ -67,6 +70,7 @@ public: static const char *GetObjectRefId(unsigned int i) noexcept; static int GetObjectRefNumIndex(unsigned int i) noexcept; + static int GetObjectCharge(unsigned int i) noexcept; static int GetObjectCount(unsigned int i) noexcept; static int GetObjectGoldValue(unsigned int i) noexcept; static double GetObjectScale(unsigned int i) noexcept; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 38d954e45..89235b894 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -72,6 +72,7 @@ namespace MWGui mwmp::WorldObject worldObject; worldObject.refId = dropped.getCellRef().getRefId(); worldObject.refNumIndex = dropped.getCellRef().getRefNum().mIndex; + worldObject.charge = dropped.getCellRef().getCharge(); // Make sure we send the RefData position instead of the CellRef one, because that's what // we actually see on this client diff --git a/apps/openmw/mwmp/LocalEvent.cpp b/apps/openmw/mwmp/LocalEvent.cpp index b0ee78a6c..7a7138404 100644 --- a/apps/openmw/mwmp/LocalEvent.cpp +++ b/apps/openmw/mwmp/LocalEvent.cpp @@ -59,6 +59,7 @@ void LocalEvent::placeObjects(MWWorld::CellStore* cellStore) MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), worldObject.refId, 1); MWWorld::Ptr newPtr = ref.getPtr(); + newPtr.getCellRef().setCharge(worldObject.charge); if (worldObject.count > 1) newPtr.getRefData().setCount(worldObject.count); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index f315e01ff..f040a8e0a 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -558,6 +558,7 @@ namespace MWScript mwmp::WorldObject worldObject; worldObject.refId = ptr.getCellRef().getRefId(); worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; + worldObject.charge = ptr.getCellRef().getCharge(); worldObject.count = 1; // Make sure we send the RefData position instead of the CellRef one, because that's what diff --git a/components/openmw-mp/Base/WorldEvent.hpp b/components/openmw-mp/Base/WorldEvent.hpp index a7e4b6158..da85e45dd 100644 --- a/components/openmw-mp/Base/WorldEvent.hpp +++ b/components/openmw-mp/Base/WorldEvent.hpp @@ -11,8 +11,9 @@ namespace mwmp { std::string refId; int refNumIndex; - int goldValue; + int charge; int count; + int goldValue; ESM::Position pos; int state; diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp index 44f1ef9fc..2e726f37c 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp @@ -35,6 +35,7 @@ void PacketObjectPlace::Packet(RakNet::BitStream *bs, WorldEvent *event, bool se RW(worldObject.refId, send); RW(worldObject.refNumIndex, send); + RW(worldObject.charge, send); RW(worldObject.count, send); RW(worldObject.goldValue, send); RW(worldObject.pos, send);