@@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
26
26
UnitSAO
27
27
*/
28
28
29
- UnitSAO::UnitSAO (ServerEnvironment *env, v3f pos):
30
- ServerActiveObject(env, pos)
29
+ UnitSAO::UnitSAO (ServerEnvironment *env, v3f pos) : ServerActiveObject(env, pos)
31
30
{
32
31
// Initialize something to armor groups
33
32
m_armor_groups[" fleshy" ] = 100 ;
@@ -54,7 +53,8 @@ const ItemGroupList &UnitSAO::getArmorGroups() const
54
53
return m_armor_groups;
55
54
}
56
55
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)
58
58
{
59
59
// store these so they can be updated to clients
60
60
m_animation_range = frame_range;
@@ -64,7 +64,8 @@ void UnitSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend
64
64
m_animation_sent = false ;
65
65
}
66
66
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)
68
69
{
69
70
*frame_range = m_animation_range;
70
71
*frame_speed = m_animation_speed;
@@ -91,14 +92,15 @@ void UnitSAO::getBonePosition(const std::string &bone, v3f *position, v3f *rotat
91
92
*rotation = m_bone_position[bone].Y ;
92
93
}
93
94
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)
95
97
{
96
98
// 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
102
104
// even if players only see the client changes.
103
105
104
106
int old_parent = m_attachment_parent_id;
@@ -114,8 +116,8 @@ void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position
114
116
}
115
117
}
116
118
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
119
121
{
120
122
*parent_id = m_attachment_parent_id;
121
123
*bone = m_attachment_bone;
@@ -194,7 +196,7 @@ void UnitSAO::onDetach(int parent_id)
194
196
m_env->getScriptIface ()->luaentity_on_detach_child (parent_id, this );
195
197
}
196
198
197
- ObjectProperties* UnitSAO::accessObjectProperties ()
199
+ ObjectProperties * UnitSAO::accessObjectProperties ()
198
200
{
199
201
return &m_prop;
200
202
}
@@ -217,8 +219,8 @@ std::string UnitSAO::generateUpdateAttachmentCommand() const
217
219
return os.str ();
218
220
}
219
221
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)
222
224
{
223
225
std::ostringstream os (std::ios::binary);
224
226
// command
@@ -230,7 +232,6 @@ std::string UnitSAO::generateUpdateBonePositionCommand(const std::string &bone,
230
232
return os.str ();
231
233
}
232
234
233
-
234
235
std::string UnitSAO::generateUpdateAnimationSpeedCommand () const
235
236
{
236
237
std::ostringstream os (std::ios::binary);
@@ -255,23 +256,21 @@ std::string UnitSAO::generateUpdateAnimationCommand() const
255
256
return os.str ();
256
257
}
257
258
258
-
259
259
std::string UnitSAO::generateUpdateArmorGroupsCommand () const
260
260
{
261
261
std::ostringstream os (std::ios::binary);
262
262
writeU8 (os, AO_CMD_UPDATE_ARMOR_GROUPS);
263
263
writeU16 (os, m_armor_groups.size ());
264
264
for (const auto &armor_group : m_armor_groups) {
265
- os<< serializeString (armor_group.first );
265
+ os << serializeString (armor_group.first );
266
266
writeS16 (os, armor_group.second );
267
267
}
268
268
return os.str ();
269
269
}
270
270
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)
275
274
{
276
275
std::ostringstream os (std::ios::binary);
277
276
// command
@@ -293,7 +292,6 @@ std::string UnitSAO::generateUpdatePositionCommand(const v3f &position, const v3
293
292
return os.str ();
294
293
}
295
294
296
-
297
295
std::string UnitSAO::generateSetPropertiesCommand (const ObjectProperties &prop) const
298
296
{
299
297
std::ostringstream os (std::ios::binary);
0 commit comments