@@ -24,14 +24,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
24
24
#include " serverobject.h"
25
25
#include " itemgroup.h"
26
26
#include " object_properties.h"
27
- #include " constants.h"
28
27
29
28
class UnitSAO : public ServerActiveObject
30
29
{
31
30
public:
32
- UnitSAO (ServerEnvironment *env, v3f pos):
33
- ServerActiveObject (env, pos),
34
- m_hp (-1 ), m_yaw(0 ) {}
31
+ UnitSAO (ServerEnvironment *env, v3f pos);
35
32
virtual ~UnitSAO () {}
36
33
37
34
virtual void setYaw (const float yaw) { m_yaw = yaw; }
@@ -46,6 +43,29 @@ class UnitSAO: public ServerActiveObject
46
43
protected:
47
44
s16 m_hp;
48
45
float m_yaw;
46
+
47
+ bool m_properties_sent;
48
+ struct ObjectProperties m_prop;
49
+
50
+ ItemGroupList m_armor_groups;
51
+ bool m_armor_groups_sent;
52
+
53
+ v2f m_animation_range;
54
+ float m_animation_speed;
55
+ float m_animation_blend;
56
+ bool m_animation_loop;
57
+ bool m_animation_sent;
58
+
59
+ // Stores position and rotation for each bone name
60
+ UNORDERED_MAP<std::string, core::vector2d<v3f> > m_bone_position;
61
+ bool m_bone_position_sent;
62
+
63
+ int m_attachment_parent_id;
64
+ UNORDERED_SET<int > m_attachment_child_ids;
65
+ std::string m_attachment_bone;
66
+ v3f m_attachment_position;
67
+ v3f m_attachment_rotation;
68
+ bool m_attachment_sent;
49
69
};
50
70
51
71
/*
@@ -81,7 +101,7 @@ class LuaEntitySAO : public UnitSAO
81
101
void setHP (s16 hp);
82
102
s16 getHP () const ;
83
103
void setArmorGroups (const ItemGroupList &armor_groups);
84
- ItemGroupList getArmorGroups ();
104
+ const ItemGroupList & getArmorGroups ();
85
105
void setAnimation (v2f frame_range, float frame_speed, float frame_blend, bool frame_loop);
86
106
void getAnimation (v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
87
107
void setBonePosition (const std::string &bone, v3f position, v3f rotation);
@@ -90,7 +110,7 @@ class LuaEntitySAO : public UnitSAO
90
110
void getAttachment (int *parent_id, std::string *bone, v3f *position, v3f *rotation);
91
111
void addAttachmentChild (int child_id);
92
112
void removeAttachmentChild (int child_id);
93
- UNORDERED_SET<int > getAttachmentChildIds ();
113
+ const UNORDERED_SET<int > & getAttachmentChildIds ();
94
114
ObjectProperties* accessObjectProperties ();
95
115
void notifyObjectPropertiesModified ();
96
116
/* LuaEntitySAO-specific */
@@ -103,45 +123,24 @@ class LuaEntitySAO : public UnitSAO
103
123
void setSprite (v2s16 p, int num_frames, float framelength,
104
124
bool select_horiz_by_yawpitch);
105
125
std::string getName ();
106
- bool getCollisionBox (aabb3f *toset);
107
- bool collideWithObjects ();
126
+ bool getCollisionBox (aabb3f *toset) const ;
127
+ bool collideWithObjects () const ;
108
128
private:
109
129
std::string getPropertyPacket ();
110
130
void sendPosition (bool do_interpolate, bool is_movement_end);
111
131
112
132
std::string m_init_name;
113
133
std::string m_init_state;
114
134
bool m_registered;
115
- struct ObjectProperties m_prop;
116
135
117
136
v3f m_velocity;
118
137
v3f m_acceleration;
119
138
120
- ItemGroupList m_armor_groups;
121
-
122
- bool m_properties_sent;
123
139
float m_last_sent_yaw;
124
140
v3f m_last_sent_position;
125
141
v3f m_last_sent_velocity;
126
142
float m_last_sent_position_timer;
127
143
float m_last_sent_move_precision;
128
- bool m_armor_groups_sent;
129
-
130
- v2f m_animation_range;
131
- float m_animation_speed;
132
- float m_animation_blend;
133
- bool m_animation_loop;
134
- bool m_animation_sent;
135
-
136
- UNORDERED_MAP<std::string, core::vector2d<v3f> > m_bone_position;
137
- bool m_bone_position_sent;
138
-
139
- int m_attachment_parent_id;
140
- UNORDERED_SET<int > m_attachment_child_ids;
141
- std::string m_attachment_bone;
142
- v3f m_attachment_position;
143
- v3f m_attachment_rotation;
144
- bool m_attachment_sent;
145
144
};
146
145
147
146
/*
@@ -235,7 +234,7 @@ class PlayerSAO : public UnitSAO
235
234
u16 getBreath () const { return m_breath; }
236
235
void setBreath (const u16 breath, bool send = true );
237
236
void setArmorGroups (const ItemGroupList &armor_groups);
238
- ItemGroupList getArmorGroups ();
237
+ const ItemGroupList & getArmorGroups ();
239
238
void setAnimation (v2f frame_range, float frame_speed, float frame_blend, bool frame_loop);
240
239
void getAnimation (v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
241
240
void setBonePosition (const std::string &bone, v3f position, v3f rotation);
@@ -244,7 +243,7 @@ class PlayerSAO : public UnitSAO
244
243
void getAttachment (int *parent_id, std::string *bone, v3f *position, v3f *rotation);
245
244
void addAttachmentChild (int child_id);
246
245
void removeAttachmentChild (int child_id);
247
- UNORDERED_SET<int > getAttachmentChildIds ();
246
+ const UNORDERED_SET<int > & getAttachmentChildIds ();
248
247
ObjectProperties* accessObjectProperties ();
249
248
void notifyObjectPropertiesModified ();
250
249
@@ -315,13 +314,13 @@ class PlayerSAO : public UnitSAO
315
314
m_is_singleplayer = is_singleplayer;
316
315
}
317
316
318
- bool getCollisionBox (aabb3f *toset);
319
- bool collideWithObjects ();
317
+ bool getCollisionBox (aabb3f *toset) const ;
318
+ bool collideWithObjects () const { return true ; }
320
319
321
320
void initialize (RemotePlayer *player, const std::set<std::string> &privs);
322
321
323
322
v3f getEyePosition () const { return m_base_position + getEyeOffset (); }
324
- v3f getEyeOffset () const { return v3f ( 0 , BS * 1 . 625f , 0 ); }
323
+ v3f getEyeOffset () const ;
325
324
326
325
private:
327
326
std::string getPropertyPacket ();
@@ -346,31 +345,11 @@ class PlayerSAO : public UnitSAO
346
345
347
346
int m_wield_index;
348
347
bool m_position_not_sent;
349
- ItemGroupList m_armor_groups;
350
- bool m_armor_groups_sent;
351
348
352
- bool m_properties_sent;
353
- struct ObjectProperties m_prop;
354
349
// Cached privileges for enforcement
355
350
std::set<std::string> m_privs;
356
351
bool m_is_singleplayer;
357
352
358
- v2f m_animation_range;
359
- float m_animation_speed;
360
- float m_animation_blend;
361
- bool m_animation_loop;
362
- bool m_animation_sent;
363
-
364
- // Stores position and rotation for each bone name
365
- UNORDERED_MAP<std::string, core::vector2d<v3f> > m_bone_position;
366
- bool m_bone_position_sent;
367
-
368
- int m_attachment_parent_id;
369
- UNORDERED_SET<int > m_attachment_child_ids;
370
- std::string m_attachment_bone;
371
- v3f m_attachment_position;
372
- v3f m_attachment_rotation;
373
- bool m_attachment_sent;
374
353
u16 m_breath;
375
354
f32 m_pitch;
376
355
f32 m_fov;
0 commit comments