mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 19:19:44 +00:00
[General] Add VR settings to GameSettings packet
This commit is contained in:
parent
a6a0b9db72
commit
da079fcfd8
5 changed files with 80 additions and 6 deletions
|
@ -78,6 +78,20 @@ void SettingFunctions::ClearGameSettingValues(unsigned short pid) {
|
|||
player->gameSettings.clear();
|
||||
}
|
||||
|
||||
void SettingFunctions::SetVRSettingValue(unsigned short pid, const char* setting, const char* value) {
|
||||
Player* player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->vrSettings[setting] = value;
|
||||
}
|
||||
|
||||
void SettingFunctions::ClearVRSettingValues(unsigned short pid) {
|
||||
Player* player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->vrSettings.clear();
|
||||
}
|
||||
|
||||
void SettingFunctions::SendSettings(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
{"SetGameSettingValue", SettingFunctions::SetGameSettingValue},\
|
||||
{"ClearGameSettingValues", SettingFunctions::ClearGameSettingValues},\
|
||||
\
|
||||
{"SetVRSettingValue", SettingFunctions::SetVRSettingValue},\
|
||||
{"ClearVRSettingValues", SettingFunctions::ClearVRSettingValues},\
|
||||
\
|
||||
{"SendSettings", SettingFunctions::SendSettings}
|
||||
|
||||
class SettingFunctions
|
||||
|
@ -125,15 +128,37 @@ public:
|
|||
static void SetGameSettingValue(unsigned short pid, const char* setting, const char* value);
|
||||
|
||||
/**
|
||||
* \brief Clear the settings values
|
||||
* \brief Clear the Game setting values stored for a player.
|
||||
*
|
||||
* Clear any changes done by SetGameSettingValue
|
||||
* Clear any changes done by SetGameSettingValue()
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \return void
|
||||
*/
|
||||
static void ClearGameSettingValues(unsigned short pid);
|
||||
|
||||
/**
|
||||
* \brief Set value for a VR setting.
|
||||
*
|
||||
* This overrides the setting value set in OpenMW Launcher. Only applies to the VR category.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param setting Name of a setting in the VR category
|
||||
* \param value Value of the setting (as a string)
|
||||
* \return void
|
||||
*/
|
||||
static void SetVRSettingValue(unsigned short pid, const char* setting, const char* value);
|
||||
|
||||
/**
|
||||
* \brief Clear the VR setting values stored for a player.
|
||||
*
|
||||
* Clear any changes done by SetVRSettingValue()
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \return void
|
||||
*/
|
||||
static void ClearVRSettingValues(unsigned short pid);
|
||||
|
||||
/**
|
||||
* \brief Send a PlayerSettings packet to the player affected by it.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace mwmp
|
|||
class ProcessorGameSettings final: public PlayerProcessor
|
||||
{
|
||||
const std::string GAME_SETTING_CATEGORY = "Game";
|
||||
const std::string VR_SETTING_CATEGORY = "VR";
|
||||
public:
|
||||
ProcessorGameSettings()
|
||||
{
|
||||
|
@ -51,9 +52,18 @@ namespace mwmp
|
|||
|
||||
MWBase::Environment::get().getWorld()->setPhysicsFramerate(player->physicsFramerate);
|
||||
|
||||
for (auto setting : player->gameSettings) {
|
||||
for (auto setting : player->gameSettings)
|
||||
{
|
||||
Settings::Manager::setString(setting.first, GAME_SETTING_CATEGORY, setting.second);
|
||||
}
|
||||
|
||||
// Only read VR settings for players using a VR build
|
||||
#ifdef USE_OPENXR
|
||||
for (auto setting : player->vrSettings)
|
||||
{
|
||||
Settings::Manager::setString(setting.first, VR_SETTING_CATEGORY, setting.second);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -253,6 +253,7 @@ namespace mwmp
|
|||
std::string chatMessage;
|
||||
CharGenState charGenState;
|
||||
std::map<std::string, std::string> gameSettings;
|
||||
std::map<std::string, std::string> vrSettings;
|
||||
|
||||
std::string sound;
|
||||
Animation animation;
|
||||
|
|
|
@ -21,12 +21,12 @@ void PacketGameSettings::Packet(RakNet::BitStream *newBitstream, bool send)
|
|||
RW(player->enforcedLogLevel, send);
|
||||
RW(player->physicsFramerate, send);
|
||||
|
||||
uint32_t gameSettingCount = static_cast<uint32_t>(player->gameSettings.size());
|
||||
RW(gameSettingCount, send);
|
||||
|
||||
std::string mapIndex;
|
||||
std::string mapValue;
|
||||
|
||||
uint32_t gameSettingCount = static_cast<uint32_t>(player->gameSettings.size());
|
||||
RW(gameSettingCount, send);
|
||||
|
||||
if (send)
|
||||
{
|
||||
for (auto&& gameSetting : player->gameSettings)
|
||||
|
@ -47,4 +47,28 @@ void PacketGameSettings::Packet(RakNet::BitStream *newBitstream, bool send)
|
|||
player->gameSettings[mapIndex] = mapValue;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t vrSettingCount = static_cast<uint32_t>(player->vrSettings.size());
|
||||
RW(vrSettingCount, send);
|
||||
|
||||
if (send)
|
||||
{
|
||||
for (auto&& vrSetting : player->vrSettings)
|
||||
{
|
||||
mapIndex = vrSetting.first;
|
||||
mapValue = vrSetting.second;
|
||||
RW(mapIndex, send, false);
|
||||
RW(mapValue, send, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player->vrSettings.clear();
|
||||
for (unsigned int n = 0; n < vrSettingCount; n++)
|
||||
{
|
||||
RW(mapIndex, send, false);
|
||||
RW(mapValue, send, false);
|
||||
player->vrSettings[mapIndex] = mapValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue