aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content_sao.cpp22
-rw-r--r--src/content_sao.h9
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/server.cpp8
4 files changed, 32 insertions, 9 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 0f3b8829e..b05ad31d1 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -747,7 +747,8 @@ void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
// No prototype, PlayerSAO does not need to be deserialized
-PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_):
+PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
+ const std::set<std::string> &privs):
ServerActiveObject(env_, v3f(0,0,0)),
m_player(player_),
m_peer_id(peer_id_),
@@ -759,6 +760,8 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_):
m_position_not_sent(false),
m_armor_groups_sent(false),
m_properties_sent(true),
+ m_privs(privs),
+ // public
m_teleported(false),
m_inventory_not_sent(false),
m_hp_not_sent(false),
@@ -872,10 +875,19 @@ void PlayerSAO::step(float dtime, bool send_recommended)
explosion.
*/
- //float player_max_speed = BS * 4.0; // Normal speed
- float player_max_speed = BS * 20; // Fast speed
- float player_max_speed_up = BS * 20;
- player_max_speed *= 2.5; // Tolerance
+ float player_max_speed = 0;
+ float player_max_speed_up = 0;
+ if(m_privs.count("fast") != 0){
+ // Fast speed
+ player_max_speed = BS * 20;
+ player_max_speed_up = BS * 20;
+ } else {
+ // Normal speed
+ player_max_speed = BS * 4.0;
+ player_max_speed_up = BS * 4.0;
+ }
+ // Tolerance
+ player_max_speed *= 2.5;
player_max_speed_up *= 2.5;
m_last_good_position_age += dtime;
diff --git a/src/content_sao.h b/src/content_sao.h
index f3b9f8b2f..55d0637ae 100644
--- a/src/content_sao.h
+++ b/src/content_sao.h
@@ -105,7 +105,8 @@ private:
class PlayerSAO : public ServerActiveObject
{
public:
- PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_);
+ PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
+ const std::set<std::string> &privs);
~PlayerSAO();
u8 getType() const
{ return ACTIVEOBJECT_TYPE_PLAYER; }
@@ -182,6 +183,10 @@ public:
m_time_from_last_punch = 0.0;
return r;
}
+ void updatePrivileges(const std::set<std::string> &privs)
+ {
+ m_privs = privs;
+ }
private:
std::string getPropertyPacket();
@@ -198,6 +203,8 @@ private:
bool m_armor_groups_sent;
bool m_properties_sent;
struct ObjectProperties m_prop;
+ // Cached privileges for enforcement
+ std::set<std::string> m_privs;
public:
// Some flags used by Server
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index bbe447a6c..9ee088a9f 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -496,7 +496,7 @@ void LocalPlayer::applyControl(float dtime)
v3f speed = v3f(0,0,0);
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
- bool fast_allowed = m_gamedef->checkLocalPrivilege("fly");
+ bool fast_allowed = m_gamedef->checkLocalPrivilege("fast");
bool free_move = fly_allowed && g_settings->getBool("free_move");
bool fast_move = fast_allowed && g_settings->getBool("fast_move");
diff --git a/src/server.cpp b/src/server.cpp
index d6357e416..b015e103e 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4315,13 +4315,16 @@ void Server::reportPrivsModified(const std::string &name)
i = m_clients.getIterator();
i.atEnd() == false; i++){
RemoteClient *client = i.getNode()->getValue();
- SendPlayerPrivileges(client->peer_id);
+ Player *player = m_env->getPlayer(client->peer_id);
+ reportPrivsModified(player->getName());
}
} else {
Player *player = m_env->getPlayer(name.c_str());
if(!player)
return;
SendPlayerPrivileges(player->peer_id);
+ player->getPlayerSAO()->updatePrivileges(
+ getPlayerEffectivePrivs(name));
}
}
@@ -4520,7 +4523,8 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id)
/*
Create a new player active object
*/
- PlayerSAO *playersao = new PlayerSAO(m_env, player, peer_id);
+ PlayerSAO *playersao = new PlayerSAO(m_env, player, peer_id,
+ getPlayerEffectivePrivs(player->getName()));
/* Add object to environment */
m_env->addActiveObject(playersao);