Prototype icon indicating copy to clipboard operation
Prototype copied to clipboard

02 MP Fall of Rome.biq Not Openable When Decompressed in C7

Open QuintillusCFC opened this issue 3 years ago • 2 comments

Some Civ3 scenarios aren't openable, for example 3 MP Fall of Rome.biq. At first I suspected variations between version 12.06 and 12.08 of the BIQ format, as that scenario is version 12.06, however, this appears not to be the case. I decompressed it with a Java decompression program, and C7 could read the decompressed version, strongly suggesting the problem is in the decompression program we are using, or perhaps how we are using it. This scenario fails with the following message:

System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
   at Mono.Debugger.Soft.TcpConnection.TransportReceive(Byte[] buf, Int32 buf_offset, Int32 len)
   at Mono.Debugger.Soft.Connection.Receive(Byte[] buf, Int32 buf_offset, Int32 len)
   at Mono.Debugger.Soft.Connection.ReadPacket()
   at Mono.Debugger.Soft.Connection.ReceivePacket()
   at Mono.Debugger.Soft.Connection.receiver_thread_main()

It almost consistently fails at the following line in the unit section:

Unit = new UNIT[count];

Count is 211, which seems normal.

The weird thing is that in the cases where it doesn't fail when I step the code forward from that line, Godot crashes while it is paused at that line, with the same SocketException. I'm not sure why yet, and it's really strange for a program to crash while it's paused at a breakpoint. But something is going on.

Our decompression library's source is at https://github.com/jamestelfer/Blast . It does mention that it is probably the least elegant way to implement a decompressor, and its summary says it could use polish, so perhaps this scenario hits an edge case. I'm wondering if there isn't a resource that's getting closed under our feet somehow.

The decompression format (PKWare Data Compression Library [DCL], not to be confused with PKWARE ZIP) is documented in this Newsgroup posting (HTTP portal link, should we need to dive into the details. Mark Adler's original C version is at https://github.com/madler/zlib/tree/master/contrib/blast .

(I'm pretty sure this can affect SAV files as well, but have mainly been testing with BIQ files as I have a wider variety of those)

QuintillusCFC avatar Feb 21 '22 08:02 QuintillusCFC