// 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_),
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),
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;
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; }
m_time_from_last_punch = 0.0;
return r;
}
+ void updatePrivileges(const std::set<std::string> &privs)
+ {
+ m_privs = privs;
+ }
private:
std::string getPropertyPacket();
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
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");
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));
}
}
/*
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);