Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: SmallJoker <[email protected]>
  • Loading branch information
appgurueu and SmallJoker authored Jun 11, 2022
1 parent 740cfbe commit 2216b92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/lua_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6727,7 +6727,7 @@ object you are working with still exists.
object.
* `set_detach()`
* `set_bone_position([bone, position, rotation])`
* Shorthand for `set_bone_override(bone, {position = {x = position.x, y = position.y, z = position.z, absolute = true}, rotation = {x = rotation.x, y = rotation.y, z = rotation.z, absolute = true}})`
* Shorthand for `set_bone_override(bone, {position = ..., rotation = ...})` using absolute values.
* Supports older servers & clients (< 5.6)
* **Deprecated**, use `set_bone_override` instead
* `get_bone_position(bone)`: returns position and rotation of the bone
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ int ObjectRef::l_set_bone_override(lua_State *L)
if (!lua_isnil(L, 2))
bone = readParam<std::string>(L, 2);
BoneOverride *override = new BoneOverride();
if (lua_isnil(L, 3) || lua_isnone(L, 3)) {
if (lua_isnoneornil(L, 3)) {
sao->setBoneOverride(bone, override);
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/unit_sao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ std::string UnitSAO::generateUpdateBonePositionCommand(
writeF32(os, override->rotation.interpolation_duration);
writeF32(os, override->scale.interpolation_duration);
// clang-format off
writeU8(os, override->position.absolute * 1
+ override->rotation.absolute * 2
+ override->scale.absolute * 4);
writeU8(os, (override->position.absolute & 1) << 0
| (override->rotation.absolute & 1) << 1
| (override->scale.absolute & 1) << 2);
// clang-format on
return os.str();
}
Expand Down
3 changes: 1 addition & 2 deletions src/server/unit_sao.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class UnitSAO : public ServerActiveObject
// Bone position
void setBoneOverride(const std::string &bone, BoneOverride *override);
BoneOverride *getBoneOverride(const std::string &bone);
const std::unordered_map<std::string, BoneOverride*> &
getBoneOverrides() const;
const std::unordered_map<std::string, BoneOverride*> &getBoneOverrides() const;

// Attachments
ServerActiveObject *getParent() const;
Expand Down

0 comments on commit 2216b92

Please sign in to comment.