From 7264f13b8ea8075e69358cfa1c36255642b15f59 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 25 Oct 2016 00:52:42 +0300 Subject: [PATCH] Implement ID_WORLD_OBJECT_SCALE and send it from ingame scripts --- apps/openmw/mwmp/Networking.cpp | 21 +++++++++++++++++++ .../mwscript/transformationextensions.cpp | 9 ++++++++ components/openmw-mp/Base/WorldEvent.hpp | 2 ++ .../Packets/World/PacketObjectScale.cpp | 10 +++++++++ 4 files changed, 42 insertions(+) diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 031e5eae7..6260b251e 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -767,6 +767,27 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) break; } + case ID_WORLD_OBJECT_SCALE: + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_OBJECT_SCALE"); + LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s", + event->cellRef.mRefID.c_str(), + event->cellRef.mRefNum.mIndex, + event->cell.getDescription().c_str()); + + MWWorld::Ptr ptrFound = ptrCellStore->searchByRefNum(event->cellRef.mRefNum); + + if (ptrFound) + { + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Found %s, %i", + ptrFound.getCellRef().getRefId().c_str(), + ptrFound.getCellRef().getRefNum()); + + MWBase::Environment::get().getWorld()->scaleObject(ptrFound, event->scale); + } + + break; + } case ID_WORLD_VIDEO_PLAY: { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Received ID_WORLD_VIDEO_PLAY"); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index e2f612748..d70203c82 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -44,6 +44,15 @@ namespace MWScript Interpreter::Type_Float scale = runtime[0].mFloat; runtime.pop(); + // Added by tes3mp + mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + event->cell = *ptr.getCell()->getCell(); + event->cellRef.mRefID = ptr.getCellRef().getRefId(); + event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->cellRef.mPos = ptr.getCellRef().getPosition(); + event->scale = scale; + mwmp::Main::get().getNetworking()->GetWorldPacket(ID_WORLD_OBJECT_SCALE)->Send(event); + MWBase::Environment::get().getWorld()->scaleObject(ptr,scale); } }; diff --git a/components/openmw-mp/Base/WorldEvent.hpp b/components/openmw-mp/Base/WorldEvent.hpp index 118ab5365..5baa6d786 100644 --- a/components/openmw-mp/Base/WorldEvent.hpp +++ b/components/openmw-mp/Base/WorldEvent.hpp @@ -25,7 +25,9 @@ namespace mwmp ESM::Cell cell; ESM::CellRef cellRef; + int lockLevel; + float scale; std::string video; bool allowSkipping; diff --git a/components/openmw-mp/Packets/World/PacketObjectScale.cpp b/components/openmw-mp/Packets/World/PacketObjectScale.cpp index 01b7a996d..ba70d3256 100644 --- a/components/openmw-mp/Packets/World/PacketObjectScale.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectScale.cpp @@ -11,4 +11,14 @@ PacketObjectScale::PacketObjectScale(RakNet::RakPeerInterface *peer) : WorldPack void PacketObjectScale::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send) { WorldPacket::Packet(bs, event, send); + + RW(event->cellRef.mRefID, send); + RW(event->cellRef.mRefNum.mIndex, send); + + RW(event->cell.mData.mFlags, send); + RW(event->cell.mData.mX, send); + RW(event->cell.mData.mY, send); + RW(event->cell.mName, send); + + RW(event->scale, send); }