SWY1985 / CivOne

An open source implementation of Sid Meier's Civilization.
http://www.civone.org/
Creative Commons Zero v1.0 Universal
245 stars 49 forks source link

Corrupted maps, Continents etc. shifted sidevice #492

Closed EnockNitti closed 6 years ago

EnockNitti commented 6 years ago

During testing of smart goto I have had many cases of corrupted maps. Included is some examples. CIVL3.MAP is the original from CIV 1 version 1. It seems like, if the corruption has started it will increase for every save/load. I have seen a case where only the continents in the lower part of the map are shifted.

One thing that might be related is: I have used JCivED 0.0.18 for inspection of maps. What is odd is that when using JCivED no railroad is displayed if the map is stored by CivOne. There are also other discrepancies when comparing original maps with maps stored by CivOne when comparing them in JCivED. Even if the map are just loaded and saved by CivOne.

c.zip

EnockNitti commented 6 years ago

Some progress: I have always suspected LZW and the RLE functions for the map corruptions. Now I have caught them red-handed. In the function PicFile.cs public byte[] GetBytes() I added decompression stage after compression just as a check. Expected 64000 bytes, got 64002. Investigation continues

civil3

EnockNitti commented 6 years ago

The problem was caused by a mismatch between RLE encode and RLE decode. Since decode worked fine when decoding PIC files, I adjusted encode. The condition that exposing the problem is very unusual but it happens now and then