Merge branch '0.8.1' of https://github.com/TES3MP/TES3MP into 0.8.1-vr

pull/619/head
David Cernat 3 years ago
commit bdebe0fc1a

@ -78,6 +78,20 @@ void SettingFunctions::ClearGameSettingValues(unsigned short pid) {
player->gameSettings.clear(); 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 void SettingFunctions::SendSettings(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{ {
Player *player; Player *player;

@ -16,6 +16,9 @@
{"SetGameSettingValue", SettingFunctions::SetGameSettingValue},\ {"SetGameSettingValue", SettingFunctions::SetGameSettingValue},\
{"ClearGameSettingValues", SettingFunctions::ClearGameSettingValues},\ {"ClearGameSettingValues", SettingFunctions::ClearGameSettingValues},\
\ \
{"SetVRSettingValue", SettingFunctions::SetVRSettingValue},\
{"ClearVRSettingValues", SettingFunctions::ClearVRSettingValues},\
\
{"SendSettings", SettingFunctions::SendSettings} {"SendSettings", SettingFunctions::SendSettings}
class SettingFunctions class SettingFunctions
@ -125,15 +128,37 @@ public:
static void SetGameSettingValue(unsigned short pid, const char* setting, const char* value); 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. * \param pid The player ID.
* \return void * \return void
*/ */
static void ClearGameSettingValues(unsigned short pid); 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. * \brief Send a PlayerSettings packet to the player affected by it.
* *

@ -12,6 +12,7 @@ namespace mwmp
class ProcessorGameSettings final: public PlayerProcessor class ProcessorGameSettings final: public PlayerProcessor
{ {
const std::string GAME_SETTING_CATEGORY = "Game"; const std::string GAME_SETTING_CATEGORY = "Game";
const std::string VR_SETTING_CATEGORY = "VR";
public: public:
ProcessorGameSettings() ProcessorGameSettings()
{ {
@ -51,9 +52,18 @@ namespace mwmp
MWBase::Environment::get().getWorld()->setPhysicsFramerate(player->physicsFramerate); 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); 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; std::string chatMessage;
CharGenState charGenState; CharGenState charGenState;
std::map<std::string, std::string> gameSettings; std::map<std::string, std::string> gameSettings;
std::map<std::string, std::string> vrSettings;
std::string sound; std::string sound;
Animation animation; Animation animation;

@ -21,12 +21,12 @@ void PacketGameSettings::Packet(RakNet::BitStream *newBitstream, bool send)
RW(player->enforcedLogLevel, send); RW(player->enforcedLogLevel, send);
RW(player->physicsFramerate, send); RW(player->physicsFramerate, send);
uint32_t gameSettingCount = static_cast<uint32_t>(player->gameSettings.size());
RW(gameSettingCount, send);
std::string mapIndex; std::string mapIndex;
std::string mapValue; std::string mapValue;
uint32_t gameSettingCount = static_cast<uint32_t>(player->gameSettings.size());
RW(gameSettingCount, send);
if (send) if (send)
{ {
for (auto&& gameSetting : player->gameSettings) for (auto&& gameSetting : player->gameSettings)
@ -47,4 +47,28 @@ void PacketGameSettings::Packet(RakNet::BitStream *newBitstream, bool send)
player->gameSettings[mapIndex] = mapValue; 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…
Cancel
Save