mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-16 01:45:36 +02:00
Proper versioning of new network-serialized stuff
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user