80 changes: 40 additions & 40 deletions src/content_sao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ LuaEntitySAO::LuaEntitySAO(ServerEnvironment *env, v3f pos,
m_last_sent_position_timer(0),
m_last_sent_move_precision(0),
m_armor_groups_sent(false),
m_animations_sent(false),
m_animations_bone_sent(false),
m_animation_sent(false),
m_bone_position_sent(false),
m_attachment_sent(false)
{
// Only register type if no environment supplied
Expand Down Expand Up @@ -537,18 +537,18 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
m_messages_out.push_back(aom);
}

if(m_animations_sent == false){
m_animations_sent = true;
std::string str = gob_cmd_update_animations(m_animation_frames, m_animation_speed, m_animation_blend);
if(m_animation_sent == false){
m_animation_sent = true;
std::string str = gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push_back(aom);
}

if(m_animations_bone_sent == false){
m_animations_bone_sent = true;
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_animation_bone.begin(); ii != m_animation_bone.end(); ++ii){
std::string str = gob_cmd_update_bone_posrot((*ii).first, (*ii).second.X, (*ii).second.Y);
if(m_bone_position_sent == false){
m_bone_position_sent = true;
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
std::string str = gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push_back(aom);
Expand All @@ -575,12 +575,12 @@ std::string LuaEntitySAO::getClientInitializationData()
writeF1000(os, m_yaw);
writeS16(os, m_hp);

writeU8(os, 4 + m_animation_bone.size()); // number of messages stuffed in here
writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here
os<<serializeLongString(getPropertyPacket()); // message 1
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
os<<serializeLongString(gob_cmd_update_animations(m_animation_frames, m_animation_speed, m_animation_blend)); // 3
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_animation_bone.begin(); ii != m_animation_bone.end(); ++ii){
os<<serializeLongString(gob_cmd_update_bone_posrot((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_animation_bone.size
os<<serializeLongString(gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend)); // 3
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4

Expand Down Expand Up @@ -728,18 +728,18 @@ void LuaEntitySAO::setArmorGroups(const ItemGroupList &armor_groups)
m_armor_groups_sent = false;
}

void LuaEntitySAO::setAnimations(v2f frames, float frame_speed, float frame_blend)
void LuaEntitySAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend)
{
m_animation_frames = frames;
m_animation_range = frame_range;
m_animation_speed = frame_speed;
m_animation_blend = frame_blend;
m_animations_sent = false;
m_animation_sent = false;
}

void LuaEntitySAO::setBonePosRot(std::string bone, v3f position, v3f rotation)
void LuaEntitySAO::setBonePosition(std::string bone, v3f position, v3f rotation)
{
m_animation_bone[bone] = core::vector2d<v3f>(position, rotation);
m_animations_bone_sent = false;
m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
m_bone_position_sent = false;
}

void LuaEntitySAO::setAttachment(int parent_id, std::string bone, v3f position, v3f rotation)
Expand Down Expand Up @@ -884,8 +884,8 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
m_properties_sent(true),
m_privs(privs),
m_is_singleplayer(is_singleplayer),
m_animations_sent(false),
m_animations_bone_sent(false),
m_animation_sent(false),
m_bone_position_sent(false),
m_attachment_sent(false),
// public
m_moved(false),
Expand Down Expand Up @@ -914,7 +914,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
m_prop.colors.push_back(video::SColor(255, 255, 255, 255));
m_prop.spritediv = v2s16(1,1);
// end of default appearance
m_prop.is_visible = (getHP() != 0); // TODO: Use a death animation instead for mesh players
m_prop.is_visible = true;
m_prop.makes_footstep_sound = true;
}

Expand Down Expand Up @@ -973,12 +973,12 @@ std::string PlayerSAO::getClientInitializationData()
writeF1000(os, m_player->getYaw());
writeS16(os, getHP());

writeU8(os, 4 + m_animation_bone.size()); // number of messages stuffed in here
writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here
os<<serializeLongString(getPropertyPacket()); // message 1
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
os<<serializeLongString(gob_cmd_update_animations(m_animation_frames, m_animation_speed, m_animation_blend)); // 3
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_animation_bone.begin(); ii != m_animation_bone.end(); ++ii){
os<<serializeLongString(gob_cmd_update_bone_posrot((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_animation_bone.size
os<<serializeLongString(gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend)); // 3
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4

Expand Down Expand Up @@ -1137,18 +1137,18 @@ void PlayerSAO::step(float dtime, bool send_recommended)
m_messages_out.push_back(aom);
}

if(m_animations_sent == false){
m_animations_sent = true;
std::string str = gob_cmd_update_animations(m_animation_frames, m_animation_speed, m_animation_blend);
if(m_animation_sent == false){
m_animation_sent = true;
std::string str = gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push_back(aom);
}

if(m_animations_bone_sent == false){
m_animations_bone_sent = true;
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_animation_bone.begin(); ii != m_animation_bone.end(); ++ii){
std::string str = gob_cmd_update_bone_posrot((*ii).first, (*ii).second.X, (*ii).second.Y);
if(m_bone_position_sent == false){
m_bone_position_sent = true;
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
std::string str = gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push_back(aom);
Expand Down Expand Up @@ -1285,20 +1285,20 @@ void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups)
m_armor_groups_sent = false;
}

void PlayerSAO::setAnimations(v2f frames, float frame_speed, float frame_blend)
void PlayerSAO::setAnimation(v2f frame_range, float frame_speed, float frame_blend)
{
// store these so they can be updated to clients
m_animation_frames = frames;
m_animation_range = frame_range;
m_animation_speed = frame_speed;
m_animation_blend = frame_blend;
m_animations_sent = false;
m_animation_sent = false;
}

void PlayerSAO::setBonePosRot(std::string bone, v3f position, v3f rotation)
void PlayerSAO::setBonePosition(std::string bone, v3f position, v3f rotation)
{
// store these so they can be updated to clients
m_animation_bone[bone] = core::vector2d<v3f>(position, rotation);
m_animations_bone_sent = false;
m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
m_bone_position_sent = false;
}

void PlayerSAO::setAttachment(int parent_id, std::string bone, v3f position, v3f rotation)
Expand Down Expand Up @@ -1381,7 +1381,7 @@ void PlayerSAO::disconnected()

std::string PlayerSAO::getPropertyPacket()
{
m_prop.is_visible = (getHP() != 0);
m_prop.is_visible = (true);
return gob_cmd_set_properties(m_prop);
}

24 changes: 12 additions & 12 deletions src/content_sao.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class LuaEntitySAO : public ServerActiveObject
void setHP(s16 hp);
s16 getHP() const;
void setArmorGroups(const ItemGroupList &armor_groups);
void setAnimations(v2f frames, float frame_speed, float frame_blend);
void setBonePosRot(std::string bone, v3f position, v3f rotation);
void setAnimation(v2f frame_range, float frame_speed, float frame_blend);
void setBonePosition(std::string bone, v3f position, v3f rotation);
void setAttachment(int parent_id, std::string bone, v3f position, v3f rotation);
ObjectProperties* accessObjectProperties();
void notifyObjectPropertiesModified();
Expand Down Expand Up @@ -101,13 +101,13 @@ class LuaEntitySAO : public ServerActiveObject
float m_last_sent_move_precision;
bool m_armor_groups_sent;

v2f m_animation_frames;
v2f m_animation_range;
float m_animation_speed;
float m_animation_blend;
bool m_animations_sent;
bool m_animation_sent;

std::map<std::string, core::vector2d<v3f> > m_animation_bone;
bool m_animations_bone_sent;
std::map<std::string, core::vector2d<v3f> > m_bone_position;
bool m_bone_position_sent;

int m_attachment_parent_id;
std::string m_attachment_bone;
Expand Down Expand Up @@ -161,8 +161,8 @@ class PlayerSAO : public ServerActiveObject
void setHP(s16 hp);

void setArmorGroups(const ItemGroupList &armor_groups);
void setAnimations(v2f frames, float frame_speed, float frame_blend);
void setBonePosRot(std::string bone, v3f position, v3f rotation);
void setAnimation(v2f frame_range, float frame_speed, float frame_blend);
void setBonePosition(std::string bone, v3f position, v3f rotation);
void setAttachment(int parent_id, std::string bone, v3f position, v3f rotation);
ObjectProperties* accessObjectProperties();
void notifyObjectPropertiesModified();
Expand Down Expand Up @@ -260,13 +260,13 @@ class PlayerSAO : public ServerActiveObject
std::set<std::string> m_privs;
bool m_is_singleplayer;

v2f m_animation_frames;
v2f m_animation_range;
float m_animation_speed;
float m_animation_blend;
bool m_animations_sent;
bool m_animation_sent;

std::map<std::string, core::vector2d<v3f> > m_animation_bone; // stores position and rotation for each bone name
bool m_animations_bone_sent;
std::map<std::string, core::vector2d<v3f> > m_bone_position; // Stores position and rotation for each bone name
bool m_bone_position_sent;

int m_attachment_parent_id;
std::string m_attachment_bone;
Expand Down
2 changes: 2 additions & 0 deletions src/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ class ClientEnvironment : public Environment

// Get event from queue. CEE_NONE is returned if queue is empty.
ClientEnvEvent getClientEvent();

std::vector<core::vector2d<int> > attachment_list; // X is child ID, Y is parent ID

private:
ClientMap *m_map;
Expand Down
8 changes: 4 additions & 4 deletions src/genericobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,23 @@ std::string gob_cmd_set_sprite(
return os.str();
}

std::string gob_cmd_update_animations(v2f frames, float frame_speed, float frame_blend)
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend)
{
std::ostringstream os(std::ios::binary);
// command
writeU8(os, GENERIC_CMD_SET_ANIMATIONS);
writeU8(os, GENERIC_CMD_SET_ANIMATION);
// parameters
writeV2F1000(os, frames);
writeF1000(os, frame_speed);
writeF1000(os, frame_blend);
return os.str();
}

std::string gob_cmd_update_bone_posrot(std::string bone, v3f position, v3f rotation)
std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation)
{
std::ostringstream os(std::ios::binary);
// command
writeU8(os, GENERIC_CMD_SET_BONE_POSROT);
writeU8(os, GENERIC_CMD_SET_BONE_POSITION);
// parameters
os<<serializeString(bone);
writeV3F1000(os, position);
Expand Down
8 changes: 4 additions & 4 deletions src/genericobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define GENERIC_CMD_UPDATE_POSITION 1
#define GENERIC_CMD_SET_TEXTURE_MOD 2
#define GENERIC_CMD_SET_SPRITE 3
#define GENERIC_CMD_SET_ANIMATIONS 4
#define GENERIC_CMD_SET_BONE_POSROT 5
#define GENERIC_CMD_SET_ANIMATION 4
#define GENERIC_CMD_SET_BONE_POSITION 5
#define GENERIC_CMD_SET_ATTACHMENT 6
#define GENERIC_CMD_PUNCHED 7
#define GENERIC_CMD_UPDATE_ARMOR_GROUPS 8
Expand Down Expand Up @@ -57,9 +57,9 @@ std::string gob_cmd_set_sprite(
bool select_horiz_by_yawpitch
);

std::string gob_cmd_update_animations(v2f frames, float frame_speed, float frame_blend);
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend);

std::string gob_cmd_update_bone_posrot(std::string bone, v3f position, v3f rotation);
std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation);

std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f position, v3f rotation);

Expand Down
2 changes: 2 additions & 0 deletions src/guiFormSpecMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ void GUIFormSpecMenu::drawMenu()
Draw backgrounds
*/
for(u32 i=0; i<m_backgrounds.size(); i++)
{
const ImageDrawSpec &spec = m_backgrounds[i];
video::ITexture *texture =
m_gamedef->tsrc()->getTextureRaw(spec.name);
Expand All @@ -727,6 +728,7 @@ void GUIFormSpecMenu::drawMenu()
core::rect<s32>(core::position2d<s32>(0,0),
core::dimension2di(texture->getOriginalSize())),
NULL/*&AbsoluteClippingRect*/, colors, true);
}

/*
Draw images
Expand Down
28 changes: 14 additions & 14 deletions src/scriptapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2716,8 +2716,8 @@ class ObjectRef
return 0;
}

// setanimations(self, frames, frame_speed, frame_blend)
static int l_set_animations(lua_State *L)
// set_animation(self, frame_range, frame_speed, frame_blend)
static int l_set_animation(lua_State *L)
{
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
Expand All @@ -2732,12 +2732,12 @@ class ObjectRef
float frame_blend = 0;
if(!lua_isnil(L, 4))
frame_blend = lua_tonumber(L, 4);
co->setAnimations(frames, frame_speed, frame_blend);
co->setAnimation(frames, frame_speed, frame_blend);
return 0;
}

// setboneposrot(self, std::string bone, v3f position, v3f rotation)
static int l_set_bone_posrot(lua_State *L)
// set_bone_position(self, std::string bone, v3f position, v3f rotation)
static int l_set_bone_position(lua_State *L)
{
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
Expand All @@ -2752,12 +2752,12 @@ class ObjectRef
v3f rotation = v3f(0, 0, 0);
if(!lua_isnil(L, 4))
rotation = read_v3f(L, 4);
co->setBonePosRot(bone, position, rotation);
co->setBonePosition(bone, position, rotation);
return 0;
}

// set_attachment(self, parent, bone, position, rotation)
static int l_set_attachment(lua_State *L)
// set_attach(self, parent, bone, position, rotation)
static int l_set_attach(lua_State *L)
{
ObjectRef *ref = checkobject(L, 1);
ObjectRef *parent_ref = checkobject(L, 2);
Expand All @@ -2779,8 +2779,8 @@ class ObjectRef
return 0;
}

// set_detachment(self)
static int l_set_detachment(lua_State *L)
// set_detach(self)
static int l_set_detach(lua_State *L)
{
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
Expand Down Expand Up @@ -3104,10 +3104,10 @@ const luaL_reg ObjectRef::methods[] = {
method(ObjectRef, get_wielded_item),
method(ObjectRef, set_wielded_item),
method(ObjectRef, set_armor_groups),
method(ObjectRef, set_animations),
method(ObjectRef, set_bone_posrot),
method(ObjectRef, set_attachment),
method(ObjectRef, set_detachment),
method(ObjectRef, set_animation),
method(ObjectRef, set_bone_position),
method(ObjectRef, set_attach),
method(ObjectRef, set_detach),
method(ObjectRef, set_properties),
// LuaEntitySAO-only
method(ObjectRef, setvelocity),
Expand Down
4 changes: 2 additions & 2 deletions src/serverobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ class ServerActiveObject : public ActiveObject

virtual void setArmorGroups(const ItemGroupList &armor_groups)
{}
virtual void setAnimations(v2f frames, float frame_speed, float frame_blend)
virtual void setAnimation(v2f frames, float frame_speed, float frame_blend)
{}
virtual void setBonePosRot(std::string bone, v3f position, v3f rotation)
virtual void setBonePosition(std::string bone, v3f position, v3f rotation)
{}
virtual void setAttachment(int parent_id, std::string bone, v3f position, v3f rotation)
{}
Expand Down