forked from teamnwah/openmw-tes3coop
[General] Implement setting of physics framerate as part of GameSettings
This commit is contained in:
parent
65c3472772
commit
60f686ee43
11 changed files with 93 additions and 0 deletions
|
@ -17,6 +17,14 @@ void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
|
|||
player->difficulty = difficulty;
|
||||
}
|
||||
|
||||
void SettingFunctions::SetPhysicsFramerate(unsigned short pid, double physicsFramerate)
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->physicsFramerate = physicsFramerate;
|
||||
}
|
||||
|
||||
void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool state)
|
||||
{
|
||||
Player *player;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#define SETTINGSAPI \
|
||||
{"SetDifficulty", SettingFunctions::SetDifficulty},\
|
||||
{"SetPhysicsFramerate", SettingFunctions::SetPhysicsFramerate},\
|
||||
\
|
||||
{"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\
|
||||
{"SetBedRestAllowed", SettingFunctions::SetBedRestAllowed},\
|
||||
{"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\
|
||||
|
@ -28,6 +30,18 @@ public:
|
|||
*/
|
||||
static void SetDifficulty(unsigned short pid, int difficulty);
|
||||
|
||||
/**
|
||||
* \brief Set the physics framerate for a player.
|
||||
*
|
||||
* This changes the physics framerate for that player in the server memory, but does not by itself
|
||||
* send a packet.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param bool The physics framerate.
|
||||
* \return void
|
||||
*/
|
||||
static void SetPhysicsFramerate(unsigned short pid, double physicsFramerate);
|
||||
|
||||
/**
|
||||
* \brief Set whether the console is allowed for a player.
|
||||
*
|
||||
|
|
|
@ -318,6 +318,16 @@ namespace MWBase
|
|||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set the physics framerate from elsewhere
|
||||
*/
|
||||
virtual void World::setPhysicsFramerate(float physFramerate) = 0;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) = 0;
|
||||
///< cast a Ray and return true if there is an object in the ray path.
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ LocalPlayer::LocalPlayer()
|
|||
charGenStage.end = 1;
|
||||
|
||||
difficulty = 0;
|
||||
physicsFramerate = 60.0;
|
||||
consoleAllowed = false;
|
||||
bedRestAllowed = true;
|
||||
wildernessRestAllowed = true;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define OPENMW_PROCESSORGAMESETTINGS_HPP
|
||||
|
||||
#include "apps/openmw/mwbase/environment.hpp"
|
||||
#include "apps/openmw/mwworld/worldimp.hpp"
|
||||
#include "apps/openmw/mwgui/windowmanagerimp.hpp"
|
||||
|
||||
#include "../PlayerProcessor.hpp"
|
||||
|
@ -28,6 +29,8 @@ namespace mwmp
|
|||
(!player->bedRestAllowed || !player->wildernessRestAllowed || !player->waitAllowed))
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWorld()->setPhysicsFramerate(player->physicsFramerate);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -794,6 +794,28 @@ namespace MWPhysics
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set the physics framerate from elsewhere
|
||||
*/
|
||||
void PhysicsSystem::setPhysicsFramerate(float physFramerate)
|
||||
{
|
||||
if (physFramerate > 0 && physFramerate < 100)
|
||||
{
|
||||
mPhysicsDt = 1.f / physFramerate;
|
||||
std::cerr << "Warning: physics framerate was overridden (a new value is " << physFramerate << ")." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Warning: attempted to override physics framerate with new value of " << physFramerate <<
|
||||
", but it was outside accepted values." << std::endl;
|
||||
}
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
class DeepestNotMeContactTestResultCallback : public btCollisionWorld::ContactResultCallback
|
||||
{
|
||||
const btCollisionObject* mMe;
|
||||
|
|
|
@ -170,6 +170,16 @@ namespace MWPhysics
|
|||
|
||||
bool isOnSolidGround (const MWWorld::Ptr& actor) const;
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set the physics framerate from elsewhere
|
||||
*/
|
||||
void setPhysicsFramerate(float physFramerate);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
private:
|
||||
|
||||
void updateWater();
|
||||
|
|
|
@ -1522,6 +1522,19 @@ namespace MWWorld
|
|||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set the physics framerate from elsewhere
|
||||
*/
|
||||
void World::setPhysicsFramerate(float physFramerate)
|
||||
{
|
||||
mPhysics->setPhysicsFramerate(physFramerate);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void World::doPhysics(float duration)
|
||||
{
|
||||
mPhysics->stepSimulation(duration);
|
||||
|
|
|
@ -417,6 +417,16 @@ namespace MWWorld
|
|||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Make it possible to set the physics framerate from elsewhere
|
||||
*/
|
||||
void World::setPhysicsFramerate(float physFramerate);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) override;
|
||||
///< cast a Ray and return true if there is an object in the ray path.
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ namespace mwmp
|
|||
CurrentContainer currentContainer;
|
||||
|
||||
int difficulty;
|
||||
float physicsFramerate;
|
||||
bool consoleAllowed;
|
||||
bool bedRestAllowed;
|
||||
bool wildernessRestAllowed;
|
||||
|
|
|
@ -14,6 +14,7 @@ void PacketGameSettings::Packet(RakNet::BitStream *bs, bool send)
|
|||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
RW(player->difficulty, send);
|
||||
RW(player->physicsFramerate, send);
|
||||
RW(player->consoleAllowed, send);
|
||||
RW(player->bedRestAllowed, send);
|
||||
RW(player->wildernessRestAllowed, send);
|
||||
|
|
Loading…
Reference in a new issue