From 4872edc5edd396bbb4ee0ba29bc14df8c87bb7f7 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 1 May 2018 16:21:58 +0400 Subject: [PATCH 1/6] Prevent PlaySound overlapping --- apps/openmw/mwbase/windowmanager.hpp | 2 +- apps/openmw/mwgui/bookwindow.cpp | 4 ++-- apps/openmw/mwgui/windowmanagerimp.cpp | 8 ++------ apps/openmw/mwgui/windowmanagerimp.hpp | 2 +- apps/openmw/mwsound/soundmanagerimp.cpp | 3 +++ 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 8a9eb2ea6..d454067c8 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -337,7 +337,7 @@ namespace MWBase /// Cycle to next or previous weapon virtual void cycleWeapon(bool next) = 0; - virtual void playSound(const std::string& soundId, bool preventOverlapping = false, float volume = 1.f, float pitch = 1.f) = 0; + virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0; // In WindowManager for now since there isn't a VFS singleton virtual std::string correctIconPath(const std::string& path) = 0; diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index cb902cadf..c18548dad 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -200,7 +200,7 @@ namespace MWGui { if ((mCurrentPage+1)*2 < mPages.size()) { - MWBase::Environment::get().getWindowManager()->playSound("book page2", true); + MWBase::Environment::get().getWindowManager()->playSound("book page2"); ++mCurrentPage; @@ -211,7 +211,7 @@ namespace MWGui { if (mCurrentPage > 0) { - MWBase::Environment::get().getWindowManager()->playSound("book page", true); + MWBase::Environment::get().getWindowManager()->playSound("book page"); --mCurrentPage; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index c103f60ad..b1e18209a 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1919,16 +1919,12 @@ namespace MWGui mInventoryWindow->cycle(next); } - void WindowManager::playSound(const std::string& soundId, bool preventOverlapping, float volume, float pitch) + void WindowManager::playSound(const std::string& soundId, float volume, float pitch) { if (soundId.empty()) return; - MWBase::SoundManager *sndmgr = MWBase::Environment::get().getSoundManager(); - if (preventOverlapping && sndmgr->getSoundPlaying(MWWorld::Ptr(), soundId)) - return; - - sndmgr->playSound(soundId, volume, pitch, MWSound::Type::Sfx, MWSound::PlayMode::NoEnv); + MWBase::Environment::get().getSoundManager()->playSound(soundId, volume, pitch, MWSound::Type::Sfx, MWSound::PlayMode::NoEnv); } void WindowManager::updateSpellWindow() diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 56ccea33b..1d250f6d4 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -366,7 +366,7 @@ namespace MWGui /// Cycle to next or previous weapon virtual void cycleWeapon(bool next); - virtual void playSound(const std::string& soundId, bool preventOverlapping = false, float volume = 1.f, float pitch = 1.f); + virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f); // In WindowManager for now since there isn't a VFS singleton virtual std::string correctIconPath(const std::string& path); diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index db02bb482..ba8ac1bba 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -577,6 +577,9 @@ namespace MWSound Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); if(!sfx) return nullptr; + // Only one copy of given sound can be played at time, so stop previous copy + stopSound(soundId); + Sound *sound = getSoundRef(); sound->init(volume * sfx->mVolume, volumeFromType(type), pitch, mode|type|Play_2D); if(!mOutput->playSound(sound, sfx->mHandle, offset)) From b15bed8e2270c7a4f2d475921bcd10472c1cf0c4 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 7 May 2018 20:40:53 +0400 Subject: [PATCH 2/6] Avoid excessive loadSound calls --- apps/openmw/mwsound/soundmanagerimp.cpp | 40 +++++++++++++------------ apps/openmw/mwsound/soundmanagerimp.hpp | 3 ++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index ba8ac1bba..0dd95f773 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -20,9 +20,9 @@ #include "../mwmechanics/actorutil.hpp" -#include "sound_output.hpp" #include "sound_buffer.hpp" #include "sound_decoder.hpp" +#include "sound_output.hpp" #include "sound.hpp" #include "openal_output.hpp" @@ -578,7 +578,7 @@ namespace MWSound if(!sfx) return nullptr; // Only one copy of given sound can be played at time, so stop previous copy - stopSound(soundId); + stopSound(sfx, MWWorld::ConstPtr()); Sound *sound = getSoundRef(); sound->init(volume * sfx->mVolume, volumeFromType(type), pitch, mode|type|Play_2D); @@ -614,7 +614,7 @@ namespace MWSound return nullptr; // Only one copy of given sound can be played at time on ptr, so stop previous copy - stopSound3D(ptr, soundId); + stopSound(sfx, ptr); bool played; Sound *sound = getSoundRef(); @@ -681,12 +681,11 @@ namespace MWSound mOutput->finishSound(sound); } - void SoundManager::stopSound3D(const MWWorld::ConstPtr &ptr, const std::string& soundId) + void SoundManager::stopSound(Sound_Buffer *sfx, const MWWorld::ConstPtr &ptr) { SoundMap::iterator snditer = mActiveSounds.find(ptr); if(snditer != mActiveSounds.end()) { - Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); for(SoundBufferRefPair &snd : snditer->second) { if(snd.second == sfx) @@ -695,6 +694,22 @@ namespace MWSound } } + void SoundManager::stopSound(const std::string& soundId) + { + Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); + if (!sfx) return; + + stopSound(sfx, MWWorld::ConstPtr()); + } + + void SoundManager::stopSound3D(const MWWorld::ConstPtr &ptr, const std::string& soundId) + { + Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); + if (!sfx) return; + + stopSound(sfx, ptr); + } + void SoundManager::stopSound3D(const MWWorld::ConstPtr &ptr) { SoundMap::iterator snditer = mActiveSounds.find(ptr); @@ -718,6 +733,7 @@ namespace MWSound mOutput->finishSound(sndbuf.first); } } + for(SaySoundMap::value_type &snd : mActiveSaySounds) { if(!snd.first.isEmpty() && snd.first != MWMechanics::getPlayer() && snd.first.getCell() == cell) @@ -725,20 +741,6 @@ namespace MWSound } } - void SoundManager::stopSound(const std::string& soundId) - { - SoundMap::iterator snditer = mActiveSounds.find(MWWorld::ConstPtr()); - if(snditer != mActiveSounds.end()) - { - Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); - for(SoundBufferRefPair &sndbuf : snditer->second) - { - if(sndbuf.second == sfx) - mOutput->finishSound(sndbuf.first); - } - } - } - void SoundManager::fadeOutSound3D(const MWWorld::ConstPtr &ptr, const std::string& soundId, float duration) { diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index e31a0e575..4064a05af 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -145,6 +145,9 @@ namespace MWSound DecoderPtr getDecoder(); friend class OpenAL_Output; + void stopSound(Sound_Buffer *sfx, const MWWorld::ConstPtr &ptr); + ///< Stop the given object from playing given sound buffer. + public: SoundManager(const VFS::Manager* vfs, const std::map& fallbackMap, bool useSound); virtual ~SoundManager(); From 32d71de2f5196ee60b0729cb3b1c024022ece119 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 9 May 2018 07:33:45 +0300 Subject: [PATCH 3/6] Update MapWindow every frame, not just when it's open (bug #4279) --- apps/openmw/mwgui/windowmanagerimp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index c103f60ad..04c8e8a7d 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -913,6 +913,9 @@ namespace MWGui updateMap(); + if (!mMap->isVisible()) + mMap->onFrame(frameDuration); + mHud->onFrame(frameDuration); mDebugWindow->onFrame(frameDuration); From d4f7936a76c4f1ec3ce45d15c3269c08485b0dcc Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 13 May 2018 04:11:05 +0300 Subject: [PATCH 4/6] [Server] Rename WorldFunctions into ObjectFunctions --- apps/openmw-mp/CMakeLists.txt | 2 +- .../Functions/{World.cpp => Objects.cpp} | 146 ++++++++--------- .../Functions/{World.hpp => Objects.hpp} | 154 +++++++++--------- apps/openmw-mp/Script/ScriptFunctions.hpp | 4 +- 4 files changed, 153 insertions(+), 153 deletions(-) rename apps/openmw-mp/Script/Functions/{World.cpp => Objects.cpp} (62%) rename apps/openmw-mp/Script/Functions/{World.hpp => Objects.hpp} (78%) diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 12691c241..7723e79aa 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -82,7 +82,7 @@ set(SERVER Script/Script.cpp Script/ScriptFunction.cpp Script/ScriptFunctions.cpp - Script/Functions/Actors.cpp Script/Functions/World.cpp Script/Functions/Miscellaneous.cpp + Script/Functions/Actors.cpp Script/Functions/Objects.cpp Script/Functions/Miscellaneous.cpp Script/Functions/Books.cpp Script/Functions/Cells.cpp Script/Functions/CharClass.cpp Script/Functions/Chat.cpp Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp similarity index 62% rename from apps/openmw-mp/Script/Functions/World.cpp rename to apps/openmw-mp/Script/Functions/Objects.cpp index 5ea394633..ccc3b95fc 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -6,7 +6,7 @@ #include #include -#include "World.hpp" +#include "Objects.hpp" using namespace mwmp; @@ -19,12 +19,12 @@ const BaseObject emptyObject = {}; ContainerItem tempContainerItem; const ContainerItem emptyContainerItem = {}; -void WorldFunctions::ReadLastObjectList() noexcept +void ObjectFunctions::ReadLastObjectList() noexcept { readObjectList = mwmp::Networking::getPtr()->getLastObjectList(); } -void WorldFunctions::InitializeObjectList(unsigned short pid) noexcept +void ObjectFunctions::InitializeObjectList(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -34,259 +34,259 @@ void WorldFunctions::InitializeObjectList(unsigned short pid) noexcept writeObjectList.guid = player->guid; } -unsigned int WorldFunctions::GetObjectChangesSize() noexcept +unsigned int ObjectFunctions::GetObjectChangesSize() noexcept { return readObjectList->baseObjectCount; } -unsigned char WorldFunctions::GetObjectListAction() noexcept +unsigned char ObjectFunctions::GetObjectListAction() noexcept { return readObjectList->action; } -unsigned char WorldFunctions::GetObjectListContainerSubAction() noexcept +unsigned char ObjectFunctions::GetObjectListContainerSubAction() noexcept { return readObjectList->containerSubAction; } -const char *WorldFunctions::GetObjectRefId(unsigned int i) noexcept +const char *ObjectFunctions::GetObjectRefId(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).refId.c_str(); } -int WorldFunctions::GetObjectRefNumIndex(unsigned int i) noexcept +int ObjectFunctions::GetObjectRefNumIndex(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).refNumIndex; } -int WorldFunctions::GetObjectMpNum(unsigned int i) noexcept +int ObjectFunctions::GetObjectMpNum(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).mpNum; } -int WorldFunctions::GetObjectCount(unsigned int i) noexcept +int ObjectFunctions::GetObjectCount(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).count; } -int WorldFunctions::GetObjectCharge(unsigned int i) noexcept +int ObjectFunctions::GetObjectCharge(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).charge; } -double WorldFunctions::GetObjectEnchantmentCharge(unsigned int i) noexcept +double ObjectFunctions::GetObjectEnchantmentCharge(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).enchantmentCharge; } -int WorldFunctions::GetObjectGoldValue(unsigned int i) noexcept +int ObjectFunctions::GetObjectGoldValue(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).goldValue; } -double WorldFunctions::GetObjectScale(unsigned int i) noexcept +double ObjectFunctions::GetObjectScale(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).scale; } -bool WorldFunctions::GetObjectState(unsigned int i) noexcept +bool ObjectFunctions::GetObjectState(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).objectState; } -int WorldFunctions::GetObjectDoorState(unsigned int i) noexcept +int ObjectFunctions::GetObjectDoorState(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).doorState; } -int WorldFunctions::GetObjectLockLevel(unsigned int i) noexcept +int ObjectFunctions::GetObjectLockLevel(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).lockLevel; } -double WorldFunctions::GetObjectPosX(unsigned int i) noexcept +double ObjectFunctions::GetObjectPosX(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.pos[0]; } -double WorldFunctions::GetObjectPosY(unsigned int i) noexcept +double ObjectFunctions::GetObjectPosY(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.pos[1]; } -double WorldFunctions::GetObjectPosZ(unsigned int i) noexcept +double ObjectFunctions::GetObjectPosZ(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.pos[2]; } -double WorldFunctions::GetObjectRotX(unsigned int i) noexcept +double ObjectFunctions::GetObjectRotX(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.rot[0]; } -double WorldFunctions::GetObjectRotY(unsigned int i) noexcept +double ObjectFunctions::GetObjectRotY(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.rot[1]; } -double WorldFunctions::GetObjectRotZ(unsigned int i) noexcept +double ObjectFunctions::GetObjectRotZ(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.rot[2]; } -unsigned int WorldFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept +unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept { return readObjectList->baseObjects.at(objectIndex).containerItemCount; } -const char *WorldFunctions::GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept +const char *ObjectFunctions::GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).refId.c_str(); } -int WorldFunctions::GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept +int ObjectFunctions::GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).count; } -int WorldFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept +int ObjectFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).charge; } -double WorldFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept +double ObjectFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).enchantmentCharge; } -int WorldFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept +int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).actionCount; } -void WorldFunctions::SetObjectListCell(const char* cellDescription) noexcept +void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept { writeObjectList.cell = Utils::getCellFromDescription(cellDescription); } -void WorldFunctions::SetObjectListAction(unsigned char action) noexcept +void ObjectFunctions::SetObjectListAction(unsigned char action) noexcept { writeObjectList.action = action; } -void WorldFunctions::SetObjectListConsoleCommand(const char* consoleCommand) noexcept +void ObjectFunctions::SetObjectListConsoleCommand(const char* consoleCommand) noexcept { writeObjectList.consoleCommand = consoleCommand; } -void WorldFunctions::SetObjectRefId(const char* refId) noexcept +void ObjectFunctions::SetObjectRefId(const char* refId) noexcept { tempObject.refId = refId; } -void WorldFunctions::SetObjectRefNumIndex(int refNumIndex) noexcept +void ObjectFunctions::SetObjectRefNumIndex(int refNumIndex) noexcept { tempObject.refNumIndex = refNumIndex; } -void WorldFunctions::SetObjectMpNum(int mpNum) noexcept +void ObjectFunctions::SetObjectMpNum(int mpNum) noexcept { tempObject.mpNum = mpNum; } -void WorldFunctions::SetObjectCount(int count) noexcept +void ObjectFunctions::SetObjectCount(int count) noexcept { tempObject.count = count; } -void WorldFunctions::SetObjectCharge(int charge) noexcept +void ObjectFunctions::SetObjectCharge(int charge) noexcept { tempObject.charge = charge; } -void WorldFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept +void ObjectFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept { tempObject.enchantmentCharge = enchantmentCharge; } -void WorldFunctions::SetObjectGoldValue(int goldValue) noexcept +void ObjectFunctions::SetObjectGoldValue(int goldValue) noexcept { tempObject.goldValue = goldValue; } -void WorldFunctions::SetObjectScale(double scale) noexcept +void ObjectFunctions::SetObjectScale(double scale) noexcept { tempObject.scale = scale; } -void WorldFunctions::SetObjectState(bool objectState) noexcept +void ObjectFunctions::SetObjectState(bool objectState) noexcept { tempObject.objectState = objectState; } -void WorldFunctions::SetObjectLockLevel(int lockLevel) noexcept +void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept { tempObject.lockLevel = lockLevel; } -void WorldFunctions::SetObjectDisarmState(bool disarmState) noexcept +void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept { tempObject.isDisarmed = disarmState; } -void WorldFunctions::SetObjectMasterState(bool masterState) noexcept +void ObjectFunctions::SetObjectMasterState(bool masterState) noexcept { tempObject.hasMaster = masterState; } -void WorldFunctions::SetObjectPosition(double x, double y, double z) noexcept +void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept { tempObject.position.pos[0] = x; tempObject.position.pos[1] = y; tempObject.position.pos[2] = z; } -void WorldFunctions::SetObjectRotation(double x, double y, double z) noexcept +void ObjectFunctions::SetObjectRotation(double x, double y, double z) noexcept { tempObject.position.rot[0] = x; tempObject.position.rot[1] = y; tempObject.position.rot[2] = z; } -void WorldFunctions::SetObjectDoorState(int doorState) noexcept +void ObjectFunctions::SetObjectDoorState(int doorState) noexcept { tempObject.doorState = doorState; } -void WorldFunctions::SetObjectDoorTeleportState(bool teleportState) noexcept +void ObjectFunctions::SetObjectDoorTeleportState(bool teleportState) noexcept { tempObject.teleportState = teleportState; } -void WorldFunctions::SetObjectDoorDestinationCell(const char* cellDescription) noexcept +void ObjectFunctions::SetObjectDoorDestinationCell(const char* cellDescription) noexcept { tempObject.destinationCell = Utils::getCellFromDescription(cellDescription); } -void WorldFunctions::SetObjectDoorDestinationPosition(double x, double y, double z) noexcept +void ObjectFunctions::SetObjectDoorDestinationPosition(double x, double y, double z) noexcept { tempObject.destinationPosition.pos[0] = x; tempObject.destinationPosition.pos[1] = y; tempObject.destinationPosition.pos[2] = z; } -void WorldFunctions::SetObjectDoorDestinationRotation(double x, double z) noexcept +void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexcept { tempObject.destinationPosition.rot[0] = x; tempObject.destinationPosition.rot[2] = z; } -void WorldFunctions::SetPlayerAsObject(unsigned short pid) noexcept +void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -295,32 +295,32 @@ void WorldFunctions::SetPlayerAsObject(unsigned short pid) noexcept tempObject.isPlayer = true; } -void WorldFunctions::SetContainerItemRefId(const char* refId) noexcept +void ObjectFunctions::SetContainerItemRefId(const char* refId) noexcept { tempContainerItem.refId = refId; } -void WorldFunctions::SetContainerItemCount(int count) noexcept +void ObjectFunctions::SetContainerItemCount(int count) noexcept { tempContainerItem.count = count; } -void WorldFunctions::SetContainerItemCharge(int charge) noexcept +void ObjectFunctions::SetContainerItemCharge(int charge) noexcept { tempContainerItem.charge = charge; } -void WorldFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept +void ObjectFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept { tempContainerItem.enchantmentCharge = enchantmentCharge; } -void WorldFunctions::SetReceivedContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept +void ObjectFunctions::SetReceivedContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept { readObjectList->baseObjects.at(objectIndex).containerItems.at(itemIndex).actionCount = actionCount; } -void WorldFunctions::AddObject() noexcept +void ObjectFunctions::AddObject() noexcept { tempObject.droppedByPlayer = false; writeObjectList.baseObjects.push_back(tempObject); @@ -328,14 +328,14 @@ void WorldFunctions::AddObject() noexcept tempObject = emptyObject; } -void WorldFunctions::AddContainerItem() noexcept +void ObjectFunctions::AddContainerItem() noexcept { tempObject.containerItems.push_back(tempContainerItem); tempContainerItem = emptyContainerItem; } -void WorldFunctions::SendObjectPlace(bool broadcast) noexcept +void ObjectFunctions::SendObjectPlace(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_PLACE); packet->setObjectList(&writeObjectList); @@ -345,7 +345,7 @@ void WorldFunctions::SendObjectPlace(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendObjectSpawn(bool broadcast) noexcept +void ObjectFunctions::SendObjectSpawn(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SPAWN); packet->setObjectList(&writeObjectList); @@ -355,7 +355,7 @@ void WorldFunctions::SendObjectSpawn(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendObjectDelete(bool broadcast) noexcept +void ObjectFunctions::SendObjectDelete(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_DELETE); packet->setObjectList(&writeObjectList); @@ -365,7 +365,7 @@ void WorldFunctions::SendObjectDelete(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendObjectLock(bool broadcast) noexcept +void ObjectFunctions::SendObjectLock(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_LOCK); packet->setObjectList(&writeObjectList); @@ -375,7 +375,7 @@ void WorldFunctions::SendObjectLock(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendObjectTrap(bool broadcast) noexcept +void ObjectFunctions::SendObjectTrap(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_TRAP); packet->setObjectList(&writeObjectList); @@ -385,7 +385,7 @@ void WorldFunctions::SendObjectTrap(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendObjectScale(bool broadcast) noexcept +void ObjectFunctions::SendObjectScale(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SCALE); packet->setObjectList(&writeObjectList); @@ -395,7 +395,7 @@ void WorldFunctions::SendObjectScale(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendObjectState(bool broadcast) noexcept +void ObjectFunctions::SendObjectState(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_STATE); packet->setObjectList(&writeObjectList); @@ -405,7 +405,7 @@ void WorldFunctions::SendObjectState(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendDoorState(bool broadcast) noexcept +void ObjectFunctions::SendDoorState(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_STATE); packet->setObjectList(&writeObjectList); @@ -415,7 +415,7 @@ void WorldFunctions::SendDoorState(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendDoorDestination(bool broadcast) noexcept +void ObjectFunctions::SendDoorDestination(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_DESTINATION); packet->setObjectList(&writeObjectList); @@ -425,7 +425,7 @@ void WorldFunctions::SendDoorDestination(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SendContainer(bool broadcast, bool useLastReadObjectList) noexcept +void ObjectFunctions::SendContainer(bool broadcast, bool useLastReadObjectList) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONTAINER); @@ -440,7 +440,7 @@ void WorldFunctions::SendContainer(bool broadcast, bool useLastReadObjectList) n packet->Send(true); } -void WorldFunctions::SendConsoleCommand(bool broadcast) noexcept +void ObjectFunctions::SendConsoleCommand(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND); packet->setObjectList(&writeObjectList); @@ -450,7 +450,7 @@ void WorldFunctions::SendConsoleCommand(bool broadcast) noexcept packet->Send(true); } -void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept +void ObjectFunctions::SetHour(unsigned short pid, double hour) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -463,7 +463,7 @@ void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_TIME)->Send(false); } -void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept +void ObjectFunctions::SetMonth(unsigned short pid, int month) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -477,7 +477,7 @@ void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept } -void WorldFunctions::SetDay(unsigned short pid, int day) noexcept +void ObjectFunctions::SetDay(unsigned short pid, int day) noexcept { Player *player; GET_PLAYER(pid, player,); diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp similarity index 78% rename from apps/openmw-mp/Script/Functions/World.hpp rename to apps/openmw-mp/Script/Functions/Objects.hpp index 8fe2dbace..e4a49ef6c 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -1,93 +1,93 @@ -#ifndef OPENMW_WORLDAPI_HPP -#define OPENMW_WORLDAPI_HPP +#ifndef OPENMW_OBJECTAPI_HPP +#define OPENMW_OBJECTAPI_HPP -#define WORLDAPI \ - {"ReadLastObjectList", WorldFunctions::ReadLastObjectList},\ - {"InitializeObjectList", WorldFunctions::InitializeObjectList},\ +#define OBJECTAPI \ + {"ReadLastObjectList", ObjectFunctions::ReadLastObjectList},\ + {"InitializeObjectList", ObjectFunctions::InitializeObjectList},\ \ - {"GetObjectChangesSize", WorldFunctions::GetObjectChangesSize},\ - {"GetObjectListAction", WorldFunctions::GetObjectListAction},\ - {"GetObjectListContainerSubAction", WorldFunctions::GetObjectListContainerSubAction},\ + {"GetObjectChangesSize", ObjectFunctions::GetObjectChangesSize},\ + {"GetObjectListAction", ObjectFunctions::GetObjectListAction},\ + {"GetObjectListContainerSubAction", ObjectFunctions::GetObjectListContainerSubAction},\ \ - {"GetObjectRefId", WorldFunctions::GetObjectRefId},\ - {"GetObjectRefNumIndex", WorldFunctions::GetObjectRefNumIndex},\ - {"GetObjectMpNum", WorldFunctions::GetObjectMpNum},\ - {"GetObjectCount", WorldFunctions::GetObjectCount},\ - {"GetObjectCharge", WorldFunctions::GetObjectCharge},\ - {"GetObjectEnchantmentCharge", WorldFunctions::GetObjectEnchantmentCharge},\ - {"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\ - {"GetObjectScale", WorldFunctions::GetObjectScale},\ - {"GetObjectState", WorldFunctions::GetObjectState},\ - {"GetObjectDoorState", WorldFunctions::GetObjectDoorState},\ - {"GetObjectLockLevel", WorldFunctions::GetObjectLockLevel},\ - {"GetObjectPosX", WorldFunctions::GetObjectPosX},\ - {"GetObjectPosY", WorldFunctions::GetObjectPosY},\ - {"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\ - {"GetObjectRotX", WorldFunctions::GetObjectRotX},\ - {"GetObjectRotY", WorldFunctions::GetObjectRotY},\ - {"GetObjectRotZ", WorldFunctions::GetObjectRotZ},\ + {"GetObjectRefId", ObjectFunctions::GetObjectRefId},\ + {"GetObjectRefNumIndex", ObjectFunctions::GetObjectRefNumIndex},\ + {"GetObjectMpNum", ObjectFunctions::GetObjectMpNum},\ + {"GetObjectCount", ObjectFunctions::GetObjectCount},\ + {"GetObjectCharge", ObjectFunctions::GetObjectCharge},\ + {"GetObjectEnchantmentCharge", ObjectFunctions::GetObjectEnchantmentCharge},\ + {"GetObjectGoldValue", ObjectFunctions::GetObjectGoldValue},\ + {"GetObjectScale", ObjectFunctions::GetObjectScale},\ + {"GetObjectState", ObjectFunctions::GetObjectState},\ + {"GetObjectDoorState", ObjectFunctions::GetObjectDoorState},\ + {"GetObjectLockLevel", ObjectFunctions::GetObjectLockLevel},\ + {"GetObjectPosX", ObjectFunctions::GetObjectPosX},\ + {"GetObjectPosY", ObjectFunctions::GetObjectPosY},\ + {"GetObjectPosZ", ObjectFunctions::GetObjectPosZ},\ + {"GetObjectRotX", ObjectFunctions::GetObjectRotX},\ + {"GetObjectRotY", ObjectFunctions::GetObjectRotY},\ + {"GetObjectRotZ", ObjectFunctions::GetObjectRotZ},\ \ - {"GetContainerChangesSize", WorldFunctions::GetContainerChangesSize},\ - {"GetContainerItemRefId", WorldFunctions::GetContainerItemRefId},\ - {"GetContainerItemCount", WorldFunctions::GetContainerItemCount},\ - {"GetContainerItemCharge", WorldFunctions::GetContainerItemCharge},\ - {"GetContainerItemEnchantmentCharge", WorldFunctions::GetContainerItemEnchantmentCharge},\ - {"GetContainerItemActionCount", WorldFunctions::GetContainerItemActionCount},\ + {"GetContainerChangesSize", ObjectFunctions::GetContainerChangesSize},\ + {"GetContainerItemRefId", ObjectFunctions::GetContainerItemRefId},\ + {"GetContainerItemCount", ObjectFunctions::GetContainerItemCount},\ + {"GetContainerItemCharge", ObjectFunctions::GetContainerItemCharge},\ + {"GetContainerItemEnchantmentCharge", ObjectFunctions::GetContainerItemEnchantmentCharge},\ + {"GetContainerItemActionCount", ObjectFunctions::GetContainerItemActionCount},\ \ - {"SetObjectListCell", WorldFunctions::SetObjectListCell},\ - {"SetObjectListAction", WorldFunctions::SetObjectListAction},\ - {"SetObjectListConsoleCommand", WorldFunctions::SetObjectListConsoleCommand},\ + {"SetObjectListCell", ObjectFunctions::SetObjectListCell},\ + {"SetObjectListAction", ObjectFunctions::SetObjectListAction},\ + {"SetObjectListConsoleCommand", ObjectFunctions::SetObjectListConsoleCommand},\ \ - {"SetObjectRefId", WorldFunctions::SetObjectRefId},\ - {"SetObjectRefNumIndex", WorldFunctions::SetObjectRefNumIndex},\ - {"SetObjectMpNum", WorldFunctions::SetObjectMpNum},\ - {"SetObjectCount", WorldFunctions::SetObjectCount},\ - {"SetObjectCharge", WorldFunctions::SetObjectCharge},\ - {"SetObjectEnchantmentCharge", WorldFunctions::SetObjectEnchantmentCharge},\ - {"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\ - {"SetObjectScale", WorldFunctions::SetObjectScale},\ - {"SetObjectState", WorldFunctions::SetObjectState},\ - {"SetObjectLockLevel", WorldFunctions::SetObjectLockLevel},\ - {"SetObjectDisarmState", WorldFunctions::SetObjectDisarmState},\ - {"SetObjectMasterState", WorldFunctions::SetObjectMasterState},\ - {"SetObjectPosition", WorldFunctions::SetObjectPosition},\ - {"SetObjectRotation", WorldFunctions::SetObjectRotation},\ + {"SetObjectRefId", ObjectFunctions::SetObjectRefId},\ + {"SetObjectRefNumIndex", ObjectFunctions::SetObjectRefNumIndex},\ + {"SetObjectMpNum", ObjectFunctions::SetObjectMpNum},\ + {"SetObjectCount", ObjectFunctions::SetObjectCount},\ + {"SetObjectCharge", ObjectFunctions::SetObjectCharge},\ + {"SetObjectEnchantmentCharge", ObjectFunctions::SetObjectEnchantmentCharge},\ + {"SetObjectGoldValue", ObjectFunctions::SetObjectGoldValue},\ + {"SetObjectScale", ObjectFunctions::SetObjectScale},\ + {"SetObjectState", ObjectFunctions::SetObjectState},\ + {"SetObjectLockLevel", ObjectFunctions::SetObjectLockLevel},\ + {"SetObjectDisarmState", ObjectFunctions::SetObjectDisarmState},\ + {"SetObjectMasterState", ObjectFunctions::SetObjectMasterState},\ + {"SetObjectPosition", ObjectFunctions::SetObjectPosition},\ + {"SetObjectRotation", ObjectFunctions::SetObjectRotation},\ \ - {"SetObjectDoorState", WorldFunctions::SetObjectDoorState},\ - {"SetObjectDoorTeleportState", WorldFunctions::SetObjectDoorTeleportState},\ - {"SetObjectDoorDestinationCell", WorldFunctions::SetObjectDoorDestinationCell},\ - {"SetObjectDoorDestinationPosition", WorldFunctions::SetObjectDoorDestinationPosition},\ - {"SetObjectDoorDestinationRotation", WorldFunctions::SetObjectDoorDestinationRotation},\ + {"SetObjectDoorState", ObjectFunctions::SetObjectDoorState},\ + {"SetObjectDoorTeleportState", ObjectFunctions::SetObjectDoorTeleportState},\ + {"SetObjectDoorDestinationCell", ObjectFunctions::SetObjectDoorDestinationCell},\ + {"SetObjectDoorDestinationPosition", ObjectFunctions::SetObjectDoorDestinationPosition},\ + {"SetObjectDoorDestinationRotation", ObjectFunctions::SetObjectDoorDestinationRotation},\ \ - {"SetPlayerAsObject", WorldFunctions::SetPlayerAsObject},\ + {"SetPlayerAsObject", ObjectFunctions::SetPlayerAsObject},\ \ - {"SetContainerItemRefId", WorldFunctions::SetContainerItemRefId},\ - {"SetContainerItemCount", WorldFunctions::SetContainerItemCount},\ - {"SetContainerItemCharge", WorldFunctions::SetContainerItemCharge},\ - {"SetContainerItemEnchantmentCharge", WorldFunctions::SetContainerItemEnchantmentCharge},\ + {"SetContainerItemRefId", ObjectFunctions::SetContainerItemRefId},\ + {"SetContainerItemCount", ObjectFunctions::SetContainerItemCount},\ + {"SetContainerItemCharge", ObjectFunctions::SetContainerItemCharge},\ + {"SetContainerItemEnchantmentCharge", ObjectFunctions::SetContainerItemEnchantmentCharge},\ \ - {"SetReceivedContainerItemActionCount", WorldFunctions::SetReceivedContainerItemActionCount},\ + {"SetReceivedContainerItemActionCount", ObjectFunctions::SetReceivedContainerItemActionCount},\ \ - {"AddObject", WorldFunctions::AddObject},\ - {"AddContainerItem", WorldFunctions::AddContainerItem},\ + {"AddObject", ObjectFunctions::AddObject},\ + {"AddContainerItem", ObjectFunctions::AddContainerItem},\ \ - {"SendObjectPlace", WorldFunctions::SendObjectPlace},\ - {"SendObjectSpawn", WorldFunctions::SendObjectSpawn},\ - {"SendObjectDelete", WorldFunctions::SendObjectDelete},\ - {"SendObjectLock", WorldFunctions::SendObjectLock},\ - {"SendObjectTrap", WorldFunctions::SendObjectTrap},\ - {"SendObjectScale", WorldFunctions::SendObjectScale},\ - {"SendObjectState", WorldFunctions::SendObjectState},\ - {"SendDoorState", WorldFunctions::SendDoorState},\ - {"SendDoorDestination", WorldFunctions::SendDoorDestination},\ - {"SendContainer", WorldFunctions::SendContainer},\ - {"SendConsoleCommand", WorldFunctions::SendConsoleCommand},\ + {"SendObjectPlace", ObjectFunctions::SendObjectPlace},\ + {"SendObjectSpawn", ObjectFunctions::SendObjectSpawn},\ + {"SendObjectDelete", ObjectFunctions::SendObjectDelete},\ + {"SendObjectLock", ObjectFunctions::SendObjectLock},\ + {"SendObjectTrap", ObjectFunctions::SendObjectTrap},\ + {"SendObjectScale", ObjectFunctions::SendObjectScale},\ + {"SendObjectState", ObjectFunctions::SendObjectState},\ + {"SendDoorState", ObjectFunctions::SendDoorState},\ + {"SendDoorDestination", ObjectFunctions::SendDoorDestination},\ + {"SendContainer", ObjectFunctions::SendContainer},\ + {"SendConsoleCommand", ObjectFunctions::SendConsoleCommand},\ \ - {"SetHour", WorldFunctions::SetHour},\ - {"SetMonth", WorldFunctions::SetMonth},\ - {"SetDay", WorldFunctions::SetDay} + {"SetHour", ObjectFunctions::SetHour},\ + {"SetMonth", ObjectFunctions::SetMonth},\ + {"SetDay", ObjectFunctions::SetDay} -class WorldFunctions +class ObjectFunctions { public: @@ -780,4 +780,4 @@ public: }; -#endif //OPENMW_WORLDAPI_HPP +#endif //OPENMW_OBJECTAPI_HPP diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index df28f5846..401bfdd1a 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -21,7 +21,7 @@ #include