forked from mirror/openmw-tes3mp
[General] Implement WorldCollisionOverride packet
This commit is contained in:
parent
5d30a884ba
commit
3efe05a88e
16 changed files with 425 additions and 13 deletions
|
@ -41,6 +41,27 @@ void WorldstateFunctions::SetTimeScale(double timeScale) noexcept
|
||||||
{
|
{
|
||||||
writeWorldstate.timeScale = timeScale;
|
writeWorldstate.timeScale = timeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SetPlayerCollisionState(bool state) noexcept
|
||||||
|
{
|
||||||
|
writeWorldstate.hasPlayerCollision = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SetActorCollisionState(bool state) noexcept
|
||||||
|
{
|
||||||
|
writeWorldstate.hasActorCollision = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SetPlacedObjectCollisionState(bool state) noexcept
|
||||||
|
{
|
||||||
|
writeWorldstate.hasPlacedObjectCollision = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept
|
||||||
|
{
|
||||||
|
writeWorldstate.useActorCollisionForPlacedObjects = useActorCollision;
|
||||||
|
}
|
||||||
|
|
||||||
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool toOthers) noexcept
|
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool toOthers) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -54,3 +75,17 @@ void WorldstateFunctions::SendWorldTime(unsigned short pid, bool toOthers) noexc
|
||||||
if (toOthers)
|
if (toOthers)
|
||||||
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(true);
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool toOthers) noexcept
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
|
writeWorldstate.guid = player->guid;
|
||||||
|
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->setWorldstate(&writeWorldstate);
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(false);
|
||||||
|
|
||||||
|
if (toOthers)
|
||||||
|
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(true);
|
||||||
|
}
|
||||||
|
|
|
@ -8,11 +8,16 @@
|
||||||
{"SetDay", WorldstateFunctions::SetDay},\
|
{"SetDay", WorldstateFunctions::SetDay},\
|
||||||
{"SetMonth", WorldstateFunctions::SetMonth},\
|
{"SetMonth", WorldstateFunctions::SetMonth},\
|
||||||
{"SetYear", WorldstateFunctions::SetYear},\
|
{"SetYear", WorldstateFunctions::SetYear},\
|
||||||
\
|
|
||||||
{"SetDaysPassed", WorldstateFunctions::SetDaysPassed},\
|
{"SetDaysPassed", WorldstateFunctions::SetDaysPassed},\
|
||||||
{"SetTimeScale", WorldstateFunctions::SetTimeScale},\
|
{"SetTimeScale", WorldstateFunctions::SetTimeScale},\
|
||||||
\
|
\
|
||||||
{"SendWorldTime", WorldstateFunctions::SendWorldTime}
|
{"SetPlayerCollisionState", WorldstateFunctions::SetPlayerCollisionState},\
|
||||||
|
{"SetActorCollisionState", WorldstateFunctions::SetActorCollisionState},\
|
||||||
|
{"SetPlacedObjectCollisionState", WorldstateFunctions::SetPlacedObjectCollisionState},\
|
||||||
|
{"UseActorCollisionForPlacedObjects", WorldstateFunctions::UseActorCollisionForPlacedObjects},\
|
||||||
|
\
|
||||||
|
{"SendWorldTime", WorldstateFunctions::SendWorldTime},\
|
||||||
|
{"SendWorldCollisionOverride", WorldstateFunctions::SendWorldCollisionOverride}
|
||||||
|
|
||||||
class WorldstateFunctions
|
class WorldstateFunctions
|
||||||
{
|
{
|
||||||
|
@ -67,6 +72,40 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SetTimeScale(double timeScale) noexcept;
|
static void SetTimeScale(double timeScale) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the collision state for other players.
|
||||||
|
*
|
||||||
|
* \param state The collision state.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetPlayerCollisionState(bool state) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the collision state for actors.
|
||||||
|
*
|
||||||
|
* \param state The collision state.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetActorCollisionState(bool state) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the collision state for placed objects.
|
||||||
|
*
|
||||||
|
* \param state The collision state.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetPlacedObjectCollisionState(bool state) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Whether placed objects with collision turned on should use
|
||||||
|
* actor collision, i.e. whether they should be slippery
|
||||||
|
* and prevent players from standing on them.
|
||||||
|
*
|
||||||
|
* \param useActorCollision Whether to use actor collision.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send a WorldTime packet with the current time and time scale
|
* \brief Send a WorldTime packet with the current time and time scale
|
||||||
* to a specific player or to all players.
|
* to a specific player or to all players.
|
||||||
|
@ -76,6 +115,15 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SendWorldTime(unsigned short pid, bool toOthers = false) noexcept;
|
static void SendWorldTime(unsigned short pid, bool toOthers = false) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Send a WorldCollisionOverride packet with the current collision overrides
|
||||||
|
* to a specific player or to all players.
|
||||||
|
*
|
||||||
|
* \param pid The player ID.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SendWorldCollisionOverride(unsigned short pid, bool toOthers = false) noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_WORLDSTATEAPI_HPP
|
#endif //OPENMW_WORLDSTATEAPI_HPP
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "apparatus.hpp"
|
#include "apparatus.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadappa.hpp>
|
#include <components/esm/loadappa.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -31,6 +42,27 @@ namespace MWClass
|
||||||
void Apparatus::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Apparatus::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "armor.hpp"
|
#include "armor.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadarmo.hpp>
|
#include <components/esm/loadarmo.hpp>
|
||||||
#include <components/esm/loadskil.hpp>
|
#include <components/esm/loadskil.hpp>
|
||||||
#include <components/esm/loadgmst.hpp>
|
#include <components/esm/loadgmst.hpp>
|
||||||
|
@ -37,6 +48,27 @@ namespace MWClass
|
||||||
void Armor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Armor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "book.hpp"
|
#include "book.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadbook.hpp>
|
#include <components/esm/loadbook.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -34,6 +45,27 @@ namespace MWClass
|
||||||
void Book::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Book::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Book::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Book::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "clothing.hpp"
|
#include "clothing.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadclot.hpp>
|
#include <components/esm/loadclot.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -33,6 +44,27 @@ namespace MWClass
|
||||||
void Clothing::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Clothing::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "ingredient.hpp"
|
#include "ingredient.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadingr.hpp>
|
#include <components/esm/loadingr.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -34,6 +45,27 @@ namespace MWClass
|
||||||
void Ingredient::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Ingredient::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "misc.hpp"
|
#include "misc.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadmisc.hpp>
|
#include <components/esm/loadmisc.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
@ -41,6 +52,27 @@ namespace MWClass
|
||||||
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "potion.hpp"
|
#include "potion.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadalch.hpp>
|
#include <components/esm/loadalch.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -35,6 +46,27 @@ namespace MWClass
|
||||||
void Potion::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Potion::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "repair.hpp"
|
#include "repair.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadrepa.hpp>
|
#include <components/esm/loadrepa.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -31,6 +42,27 @@ namespace MWClass
|
||||||
void Repair::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Repair::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "weapon.hpp"
|
#include "weapon.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/esm/loadweap.hpp>
|
#include <components/esm/loadweap.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
@ -35,6 +46,27 @@ namespace MWClass
|
||||||
void Weapon::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
void Weapon::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
// TODO: add option somewhere to enable collision for placeable objects
|
// TODO: add option somewhere to enable collision for placeable objects
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to enable collision for this object class from a packet
|
||||||
|
*/
|
||||||
|
if (!model.empty())
|
||||||
|
{
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (worldstate->hasPlacedObjectCollision)
|
||||||
|
{
|
||||||
|
if (worldstate->useActorCollisionForPlacedObjects)
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_Actor);
|
||||||
|
else
|
||||||
|
physics.addObject(ptr, model, MWPhysics::CollisionType_World);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const
|
std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const
|
||||||
|
|
|
@ -7,7 +7,10 @@ using namespace std;
|
||||||
|
|
||||||
Worldstate::Worldstate()
|
Worldstate::Worldstate()
|
||||||
{
|
{
|
||||||
|
hasPlayerCollision = true;
|
||||||
|
hasActorCollision = true;
|
||||||
|
hasPlacedObjectCollision = false;
|
||||||
|
useActorCollisionForPlacedObjects = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Worldstate::~Worldstate()
|
Worldstate::~Worldstate()
|
||||||
|
|
|
@ -1,5 +1,18 @@
|
||||||
#include "actor.hpp"
|
#include "actor.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/Networking.hpp"
|
||||||
|
#include "../mwmp/PlayerList.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <BulletCollision/CollisionShapes/btCapsuleShape.h>
|
#include <BulletCollision/CollisionShapes/btCapsuleShape.h>
|
||||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||||
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
|
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
|
||||||
|
@ -53,6 +66,27 @@ Actor::Actor(const MWWorld::Ptr& ptr, osg::ref_ptr<const Resource::BulletShape>
|
||||||
updatePosition();
|
updatePosition();
|
||||||
|
|
||||||
addCollisionMask(getCollisionMask());
|
addCollisionMask(getCollisionMask());
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Make it possible to disable collision for players or regular actors from a packet
|
||||||
|
*/
|
||||||
|
mwmp::BaseWorldstate *worldstate = mwmp::Main::get().getNetworking()->getWorldstate();
|
||||||
|
|
||||||
|
if (mwmp::PlayerList::isDedicatedPlayer(ptr))
|
||||||
|
{
|
||||||
|
if (!worldstate->hasPlayerCollision)
|
||||||
|
enableCollisionBody(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!worldstate->hasActorCollision)
|
||||||
|
enableCollisionBody(false);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor::~Actor()
|
Actor::~Actor()
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
//
|
|
||||||
// Created by koncord on 07.01.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_BASEPLAYER_HPP
|
#ifndef OPENMW_BASEPLAYER_HPP
|
||||||
#define OPENMW_BASEPLAYER_HPP
|
#define OPENMW_BASEPLAYER_HPP
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ namespace mwmp
|
||||||
int daysPassed;
|
int daysPassed;
|
||||||
float timeScale;
|
float timeScale;
|
||||||
|
|
||||||
|
bool hasPlayerCollision;
|
||||||
|
bool hasActorCollision;
|
||||||
|
bool hasPlacedObjectCollision;
|
||||||
|
bool useActorCollisionForPlacedObjects;
|
||||||
|
|
||||||
bool isValid;
|
bool isValid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,8 @@ void PacketWorldCollisionOverride::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
WorldstatePacket::Packet(bs, send);
|
WorldstatePacket::Packet(bs, send);
|
||||||
|
|
||||||
// Placeholder
|
RW(worldstate->hasPlayerCollision, send);
|
||||||
|
RW(worldstate->hasActorCollision, send);
|
||||||
|
RW(worldstate->hasPlacedObjectCollision, send);
|
||||||
|
RW(worldstate->useActorCollisionForPlacedObjects, send);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue