mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-22 04:14:04 +00:00
[General] Set any settings from the Game category with the GAME_SETTINGS packet
This commit is contained in:
parent
9d3afc019a
commit
bb8182663f
5 changed files with 78 additions and 3 deletions
|
@ -65,7 +65,21 @@ void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
|
||||||
player->waitAllowed = 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;
|
Player *player;
|
||||||
GET_PLAYER(pid, 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);
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS);
|
||||||
packet->setPlayer(player);
|
packet->setPlayer(player);
|
||||||
|
|
||||||
|
if (!skipAttachedPlayer)
|
||||||
packet->Send(false);
|
packet->Send(false);
|
||||||
|
if (sendToOtherPlayers)
|
||||||
|
packet->Send(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
{"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\
|
{"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\
|
||||||
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\
|
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\
|
||||||
\
|
\
|
||||||
|
{"SetGameSettingValue", SettingFunctions::SetGameSettingValue},\
|
||||||
|
{"ClearGameSettingValues", SettingFunctions::ClearGameSettingValues},\
|
||||||
|
\
|
||||||
{"SendSettings", SettingFunctions::SendSettings}
|
{"SendSettings", SettingFunctions::SendSettings}
|
||||||
|
|
||||||
class SettingFunctions
|
class SettingFunctions
|
||||||
|
@ -109,13 +112,35 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SetWaitAllowed(unsigned short pid, bool state);
|
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.
|
* \brief Send a PlayerSettings packet to the player affected by it.
|
||||||
*
|
*
|
||||||
* \param pid The player ID to send it to.
|
* \param pid The player ID to send it to.
|
||||||
* \return void
|
* \return void
|
||||||
*/
|
*/
|
||||||
static void SendSettings(unsigned short pid) noexcept;
|
static void SendSettings(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_SETTINGSAPI_HPP
|
#endif //OPENMW_SETTINGSAPI_HPP
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
class ProcessorGameSettings final: public PlayerProcessor
|
class ProcessorGameSettings final: public PlayerProcessor
|
||||||
{
|
{
|
||||||
|
const std::string GAME_SETTING_CATEGORY = "Game";
|
||||||
public:
|
public:
|
||||||
ProcessorGameSettings()
|
ProcessorGameSettings()
|
||||||
{
|
{
|
||||||
|
@ -49,6 +50,10 @@ namespace mwmp
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->setPhysicsFramerate(player->physicsFramerate);
|
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 birthsign;
|
||||||
std::string chatMessage;
|
std::string chatMessage;
|
||||||
CharGenState charGenState;
|
CharGenState charGenState;
|
||||||
|
std::map<std::string, std::string> gameSettings;
|
||||||
|
|
||||||
std::string sound;
|
std::string sound;
|
||||||
Animation animation;
|
Animation animation;
|
||||||
|
|
|
@ -20,4 +20,31 @@ void PacketGameSettings::Packet(RakNet::BitStream *newBitstream, bool send)
|
||||||
RW(player->waitAllowed, send);
|
RW(player->waitAllowed, 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 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