Zoom: Move enabling zoom to a new player object property

Default enabled for no change in default behaviour.
Remove 'zoom' privilege.
master
paramat 2017-08-28 22:46:12 +01:00 committed by paramat
parent bd6b90359c
commit 561a01cc2a
8 changed files with 20 additions and 11 deletions

View File

@ -82,10 +82,6 @@ core.register_privilege("rollback", {
description = "Can use the rollback functionality", description = "Can use the rollback functionality",
give_to_singleplayer = false, give_to_singleplayer = false,
}) })
core.register_privilege("zoom", {
description = "Can zoom the camera",
give_to_singleplayer = false,
})
core.register_privilege("debug", { core.register_privilege("debug", {
description = "Allows enabling various debug options that may affect gameplay", description = "Allows enabling various debug options that may affect gameplay",
give_to_singleplayer = false, give_to_singleplayer = false,

View File

@ -453,7 +453,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
// Get FOV // Get FOV
f32 fov_degrees; f32 fov_degrees;
if (player->getPlayerControl().zoom && m_client->checkLocalPrivilege("zoom")) { if (player->getPlayerControl().zoom && player->getCanZoom()) {
fov_degrees = m_cache_zoom_fov; fov_degrees = m_cache_zoom_fov;
} else { } else {
fov_degrees = m_cache_fov; fov_degrees = m_cache_fov;

View File

@ -1239,6 +1239,7 @@ void GenericCAO::processMessage(const std::string &data)
collision_box.MinEdge *= BS; collision_box.MinEdge *= BS;
collision_box.MaxEdge *= BS; collision_box.MaxEdge *= BS;
player->setCollisionbox(collision_box); player->setCollisionbox(collision_box);
player->setCanZoom(m_prop.can_zoom);
} }
if ((m_is_player && !m_is_local_player) && m_prop.nametag.empty()) if ((m_is_player && !m_is_local_player) && m_prop.nametag.empty())

View File

@ -801,6 +801,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
m_prop.is_visible = true; m_prop.is_visible = true;
m_prop.makes_footstep_sound = true; m_prop.makes_footstep_sound = true;
m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS; m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS;
m_prop.can_zoom = true;
m_hp = m_prop.hp_max; m_hp = m_prop.hp_max;
} }

View File

@ -124,11 +124,9 @@ public:
v3s16 getLightPosition() const; v3s16 getLightPosition() const;
void setYaw(f32 yaw) { m_yaw = yaw; } void setYaw(f32 yaw) { m_yaw = yaw; }
f32 getYaw() const { return m_yaw; } f32 getYaw() const { return m_yaw; }
void setPitch(f32 pitch) { m_pitch = pitch; } void setPitch(f32 pitch) { m_pitch = pitch; }
f32 getPitch() const { return m_pitch; } f32 getPitch() const { return m_pitch; }
inline void setPosition(const v3f &position) inline void setPosition(const v3f &position)
@ -143,6 +141,9 @@ public:
void setCollisionbox(const aabb3f &box) { m_collisionbox = box; } void setCollisionbox(const aabb3f &box) { m_collisionbox = box; }
bool getCanZoom() const { return m_can_zoom; }
void setCanZoom(bool can_zoom) { m_can_zoom = can_zoom; }
private: private:
void accelerateHorizontal(const v3f &target_speed, const f32 max_increase); void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
void accelerateVertical(const v3f &target_speed, const f32 max_increase); void accelerateVertical(const v3f &target_speed, const f32 max_increase);
@ -178,6 +179,7 @@ private:
bool camera_barely_in_ceiling = false; bool camera_barely_in_ceiling = false;
aabb3f m_collisionbox = aabb3f(-BS * 0.30f, 0.0f, -BS * 0.30f, BS * 0.30f, aabb3f m_collisionbox = aabb3f(-BS * 0.30f, 0.0f, -BS * 0.30f, BS * 0.30f,
BS * 1.75f, BS * 0.30f); BS * 1.75f, BS * 0.30f);
bool m_can_zoom = true;
GenericCAO *m_cao = nullptr; GenericCAO *m_cao = nullptr;
Client *m_client; Client *m_client;

View File

@ -63,6 +63,7 @@ std::string ObjectProperties::dump()
<< "," << nametag_color.getGreen() << "," << nametag_color.getBlue() << "\" "; << "," << nametag_color.getGreen() << "," << nametag_color.getBlue() << "\" ";
os << ", selectionbox=" << PP(selectionbox.MinEdge) << "," << PP(selectionbox.MaxEdge); os << ", selectionbox=" << PP(selectionbox.MinEdge) << "," << PP(selectionbox.MaxEdge);
os << ", pointable=" << pointable; os << ", pointable=" << pointable;
os << ", can_zoom=" << can_zoom;
return os.str(); return os.str();
} }
@ -104,6 +105,7 @@ void ObjectProperties::serialize(std::ostream &os) const
writeF1000(os, automatic_face_movement_max_rotation_per_sec); writeF1000(os, automatic_face_movement_max_rotation_per_sec);
os << serializeString(infotext); os << serializeString(infotext);
os << serializeString(wield_item); os << serializeString(wield_item);
writeU8(os, can_zoom);
// Add stuff only at the bottom. // Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this // Never remove anything, because we don't want new versions of this
@ -150,4 +152,5 @@ void ObjectProperties::deSerialize(std::istream &is)
automatic_face_movement_max_rotation_per_sec = readF1000(is); automatic_face_movement_max_rotation_per_sec = readF1000(is);
infotext = deSerializeString(is); infotext = deSerializeString(is);
wield_item = deSerializeString(is); wield_item = deSerializeString(is);
can_zoom = readU8(is);
} }

View File

@ -44,8 +44,9 @@ struct ObjectProperties
v2s16 initial_sprite_basepos; v2s16 initial_sprite_basepos;
bool is_visible = true; bool is_visible = true;
bool makes_footstep_sound = false; bool makes_footstep_sound = false;
float automatic_rotate = 0.0f;
f32 stepheight = 0.0f; f32 stepheight = 0.0f;
bool can_zoom = true;
float automatic_rotate = 0.0f;
bool automatic_face_movement_dir = false; bool automatic_face_movement_dir = false;
f32 automatic_face_movement_dir_offset = 0.0f; f32 automatic_face_movement_dir_offset = 0.0f;
bool backface_culling = true; bool backface_culling = true;

View File

@ -260,9 +260,11 @@ void read_object_properties(lua_State *L, int index,
getboolfield(L, -1, "is_visible", prop->is_visible); getboolfield(L, -1, "is_visible", prop->is_visible);
getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound); getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound);
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
if (getfloatfield(L, -1, "stepheight", prop->stepheight)) if (getfloatfield(L, -1, "stepheight", prop->stepheight))
prop->stepheight *= BS; prop->stepheight *= BS;
getboolfield(L, -1, "can_zoom", prop->can_zoom);
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
lua_getfield(L, -1, "automatic_face_movement_dir"); lua_getfield(L, -1, "automatic_face_movement_dir");
if (lua_isnumber(L, -1)) { if (lua_isnumber(L, -1)) {
prop->automatic_face_movement_dir = true; prop->automatic_face_movement_dir = true;
@ -344,10 +346,13 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
lua_setfield(L, -2, "is_visible"); lua_setfield(L, -2, "is_visible");
lua_pushboolean(L, prop->makes_footstep_sound); lua_pushboolean(L, prop->makes_footstep_sound);
lua_setfield(L, -2, "makes_footstep_sound"); lua_setfield(L, -2, "makes_footstep_sound");
lua_pushnumber(L, prop->automatic_rotate);
lua_setfield(L, -2, "automatic_rotate");
lua_pushnumber(L, prop->stepheight / BS); lua_pushnumber(L, prop->stepheight / BS);
lua_setfield(L, -2, "stepheight"); lua_setfield(L, -2, "stepheight");
lua_pushboolean(L, prop->can_zoom);
lua_setfield(L, -2, "can_zoom");
lua_pushnumber(L, prop->automatic_rotate);
lua_setfield(L, -2, "automatic_rotate");
if (prop->automatic_face_movement_dir) if (prop->automatic_face_movement_dir)
lua_pushnumber(L, prop->automatic_face_movement_dir_offset); lua_pushnumber(L, prop->automatic_face_movement_dir_offset);
else else