summaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-31 17:08:39 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-31 17:08:39 +0300
commit13159c1a48690d4ede3dbabc7699ea3d49072860 (patch)
tree7a5458d911bbc0e13cdadf0afc6b63a904b4a785 /src/content_sao.cpp
parent0fbef74f3159422bc4a299226ab05692218f2c3b (diff)
downloadminetest-13159c1a48690d4ede3dbabc7699ea3d49072860.tar.gz
minetest-13159c1a48690d4ede3dbabc7699ea3d49072860.tar.bz2
minetest-13159c1a48690d4ede3dbabc7699ea3d49072860.zip
Add server-side enforcement of the 'fast' privilege; also fix client checking 'fly' instead of 'fast'
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r--src/content_sao.cpp22
1 files changed, 17 insertions, 5 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;