mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:15:31 +00:00
Merge remote-tracking branch 'uramer/0.7.1-game-settings' into 0.7.1
This commit is contained in:
commit
06a3604f9e
5 changed files with 78 additions and 3 deletions
|
@ -65,7 +65,21 @@ void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
|
|||
player->waitAllowed = state;
|
||||
}
|
||||
|
||||
void SettingFunctions::SendSettings(unsigned short pid) noexcept
|
||||
void SettingFunctions::SetGameSettingValue(unsigned short pid, const char* setting, const char* value) {
|
||||
Player* player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->gameSettings[setting] = value;
|
||||
}
|
||||
|
||||
void SettingFunctions::ClearGameSettingValues(unsigned short pid) {
|
||||
Player* player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->gameSettings.clear();
|
||||
}
|
||||
|
||||
void SettingFunctions::SendSettings(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
@ -73,5 +87,8 @@ void SettingFunctions::SendSettings(unsigned short pid) noexcept
|
|||
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS);
|
||||
packet->setPlayer(player);
|
||||
|
||||
packet->Send(false);
|
||||
if (!skipAttachedPlayer)
|
||||
packet->Send(false);
|
||||
if (sendToOtherPlayers)
|
||||
packet->Send(true);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
{"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\
|
||||
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\
|
||||
\
|
||||
{"SetGameSettingValue", SettingFunctions::SetGameSettingValue},\
|
||||
{"ClearGameSettingValues", SettingFunctions::ClearGameSettingValues},\
|
||||
\
|
||||
{"SendSettings", SettingFunctions::SendSettings}
|
||||
|
||||
class SettingFunctions
|
||||
|
@ -109,13 +112,35 @@ public:
|
|||
*/
|
||||
static void SetWaitAllowed(unsigned short pid, bool state);
|
||||
|
||||
/**
|
||||
* \brief Set value for a game setting.
|
||||
*
|
||||
* This overrides the setting value set in OpenMW Launcher. Only applies to the Game category.
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \param setting Name of a setting in the Game category
|
||||
* \param value Value of the setting (as a string)
|
||||
* \return void
|
||||
*/
|
||||
static void SetGameSettingValue(unsigned short pid, const char* setting, const char* value);
|
||||
|
||||
/**
|
||||
* \brief Clear the settings values
|
||||
*
|
||||
* Clear any changes done by SetGameSettingValue
|
||||
*
|
||||
* \param pid The player ID.
|
||||
* \return void
|
||||
*/
|
||||
static void ClearGameSettingValues(unsigned short pid);
|
||||
|
||||
/**
|
||||
* \brief Send a PlayerSettings packet to the player affected by it.
|
||||
*
|
||||
* \param pid The player ID to send it to.
|
||||
* \return void
|
||||
*/
|
||||
static void SendSettings(unsigned short pid) noexcept;
|
||||
static void SendSettings(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
|
||||
};
|
||||
|
||||
#endif //OPENMW_SETTINGSAPI_HPP
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace mwmp
|
|||
{
|
||||
class ProcessorGameSettings final: public PlayerProcessor
|
||||
{
|
||||
const std::string GAME_SETTING_CATEGORY = "Game";
|
||||
public:
|
||||
ProcessorGameSettings()
|
||||
{
|
||||
|
@ -49,6 +50,10 @@ namespace mwmp
|
|||
}
|
||||
|
||||
MWBase::Environment::get().getWorld()->setPhysicsFramerate(player->physicsFramerate);
|
||||
|
||||
for (auto setting : player->gameSettings) {
|
||||
Settings::Manager::setString(setting.first, GAME_SETTING_CATEGORY, setting.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -250,6 +250,7 @@ namespace mwmp
|
|||
std::string birthsign;
|
||||
std::string chatMessage;
|
||||
CharGenState charGenState;
|
||||
std::map<std::string, std::string> gameSettings;
|
||||
|
||||
std::string sound;
|
||||
Animation animation;
|
||||
|
|
|
@ -20,4 +20,31 @@ void PacketGameSettings::Packet(RakNet::BitStream *newBitstream, bool send)
|
|||
RW(player->waitAllowed, 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;
|
||||
|
||||
if (send)
|
||||
{
|
||||
for (auto&& gameSetting : player->gameSettings)
|
||||
{
|
||||
mapIndex = gameSetting.first;
|
||||
mapValue = gameSetting.second;
|
||||
RW(mapIndex, send, false);
|
||||
RW(mapValue, send, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player->gameSettings.clear();
|
||||
for (unsigned int n = 0; n < gameSettingCount; n++)
|
||||
{
|
||||
RW(mapIndex, send, false);
|
||||
RW(mapValue, send, false);
|
||||
player->gameSettings[mapIndex] = mapValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue