Skip to content

Commit c99e8df

Browse files
committedApr 11, 2020
pass clang-format
1 parent 2a7267f commit c99e8df

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed
 

Diff for: ‎src/server/unit_sao.cpp

+21-23
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
UnitSAO
2727
*/
2828

29-
UnitSAO::UnitSAO(ServerEnvironment *env, v3f pos):
30-
ServerActiveObject(env, pos)
29+
UnitSAO::UnitSAO(ServerEnvironment *env, v3f pos) : ServerActiveObject(env, pos)
3130
{
3231
// Initialize something to armor groups
3332
m_armor_groups["fleshy"] = 100;
@@ -54,7 +53,8 @@ const ItemGroupList &UnitSAO::getArmorGroups() const
5453
return m_armor_groups;
5554
}
5655

57-
void UnitSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop)
56+
void UnitSAO::setAnimation(
57+
v2f frame_range, float frame_speed, float frame_blend, bool frame_loop)
5858
{
5959
// store these so they can be updated to clients
6060
m_animation_range = frame_range;
@@ -64,7 +64,8 @@ void UnitSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend
6464
m_animation_sent = false;
6565
}
6666

67-
void UnitSAO::getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop)
67+
void UnitSAO::getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend,
68+
bool *frame_loop)
6869
{
6970
*frame_range = m_animation_range;
7071
*frame_speed = m_animation_speed;
@@ -91,14 +92,15 @@ void UnitSAO::getBonePosition(const std::string &bone, v3f *position, v3f *rotat
9192
*rotation = m_bone_position[bone].Y;
9293
}
9394

94-
void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation)
95+
void UnitSAO::setAttachment(
96+
int parent_id, const std::string &bone, v3f position, v3f rotation)
9597
{
9698
// Attachments need to be handled on both the server and client.
97-
// If we just attach on the server, we can only copy the position of the parent. Attachments
98-
// are still sent to clients at an interval so players might see them lagging, plus we can't
99-
// read and attach to skeletal bones.
100-
// If we just attach on the client, the server still sees the child at its original location.
101-
// This breaks some things so we also give the server the most accurate representation
99+
// If we just attach on the server, we can only copy the position of the parent.
100+
// Attachments are still sent to clients at an interval so players might see them
101+
// lagging, plus we can't read and attach to skeletal bones. If we just attach on
102+
// the client, the server still sees the child at its original location. This
103+
// breaks some things so we also give the server the most accurate representation
102104
// even if players only see the client changes.
103105

104106
int old_parent = m_attachment_parent_id;
@@ -114,8 +116,8 @@ void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position
114116
}
115117
}
116118

117-
void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
118-
v3f *rotation) const
119+
void UnitSAO::getAttachment(
120+
int *parent_id, std::string *bone, v3f *position, v3f *rotation) const
119121
{
120122
*parent_id = m_attachment_parent_id;
121123
*bone = m_attachment_bone;
@@ -194,7 +196,7 @@ void UnitSAO::onDetach(int parent_id)
194196
m_env->getScriptIface()->luaentity_on_detach_child(parent_id, this);
195197
}
196198

197-
ObjectProperties* UnitSAO::accessObjectProperties()
199+
ObjectProperties *UnitSAO::accessObjectProperties()
198200
{
199201
return &m_prop;
200202
}
@@ -217,8 +219,8 @@ std::string UnitSAO::generateUpdateAttachmentCommand() const
217219
return os.str();
218220
}
219221

220-
std::string UnitSAO::generateUpdateBonePositionCommand(const std::string &bone,
221-
const v3f &position, const v3f &rotation)
222+
std::string UnitSAO::generateUpdateBonePositionCommand(
223+
const std::string &bone, const v3f &position, const v3f &rotation)
222224
{
223225
std::ostringstream os(std::ios::binary);
224226
// command
@@ -230,7 +232,6 @@ std::string UnitSAO::generateUpdateBonePositionCommand(const std::string &bone,
230232
return os.str();
231233
}
232234

233-
234235
std::string UnitSAO::generateUpdateAnimationSpeedCommand() const
235236
{
236237
std::ostringstream os(std::ios::binary);
@@ -255,23 +256,21 @@ std::string UnitSAO::generateUpdateAnimationCommand() const
255256
return os.str();
256257
}
257258

258-
259259
std::string UnitSAO::generateUpdateArmorGroupsCommand() const
260260
{
261261
std::ostringstream os(std::ios::binary);
262262
writeU8(os, AO_CMD_UPDATE_ARMOR_GROUPS);
263263
writeU16(os, m_armor_groups.size());
264264
for (const auto &armor_group : m_armor_groups) {
265-
os<<serializeString(armor_group.first);
265+
os << serializeString(armor_group.first);
266266
writeS16(os, armor_group.second);
267267
}
268268
return os.str();
269269
}
270270

271-
272-
std::string UnitSAO::generateUpdatePositionCommand(const v3f &position, const v3f &velocity,
273-
const v3f &acceleration, const v3f &rotation, bool do_interpolate, bool is_movement_end,
274-
f32 update_interval)
271+
std::string UnitSAO::generateUpdatePositionCommand(const v3f &position,
272+
const v3f &velocity, const v3f &acceleration, const v3f &rotation,
273+
bool do_interpolate, bool is_movement_end, f32 update_interval)
275274
{
276275
std::ostringstream os(std::ios::binary);
277276
// command
@@ -293,7 +292,6 @@ std::string UnitSAO::generateUpdatePositionCommand(const v3f &position, const v3
293292
return os.str();
294293
}
295294

296-
297295
std::string UnitSAO::generateSetPropertiesCommand(const ObjectProperties &prop) const
298296
{
299297
std::ostringstream os(std::ios::binary);

Diff for: ‎src/server/unit_sao.h

+17-12
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323
#include "object_properties.h"
2424
#include "serveractiveobject.h"
2525

26-
class UnitSAO: public ServerActiveObject
26+
class UnitSAO : public ServerActiveObject
2727
{
2828
public:
2929
UnitSAO(ServerEnvironment *env, v3f pos);
@@ -40,20 +40,24 @@ class UnitSAO: public ServerActiveObject
4040
// Use a function, if isDead can be defined by other conditions
4141
bool isDead() const { return m_hp == 0; }
4242

43-
inline bool isAttached() const
44-
{ return getParent(); }
43+
inline bool isAttached() const { return getParent(); }
4544

4645
inline bool isImmortal() const
47-
{ return itemgroup_get(getArmorGroups(), "immortal"); }
46+
{
47+
return itemgroup_get(getArmorGroups(), "immortal");
48+
}
4849

4950
void setArmorGroups(const ItemGroupList &armor_groups);
5051
const ItemGroupList &getArmorGroups() const;
51-
void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop);
52-
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
52+
void setAnimation(v2f frame_range, float frame_speed, float frame_blend,
53+
bool frame_loop);
54+
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend,
55+
bool *frame_loop);
5356
void setAnimationSpeed(float frame_speed);
5457
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
5558
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
56-
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
59+
void setAttachment(int parent_id, const std::string &bone, v3f position,
60+
v3f rotation);
5761
void getAttachment(int *parent_id, std::string *bone, v3f *position,
5862
v3f *rotation) const;
5963
void clearChildAttachments();
@@ -62,20 +66,20 @@ class UnitSAO: public ServerActiveObject
6266
void removeAttachmentChild(int child_id);
6367
const std::unordered_set<int> &getAttachmentChildIds() const;
6468
ServerActiveObject *getParent() const;
65-
ObjectProperties* accessObjectProperties();
69+
ObjectProperties *accessObjectProperties();
6670
void notifyObjectPropertiesModified();
6771

6872
std::string generateUpdateAttachmentCommand() const;
6973
std::string generateUpdateAnimationSpeedCommand() const;
7074
std::string generateUpdateAnimationCommand() const;
7175
std::string generateUpdateArmorGroupsCommand() const;
72-
static std::string generateUpdatePositionCommand(const v3f &position, const v3f &velocity,
73-
const v3f &acceleration, const v3f &rotation, bool do_interpolate,
74-
bool is_movement_end, f32 update_interval);
76+
static std::string generateUpdatePositionCommand(const v3f &position,
77+
const v3f &velocity, const v3f &acceleration, const v3f &rotation,
78+
bool do_interpolate, bool is_movement_end, f32 update_interval);
7579
std::string generateSetPropertiesCommand(const ObjectProperties &prop) const;
7680
void sendPunchCommand();
7781
static std::string generateUpdateBonePositionCommand(const std::string &bone,
78-
const v3f &position, const v3f &rotation);
82+
const v3f &position, const v3f &rotation);
7983

8084
protected:
8185
u16 m_hp = 1;
@@ -105,6 +109,7 @@ class UnitSAO: public ServerActiveObject
105109
v3f m_attachment_position;
106110
v3f m_attachment_rotation;
107111
bool m_attachment_sent = false;
112+
108113
private:
109114
void onAttach(int parent_id);
110115
void onDetach(int parent_id);

0 commit comments

Comments
 (0)
Please sign in to comment.