libtw2 icon indicating copy to clipboard operation
libtw2 copied to clipboard

map_properties: maps/zbSkyCraft.map: Error(Df(Df(TooShort)))

Open def- opened this issue 5 years ago • 4 comments

maps/zbSkyCraft.map: Error(Df(Df(TooShort)))

http://maps.ddnet.tw/zbSkyCraft_4475fbc8_17d53689f94b8a01a89d50c96f8702e568812ee7f37c324ed63c0265cb741c60.map

def- avatar Jan 09 '19 13:01 def-

This is due to m_Version of layer # 31 having a value of 322. Here's the struct in DDNet repo: https://github.com/ddnet/ddnet/blob/master/src/game/mapitems.h#L302.

We use version to decide whether the structure should contain m_aName field. DDNet does this by shifting the rest of the fields when m_Version <= 2: https://github.com/ddnet/ddnet/blob/master/src/game/layers.cpp#L69-L104.

libtw2 does something similar, but only distinguishes values of 2 and 3 (also possibly 0 and 1), failing for other values: https://github.com/heinrich5991/libtw2/blob/master/map/src/format.rs#L244-L246.

There isn't a separate error for this situation at the moment so it gets incorrectly attributed to the layer buffer being too short.

Since apparently we don't encounter this error often, most of the maps must have values up to 3. However, we could make libtw2 behavior consistent with DDNet and just treat all versions higher than 2 equally.

This would also remove the need to improve error reporting - we'd remove this error situation completely.

Fireball-Teeworlds avatar Sep 02 '20 00:09 Fireball-Teeworlds

Thanks for investigating.

heinrich5991 avatar Sep 02 '20 11:09 heinrich5991

Oh, I've just noticed that all this time I've been investigating the map from #15. Sorry for that, I've reposted my comment there.

Fireball-Teeworlds avatar Sep 02 '20 19:09 Fireball-Teeworlds

ERROR:datafile::raw: file is not long enough, wanted 154179
.../zbSkyCraft.map: Df(Df(TooShort))

I think this map may be legitimately corrupted. I can't get the editor to open it.

Fireball-Teeworlds avatar Sep 02 '20 21:09 Fireball-Teeworlds