From 1b5bd399cd29ab6acaefdb96852d34a77e8718dd Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Fri, 7 Jun 2024 10:38:21 -0500 Subject: [PATCH] now read off individual file times from packed gamefiles --- Makefile | 4 +--- source/engine/resources.c | 14 ++++++++++---- tools/packer.c | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 3e6ef109..881324bf 100755 --- a/Makefile +++ b/Makefile @@ -75,9 +75,7 @@ else CPPFLAGS += -O2 endif -UNIX_TIME != stat -f "%m" core.cdb - -CPPFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DCP_USE_DOUBLES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) $(WARNING_FLAGS) -I. -DVER=\"$(SEM)\" -DCOM=\"$(COM)\" -DINFO=\"$(INFO)\" -Wno-narrowing -DUNIX_TIME=$(UNIX_TIME) #-DENABLE_SINC_MEDIUM_CONVERTER -DENABLE_SINC_FAST_CONVERTER -DCP_COLLISION_TYPE_TYPE=uintptr_t -DCP_BITMASK_TYPE=uintptr_t +CPPFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DCP_USE_DOUBLES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) $(WARNING_FLAGS) -I. -DVER=\"$(SEM)\" -DCOM=\"$(COM)\" -DINFO=\"$(INFO)\" -Wno-narrowing #-DENABLE_SINC_MEDIUM_CONVERTER -DENABLE_SINC_FAST_CONVERTER -DCP_COLLISION_TYPE_TYPE=uintptr_t -DCP_BITMASK_TYPE=uintptr_t CPPFLAGS += -DCONFIG_VERSION=\"2024-02-14\" -DCONFIG_BIGNUM #for quickjs # ENABLE_SINC_[BEST|FAST|MEDIUM]_CONVERTER diff --git a/source/engine/resources.c b/source/engine/resources.c index f1c3b884..5889d912 100644 --- a/source/engine/resources.c +++ b/source/engine/resources.c @@ -167,11 +167,17 @@ static int ls_ftw(const char *path, const struct stat *sb, int typeflag) time_t file_mod_secs(const char *file) { struct stat attr; + mz_uint index; + mz_zip_archive_file_stat pstat; - if (mz_zip_reader_locate_file(&game_cdb, file, NULL, 0) != -1) - stat("game.zip", &attr); - else if (mz_zip_reader_locate_file(&corecdb, file, NULL, 0) != -1) - return UNIX_TIME; + if ((index = mz_zip_reader_locate_file(&game_cdb, file, NULL, 0)) != -1) { + mz_zip_reader_file_stat(&game_cdb, index,&pstat); + return pstat.m_time; + } + else if ((index = mz_zip_reader_locate_file(&corecdb, file, NULL, 0)) != -1) { + mz_zip_reader_file_stat(&corecdb, index, &pstat); + return pstat.m_time; + } else stat(file, &attr); diff --git a/tools/packer.c b/tools/packer.c index ef4af6f0..4e9b8471 100644 --- a/tools/packer.c +++ b/tools/packer.c @@ -30,4 +30,4 @@ int main(int argc, char *argv[]) mz_zip_writer_end(&zip_archive); return 0; -} \ No newline at end of file +}