update cooker

main
Dominik Madarász 2023-08-26 15:33:29 +02:00
parent 380732c4ad
commit 3a70df594b
20 changed files with 304 additions and 89 deletions

View File

@ -23,9 +23,7 @@ int main() {
camera_t cam = camera(); camera_t cam = camera();
skybox_t sky = skybox("cubemaps/stardust", 0); skybox_t sky = skybox("cubemaps/stardust", 0);
model_t mdl = model("Stan.fbx", 0); model_t mdl = model("Stan.fbx", 0);
anims_t a = animations("Stan.anim", 0); anims_t a = animations("Stan.fbx", 0);
// load all postfx files in all subdirs // load all postfx files in all subdirs
fx_load("fx**.fs"); fx_load("fx**.fs");

View File

@ -0,0 +1,14 @@
frame: 0-50 AlienArmature|Alien_Clapping
frame: 51-106 AlienArmature|Alien_Death
frame: 107-207 AlienArmature|Alien_Idle
frame: 208-308 AlienArmature|Alien_IdleHold
frame: 309-334 AlienArmature|Alien_Jump
frame: 335-357 AlienArmature|Alien_Punch
frame: 358-379 AlienArmature|Alien_Run
frame: 380-401 AlienArmature|Alien_RunHold
frame: 402-432 AlienArmature|Alien_RunningJump
frame: 433-459 AlienArmature|Alien_Sitting
frame: 460-475 AlienArmature|Alien_Standing
frame: 476-508 AlienArmature|Alien_Swimming
frame: 509-534 AlienArmature|Alien_SwordSlash
frame: 535-560 AlienArmature|Alien_Walk

View File

@ -0,0 +1,14 @@
frame: 0-50 AlienArmature|Alien_Clapping
frame: 51-106 AlienArmature|Alien_Death
frame: 107-207 AlienArmature|Alien_Idle
frame: 208-308 AlienArmature|Alien_IdleHold
frame: 309-334 AlienArmature|Alien_Jump
frame: 335-357 AlienArmature|Alien_Punch
frame: 358-379 AlienArmature|Alien_Run
frame: 380-401 AlienArmature|Alien_RunHold
frame: 402-432 AlienArmature|Alien_RunningJump
frame: 433-459 AlienArmature|Alien_Sitting
frame: 460-475 AlienArmature|Alien_Standing
frame: 476-508 AlienArmature|Alien_Swimming
frame: 509-534 AlienArmature|Alien_SwordSlash
frame: 535-560 AlienArmature|Alien_Walk

View File

@ -0,0 +1 @@
frame: 0-506 Take 001

View File

@ -0,0 +1,40 @@
frame: 0-100 Idle
frame: 101-125 Dance
frame: 126-169 Death
frame: 170-215 Hello
frame: 216-228 HitRecieve_1
frame: 229-241 HitRecieve_2
frame: 242-268 Jump
frame: 269-310 No
frame: 311-353 Pickup
frame: 354-371 Punch
frame: 372-397 Run
frame: 398-423 Run_Holding
frame: 424-449 Run_Tall
frame: 450-465 Shoot
frame: 466-484 SwordSlash
frame: 485-510 Walk
frame: 511-536 Walk_Holding
frame: 537-562 Walk_Tall
frame: 563-604 Yes
frame: 605-623 Kick
frame: 624-648 RobotArmature|Dance
frame: 649-692 RobotArmature|Death
frame: 693-738 RobotArmature|Hello
frame: 739-751 RobotArmature|HitRecieve_1
frame: 752-764 RobotArmature|HitRecieve_2
frame: 765-865 RobotArmature|Idle
frame: 866-892 RobotArmature|Jump
frame: 893-911 RobotArmature|Kick
frame: 912-953 RobotArmature|No
frame: 954-996 RobotArmature|Pickup
frame: 997-1014 RobotArmature|Punch
frame: 1015-1040 RobotArmature|Run
frame: 1041-1066 RobotArmature|Run_Holding
frame: 1067-1092 RobotArmature|Run_Tall
frame: 1093-1108 RobotArmature|Shoot
frame: 1109-1127 RobotArmature|SwordSlash
frame: 1128-1153 RobotArmature|Walk
frame: 1154-1179 RobotArmature|Walk_Holding
frame: 1180-1205 RobotArmature|Walk_Tall
frame: 1206-1247 RobotArmature|Yes

View File

@ -0,0 +1,36 @@
frame: 0-24 Dance
frame: 25-68 Death
frame: 69-114 Hello
frame: 115-127 HitRecieve_1
frame: 128-140 HitRecieve_2
frame: 141-241 Idle
frame: 242-268 Jump
frame: 269-287 Kick
frame: 288-329 No
frame: 330-372 Pickup
frame: 373-390 Punch
frame: 391-416 Run
frame: 417-442 Run_Tall
frame: 443-458 Shoot
frame: 459-477 SwordSlash
frame: 478-503 Walk
frame: 504-529 Walk_Tall
frame: 530-572 Yes
frame: 573-597 RobotArmature|Dance
frame: 598-641 RobotArmature|Death
frame: 642-687 RobotArmature|Hello
frame: 688-700 RobotArmature|HitRecieve_1
frame: 701-713 RobotArmature|HitRecieve_2
frame: 714-814 RobotArmature|Idle
frame: 815-841 RobotArmature|Jump
frame: 842-860 RobotArmature|Kick
frame: 861-902 RobotArmature|No
frame: 903-945 RobotArmature|Pickup
frame: 946-963 RobotArmature|Punch
frame: 964-989 RobotArmature|Run
frame: 990-1015 RobotArmature|Run_Tall
frame: 1016-1031 RobotArmature|Shoot
frame: 1032-1050 RobotArmature|SwordSlash
frame: 1051-1076 RobotArmature|Walk
frame: 1077-1102 RobotArmature|Walk_Tall
frame: 1103-1145 RobotArmature|Yes

View File

@ -0,0 +1,36 @@
frame: 0-100 Idle
frame: 101-125 Dance
frame: 126-169 Death
frame: 170-215 Hello
frame: 216-228 HitRecieve_1
frame: 229-241 HitRecieve_2
frame: 242-268 Jump
frame: 269-311 No
frame: 312-354 Pickup
frame: 355-372 Punch
frame: 373-398 Run
frame: 399-424 Run_Holding
frame: 425-440 Shoot
frame: 441-459 SwordSlash
frame: 460-485 Walk
frame: 486-528 Yes
frame: 529-547 Kick
frame: 548-573 Walk_Holding
frame: 574-598 RobotArmature|Dance
frame: 599-642 RobotArmature|Death
frame: 643-688 RobotArmature|Hello
frame: 689-701 RobotArmature|HitRecieve_1
frame: 702-714 RobotArmature|HitRecieve_2
frame: 715-815 RobotArmature|Idle
frame: 816-842 RobotArmature|Jump
frame: 843-861 RobotArmature|Kick
frame: 862-904 RobotArmature|No
frame: 905-947 RobotArmature|Pickup
frame: 948-965 RobotArmature|Punch
frame: 966-991 RobotArmature|Run
frame: 992-1017 RobotArmature|Run_Holding
frame: 1018-1033 RobotArmature|Shoot
frame: 1034-1052 RobotArmature|SwordSlash
frame: 1053-1078 RobotArmature|Walk
frame: 1079-1104 RobotArmature|Walk_Holding
frame: 1105-1147 RobotArmature|Yes

Binary file not shown.

View File

@ -0,0 +1,36 @@
frame: 0-100 Idle
frame: 101-125 Dance
frame: 126-169 Death
frame: 170-215 Hello
frame: 216-228 HitRecieve_1
frame: 229-241 HitRecieve_2
frame: 242-268 Jump
frame: 269-311 No
frame: 312-354 Pickup
frame: 355-372 Punch
frame: 373-398 Run
frame: 399-424 Run_Holding
frame: 425-440 Shoot
frame: 441-459 SwordSlash
frame: 460-485 Walk
frame: 486-528 Yes
frame: 529-547 Kick
frame: 548-573 Walk_Holding
frame: 574-598 RobotArmature|Dance
frame: 599-642 RobotArmature|Death
frame: 643-688 RobotArmature|Hello
frame: 689-701 RobotArmature|HitRecieve_1
frame: 702-714 RobotArmature|HitRecieve_2
frame: 715-815 RobotArmature|Idle
frame: 816-842 RobotArmature|Jump
frame: 843-861 RobotArmature|Kick
frame: 862-904 RobotArmature|No
frame: 905-947 RobotArmature|Pickup
frame: 948-965 RobotArmature|Punch
frame: 966-991 RobotArmature|Run
frame: 992-1017 RobotArmature|Run_Holding
frame: 1018-1033 RobotArmature|Shoot
frame: 1034-1052 RobotArmature|SwordSlash
frame: 1053-1078 RobotArmature|Walk
frame: 1079-1104 RobotArmature|Walk_Holding
frame: 1105-1147 RobotArmature|Yes

View File

@ -0,0 +1 @@
frame: 0-0 Idle

View File

@ -1947,7 +1947,7 @@ COMPRESS_ZLIB = (12<<4),
char * file_normalize(const char *pathfile); char * file_normalize(const char *pathfile);
char * file_counter(const char *pathfile); char * file_counter(const char *pathfile);
uint64_t file_stamp(const char *pathfile); uint64_t file_stamp(const char *pathfile);
uint64_t file_stamp_epoch(const char *pathfile); uint64_t file_stamp10(const char *pathfile);
bool file_exist(const char *pathfile); bool file_exist(const char *pathfile);
bool file_delete(const char *pathfile); bool file_delete(const char *pathfile);
bool file_copy(const char *src, const char *dst); bool file_copy(const char *src, const char *dst);

View File

@ -15536,8 +15536,8 @@ API char * file_normalize(const char *pathfile); // c:/prj/dir/file.ext ->
//API char * file_normalize_with_folder(const char *pathfile); // c:/prj/dir/file.ext -> dir/file_ext //API char * file_normalize_with_folder(const char *pathfile); // c:/prj/dir/file.ext -> dir/file_ext
API char * file_counter(const char *pathfile); // in: v4k.ini -> out: v4k(001).ini -> out: v4k(002).ini [-> etc...] API char * file_counter(const char *pathfile); // in: v4k.ini -> out: v4k(001).ini -> out: v4k(002).ini [-> etc...]
API uint64_t file_stamp(const char *pathfile); // 20210319113316 (datetime in base10) API uint64_t file_stamp(const char *pathfile); // 1616153596 (seconds since unix epoch)
API uint64_t file_stamp_epoch(const char *pathfile); // 1616153596 (seconds since unix epoch) API uint64_t file_stamp10(const char *pathfile); // 20210319113316 (absolute datetime in base10)
API bool file_exist(const char *pathfile); API bool file_exist(const char *pathfile);
API bool file_delete(const char *pathfile); API bool file_delete(const char *pathfile);
@ -332114,7 +332114,7 @@ cook_script_t cook_script(const char *rules, const char *infile, const char *out
if( strchr(newer_extension, '.') ) { if( strchr(newer_extension, '.') ) {
// newer filename // newer filename
cs.outname = stringf("%s@%s", cs.outname ? cs.outname : infile, newer_extension); // @leak cs.outname = stringf("%s@%s", cs.outname ? cs.outname : infile, newer_extension); // @leak // special char (multi-pass cooks)
newer_extension = NULL; newer_extension = NULL;
} else { } else {
strcatf(&*OUTPUT, ".%s", newer_extension); strcatf(&*OUTPUT, ".%s", newer_extension);
@ -332271,6 +332271,7 @@ array(struct fs) zipscan_filter(int threadid, int numthreads) {
// long time ago but that is less resilient to file relocations across the repository. // long time ago but that is less resilient to file relocations across the repository.
// excluding the file extension from the hash also helps from external file conversions. // excluding the file extension from the hash also helps from external file conversions.
char *fname = file_name(fs_now[i].fname); char *fname = file_name(fs_now[i].fname);
char *sign = strrchr(fname, '@'); if(sign) *sign = '\0'; // special char (multi-pass cooks)
char *dot = strrchr(fname, '.'); if(dot) *dot = '\0'; char *dot = strrchr(fname, '.'); if(dot) *dot = '\0';
// skip if list item does not belong to this thread bucket // skip if list item does not belong to this thread bucket
@ -332306,9 +332307,10 @@ int zipscan_diff( zip* old, array(struct fs) now ) {
array_push(uncooked, STRDUP(now[i].fname)); array_push(uncooked, STRDUP(now[i].fname));
} else { } else {
uint64_t oldsize = atoi64(zip_comment(old,found)); // zip_size(old, found); returns sizeof processed asset. return original size of unprocessed asset, which we store in comment section uint64_t oldsize = atoi64(zip_comment(old,found)); // zip_size(old, found); returns sizeof processed asset. return original size of unprocessed asset, which we store in comment section
uint64_t oldstamp = atoi64(zip_modt(old, found)+20); uint64_t oldstamp = atoi64(zip_modt(old,found)+20); // format is "YYYY/MM/DD hh:mm:ss", then +20 chars later a hidden epoch timestamp in base10 can be found
if( oldsize != now[i].bytes || oldstamp > (now[i].stamp + 1) ) { // @fixme: should use hash instead. hashof(tool) ^ hashof(args used) ^ hashof(rawsize) ^ hashof(rawdate) int64_t diffstamp = oldstamp < now[i].stamp ? now[i].stamp - oldstamp : oldstamp - now[i].stamp;
printf("%s:\t%u vs %u, %u vs %u\n", now[i].fname, (unsigned)oldsize,(unsigned)now[i].bytes, (unsigned)oldstamp,(unsigned)now[i].stamp); if( oldsize != now[i].bytes || diffstamp > 1 ) { // @fixme: should use hash instead. hashof(tool) ^ hashof(args used) ^ hashof(rawsize) ^ hashof(rawdate)
printf("%s:\t%u vs %u, %llu vs %llu\n", now[i].fname, (unsigned)oldsize,(unsigned)now[i].bytes, oldstamp,now[i].stamp);
array_push(changed, STRDUP(now[i].fname)); array_push(changed, STRDUP(now[i].fname));
array_push(uncooked, STRDUP(now[i].fname)); array_push(uncooked, STRDUP(now[i].fname));
} }
@ -332317,6 +332319,8 @@ int zipscan_diff( zip* old, array(struct fs) now ) {
// compare for deleted files // compare for deleted files
for( int i = 0; i < zip_count(old); ++i ) { for( int i = 0; i < zip_count(old); ++i ) {
char *oldname = zip_name(old, i); char *oldname = zip_name(old, i);
//if( strchr(oldname, '@') ) oldname = va("%*.s", (int)(strchr(oldname, '@') - oldname), oldname ); // special char (multi-pass cooks)
int idx = zip_find(old, oldname); // find latest versioned file in zip int idx = zip_find(old, oldname); // find latest versioned file in zip
unsigned oldsize = zip_size(old, idx); unsigned oldsize = zip_size(old, idx);
if (!oldsize) continue; if (!oldsize) continue;
@ -332430,12 +332434,22 @@ int cook(void *userdata) {
int outlen = file_size(cs.outfile); int outlen = file_size(cs.outfile);
int failed = cs.script[0] ? rc || !outlen : 0; int failed = cs.script[0] ? rc || !outlen : 0;
// print errors, or... // print errors
if( failed ) { if( failed ) {
PRINTF("Import failed: %s while executing:\n%s\nReturned:\n%s\n", cs.outname, cs.script, rc_output); PRINTF("Import failed: %s while executing:\n%s\nReturned:\n%s\n", cs.outname, cs.script, rc_output);
continue;
} }
// ...process only if included. may include optional compression.
else if( cs.compress_level >= 0 ) { // special char (multi-pass cook). newly generated file: refresh values
// ensure newly created files by cook are also present on repo/disc for further cook passes
if( pass > 0 ) { // && strchr(cs.outname, '@') ) { // pass>0 is a small optimization // special char (multi-pass cooks)
file_delete(cs.outname);
file_move(cs.outfile, cs.outname);
inlen = file_size(infile = cs.outfile = cs.outname);
}
// process only if included. may include optional compression.
if( cs.compress_level >= 0 ) {
FILE *in = fopen(cs.outfile, "rb"); FILE *in = fopen(cs.outfile, "rb");
#if 0 #if 0
@ -332445,13 +332459,12 @@ int cook(void *userdata) {
#endif #endif
char *comment = va("%d", inlen); char *comment = va("%d", inlen);
if( !zip_append_file/*_timeinfo*/(z, cs.outname, comment, in, cs.compress_level/*, timeinfo*/) ) { if( !zip_append_file/*_timeinfo*/(z, infile, comment, in, cs.compress_level/*, timeinfo*/) ) {
PANIC("failed to add processed file into %s: %s(%s)", zipfile, cs.outname, infile); PANIC("failed to add processed file into %s: %s(%s)", zipfile, cs.outname, infile);
} }
fclose(in); fclose(in);
} }
} }
} }
@ -332637,7 +332650,7 @@ bool cook_start( const char *cook_ini, const char *masks, int flags ) {
struct fs fi = {0}; struct fs fi = {0};
fi.fname = fname; // STRDUP(fname); fi.fname = fname; // STRDUP(fname);
fi.bytes = file_size(fname); fi.bytes = file_size(fname);
fi.stamp = file_stamp(fname); // human-readable base10 timestamp fi.stamp = file_stamp10(fname); // timestamp in base10(yyyymmddhhmmss)
array_push(fs_now, fi); array_push(fs_now, fi);
} }
@ -333174,11 +333187,6 @@ bool file_append(const char *name, const void *ptr, int len) {
} }
return ok; return ok;
} }
uint64_t file_stamp(const char *fname) {
time_t mtime = (time_t)file_stamp_epoch(fname);
struct tm *ti = localtime(&mtime);
return atoi64(va("%04d%02d%02d%02d%02d%02d",ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec));
}
static bool file_stat(const char *fname, struct stat *st) { static bool file_stat(const char *fname, struct stat *st) {
// remove ending slashes. win32+tcc does not like them. // remove ending slashes. win32+tcc does not like them.
int l = strlen(fname), m = l; int l = strlen(fname), m = l;
@ -333186,10 +333194,15 @@ static bool file_stat(const char *fname, struct stat *st) {
fname = l == m ? fname : va("%.*s", l, fname); fname = l == m ? fname : va("%.*s", l, fname);
return stat(fname, st) >= 0; return stat(fname, st) >= 0;
} }
uint64_t file_stamp_epoch(const char *fname) { uint64_t file_stamp(const char *fname) {
struct stat st; struct stat st;
return !file_stat(fname, &st) ? 0ULL : st.st_mtime; return !file_stat(fname, &st) ? 0ULL : st.st_mtime;
} }
uint64_t file_stamp10(const char *fname) {
time_t mtime = (time_t)file_stamp(fname);
struct tm *ti = localtime(&mtime);
return atoi64(va("%04d%02d%02d%02d%02d%02d",ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec));
}
uint64_t file_size(const char *fname) { uint64_t file_size(const char *fname) {
struct stat st; struct stat st;
return !file_stat(fname, &st) ? 0ULL : st.st_size; return !file_stat(fname, &st) ? 0ULL : st.st_size;
@ -344110,7 +344123,7 @@ void model_destroy(model_t m) {
anims_t animations(const char *pathfile, int flags) { anims_t animations(const char *pathfile, int flags) {
anims_t a = {0}; anims_t a = {0};
char *anim_file = vfs_read(pathfile); char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
for each_substring(anim_file, "\r\n", anim) { for each_substring(anim_file, "\r\n", anim) {
int from, to; int from, to;
char anim_name[128] = {0}; char anim_name[128] = {0};

View File

@ -202,7 +202,7 @@ cook_script_t cook_script(const char *rules, const char *infile, const char *out
if( strchr(newer_extension, '.') ) { if( strchr(newer_extension, '.') ) {
// newer filename // newer filename
cs.outname = stringf("%s@%s", cs.outname ? cs.outname : infile, newer_extension); // @leak cs.outname = stringf("%s@%s", cs.outname ? cs.outname : infile, newer_extension); // @leak // special char (multi-pass cooks)
newer_extension = NULL; newer_extension = NULL;
} else { } else {
strcatf(&*OUTPUT, ".%s", newer_extension); strcatf(&*OUTPUT, ".%s", newer_extension);
@ -359,6 +359,7 @@ array(struct fs) zipscan_filter(int threadid, int numthreads) {
// long time ago but that is less resilient to file relocations across the repository. // long time ago but that is less resilient to file relocations across the repository.
// excluding the file extension from the hash also helps from external file conversions. // excluding the file extension from the hash also helps from external file conversions.
char *fname = file_name(fs_now[i].fname); char *fname = file_name(fs_now[i].fname);
char *sign = strrchr(fname, '@'); if(sign) *sign = '\0'; // special char (multi-pass cooks)
char *dot = strrchr(fname, '.'); if(dot) *dot = '\0'; char *dot = strrchr(fname, '.'); if(dot) *dot = '\0';
// skip if list item does not belong to this thread bucket // skip if list item does not belong to this thread bucket
@ -394,9 +395,10 @@ int zipscan_diff( zip* old, array(struct fs) now ) {
array_push(uncooked, STRDUP(now[i].fname)); array_push(uncooked, STRDUP(now[i].fname));
} else { } else {
uint64_t oldsize = atoi64(zip_comment(old,found)); // zip_size(old, found); returns sizeof processed asset. return original size of unprocessed asset, which we store in comment section uint64_t oldsize = atoi64(zip_comment(old,found)); // zip_size(old, found); returns sizeof processed asset. return original size of unprocessed asset, which we store in comment section
uint64_t oldstamp = atoi64(zip_modt(old, found)+20); uint64_t oldstamp = atoi64(zip_modt(old,found)+20); // format is "YYYY/MM/DD hh:mm:ss", then +20 chars later a hidden epoch timestamp in base10 can be found
if( oldsize != now[i].bytes || oldstamp > (now[i].stamp + 1) ) { // @fixme: should use hash instead. hashof(tool) ^ hashof(args used) ^ hashof(rawsize) ^ hashof(rawdate) int64_t diffstamp = oldstamp < now[i].stamp ? now[i].stamp - oldstamp : oldstamp - now[i].stamp;
printf("%s:\t%u vs %u, %u vs %u\n", now[i].fname, (unsigned)oldsize,(unsigned)now[i].bytes, (unsigned)oldstamp,(unsigned)now[i].stamp); if( oldsize != now[i].bytes || diffstamp > 1 ) { // @fixme: should use hash instead. hashof(tool) ^ hashof(args used) ^ hashof(rawsize) ^ hashof(rawdate)
printf("%s:\t%u vs %u, %llu vs %llu\n", now[i].fname, (unsigned)oldsize,(unsigned)now[i].bytes, oldstamp,now[i].stamp);
array_push(changed, STRDUP(now[i].fname)); array_push(changed, STRDUP(now[i].fname));
array_push(uncooked, STRDUP(now[i].fname)); array_push(uncooked, STRDUP(now[i].fname));
} }
@ -405,6 +407,8 @@ int zipscan_diff( zip* old, array(struct fs) now ) {
// compare for deleted files // compare for deleted files
for( int i = 0; i < zip_count(old); ++i ) { for( int i = 0; i < zip_count(old); ++i ) {
char *oldname = zip_name(old, i); char *oldname = zip_name(old, i);
//if( strchr(oldname, '@') ) oldname = va("%*.s", (int)(strchr(oldname, '@') - oldname), oldname ); // special char (multi-pass cooks)
int idx = zip_find(old, oldname); // find latest versioned file in zip int idx = zip_find(old, oldname); // find latest versioned file in zip
unsigned oldsize = zip_size(old, idx); unsigned oldsize = zip_size(old, idx);
if (!oldsize) continue; if (!oldsize) continue;
@ -518,12 +522,22 @@ int cook(void *userdata) {
int outlen = file_size(cs.outfile); int outlen = file_size(cs.outfile);
int failed = cs.script[0] ? rc || !outlen : 0; int failed = cs.script[0] ? rc || !outlen : 0;
// print errors, or... // print errors
if( failed ) { if( failed ) {
PRINTF("Import failed: %s while executing:\n%s\nReturned:\n%s\n", cs.outname, cs.script, rc_output); PRINTF("Import failed: %s while executing:\n%s\nReturned:\n%s\n", cs.outname, cs.script, rc_output);
continue;
} }
// ...process only if included. may include optional compression.
else if( cs.compress_level >= 0 ) { // special char (multi-pass cook). newly generated file: refresh values
// ensure newly created files by cook are also present on repo/disc for further cook passes
if( pass > 0 ) { // && strchr(cs.outname, '@') ) { // pass>0 is a small optimization // special char (multi-pass cooks)
file_delete(cs.outname);
file_move(cs.outfile, cs.outname);
inlen = file_size(infile = cs.outfile = cs.outname);
}
// process only if included. may include optional compression.
if( cs.compress_level >= 0 ) {
FILE *in = fopen(cs.outfile, "rb"); FILE *in = fopen(cs.outfile, "rb");
#if 0 #if 0
@ -533,13 +547,12 @@ int cook(void *userdata) {
#endif #endif
char *comment = va("%d", inlen); char *comment = va("%d", inlen);
if( !zip_append_file/*_timeinfo*/(z, cs.outname, comment, in, cs.compress_level/*, timeinfo*/) ) { if( !zip_append_file/*_timeinfo*/(z, infile, comment, in, cs.compress_level/*, timeinfo*/) ) {
PANIC("failed to add processed file into %s: %s(%s)", zipfile, cs.outname, infile); PANIC("failed to add processed file into %s: %s(%s)", zipfile, cs.outname, infile);
} }
fclose(in); fclose(in);
} }
} }
} }
@ -725,7 +738,7 @@ bool cook_start( const char *cook_ini, const char *masks, int flags ) {
struct fs fi = {0}; struct fs fi = {0};
fi.fname = fname; // STRDUP(fname); fi.fname = fname; // STRDUP(fname);
fi.bytes = file_size(fname); fi.bytes = file_size(fname);
fi.stamp = file_stamp(fname); // human-readable base10 timestamp fi.stamp = file_stamp10(fname); // timestamp in base10(yyyymmddhhmmss)
array_push(fs_now, fi); array_push(fs_now, fi);
} }

View File

@ -79,11 +79,6 @@ bool file_append(const char *name, const void *ptr, int len) {
} }
return ok; return ok;
} }
uint64_t file_stamp(const char *fname) {
time_t mtime = (time_t)file_stamp_epoch(fname);
struct tm *ti = localtime(&mtime);
return atoi64(va("%04d%02d%02d%02d%02d%02d",ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec));
}
static bool file_stat(const char *fname, struct stat *st) { static bool file_stat(const char *fname, struct stat *st) {
// remove ending slashes. win32+tcc does not like them. // remove ending slashes. win32+tcc does not like them.
int l = strlen(fname), m = l; int l = strlen(fname), m = l;
@ -91,10 +86,15 @@ static bool file_stat(const char *fname, struct stat *st) {
fname = l == m ? fname : va("%.*s", l, fname); fname = l == m ? fname : va("%.*s", l, fname);
return stat(fname, st) >= 0; return stat(fname, st) >= 0;
} }
uint64_t file_stamp_epoch(const char *fname) { uint64_t file_stamp(const char *fname) {
struct stat st; struct stat st;
return !file_stat(fname, &st) ? 0ULL : st.st_mtime; return !file_stat(fname, &st) ? 0ULL : st.st_mtime;
} }
uint64_t file_stamp10(const char *fname) {
time_t mtime = (time_t)file_stamp(fname);
struct tm *ti = localtime(&mtime);
return atoi64(va("%04d%02d%02d%02d%02d%02d",ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec));
}
uint64_t file_size(const char *fname) { uint64_t file_size(const char *fname) {
struct stat st; struct stat st;
return !file_stat(fname, &st) ? 0ULL : st.st_size; return !file_stat(fname, &st) ? 0ULL : st.st_size;

View File

@ -28,8 +28,8 @@ API char * file_normalize(const char *pathfile); // c:/prj/dir/file.ext ->
//API char * file_normalize_with_folder(const char *pathfile); // c:/prj/dir/file.ext -> dir/file_ext //API char * file_normalize_with_folder(const char *pathfile); // c:/prj/dir/file.ext -> dir/file_ext
API char * file_counter(const char *pathfile); // in: v4k.ini -> out: v4k(001).ini -> out: v4k(002).ini [-> etc...] API char * file_counter(const char *pathfile); // in: v4k.ini -> out: v4k(001).ini -> out: v4k(002).ini [-> etc...]
API uint64_t file_stamp(const char *pathfile); // 20210319113316 (datetime in base10) API uint64_t file_stamp(const char *pathfile); // 1616153596 (seconds since unix epoch)
API uint64_t file_stamp_epoch(const char *pathfile); // 1616153596 (seconds since unix epoch) API uint64_t file_stamp10(const char *pathfile); // 20210319113316 (absolute datetime in base10)
API bool file_exist(const char *pathfile); API bool file_exist(const char *pathfile);
API bool file_delete(const char *pathfile); API bool file_delete(const char *pathfile);

View File

@ -4222,7 +4222,7 @@ void model_destroy(model_t m) {
anims_t animations(const char *pathfile, int flags) { anims_t animations(const char *pathfile, int flags) {
anims_t a = {0}; anims_t a = {0};
char *anim_file = vfs_read(pathfile); char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
for each_substring(anim_file, "\r\n", anim) { for each_substring(anim_file, "\r\n", anim) {
int from, to; int from, to;
char anim_name[128] = {0}; char anim_name[128] = {0};

View File

@ -3127,7 +3127,7 @@ cook_script_t cook_script(const char *rules, const char *infile, const char *out
if( strchr(newer_extension, '.') ) { if( strchr(newer_extension, '.') ) {
// newer filename // newer filename
cs.outname = stringf("%s@%s", cs.outname ? cs.outname : infile, newer_extension); // @leak cs.outname = stringf("%s@%s", cs.outname ? cs.outname : infile, newer_extension); // @leak // special char (multi-pass cooks)
newer_extension = NULL; newer_extension = NULL;
} else { } else {
strcatf(&*OUTPUT, ".%s", newer_extension); strcatf(&*OUTPUT, ".%s", newer_extension);
@ -3284,6 +3284,7 @@ array(struct fs) zipscan_filter(int threadid, int numthreads) {
// long time ago but that is less resilient to file relocations across the repository. // long time ago but that is less resilient to file relocations across the repository.
// excluding the file extension from the hash also helps from external file conversions. // excluding the file extension from the hash also helps from external file conversions.
char *fname = file_name(fs_now[i].fname); char *fname = file_name(fs_now[i].fname);
char *sign = strrchr(fname, '@'); if(sign) *sign = '\0'; // special char (multi-pass cooks)
char *dot = strrchr(fname, '.'); if(dot) *dot = '\0'; char *dot = strrchr(fname, '.'); if(dot) *dot = '\0';
// skip if list item does not belong to this thread bucket // skip if list item does not belong to this thread bucket
@ -3319,9 +3320,10 @@ int zipscan_diff( zip* old, array(struct fs) now ) {
array_push(uncooked, STRDUP(now[i].fname)); array_push(uncooked, STRDUP(now[i].fname));
} else { } else {
uint64_t oldsize = atoi64(zip_comment(old,found)); // zip_size(old, found); returns sizeof processed asset. return original size of unprocessed asset, which we store in comment section uint64_t oldsize = atoi64(zip_comment(old,found)); // zip_size(old, found); returns sizeof processed asset. return original size of unprocessed asset, which we store in comment section
uint64_t oldstamp = atoi64(zip_modt(old, found)+20); uint64_t oldstamp = atoi64(zip_modt(old,found)+20); // format is "YYYY/MM/DD hh:mm:ss", then +20 chars later a hidden epoch timestamp in base10 can be found
if( oldsize != now[i].bytes || oldstamp > (now[i].stamp + 1) ) { // @fixme: should use hash instead. hashof(tool) ^ hashof(args used) ^ hashof(rawsize) ^ hashof(rawdate) int64_t diffstamp = oldstamp < now[i].stamp ? now[i].stamp - oldstamp : oldstamp - now[i].stamp;
printf("%s:\t%u vs %u, %u vs %u\n", now[i].fname, (unsigned)oldsize,(unsigned)now[i].bytes, (unsigned)oldstamp,(unsigned)now[i].stamp); if( oldsize != now[i].bytes || diffstamp > 1 ) { // @fixme: should use hash instead. hashof(tool) ^ hashof(args used) ^ hashof(rawsize) ^ hashof(rawdate)
printf("%s:\t%u vs %u, %llu vs %llu\n", now[i].fname, (unsigned)oldsize,(unsigned)now[i].bytes, oldstamp,now[i].stamp);
array_push(changed, STRDUP(now[i].fname)); array_push(changed, STRDUP(now[i].fname));
array_push(uncooked, STRDUP(now[i].fname)); array_push(uncooked, STRDUP(now[i].fname));
} }
@ -3330,6 +3332,8 @@ int zipscan_diff( zip* old, array(struct fs) now ) {
// compare for deleted files // compare for deleted files
for( int i = 0; i < zip_count(old); ++i ) { for( int i = 0; i < zip_count(old); ++i ) {
char *oldname = zip_name(old, i); char *oldname = zip_name(old, i);
//if( strchr(oldname, '@') ) oldname = va("%*.s", (int)(strchr(oldname, '@') - oldname), oldname ); // special char (multi-pass cooks)
int idx = zip_find(old, oldname); // find latest versioned file in zip int idx = zip_find(old, oldname); // find latest versioned file in zip
unsigned oldsize = zip_size(old, idx); unsigned oldsize = zip_size(old, idx);
if (!oldsize) continue; if (!oldsize) continue;
@ -3443,12 +3447,22 @@ int cook(void *userdata) {
int outlen = file_size(cs.outfile); int outlen = file_size(cs.outfile);
int failed = cs.script[0] ? rc || !outlen : 0; int failed = cs.script[0] ? rc || !outlen : 0;
// print errors, or... // print errors
if( failed ) { if( failed ) {
PRINTF("Import failed: %s while executing:\n%s\nReturned:\n%s\n", cs.outname, cs.script, rc_output); PRINTF("Import failed: %s while executing:\n%s\nReturned:\n%s\n", cs.outname, cs.script, rc_output);
continue;
} }
// ...process only if included. may include optional compression.
else if( cs.compress_level >= 0 ) { // special char (multi-pass cook). newly generated file: refresh values
// ensure newly created files by cook are also present on repo/disc for further cook passes
if( pass > 0 ) { // && strchr(cs.outname, '@') ) { // pass>0 is a small optimization // special char (multi-pass cooks)
file_delete(cs.outname);
file_move(cs.outfile, cs.outname);
inlen = file_size(infile = cs.outfile = cs.outname);
}
// process only if included. may include optional compression.
if( cs.compress_level >= 0 ) {
FILE *in = fopen(cs.outfile, "rb"); FILE *in = fopen(cs.outfile, "rb");
#if 0 #if 0
@ -3458,13 +3472,12 @@ int cook(void *userdata) {
#endif #endif
char *comment = va("%d", inlen); char *comment = va("%d", inlen);
if( !zip_append_file/*_timeinfo*/(z, cs.outname, comment, in, cs.compress_level/*, timeinfo*/) ) { if( !zip_append_file/*_timeinfo*/(z, infile, comment, in, cs.compress_level/*, timeinfo*/) ) {
PANIC("failed to add processed file into %s: %s(%s)", zipfile, cs.outname, infile); PANIC("failed to add processed file into %s: %s(%s)", zipfile, cs.outname, infile);
} }
fclose(in); fclose(in);
} }
} }
} }
@ -3650,7 +3663,7 @@ bool cook_start( const char *cook_ini, const char *masks, int flags ) {
struct fs fi = {0}; struct fs fi = {0};
fi.fname = fname; // STRDUP(fname); fi.fname = fname; // STRDUP(fname);
fi.bytes = file_size(fname); fi.bytes = file_size(fname);
fi.stamp = file_stamp(fname); // human-readable base10 timestamp fi.stamp = file_stamp10(fname); // timestamp in base10(yyyymmddhhmmss)
array_push(fs_now, fi); array_push(fs_now, fi);
} }
@ -4187,11 +4200,6 @@ bool file_append(const char *name, const void *ptr, int len) {
} }
return ok; return ok;
} }
uint64_t file_stamp(const char *fname) {
time_t mtime = (time_t)file_stamp_epoch(fname);
struct tm *ti = localtime(&mtime);
return atoi64(va("%04d%02d%02d%02d%02d%02d",ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec));
}
static bool file_stat(const char *fname, struct stat *st) { static bool file_stat(const char *fname, struct stat *st) {
// remove ending slashes. win32+tcc does not like them. // remove ending slashes. win32+tcc does not like them.
int l = strlen(fname), m = l; int l = strlen(fname), m = l;
@ -4199,10 +4207,15 @@ static bool file_stat(const char *fname, struct stat *st) {
fname = l == m ? fname : va("%.*s", l, fname); fname = l == m ? fname : va("%.*s", l, fname);
return stat(fname, st) >= 0; return stat(fname, st) >= 0;
} }
uint64_t file_stamp_epoch(const char *fname) { uint64_t file_stamp(const char *fname) {
struct stat st; struct stat st;
return !file_stat(fname, &st) ? 0ULL : st.st_mtime; return !file_stat(fname, &st) ? 0ULL : st.st_mtime;
} }
uint64_t file_stamp10(const char *fname) {
time_t mtime = (time_t)file_stamp(fname);
struct tm *ti = localtime(&mtime);
return atoi64(va("%04d%02d%02d%02d%02d%02d",ti->tm_year+1900,ti->tm_mon+1,ti->tm_mday,ti->tm_hour,ti->tm_min,ti->tm_sec));
}
uint64_t file_size(const char *fname) { uint64_t file_size(const char *fname) {
struct stat st; struct stat st;
return !file_stat(fname, &st) ? 0ULL : st.st_size; return !file_stat(fname, &st) ? 0ULL : st.st_size;
@ -15123,7 +15136,7 @@ void model_destroy(model_t m) {
anims_t animations(const char *pathfile, int flags) { anims_t animations(const char *pathfile, int flags) {
anims_t a = {0}; anims_t a = {0};
char *anim_file = vfs_read(pathfile); char *anim_file = vfs_read(va("%s@animlist.txt", pathfile));
for each_substring(anim_file, "\r\n", anim) { for each_substring(anim_file, "\r\n", anim) {
int from, to; int from, to;
char anim_name[128] = {0}; char anim_name[128] = {0};

View File

@ -1619,8 +1619,8 @@ API char * file_normalize(const char *pathfile); // c:/prj/dir/file.ext ->
//API char * file_normalize_with_folder(const char *pathfile); // c:/prj/dir/file.ext -> dir/file_ext //API char * file_normalize_with_folder(const char *pathfile); // c:/prj/dir/file.ext -> dir/file_ext
API char * file_counter(const char *pathfile); // in: v4k.ini -> out: v4k(001).ini -> out: v4k(002).ini [-> etc...] API char * file_counter(const char *pathfile); // in: v4k.ini -> out: v4k(001).ini -> out: v4k(002).ini [-> etc...]
API uint64_t file_stamp(const char *pathfile); // 20210319113316 (datetime in base10) API uint64_t file_stamp(const char *pathfile); // 1616153596 (seconds since unix epoch)
API uint64_t file_stamp_epoch(const char *pathfile); // 1616153596 (seconds since unix epoch) API uint64_t file_stamp10(const char *pathfile); // 20210319113316 (absolute datetime in base10)
API bool file_exist(const char *pathfile); API bool file_exist(const char *pathfile);
API bool file_delete(const char *pathfile); API bool file_delete(const char *pathfile);

File diff suppressed because one or more lines are too long

Binary file not shown.