mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 02:49:55 +00:00
6a3fbf4e98
Previously, there was a confusing separation between script functions that had a "broadcast" argument and script functions that had a "toOthers" argument. Those with broadcast sent the packet to all players on the server when broadcast was true. Those with toOthers sent the packet to all players other than the packet's attached player. The former was based on the pattern of the original SendMessage() script function. The latter more closely resembled RakNet's own broadcast argument as seen here: https://github.com/TES3MP/CrabNet/blob/master/include/raknet/RakPeer.h#L219 This commit makes it so all sending functions have a sendToOtherPlayers argument that is false by default and a sendToAttachedPlayer that is true by default. This should simultaneously allow sending to be more intuitive, while not breaking previous existing scripts to a significant degree. Additionally, this commit also reduces some code repetition for all instances of packet-fetching in script functions.
77 lines
1.7 KiB
C++
77 lines
1.7 KiB
C++
#include "Settings.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include <components/openmw-mp/Log.hpp>
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->difficulty = difficulty;
|
|
}
|
|
|
|
void SettingFunctions::SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel)
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->enforcedLogLevel = enforcedLogLevel;
|
|
}
|
|
|
|
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;
|
|
GET_PLAYER(pid, player,);
|
|
|
|
player->consoleAllowed = state;
|
|
}
|
|
|
|
void SettingFunctions::SetBedRestAllowed(unsigned short pid, bool state)
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->bedRestAllowed = state;
|
|
}
|
|
|
|
void SettingFunctions::SetWildernessRestAllowed(unsigned short pid, bool state)
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->wildernessRestAllowed = state;
|
|
}
|
|
|
|
void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
player->waitAllowed = state;
|
|
}
|
|
|
|
void SettingFunctions::SendSettings(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player,);
|
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS);
|
|
packet->setPlayer(player);
|
|
|
|
packet->Send(false);
|
|
}
|