Skip to content

Commit 283bf97

Browse files
committedSep 14, 2015
Serialisation: documentation fixes, clarifying renames and whitespace fixes
1. Do two renames: * SER_FMT_CLIENT_VER_LOWEST -> SER_FMT_VER_LOWEST_WRITE * SER_FMT_VER_LOWEST -> SER_FMT_VER_LOWEST_READ Now the two define values are consistently named with the _WRITE defines SER_FMT_VER_{HIGHEST,LOWEST}_WRITE, and to better point out what the two serialisation versions actually are for. 2. wrap some lines in doc/worldformat.txt, and point out that the node timers are serialized at a later point, as this can cause confusion about what now happens (if one doesn't strictly read the if block's conditions). 3. some whitespace fixes in NodeTimerList::serialize, and one new comment.
1 parent 915807f commit 283bf97

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed
 

Diff for: ‎doc/worldformat.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ Contains authentication data, player per line.
4545
Legacy format (until 0.4.12) of password hash is <name><password> SHA1'd,
4646
in the base64 encoding.
4747

48-
Format (since 0.4.13) of password hash is #1#<salt>#<verifier>, with the parts inside <> encoded in the base64 encoding.
48+
Format (since 0.4.13) of password hash is #1#<salt>#<verifier>, with the
49+
parts inside <> encoded in the base64 encoding.
4950
<verifier> is an RFC 5054 compatible SRP-2048-SHA1 verifier
5051
of the given salt, password, and the player's name lowercased.
5152

@@ -54,7 +55,7 @@ Example lines:
5455
celeron55::interact,shout
5556
- Player "Foo", password "bar", privilege "shout", with a legacy password hash:
5657
foo:iEPX+SQWIR3p67lj/0zigSWTKHg:shout
57-
- Player "Foo", password "bar", privilege "shout", with an up to date pw hash (yes it is THAT long):
58+
- Player "Foo", password "bar", privilege "shout", with a 0.4.13 pw hash:
5859
foo:#1#hPpy4O3IAn1hsNK00A6wNw#Kpu6rj7McsrPCt4euTb5RA5ltF7wdcWGoYMcRngwDi11cZhPuuR9i5Bo7o6A877TgcEwoc//HNrj9EjR/CGjdyTFmNhiermZOADvd8eu32FYK1kf7RMC0rXWxCenYuOQCG4WF9mMGiyTPxC63VAjAMuc1nCZzmy6D9zt0SIKxOmteI75pAEAIee2hx4OkSXRIiU4Zrxo1Xf7QFxkMY4x77vgaPcvfmuzom0y/fU1EdSnZeopGPvzMpFx80ODFx1P34R52nmVl0W8h4GNo0k8ZiWtRCdrJxs8xIg7z5P1h3Th/BJ0lwexpdK8sQZWng8xaO5ElthNuhO8UQx1l6FgEA:shout
5960
- Player "bar", no password, no privileges:
6061
bar::
@@ -316,6 +317,8 @@ if map format version == 24: (NOTE: Not released as stable)
316317
u16 timer position (z*16*16 + y*16 + x)
317318
s32 timeout*1000
318319
s32 elapsed*1000
320+
if map format version >= 25:
321+
-- Nothing right here, node timers are serialized later
319322

320323
u8 static object version:
321324
- Always 0

Diff for: ‎src/mapblock.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
564564
throw SerializationError("ERROR: Not writing dummy block.");
565565
}
566566

567-
FATAL_ERROR_IF(version < SER_FMT_CLIENT_VER_LOWEST, "Serialize version error");
567+
FATAL_ERROR_IF(version < SER_FMT_VER_LOWEST_WRITE, "Serialisation version error");
568568

569569
// First byte
570570
u8 flags = 0;

Diff for: ‎src/mapblock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class MapBlock /*: public NodeContainer*/
504504

505505
// These don't write or read version by itself
506506
// Set disk to true for on-disk format, false for over-the-network format
507-
// Precondition: version >= SER_FMT_CLIENT_VER_LOWEST
507+
// Precondition: version >= SER_FMT_VER_LOWEST_WRITE
508508
void serialize(std::ostream &os, u8 version, bool disk);
509509
// If disk == true: In addition to doing other things, will add
510510
// unknown blocks from id-name mapping to wndef

Diff for: ‎src/network/serverpackethandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
103103
// Use the highest version supported by both
104104
u8 depl_serial_v = std::min(client_max, our_max);
105105
// If it's lower than the lowest supported, give up.
106-
if (depl_serial_v < SER_FMT_VER_LOWEST)
106+
if (depl_serial_v < SER_FMT_VER_LOWEST_READ)
107107
depl_serial_v = SER_FMT_VER_INVALID;
108108

109109
if (depl_serial_v == SER_FMT_VER_INVALID) {
@@ -347,7 +347,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
347347
// Use the highest version supported by both
348348
int deployed = std::min(client_max, our_max);
349349
// If it's lower than the lowest supported, give up.
350-
if (deployed < SER_FMT_VER_LOWEST)
350+
if (deployed < SER_FMT_VER_LOWEST_READ)
351351
deployed = SER_FMT_VER_INVALID;
352352

353353
if (deployed == SER_FMT_VER_INVALID) {

Diff for: ‎src/nodetimer.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ void NodeTimer::deSerialize(std::istream &is)
4545

4646
void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const
4747
{
48-
if(map_format_version == 24){
48+
if (map_format_version == 24) {
4949
// Version 0 is a placeholder for "nothing to see here; go away."
50-
if(m_data.empty()){
50+
if (m_data.empty()) {
5151
writeU8(os, 0); // version
5252
return;
5353
}
5454
writeU8(os, 1); // version
5555
writeU16(os, m_data.size());
5656
}
5757

58-
if(map_format_version >= 25){
59-
writeU8(os, 2+4+4);
58+
if (map_format_version >= 25) {
59+
writeU8(os, 2 + 4 + 4); // length of the data for a single timer
6060
writeU16(os, m_data.size());
6161
}
6262

63-
for(std::map<v3s16, NodeTimer>::const_iterator
63+
for (std::map<v3s16, NodeTimer>::const_iterator
6464
i = m_data.begin();
65-
i != m_data.end(); ++i){
65+
i != m_data.end(); ++i) {
6666
v3s16 p = i->first;
6767
NodeTimer t = i->second;
6868

69-
u16 p16 = p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X;
69+
u16 p16 = p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE + p.Y * MAP_BLOCKSIZE + p.X;
7070
writeU16(os, p16);
7171
t.serialize(os);
7272
}
@@ -75,7 +75,7 @@ void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const
7575
void NodeTimerList::deSerialize(std::istream &is, u8 map_format_version)
7676
{
7777
m_data.clear();
78-
78+
7979
if(map_format_version == 24){
8080
u8 timer_version = readU8(is);
8181
if(timer_version == 0)

Diff for: ‎src/serialization.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3030
--------------------------------
3131
3232
For map data (blocks, nodes, sectors).
33-
33+
3434
NOTE: The goal is to increment this so that saved maps will be
3535
loadable by any version. Other compatibility is not
3636
maintained.
37-
37+
3838
0: original networked test with 1-byte nodes
3939
1: update with 2-byte nodes
4040
2: lighting is transmitted in param
@@ -70,14 +70,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
7070
// Saved on disk version
7171
#define SER_FMT_VER_HIGHEST_WRITE 25
7272
// Lowest supported serialization version
73-
#define SER_FMT_VER_LOWEST 0
74-
// Lowest client supported serialization version
73+
#define SER_FMT_VER_LOWEST_READ 0
74+
// Lowest serialization version for writing
7575
// Can't do < 24 anymore; we have 16-bit dynamically allocated node IDs
7676
// in memory; conversion just won't work in this direction.
77-
#define SER_FMT_CLIENT_VER_LOWEST 24
77+
#define SER_FMT_VER_LOWEST_WRITE 24
7878

7979
inline bool ser_ver_supported(s32 v) {
80-
return v >= SER_FMT_VER_LOWEST && v <= SER_FMT_VER_HIGHEST_READ;
80+
return v >= SER_FMT_VER_LOWEST_READ && v <= SER_FMT_VER_HIGHEST_READ;
8181
}
8282

8383
/*

0 commit comments

Comments
 (0)
Please sign in to comment.