[Client] Disallow clients from scaling their associated players

Additionally, display messages when trying to scale players.
remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 7 years ago
parent 8ca29dbaac
commit 59a56ca35e

@ -239,7 +239,7 @@ void DedicatedPlayer::setShapeshift()
if (!isWerewolf) if (!isWerewolf)
setEquipment(); setEquipment();
} }
MWBase::Environment::get().getWorld()->scaleObject(ptr, scale); MWBase::Environment::get().getWorld()->scaleObject(ptr, scale);
} }

@ -1596,16 +1596,6 @@ void LocalPlayer::sendBook(const std::string& bookId)
getNetworking()->getPlayerPacket(ID_PLAYER_BOOK)->Send(); getNetworking()->getPlayerPacket(ID_PLAYER_BOOK)->Send();
} }
void LocalPlayer::sendScale(float newScale)
{
scale = newScale;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_SHAPESHIFT with scale of %f", scale);
getNetworking()->getPlayerPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SHAPESHIFT)->Send();
}
void LocalPlayer::sendWerewolfState(bool werewolfState) void LocalPlayer::sendWerewolfState(bool werewolfState)
{ {
isWerewolf = werewolfState; isWerewolf = werewolfState;

@ -86,7 +86,6 @@ namespace mwmp
void sendTopic(const std::string& topic); void sendTopic(const std::string& topic);
void sendKill(const std::string& refId, int number); void sendKill(const std::string& refId, int number);
void sendBook(const std::string& bookId); void sendBook(const std::string& bookId);
void sendScale(float newScale);
void sendWerewolfState(bool isWerewolf); void sendWerewolfState(bool isWerewolf);
void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition); void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition);
void sendSelectedSpell(const std::string& newSelectedSpellId); void sendSelectedSpell(const std::string& newSelectedSpellId);

@ -6,6 +6,7 @@
Include additional headers for multiplayer purposes Include additional headers for multiplayer purposes
*/ */
#include <components/openmw-mp/Log.hpp> #include <components/openmw-mp/Log.hpp>
#include "../mwbase/windowmanager.hpp"
#include "../mwmp/Main.hpp" #include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp" #include "../mwmp/Networking.hpp"
#include "../mwmp/LocalPlayer.hpp" #include "../mwmp/LocalPlayer.hpp"
@ -59,19 +60,24 @@ namespace MWScript
/* /*
Start of tes3mp addition Start of tes3mp addition
Send an ID_PLAYER_SHAPESHIFT every time a player changes Prevent players from changing their own scale
their own scale
Otherwise, send an ID_OBJECT_SCALE every time an object's Send an ID_OBJECT_SCALE every time an object's
scale is changed through a script scale is changed through a script
*/ */
if (ptr == MWMechanics::getPlayer()) if (ptr == MWMechanics::getPlayer())
mwmp::Main::get().getLocalPlayer()->sendScale(scale); {
else if (ptr.isInCell() && (ptr.getCellRef().getScale() != scale)) MWBase::Environment::get().getWindowManager()->
messageBox("You can't change your own scale in multiplayer. Only the server can.");
}
else if (ptr.isInCell() && ptr.getCellRef().getScale() != scale)
{ {
// Ignore attempts to change another player's scale // Ignore attempts to change another player's scale
if (mwmp::PlayerList::isDedicatedPlayer(ptr)) if (mwmp::PlayerList::isDedicatedPlayer(ptr))
return; {
MWBase::Environment::get().getWindowManager()->
messageBox("You can't change the scales of other players. Only the server can.");
}
else else
{ {
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();

Loading…
Cancel
Save