forked from Mirrorlandia_minetest/minetest
pass clang-format
This commit is contained in:
parent
2a7267febf
commit
c99e8df07f
@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
UnitSAO
|
UnitSAO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
UnitSAO::UnitSAO(ServerEnvironment *env, v3f pos):
|
UnitSAO::UnitSAO(ServerEnvironment *env, v3f pos) : ServerActiveObject(env, pos)
|
||||||
ServerActiveObject(env, pos)
|
|
||||||
{
|
{
|
||||||
// Initialize something to armor groups
|
// Initialize something to armor groups
|
||||||
m_armor_groups["fleshy"] = 100;
|
m_armor_groups["fleshy"] = 100;
|
||||||
@ -54,7 +53,8 @@ const ItemGroupList &UnitSAO::getArmorGroups() const
|
|||||||
return m_armor_groups;
|
return m_armor_groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop)
|
void UnitSAO::setAnimation(
|
||||||
|
v2f frame_range, float frame_speed, float frame_blend, bool frame_loop)
|
||||||
{
|
{
|
||||||
// store these so they can be updated to clients
|
// store these so they can be updated to clients
|
||||||
m_animation_range = frame_range;
|
m_animation_range = frame_range;
|
||||||
@ -64,7 +64,8 @@ void UnitSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend
|
|||||||
m_animation_sent = false;
|
m_animation_sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitSAO::getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop)
|
void UnitSAO::getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend,
|
||||||
|
bool *frame_loop)
|
||||||
{
|
{
|
||||||
*frame_range = m_animation_range;
|
*frame_range = m_animation_range;
|
||||||
*frame_speed = m_animation_speed;
|
*frame_speed = m_animation_speed;
|
||||||
@ -91,14 +92,15 @@ void UnitSAO::getBonePosition(const std::string &bone, v3f *position, v3f *rotat
|
|||||||
*rotation = m_bone_position[bone].Y;
|
*rotation = m_bone_position[bone].Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation)
|
void UnitSAO::setAttachment(
|
||||||
|
int parent_id, const std::string &bone, v3f position, v3f rotation)
|
||||||
{
|
{
|
||||||
// Attachments need to be handled on both the server and client.
|
// Attachments need to be handled on both the server and client.
|
||||||
// If we just attach on the server, we can only copy the position of the parent. Attachments
|
// If we just attach on the server, we can only copy the position of the parent.
|
||||||
// are still sent to clients at an interval so players might see them lagging, plus we can't
|
// Attachments are still sent to clients at an interval so players might see them
|
||||||
// read and attach to skeletal bones.
|
// lagging, plus we can't read and attach to skeletal bones. If we just attach on
|
||||||
// If we just attach on the client, the server still sees the child at its original location.
|
// the client, the server still sees the child at its original location. This
|
||||||
// This breaks some things so we also give the server the most accurate representation
|
// breaks some things so we also give the server the most accurate representation
|
||||||
// even if players only see the client changes.
|
// even if players only see the client changes.
|
||||||
|
|
||||||
int old_parent = m_attachment_parent_id;
|
int old_parent = m_attachment_parent_id;
|
||||||
@ -114,8 +116,8 @@ void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
|
void UnitSAO::getAttachment(
|
||||||
v3f *rotation) const
|
int *parent_id, std::string *bone, v3f *position, v3f *rotation) const
|
||||||
{
|
{
|
||||||
*parent_id = m_attachment_parent_id;
|
*parent_id = m_attachment_parent_id;
|
||||||
*bone = m_attachment_bone;
|
*bone = m_attachment_bone;
|
||||||
@ -194,7 +196,7 @@ void UnitSAO::onDetach(int parent_id)
|
|||||||
m_env->getScriptIface()->luaentity_on_detach_child(parent_id, this);
|
m_env->getScriptIface()->luaentity_on_detach_child(parent_id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectProperties* UnitSAO::accessObjectProperties()
|
ObjectProperties *UnitSAO::accessObjectProperties()
|
||||||
{
|
{
|
||||||
return &m_prop;
|
return &m_prop;
|
||||||
}
|
}
|
||||||
@ -217,8 +219,8 @@ std::string UnitSAO::generateUpdateAttachmentCommand() const
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UnitSAO::generateUpdateBonePositionCommand(const std::string &bone,
|
std::string UnitSAO::generateUpdateBonePositionCommand(
|
||||||
const v3f &position, const v3f &rotation)
|
const std::string &bone, const v3f &position, const v3f &rotation)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// command
|
// command
|
||||||
@ -230,7 +232,6 @@ std::string UnitSAO::generateUpdateBonePositionCommand(const std::string &bone,
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string UnitSAO::generateUpdateAnimationSpeedCommand() const
|
std::string UnitSAO::generateUpdateAnimationSpeedCommand() const
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
@ -255,23 +256,21 @@ std::string UnitSAO::generateUpdateAnimationCommand() const
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string UnitSAO::generateUpdateArmorGroupsCommand() const
|
std::string UnitSAO::generateUpdateArmorGroupsCommand() const
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
writeU8(os, AO_CMD_UPDATE_ARMOR_GROUPS);
|
writeU8(os, AO_CMD_UPDATE_ARMOR_GROUPS);
|
||||||
writeU16(os, m_armor_groups.size());
|
writeU16(os, m_armor_groups.size());
|
||||||
for (const auto &armor_group : m_armor_groups) {
|
for (const auto &armor_group : m_armor_groups) {
|
||||||
os<<serializeString(armor_group.first);
|
os << serializeString(armor_group.first);
|
||||||
writeS16(os, armor_group.second);
|
writeS16(os, armor_group.second);
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UnitSAO::generateUpdatePositionCommand(const v3f &position,
|
||||||
std::string UnitSAO::generateUpdatePositionCommand(const v3f &position, const v3f &velocity,
|
const v3f &velocity, const v3f &acceleration, const v3f &rotation,
|
||||||
const v3f &acceleration, const v3f &rotation, bool do_interpolate, bool is_movement_end,
|
bool do_interpolate, bool is_movement_end, f32 update_interval)
|
||||||
f32 update_interval)
|
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// command
|
// command
|
||||||
@ -293,7 +292,6 @@ std::string UnitSAO::generateUpdatePositionCommand(const v3f &position, const v3
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string UnitSAO::generateSetPropertiesCommand(const ObjectProperties &prop) const
|
std::string UnitSAO::generateSetPropertiesCommand(const ObjectProperties &prop) const
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "object_properties.h"
|
#include "object_properties.h"
|
||||||
#include "serveractiveobject.h"
|
#include "serveractiveobject.h"
|
||||||
|
|
||||||
class UnitSAO: public ServerActiveObject
|
class UnitSAO : public ServerActiveObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UnitSAO(ServerEnvironment *env, v3f pos);
|
UnitSAO(ServerEnvironment *env, v3f pos);
|
||||||
@ -40,20 +40,24 @@ public:
|
|||||||
// Use a function, if isDead can be defined by other conditions
|
// Use a function, if isDead can be defined by other conditions
|
||||||
bool isDead() const { return m_hp == 0; }
|
bool isDead() const { return m_hp == 0; }
|
||||||
|
|
||||||
inline bool isAttached() const
|
inline bool isAttached() const { return getParent(); }
|
||||||
{ return getParent(); }
|
|
||||||
|
|
||||||
inline bool isImmortal() const
|
inline bool isImmortal() const
|
||||||
{ return itemgroup_get(getArmorGroups(), "immortal"); }
|
{
|
||||||
|
return itemgroup_get(getArmorGroups(), "immortal");
|
||||||
|
}
|
||||||
|
|
||||||
void setArmorGroups(const ItemGroupList &armor_groups);
|
void setArmorGroups(const ItemGroupList &armor_groups);
|
||||||
const ItemGroupList &getArmorGroups() const;
|
const ItemGroupList &getArmorGroups() const;
|
||||||
void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop);
|
void setAnimation(v2f frame_range, float frame_speed, float frame_blend,
|
||||||
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
|
bool frame_loop);
|
||||||
|
void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend,
|
||||||
|
bool *frame_loop);
|
||||||
void setAnimationSpeed(float frame_speed);
|
void setAnimationSpeed(float frame_speed);
|
||||||
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
||||||
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
||||||
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
|
void setAttachment(int parent_id, const std::string &bone, v3f position,
|
||||||
|
v3f rotation);
|
||||||
void getAttachment(int *parent_id, std::string *bone, v3f *position,
|
void getAttachment(int *parent_id, std::string *bone, v3f *position,
|
||||||
v3f *rotation) const;
|
v3f *rotation) const;
|
||||||
void clearChildAttachments();
|
void clearChildAttachments();
|
||||||
@ -62,16 +66,16 @@ public:
|
|||||||
void removeAttachmentChild(int child_id);
|
void removeAttachmentChild(int child_id);
|
||||||
const std::unordered_set<int> &getAttachmentChildIds() const;
|
const std::unordered_set<int> &getAttachmentChildIds() const;
|
||||||
ServerActiveObject *getParent() const;
|
ServerActiveObject *getParent() const;
|
||||||
ObjectProperties* accessObjectProperties();
|
ObjectProperties *accessObjectProperties();
|
||||||
void notifyObjectPropertiesModified();
|
void notifyObjectPropertiesModified();
|
||||||
|
|
||||||
std::string generateUpdateAttachmentCommand() const;
|
std::string generateUpdateAttachmentCommand() const;
|
||||||
std::string generateUpdateAnimationSpeedCommand() const;
|
std::string generateUpdateAnimationSpeedCommand() const;
|
||||||
std::string generateUpdateAnimationCommand() const;
|
std::string generateUpdateAnimationCommand() const;
|
||||||
std::string generateUpdateArmorGroupsCommand() const;
|
std::string generateUpdateArmorGroupsCommand() const;
|
||||||
static std::string generateUpdatePositionCommand(const v3f &position, const v3f &velocity,
|
static std::string generateUpdatePositionCommand(const v3f &position,
|
||||||
const v3f &acceleration, const v3f &rotation, bool do_interpolate,
|
const v3f &velocity, const v3f &acceleration, const v3f &rotation,
|
||||||
bool is_movement_end, f32 update_interval);
|
bool do_interpolate, bool is_movement_end, f32 update_interval);
|
||||||
std::string generateSetPropertiesCommand(const ObjectProperties &prop) const;
|
std::string generateSetPropertiesCommand(const ObjectProperties &prop) const;
|
||||||
void sendPunchCommand();
|
void sendPunchCommand();
|
||||||
static std::string generateUpdateBonePositionCommand(const std::string &bone,
|
static std::string generateUpdateBonePositionCommand(const std::string &bone,
|
||||||
@ -105,6 +109,7 @@ protected:
|
|||||||
v3f m_attachment_position;
|
v3f m_attachment_position;
|
||||||
v3f m_attachment_rotation;
|
v3f m_attachment_rotation;
|
||||||
bool m_attachment_sent = false;
|
bool m_attachment_sent = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onAttach(int parent_id);
|
void onAttach(int parent_id);
|
||||||
void onDetach(int parent_id);
|
void onDetach(int parent_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user