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 suggestedmaster
parent
40226e5274
commit
dd91b3d6fb
|
@ -543,7 +543,6 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
|
||||||
//
|
//
|
||||||
m_is_player(false),
|
m_is_player(false),
|
||||||
m_is_local_player(false),
|
m_is_local_player(false),
|
||||||
m_id(0),
|
|
||||||
//
|
//
|
||||||
m_smgr(NULL),
|
m_smgr(NULL),
|
||||||
m_irr(NULL),
|
m_irr(NULL),
|
||||||
|
@ -747,7 +746,7 @@ ClientActiveObject* GenericCAO::getParent()
|
||||||
{
|
{
|
||||||
ClientActiveObject *obj = NULL;
|
ClientActiveObject *obj = NULL;
|
||||||
|
|
||||||
u16 attached_id = m_env->m_attachements[getId()];
|
u16 attached_id = m_env->attachement_parent_ids[getId()];
|
||||||
|
|
||||||
if ((attached_id != 0) &&
|
if ((attached_id != 0) &&
|
||||||
(attached_id != getId())) {
|
(attached_id != getId())) {
|
||||||
|
@ -764,12 +763,12 @@ void GenericCAO::removeFromScene(bool permanent)
|
||||||
for(std::vector<u16>::iterator ci = m_children.begin();
|
for(std::vector<u16>::iterator ci = m_children.begin();
|
||||||
ci != m_children.end(); ci++)
|
ci != m_children.end(); ci++)
|
||||||
{
|
{
|
||||||
if (m_env->m_attachements[*ci] == getId()) {
|
if (m_env->attachement_parent_ids[*ci] == getId()) {
|
||||||
m_env->m_attachements[*ci] = 0;
|
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();
|
LocalPlayer* player = m_env->getLocalPlayer();
|
||||||
if (this == player->parent) {
|
if (this == player->parent) {
|
||||||
|
@ -1111,7 +1110,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
||||||
for(std::vector<u16>::iterator ci = m_children.begin();
|
for(std::vector<u16>::iterator ci = m_children.begin();
|
||||||
ci != m_children.end();)
|
ci != m_children.end();)
|
||||||
{
|
{
|
||||||
if (m_env->m_attachements[*ci] != getId()) {
|
if (m_env->attachement_parent_ids[*ci] != getId()) {
|
||||||
ci = m_children.erase(ci);
|
ci = m_children.erase(ci);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1669,9 +1668,9 @@ void GenericCAO::processMessage(const std::string &data)
|
||||||
m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
|
m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
|
||||||
|
|
||||||
updateBonePosition();
|
updateBonePosition();
|
||||||
} else if (cmd == GENERIC_CMD_SET_ATTACHMENT) {
|
} else if (cmd == GENERIC_CMD_ATTACH_TO) {
|
||||||
u16 parentID = readS16(is);
|
u16 parentID = readS16(is);
|
||||||
m_env->m_attachements[getId()] = parentID;
|
m_env->attachement_parent_ids[getId()] = parentID;
|
||||||
GenericCAO *parentobj = m_env->getGenericCAO(parentID);
|
GenericCAO *parentobj = m_env->getGenericCAO(parentID);
|
||||||
|
|
||||||
if (parentobj) {
|
if (parentobj) {
|
||||||
|
|
|
@ -60,7 +60,6 @@ private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
bool m_is_player;
|
bool m_is_player;
|
||||||
bool m_is_local_player;
|
bool m_is_local_player;
|
||||||
int m_id;
|
|
||||||
// Property-ish things
|
// Property-ish things
|
||||||
ObjectProperties m_prop;
|
ObjectProperties m_prop;
|
||||||
//
|
//
|
||||||
|
|
|
@ -2009,7 +2009,7 @@ ClientEnvironment::ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
|
||||||
m_irr(irr)
|
m_irr(irr)
|
||||||
{
|
{
|
||||||
char zero = 0;
|
char zero = 0;
|
||||||
memset(m_attachements, zero, sizeof(m_attachements));
|
memset(attachement_parent_ids, zero, sizeof(attachement_parent_ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientEnvironment::~ClientEnvironment()
|
ClientEnvironment::~ClientEnvironment()
|
||||||
|
|
|
@ -505,7 +505,7 @@ public:
|
||||||
// Get event from queue. CEE_NONE is returned if queue is empty.
|
// Get event from queue. CEE_NONE is returned if queue is empty.
|
||||||
ClientEnvEvent getClientEvent();
|
ClientEnvEvent getClientEvent();
|
||||||
|
|
||||||
u16 m_attachements[USHRT_MAX];
|
u16 attachement_parent_ids[USHRT_MAX + 1];
|
||||||
|
|
||||||
std::list<std::string> getPlayerNames()
|
std::list<std::string> getPlayerNames()
|
||||||
{ return m_player_names; }
|
{ return m_player_names; }
|
||||||
|
|
|
@ -161,7 +161,7 @@ std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f posit
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// command
|
// command
|
||||||
writeU8(os, GENERIC_CMD_SET_ATTACHMENT);
|
writeU8(os, GENERIC_CMD_ATTACH_TO);
|
||||||
// parameters
|
// parameters
|
||||||
writeS16(os, parent_id);
|
writeS16(os, parent_id);
|
||||||
os<<serializeString(bone);
|
os<<serializeString(bone);
|
||||||
|
|
|
@ -24,17 +24,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "irrlichttypes_bloated.h"
|
#include "irrlichttypes_bloated.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define GENERIC_CMD_SET_PROPERTIES 0
|
enum GenericCMD {
|
||||||
#define GENERIC_CMD_UPDATE_POSITION 1
|
GENERIC_CMD_SET_PROPERTIES,
|
||||||
#define GENERIC_CMD_SET_TEXTURE_MOD 2
|
GENERIC_CMD_UPDATE_POSITION,
|
||||||
#define GENERIC_CMD_SET_SPRITE 3
|
GENERIC_CMD_SET_TEXTURE_MOD,
|
||||||
#define GENERIC_CMD_PUNCHED 4
|
GENERIC_CMD_SET_SPRITE,
|
||||||
#define GENERIC_CMD_UPDATE_ARMOR_GROUPS 5
|
GENERIC_CMD_PUNCHED,
|
||||||
#define GENERIC_CMD_SET_ANIMATION 6
|
GENERIC_CMD_UPDATE_ARMOR_GROUPS,
|
||||||
#define GENERIC_CMD_SET_BONE_POSITION 7
|
GENERIC_CMD_SET_ANIMATION,
|
||||||
#define GENERIC_CMD_SET_ATTACHMENT 8
|
GENERIC_CMD_SET_BONE_POSITION,
|
||||||
#define GENERIC_CMD_SET_PHYSICS_OVERRIDE 9
|
GENERIC_CMD_ATTACH_TO,
|
||||||
#define GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES 10
|
GENERIC_CMD_SET_PHYSICS_OVERRIDE,
|
||||||
|
GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES
|
||||||
|
};
|
||||||
|
|
||||||
#include "object_properties.h"
|
#include "object_properties.h"
|
||||||
std::string gob_cmd_set_properties(const ObjectProperties &prop);
|
std::string gob_cmd_set_properties(const ObjectProperties &prop);
|
||||||
|
|
|
@ -465,11 +465,11 @@ s16 MapBlock::getGroundLevel(v2s16 p2d)
|
||||||
// sure we can handle all content ids. But it's absolutely worth it as it's
|
// sure we can handle all content ids. But it's absolutely worth it as it's
|
||||||
// a speedup of 4 for one of the major time consuming functions on storing
|
// a speedup of 4 for one of the major time consuming functions on storing
|
||||||
// mapblocks.
|
// mapblocks.
|
||||||
static content_t getBlockNodeIdMapping_mapping[USHRT_MAX];
|
static content_t getBlockNodeIdMapping_mapping[USHRT_MAX + 1];
|
||||||
static void getBlockNodeIdMapping(NameIdMapping *nimap, MapNode *nodes,
|
static void getBlockNodeIdMapping(NameIdMapping *nimap, MapNode *nodes,
|
||||||
INodeDefManager *nodedef)
|
INodeDefManager *nodedef)
|
||||||
{
|
{
|
||||||
memset(getBlockNodeIdMapping_mapping, 0xFF, USHRT_MAX * sizeof(content_t));
|
memset(getBlockNodeIdMapping_mapping, 0xFF, (USHRT_MAX + 1) * sizeof(content_t));
|
||||||
|
|
||||||
std::set<content_t> unknown_contents;
|
std::set<content_t> unknown_contents;
|
||||||
content_t id_counter = 0;
|
content_t id_counter = 0;
|
||||||
|
|
|
@ -129,6 +129,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
Add TOCLIENT_HELLO for presenting server to client after client
|
Add TOCLIENT_HELLO for presenting server to client after client
|
||||||
presentation
|
presentation
|
||||||
Add TOCLIENT_AUTH_ACCEPT to accept connection from client
|
Add TOCLIENT_AUTH_ACCEPT to accept connection from client
|
||||||
|
Rename GENERIC_CMD_SET_ATTACHMENT to GENERIC_CMD_ATTACH_TO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LATEST_PROTOCOL_VERSION 25
|
#define LATEST_PROTOCOL_VERSION 25
|
||||||
|
|
Loading…
Reference in New Issue