forked from Mirrorlandia_minetest/minetest
Full protocol 13 compatibility on server side
This commit is contained in:
parent
96a286dcf5
commit
7b6d642300
@ -245,7 +245,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getClientInitializationData()
|
std::string getClientInitializationData(u16 protocol_version)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// version
|
// version
|
||||||
@ -564,25 +564,41 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LuaEntitySAO::getClientInitializationData()
|
std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
writeU8(os, 1); // version
|
|
||||||
os<<serializeString(""); // name
|
|
||||||
writeU8(os, 0); // is_player
|
|
||||||
writeS16(os, getId()); //id
|
|
||||||
writeV3F1000(os, m_base_position);
|
|
||||||
writeF1000(os, m_yaw);
|
|
||||||
writeS16(os, m_hp);
|
|
||||||
|
|
||||||
writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here
|
if(protocol_version >= 14)
|
||||||
os<<serializeLongString(getPropertyPacket()); // message 1
|
{
|
||||||
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
|
writeU8(os, 1); // version
|
||||||
os<<serializeLongString(gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend)); // 3
|
os<<serializeString(""); // name
|
||||||
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
|
writeU8(os, 0); // is_player
|
||||||
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
|
writeS16(os, getId()); //id
|
||||||
|
writeV3F1000(os, m_base_position);
|
||||||
|
writeF1000(os, m_yaw);
|
||||||
|
writeS16(os, m_hp);
|
||||||
|
|
||||||
|
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_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
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeU8(os, 0); // version
|
||||||
|
os<<serializeString(""); // name
|
||||||
|
writeU8(os, 0); // is_player
|
||||||
|
writeV3F1000(os, m_base_position);
|
||||||
|
writeF1000(os, m_yaw);
|
||||||
|
writeS16(os, m_hp);
|
||||||
|
writeU8(os, 2); // 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_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
|
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
return os.str();
|
return os.str();
|
||||||
@ -962,25 +978,41 @@ bool PlayerSAO::unlimitedTransferDistance() const
|
|||||||
return g_settings->getBool("unlimited_player_transfer_distance");
|
return g_settings->getBool("unlimited_player_transfer_distance");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PlayerSAO::getClientInitializationData()
|
std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
|
||||||
{
|
{
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
writeU8(os, 1); // version
|
|
||||||
os<<serializeString(m_player->getName()); // name
|
|
||||||
writeU8(os, 1); // is_player
|
|
||||||
writeS16(os, getId()); //id
|
|
||||||
writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
|
|
||||||
writeF1000(os, m_player->getYaw());
|
|
||||||
writeS16(os, getHP());
|
|
||||||
|
|
||||||
writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here
|
if(protocol_version >= 15)
|
||||||
os<<serializeLongString(getPropertyPacket()); // message 1
|
{
|
||||||
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
|
writeU8(os, 1); // version
|
||||||
os<<serializeLongString(gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend)); // 3
|
os<<serializeString(m_player->getName()); // name
|
||||||
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
|
writeU8(os, 1); // is_player
|
||||||
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
|
writeS16(os, getId()); //id
|
||||||
|
writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
|
||||||
|
writeF1000(os, m_player->getYaw());
|
||||||
|
writeS16(os, getHP());
|
||||||
|
|
||||||
|
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_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
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeU8(os, 0); // version
|
||||||
|
os<<serializeString(m_player->getName()); // name
|
||||||
|
writeU8(os, 1); // is_player
|
||||||
|
writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
|
||||||
|
writeF1000(os, m_player->getYaw());
|
||||||
|
writeS16(os, getHP());
|
||||||
|
writeU8(os, 2); // 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_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
|
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
return os.str();
|
return os.str();
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
const std::string &data);
|
const std::string &data);
|
||||||
bool isAttached();
|
bool isAttached();
|
||||||
void step(float dtime, bool send_recommended);
|
void step(float dtime, bool send_recommended);
|
||||||
std::string getClientInitializationData();
|
std::string getClientInitializationData(u16 protocol_version);
|
||||||
std::string getStaticData();
|
std::string getStaticData();
|
||||||
int punch(v3f dir,
|
int punch(v3f dir,
|
||||||
const ToolCapabilities *toolcap=NULL,
|
const ToolCapabilities *toolcap=NULL,
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
void removingFromEnvironment();
|
void removingFromEnvironment();
|
||||||
bool isStaticAllowed() const;
|
bool isStaticAllowed() const;
|
||||||
bool unlimitedTransferDistance() const;
|
bool unlimitedTransferDistance() const;
|
||||||
std::string getClientInitializationData();
|
std::string getClientInitializationData(u16 protocol_version);
|
||||||
std::string getStaticData();
|
std::string getStaticData();
|
||||||
bool isAttached();
|
bool isAttached();
|
||||||
void step(float dtime, bool send_recommended);
|
void step(float dtime, bool send_recommended);
|
||||||
|
@ -1568,7 +1568,7 @@ void Server::AsyncRunStep()
|
|||||||
|
|
||||||
if(obj)
|
if(obj)
|
||||||
data_buffer.append(serializeLongString(
|
data_buffer.append(serializeLongString(
|
||||||
obj->getClientInitializationData()));
|
obj->getClientInitializationData(client->net_proto_version)));
|
||||||
else
|
else
|
||||||
data_buffer.append(serializeLongString(""));
|
data_buffer.append(serializeLongString(""));
|
||||||
|
|
||||||
@ -2407,7 +2407,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
|
|
||||||
if(command == TOSERVER_PLAYERPOS)
|
if(command == TOSERVER_PLAYERPOS)
|
||||||
{
|
{
|
||||||
if(datasize < 2+12+12+4+4+4)
|
if(datasize < 2+12+12+4+4)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 start = 0;
|
u32 start = 0;
|
||||||
@ -2415,7 +2415,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
v3s32 ss = readV3S32(&data[start+2+12]);
|
v3s32 ss = readV3S32(&data[start+2+12]);
|
||||||
f32 pitch = (f32)readS32(&data[2+12+12]) / 100.0;
|
f32 pitch = (f32)readS32(&data[2+12+12]) / 100.0;
|
||||||
f32 yaw = (f32)readS32(&data[2+12+12+4]) / 100.0;
|
f32 yaw = (f32)readS32(&data[2+12+12+4]) / 100.0;
|
||||||
u32 keyPressed = (u32)readU32(&data[2+12+12+4+4]);
|
u32 keyPressed = 0;
|
||||||
|
if(datasize >= 2+12+12+4+4+4)
|
||||||
|
keyPressed = (u32)readU32(&data[2+12+12+4+4]);
|
||||||
v3f position((f32)ps.X/100., (f32)ps.Y/100., (f32)ps.Z/100.);
|
v3f position((f32)ps.X/100., (f32)ps.Y/100., (f32)ps.Z/100.);
|
||||||
v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.);
|
v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.);
|
||||||
pitch = wrapDegrees(pitch);
|
pitch = wrapDegrees(pitch);
|
||||||
|
@ -118,7 +118,7 @@ public:
|
|||||||
The return value of this is passed to the client-side object
|
The return value of this is passed to the client-side object
|
||||||
when it is created
|
when it is created
|
||||||
*/
|
*/
|
||||||
virtual std::string getClientInitializationData(){return "";}
|
virtual std::string getClientInitializationData(u16 protocol_version){return "";}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The return value of this is passed to the server-side object
|
The return value of this is passed to the server-side object
|
||||||
|
Loading…
Reference in New Issue
Block a user