From f727f387aee2b7237d2e30de1196331403165cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sun, 22 Oct 2023 00:05:22 +0200 Subject: [PATCH] sync fwk --- _mirror | 2 +- engine/joint/v4k.h | 31 +++++++++++++++++-------------- engine/split/v4k_config.h | 2 +- engine/split/v4k_cooker.c | 11 +++++++---- engine/split/v4k_obj.c | 4 ++-- engine/split/v4k_pack.c | 8 ++++---- engine/split/v4k_render.c | 2 +- engine/v4k.c | 25 ++++++++++++++----------- engine/v4k.h | 2 +- 9 files changed, 48 insertions(+), 39 deletions(-) diff --git a/_mirror b/_mirror index f7cf64e..b7dc665 160000 --- a/_mirror +++ b/_mirror @@ -1 +1 @@ -Subproject commit f7cf64ed703b21981c5c5e600bd55c43e0b9e66e +Subproject commit b7dc66559ecfae5c485f883470384eaf7e9fb55f diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 99f8c2f..ee6341b 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -14148,7 +14148,7 @@ extern "C" { #define ifdef_release ifdef_false #endif -#if ENABLE_RETAIL +#if ENABLE_RETAIL // NDEBUG>=2 ? #define ifdef_retail ifdef_true #else #define ifdef_retail ifdef_false @@ -336213,11 +336213,14 @@ int cook(void *userdata) { cook_subscript_t cs = mcs.cs[pass]; // log to batch file for forensic purposes, if explicitly requested - static __thread bool logging = 0; do_once logging = !!flag("--cook-debug") || cook_debug; + static __thread int logging = -1; if(logging < 0) logging = !!flag("--cook-debug") || cook_debug; if( logging ) { - FILE *logfile = fopen(va("cook%d.cmd",job->threadid), "a+t"); - if( logfile ) { fprintf(logfile, "@rem %s\n%s\n", cs.outname, cs.script); fclose(logfile); } - fprintf(stderr, "%s\n", cs.script); + static __thread FILE *logfile = 0; if(!logfile) fseek(logfile = fopen(va("cook%d.cmd",job->threadid), "a+t"), 0L, SEEK_END); + if( logfile ) { + fprintf(logfile, "@rem %s\n%s\n", cs.outname, cs.script); + fprintf(logfile, "for %%%%i in (\"%s\") do md _cook\\%%%%~pi\\%%%%~ni%%%%~xi 1>nul 2>nul\n", infile); + fprintf(logfile, "for %%%%i in (\"%s\") do xcopy /y %s _cook\\%%%%~pi\\%%%%~ni%%%%~xi\n\n", infile, file_normalize(cs.outfile)); + } } // invoke cooking script and recap status @@ -343241,12 +343244,12 @@ char* ftoa4(vec4 v) { float atof1(const char *s) { char buf[64]; - return sscanf(s, "%64[^]\r\n,}]", buf) == 1 ? (float)eval(buf) : (float)NAN; + return sscanf(s, "%63[^]\r\n,}]", buf) == 1 ? (float)eval(buf) : (float)NAN; } vec2 atof2(const char *s) { vec2 v = { 0 }; char buf1[64],buf2[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); return v; @@ -343254,7 +343257,7 @@ vec2 atof2(const char *s) { vec3 atof3(const char *s) { vec3 v = {0}; char buf1[64],buf2[64],buf3[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2, buf3); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2, buf3); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); if( num > 2 ) v.z = eval(buf3); @@ -343263,7 +343266,7 @@ vec3 atof3(const char *s) { vec4 atof4(const char *s) { vec4 v = {0}; char buf1[64],buf2[64],buf3[64],buf4[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2, buf3, buf4); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2, buf3, buf4); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); if( num > 2 ) v.z = eval(buf3); @@ -348010,7 +348013,7 @@ unsigned fbo(unsigned color_texture_id, unsigned depth_texture_id, int flags) { if( color_texture_id ) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_texture_id, 0); if( depth_texture_id ) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture_id, 0); -#if 0 +#if 0 // this is working; it's just not enabled for now else { // create a non-sampleable renderbuffer object for depth and stencil attachments unsigned int rbo; @@ -355566,7 +355569,7 @@ void window_drop_callback(GLFWwindow* window, int count, const char** paths) { void window_hints(unsigned flags) { #ifdef __APPLE__ //glfwInitHint( GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE ); - //glfwWindowHint( GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE ); + glfwWindowHint( GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE ); //glfwWindowHint( GLFW_COCOA_GRAPHICS_SWITCHING, GLFW_FALSE ); //glfwWindowHint( GLFW_COCOA_MENUBAR, GLFW_FALSE ); #endif @@ -356441,7 +356444,7 @@ int window_record(const char *outfile_mp4) { vec2 window_dpi() { vec2 dpi = vec2(1,1); -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__APPLE__) glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &dpi.x, &dpi.y); #endif return dpi; @@ -357183,7 +357186,7 @@ obj *obj_mergeini(void *o, const char *ini) { // @testme ini = sqr+1; char T[64] = {0}; - if( sscanf(ini, "%64[^]]", &T) != 1 ) return 0; // @todo: parse version as well + if( sscanf(ini, "%63[^]]", T) != 1 ) return 0; // @todo: parse version as well ini += strlen(T); for each_member(T,R) { @@ -357467,7 +357470,7 @@ void *obj_make(const char *str) { else T = I < J ? I : J; char name[64] = {0}; - if( sscanf(T+1, T == I ? "%64[^]]" : "%64[^:=]", &name) != 1 ) return 0; + if( sscanf(T+1, T == I ? "%63[^]]" : "%63[^:=]", name) != 1 ) return 0; int has_components = 0; // @todo: support entities too diff --git a/engine/split/v4k_config.h b/engine/split/v4k_config.h index d28c26a..ee36496 100644 --- a/engine/split/v4k_config.h +++ b/engine/split/v4k_config.h @@ -117,7 +117,7 @@ #define ifdef_release ifdef_false #endif -#if ENABLE_RETAIL +#if ENABLE_RETAIL // NDEBUG>=2 ? #define ifdef_retail ifdef_true #else #define ifdef_retail ifdef_false diff --git a/engine/split/v4k_cooker.c b/engine/split/v4k_cooker.c index 1bf843e..179a49b 100644 --- a/engine/split/v4k_cooker.c +++ b/engine/split/v4k_cooker.c @@ -509,11 +509,14 @@ int cook(void *userdata) { cook_subscript_t cs = mcs.cs[pass]; // log to batch file for forensic purposes, if explicitly requested - static __thread bool logging = 0; do_once logging = !!flag("--cook-debug") || cook_debug; + static __thread int logging = -1; if(logging < 0) logging = !!flag("--cook-debug") || cook_debug; if( logging ) { - FILE *logfile = fopen(va("cook%d.cmd",job->threadid), "a+t"); - if( logfile ) { fprintf(logfile, "@rem %s\n%s\n", cs.outname, cs.script); fclose(logfile); } - fprintf(stderr, "%s\n", cs.script); + static __thread FILE *logfile = 0; if(!logfile) fseek(logfile = fopen(va("cook%d.cmd",job->threadid), "a+t"), 0L, SEEK_END); + if( logfile ) { + fprintf(logfile, "@rem %s\n%s\n", cs.outname, cs.script); + fprintf(logfile, "for %%%%i in (\"%s\") do md _cook\\%%%%~pi\\%%%%~ni%%%%~xi 1>nul 2>nul\n", infile); + fprintf(logfile, "for %%%%i in (\"%s\") do xcopy /y %s _cook\\%%%%~pi\\%%%%~ni%%%%~xi\n\n", infile, file_normalize(cs.outfile)); + } } // invoke cooking script and recap status diff --git a/engine/split/v4k_obj.c b/engine/split/v4k_obj.c index 18db346..2c0d7ca 100644 --- a/engine/split/v4k_obj.c +++ b/engine/split/v4k_obj.c @@ -499,7 +499,7 @@ obj *obj_mergeini(void *o, const char *ini) { // @testme ini = sqr+1; char T[64] = {0}; - if( sscanf(ini, "%64[^]]", &T) != 1 ) return 0; // @todo: parse version as well + if( sscanf(ini, "%63[^]]", T) != 1 ) return 0; // @todo: parse version as well ini += strlen(T); for each_member(T,R) { @@ -783,7 +783,7 @@ void *obj_make(const char *str) { else T = I < J ? I : J; char name[64] = {0}; - if( sscanf(T+1, T == I ? "%64[^]]" : "%64[^:=]", &name) != 1 ) return 0; + if( sscanf(T+1, T == I ? "%63[^]]" : "%63[^:=]", name) != 1 ) return 0; int has_components = 0; // @todo: support entities too diff --git a/engine/split/v4k_pack.c b/engine/split/v4k_pack.c index 7637b99..0992b86 100644 --- a/engine/split/v4k_pack.c +++ b/engine/split/v4k_pack.c @@ -95,12 +95,12 @@ char* ftoa4(vec4 v) { float atof1(const char *s) { char buf[64]; - return sscanf(s, "%64[^]\r\n,}]", buf) == 1 ? (float)eval(buf) : (float)NAN; + return sscanf(s, "%63[^]\r\n,}]", buf) == 1 ? (float)eval(buf) : (float)NAN; } vec2 atof2(const char *s) { vec2 v = { 0 }; char buf1[64],buf2[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); return v; @@ -108,7 +108,7 @@ vec2 atof2(const char *s) { vec3 atof3(const char *s) { vec3 v = {0}; char buf1[64],buf2[64],buf3[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2, buf3); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2, buf3); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); if( num > 2 ) v.z = eval(buf3); @@ -117,7 +117,7 @@ vec3 atof3(const char *s) { vec4 atof4(const char *s) { vec4 v = {0}; char buf1[64],buf2[64],buf3[64],buf4[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2, buf3, buf4); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2, buf3, buf4); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); if( num > 2 ) v.z = eval(buf3); diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 9a107d7..26f5fad 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -3080,7 +3080,7 @@ unsigned fbo(unsigned color_texture_id, unsigned depth_texture_id, int flags) { if( color_texture_id ) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_texture_id, 0); if( depth_texture_id ) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture_id, 0); -#if 0 +#if 0 // this is working; it's just not enabled for now else { // create a non-sampleable renderbuffer object for depth and stencil attachments unsigned int rbo; diff --git a/engine/v4k.c b/engine/v4k.c index 25f56cd..25da05a 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -4321,11 +4321,14 @@ int cook(void *userdata) { cook_subscript_t cs = mcs.cs[pass]; // log to batch file for forensic purposes, if explicitly requested - static __thread bool logging = 0; do_once logging = !!flag("--cook-debug") || cook_debug; + static __thread int logging = -1; if(logging < 0) logging = !!flag("--cook-debug") || cook_debug; if( logging ) { - FILE *logfile = fopen(va("cook%d.cmd",job->threadid), "a+t"); - if( logfile ) { fprintf(logfile, "@rem %s\n%s\n", cs.outname, cs.script); fclose(logfile); } - fprintf(stderr, "%s\n", cs.script); + static __thread FILE *logfile = 0; if(!logfile) fseek(logfile = fopen(va("cook%d.cmd",job->threadid), "a+t"), 0L, SEEK_END); + if( logfile ) { + fprintf(logfile, "@rem %s\n%s\n", cs.outname, cs.script); + fprintf(logfile, "for %%%%i in (\"%s\") do md _cook\\%%%%~pi\\%%%%~ni%%%%~xi 1>nul 2>nul\n", infile); + fprintf(logfile, "for %%%%i in (\"%s\") do xcopy /y %s _cook\\%%%%~pi\\%%%%~ni%%%%~xi\n\n", infile, file_normalize(cs.outfile)); + } } // invoke cooking script and recap status @@ -11349,12 +11352,12 @@ char* ftoa4(vec4 v) { float atof1(const char *s) { char buf[64]; - return sscanf(s, "%64[^]\r\n,}]", buf) == 1 ? (float)eval(buf) : (float)NAN; + return sscanf(s, "%63[^]\r\n,}]", buf) == 1 ? (float)eval(buf) : (float)NAN; } vec2 atof2(const char *s) { vec2 v = { 0 }; char buf1[64],buf2[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); return v; @@ -11362,7 +11365,7 @@ vec2 atof2(const char *s) { vec3 atof3(const char *s) { vec3 v = {0}; char buf1[64],buf2[64],buf3[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2, buf3); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2, buf3); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); if( num > 2 ) v.z = eval(buf3); @@ -11371,7 +11374,7 @@ vec3 atof3(const char *s) { vec4 atof4(const char *s) { vec4 v = {0}; char buf1[64],buf2[64],buf3[64],buf4[64]; - int num = sscanf(s, "%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}],%64[^]\r\n,}]", buf1, buf2, buf3, buf4); + int num = sscanf(s, "%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}],%63[^]\r\n,}]", buf1, buf2, buf3, buf4); if( num > 0 ) v.x = eval(buf1); if( num > 1 ) v.y = eval(buf2); if( num > 2 ) v.z = eval(buf3); @@ -16118,7 +16121,7 @@ unsigned fbo(unsigned color_texture_id, unsigned depth_texture_id, int flags) { if( color_texture_id ) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_texture_id, 0); if( depth_texture_id ) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture_id, 0); -#if 0 +#if 0 // this is working; it's just not enabled for now else { // create a non-sampleable renderbuffer object for depth and stencil attachments unsigned int rbo; @@ -25291,7 +25294,7 @@ obj *obj_mergeini(void *o, const char *ini) { // @testme ini = sqr+1; char T[64] = {0}; - if( sscanf(ini, "%64[^]]", &T) != 1 ) return 0; // @todo: parse version as well + if( sscanf(ini, "%63[^]]", T) != 1 ) return 0; // @todo: parse version as well ini += strlen(T); for each_member(T,R) { @@ -25575,7 +25578,7 @@ void *obj_make(const char *str) { else T = I < J ? I : J; char name[64] = {0}; - if( sscanf(T+1, T == I ? "%64[^]]" : "%64[^:=]", &name) != 1 ) return 0; + if( sscanf(T+1, T == I ? "%63[^]]" : "%63[^:=]", name) != 1 ) return 0; int has_components = 0; // @todo: support entities too diff --git a/engine/v4k.h b/engine/v4k.h index 02f0efa..e643ea4 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -215,7 +215,7 @@ extern "C" { #define ifdef_release ifdef_false #endif -#if ENABLE_RETAIL +#if ENABLE_RETAIL // NDEBUG>=2 ? #define ifdef_retail ifdef_true #else #define ifdef_retail ifdef_false