reduce mob client initialisation data

This commit is contained in:
darkrose 2015-04-23 00:02:31 +10:00
parent 549cfea8de
commit 94d295dacb
2 changed files with 22 additions and 9 deletions

View File

@ -540,7 +540,7 @@ void MobCAO::initialize(const std::string &data)
// version
u8 version = readU8(is);
// check version
if (version != 0)
if (version < 0 || version > 1)
return;
// pos
m_position = readV3F1000(is);
@ -550,13 +550,15 @@ void MobCAO::initialize(const std::string &data)
// yaw
m_yaw = readF1000(is);
pos_translator.init(m_position,m_yaw);
// client doesn't use these, but has to read past them
// speed
readV3F1000(is);
// age
readF1000(is);
// hp
readU8(is);
if (version == 0) {
// client doesn't use these, but has to read past them
// speed
readV3F1000(is);
// age
readF1000(is);
// hp
readU8(is);
}
// shooting
m_shooting = !!readU8(is);
}

View File

@ -490,7 +490,18 @@ std::string MobSAO::getStaticData()
}
std::string MobSAO::getClientInitializationData()
{
return getStaticData();
std::ostringstream os(std::ios::binary);
// version
writeU8(os, 1);
// pos
writeV3F1000(os, m_base_position);
// content
writeU16(os,m_content);
// yaw
writeF1000(os,m_yaw);
// shooting
writeU8(os,(u8)m_shooting);
return os.str();
}
void MobSAO::step(float dtime, bool send_recommended)
{