[General] Make WorldCollisionOverride also work with specific refIds

For now, this only makes it possible to enforce collision for specific refIds for placed objects.
0.6.3
David Cernat 7 years ago
parent c7f10892a9
commit 9102df7fde

@ -93,6 +93,16 @@ void WorldstateFunctions::UseActorCollisionForPlacedObjects(bool useActorCollisi
writeWorldstate.useActorCollisionForPlacedObjects = useActorCollision;
}
void WorldstateFunctions::AddEnforcedCollisionRefId(const char *refId) noexcept
{
writeWorldstate.enforcedCollisionRefIds.push_back(refId);
}
void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept
{
writeWorldstate.enforcedCollisionRefIds.clear();
}
void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept
{
if (index >= readWorldstate->mapChanges.mapTiles.size())

@ -27,6 +27,9 @@
{"SetPlacedObjectCollisionState", WorldstateFunctions::SetPlacedObjectCollisionState},\
{"UseActorCollisionForPlacedObjects", WorldstateFunctions::UseActorCollisionForPlacedObjects},\
\
{"AddEnforcedCollisionRefId", WorldstateFunctions::AddEnforcedCollisionRefId},\
{"ClearEnforcedCollisionRefIds", WorldstateFunctions::ClearEnforcedCollisionRefIds},\
\
{"SaveMapTileImageFile", WorldstateFunctions::SaveMapTileImageFile},\
{"LoadMapTileImageFile", WorldstateFunctions::LoadMapTileImageFile},\
\
@ -173,6 +176,23 @@ public:
*/
static void UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept;
/**
* \brief Add a refId to the list of refIds for which collision should be enforced
* irrespective of other settings.
*
* \param refId The refId.
* \return void
*/
static void AddEnforcedCollisionRefId(const char* refId) noexcept;
/**
* \brief Clear the list of refIdsd for which collision should be enforced irrespective
* of other settings.
*
* \return void
*/
static void ClearEnforcedCollisionRefIds() noexcept;
/**
* \brief Save the .png image data of the map tile at a certain index in the read worldstate's
* map changes.

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -52,7 +53,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -58,7 +59,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -55,7 +56,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -54,7 +55,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -55,7 +56,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -62,7 +63,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -56,7 +57,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -52,7 +53,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -5,6 +5,7 @@
Include additional headers for multiplayer purposes
*/
#include <components/openmw-mp/Utils.hpp>
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
/*
@ -56,7 +57,7 @@ namespace MWClass
{
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
if (worldstate->hasPlacedObjectCollision)
if (worldstate->hasPlacedObjectCollision || Utils::vectorContains(&worldstate->enforcedCollisionRefIds, ptr.getCellRef().getRefId()))
{
if (worldstate->useActorCollisionForPlacedObjects)
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);

@ -52,6 +52,8 @@ namespace mwmp
bool hasPlacedObjectCollision;
bool useActorCollisionForPlacedObjects;
std::vector<std::string> enforcedCollisionRefIds;
MapChanges mapChanges;
bool isValid;

@ -17,4 +17,22 @@ void PacketWorldCollisionOverride::Packet(RakNet::BitStream *bs, bool send)
RW(worldstate->hasActorCollision, send);
RW(worldstate->hasPlacedObjectCollision, send);
RW(worldstate->useActorCollisionForPlacedObjects, send);
uint32_t enforcedCollisionCount;
if (send)
enforcedCollisionCount = static_cast<uint32_t>(worldstate->enforcedCollisionRefIds.size());
RW(enforcedCollisionCount, send);
if (!send)
{
worldstate->enforcedCollisionRefIds.clear();
worldstate->enforcedCollisionRefIds.resize(enforcedCollisionCount);
}
for (auto &&enforcedCollisionRefId : worldstate->enforcedCollisionRefIds)
{
RW(enforcedCollisionRefId, send);
}
}

Loading…
Cancel
Save