aboutsummaryrefslogtreecommitdiff
path: root/src/content_cao.cpp
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2016-10-08 16:51:25 +0400
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-08 14:51:25 +0200
commitad163ee5c3f7d6ca31e0add052fb76466a9bfcc8 (patch)
tree6eebdb83bb210f4f57caa4a0f57189d95666d9c2 /src/content_cao.cpp
parent9978d0796fa61eabb235d715a56ad6e5396d2e1e (diff)
downloadminetest-ad163ee5c3f7d6ca31e0add052fb76466a9bfcc8.tar.gz
minetest-ad163ee5c3f7d6ca31e0add052fb76466a9bfcc8.tar.bz2
minetest-ad163ee5c3f7d6ca31e0add052fb76466a9bfcc8.zip
Prevent attached models from disappearing during parent reload (#4128)
Diffstat (limited to 'src/content_cao.cpp')
-rw-r--r--src/content_cao.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 33dae6822..207a630d7 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1567,8 +1567,7 @@ void GenericCAO::processMessage(const std::string &data)
std::istringstream is(data, std::ios::binary);
// command
u8 cmd = readU8(is);
- if(cmd == GENERIC_CMD_SET_PROPERTIES)
- {
+ if (cmd == GENERIC_CMD_SET_PROPERTIES) {
m_prop = gob_read_set_properties(is);
m_selection_box = m_prop.collisionbox;
@@ -1587,9 +1586,7 @@ void GenericCAO::processMessage(const std::string &data)
m_prop.nametag = m_name;
expireVisuals();
- }
- else if(cmd == GENERIC_CMD_UPDATE_POSITION)
- {
+ } else if (cmd == GENERIC_CMD_UPDATE_POSITION) {
// Not sent by the server if this object is an attachment.
// We might however get here if the server notices the object being detached before the client.
m_position = readV3F1000(is);
@@ -1619,12 +1616,10 @@ void GenericCAO::processMessage(const std::string &data)
pos_translator.init(m_position);
}
updateNodePos();
- }
- else if(cmd == GENERIC_CMD_SET_TEXTURE_MOD) {
+ } else if (cmd == GENERIC_CMD_SET_TEXTURE_MOD) {
std::string mod = deSerializeString(is);
updateTextures(mod);
- }
- else if(cmd == GENERIC_CMD_SET_SPRITE) {
+ } else if (cmd == GENERIC_CMD_SET_SPRITE) {
v2s16 p = readV2S16(is);
int num_frames = readU16(is);
float framelength = readF1000(is);
@@ -1636,8 +1631,7 @@ void GenericCAO::processMessage(const std::string &data)
m_tx_select_horiz_by_yawpitch = select_horiz_by_yawpitch;
updateTexturePos();
- }
- else if(cmd == GENERIC_CMD_SET_PHYSICS_OVERRIDE) {
+ } else if (cmd == GENERIC_CMD_SET_PHYSICS_OVERRIDE) {
float override_speed = readF1000(is);
float override_jump = readF1000(is);
float override_gravity = readF1000(is);
@@ -1655,8 +1649,7 @@ void GenericCAO::processMessage(const std::string &data)
player->physics_override_sneak = sneak;
player->physics_override_sneak_glitch = sneak_glitch;
}
- }
- else if(cmd == GENERIC_CMD_SET_ANIMATION) {
+ } else if (cmd == GENERIC_CMD_SET_ANIMATION) {
// TODO: change frames send as v2s32 value
v2f range = readV2F1000(is);
if (!m_is_local_player) {
@@ -1690,8 +1683,7 @@ void GenericCAO::processMessage(const std::string &data)
updateAnimation();
}
}
- }
- else if(cmd == GENERIC_CMD_SET_BONE_POSITION) {
+ } else if (cmd == GENERIC_CMD_SET_BONE_POSITION) {
std::string bone = deSerializeString(is);
v3f position = readV3F1000(is);
v3f rotation = readV3F1000(is);
@@ -1724,8 +1716,7 @@ void GenericCAO::processMessage(const std::string &data)
}
updateAttachments();
- }
- else if(cmd == GENERIC_CMD_PUNCHED) {
+ } else if (cmd == GENERIC_CMD_PUNCHED) {
/*s16 damage =*/ readS16(is);
s16 result_hp = readS16(is);
@@ -1753,8 +1744,7 @@ void GenericCAO::processMessage(const std::string &data)
updateTextures("^[brighten");
}
}
- }
- else if(cmd == GENERIC_CMD_UPDATE_ARMOR_GROUPS) {
+ } else if (cmd == GENERIC_CMD_UPDATE_ARMOR_GROUPS) {
m_armor_groups.clear();
int armor_groups_size = readU16(is);
for(int i=0; i<armor_groups_size; i++)
@@ -1770,6 +1760,19 @@ void GenericCAO::processMessage(const std::string &data)
if (m_nametag != NULL) {
m_nametag->nametag_color = m_prop.nametag_color;
}
+ } else if (cmd == GENERIC_CMD_SPAWN_INFANT) {
+ u16 child_id = readU16(is);
+ u8 type = readU8(is);
+
+ if (GenericCAO *childobj = m_env->getGenericCAO(child_id)) {
+ childobj->initialize(deSerializeLongString(is));
+ } else {
+ m_env->addActiveObject(child_id, type, deSerializeLongString(is));
+ }
+ } else {
+ warningstream << FUNCTION_NAME
+ << ": unknown command or outdated client \""
+ << cmd << std::endl;
}
}