mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Proper versioning of new network-serialized stuff
This commit is contained in:
parent
197542c7ec
commit
4fa4340b95
4 changed files with 195 additions and 93 deletions
|
@ -647,22 +647,36 @@ public:
|
|||
{
|
||||
infostream<<"GenericCAO: Got init data"<<std::endl;
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
int num_messages = 0;
|
||||
// version
|
||||
u8 version = readU8(is);
|
||||
// check version
|
||||
if(version != 1){
|
||||
if(version == 1) // In PROTOCOL_VERSION 14
|
||||
{
|
||||
m_name = deSerializeString(is);
|
||||
m_is_player = readU8(is);
|
||||
m_id = readS16(is);
|
||||
m_position = readV3F1000(is);
|
||||
m_yaw = readF1000(is);
|
||||
m_hp = readS16(is);
|
||||
num_messages = readU8(is);
|
||||
}
|
||||
else if(version == 0) // In PROTOCOL_VERSION 13
|
||||
{
|
||||
m_name = deSerializeString(is);
|
||||
m_is_player = readU8(is);
|
||||
m_position = readV3F1000(is);
|
||||
m_yaw = readF1000(is);
|
||||
m_hp = readS16(is);
|
||||
num_messages = readU8(is);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorstream<<"GenericCAO: Unsupported init data version"
|
||||
<<std::endl;
|
||||
return;
|
||||
}
|
||||
m_name = deSerializeString(is);
|
||||
m_is_player = readU8(is);
|
||||
m_id = readS16(is);
|
||||
m_position = readV3F1000(is);
|
||||
m_yaw = readF1000(is);
|
||||
m_hp = readS16(is);
|
||||
|
||||
int num_messages = readU8(is);
|
||||
|
||||
for(int i=0; i<num_messages; i++){
|
||||
std::string message = deSerializeLongString(is);
|
||||
processMessage(message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue