From dd91b3d6fbc3a0b4b18b36b14864d703213dd622 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 20 Jun 2015 03:20:06 +0200 Subject: Generic CAO cleanups and renames for clarification * Use enum for GENERIC_CMD_* * Rename m_attachements to attachement_parent_ids (public member and clearer name) * Rename GENERIC_CMD_SET_ATTACHMENT to GENERIC_CMD_ATTACH_TO * USHRT_MAX + 1 buffer sizes to prevent overflows as @kahrl suggested * Remove unneccessary m_id from GenericCAO (shadowing protected superclass member for no reason) as @kahrl suggested --- src/content_cao.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/content_cao.cpp') diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 4f1336d28..d82af9e57 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -543,7 +543,6 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env): // m_is_player(false), m_is_local_player(false), - m_id(0), // m_smgr(NULL), m_irr(NULL), @@ -747,7 +746,7 @@ ClientActiveObject* GenericCAO::getParent() { ClientActiveObject *obj = NULL; - u16 attached_id = m_env->m_attachements[getId()]; + u16 attached_id = m_env->attachement_parent_ids[getId()]; if ((attached_id != 0) && (attached_id != getId())) { @@ -764,12 +763,12 @@ void GenericCAO::removeFromScene(bool permanent) for(std::vector::iterator ci = m_children.begin(); ci != m_children.end(); ci++) { - if (m_env->m_attachements[*ci] == getId()) { - m_env->m_attachements[*ci] = 0; + if (m_env->attachement_parent_ids[*ci] == getId()) { + m_env->attachement_parent_ids[*ci] = 0; } } - m_env->m_attachements[getId()] = 0; + m_env->attachement_parent_ids[getId()] = 0; LocalPlayer* player = m_env->getLocalPlayer(); if (this == player->parent) { @@ -1111,7 +1110,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env) for(std::vector::iterator ci = m_children.begin(); ci != m_children.end();) { - if (m_env->m_attachements[*ci] != getId()) { + if (m_env->attachement_parent_ids[*ci] != getId()) { ci = m_children.erase(ci); continue; } @@ -1669,9 +1668,9 @@ void GenericCAO::processMessage(const std::string &data) m_bone_position[bone] = core::vector2d(position, rotation); updateBonePosition(); - } else if (cmd == GENERIC_CMD_SET_ATTACHMENT) { + } else if (cmd == GENERIC_CMD_ATTACH_TO) { u16 parentID = readS16(is); - m_env->m_attachements[getId()] = parentID; + m_env->attachement_parent_ids[getId()] = parentID; GenericCAO *parentobj = m_env->getGenericCAO(parentID); if (parentobj) { -- cgit v1.2.3