Fix:

./dirtree.cc:173:4: error: no matching function for call to 'gzclose'
                        gzclose(file);
                        ^~~~~~~
/opt/local/include/zlib.h:1630:24: note: candidate function not viable: no known conversion from 'FILE *' (aka '__sFILE *') to 'gzFile' (aka 'gzFile_s *') for 1st argument
ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
                       ^
./dirtree.cc:178:4: error: no matching function for call to 'gzclose'
                        gzclose(file);
                        ^~~~~~~
/opt/local/include/zlib.h:1630:24: note: candidate function not viable: no known conversion from 'FILE *' (aka '__sFILE *') to 'gzFile' (aka 'gzFile_s *') for 1st argument
ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
                       ^
2 errors generated.

https://sourceforge.net/p/kcd/patches/3/
--- dirtree.cc.orig	2009-02-18 06:01:05.000000000 -0600
+++ dirtree.cc	2019-11-04 07:19:48.000000000 -0600
@@ -170,12 +170,12 @@
 			ReadSaveFile(dirTree, filegz);
 		}
 		catch(ErrorBadFileFormat &) {
-			gzclose(file);
+			gzclose(filegz);
 			throw ErrorGenericFile(_("invalid file format in %$"), saveFile);
 
 		}
 		catch(ErrorGZIO &) {
-			gzclose(file);
+			gzclose(filegz);
 			throw ErrorGenericFile(_("error reading file %$"), saveFile);
 		}
 		gzclose(filegz);
