diff --git a/4ed_math.h b/4ed_math.h index ac5bee8f..ce0a11a8 100644 --- a/4ed_math.h +++ b/4ed_math.h @@ -15,37 +15,41 @@ * Scalar operators */ -#define DEG_TO_RAD 0.0174533f +#define DEG_TO_RAD (0.0174533f) + +inline f32 +ABS(f32 x){ + if (x < 0) x = -x; + return(x); +} #if C_MATH #include -inline f32 -ABS(f32 x){ - if (x < 0) x = -x; - return x; -} - inline f32 MOD(f32 x, i32 m){ - f32 whole, frac; + f32 whole, frac, r; frac = modff(x, &whole); - return ((i32)(whole) % m) + frac; + r = ((i32)(whole) % m) + frac; + return(r); } inline f32 SQRT(f32 x){ - return sqrt(x); + f32 r = sqrt(x); + return(r); } inline f32 SIN(f32 x_degrees){ - return sinf(x_degrees * DEG_TO_RAD); + f32 r = sinf(x_degrees * DEG_TO_RAD); + return(r); } inline f32 COS(f32 x_degrees){ - return cosf(x_degrees * DEG_TO_RAD); + f32 r = cosf(x_degrees * DEG_TO_RAD); + return(r); } #endif diff --git a/build.c b/build.c index ceba93f0..8560e303 100644 --- a/build.c +++ b/build.c @@ -14,8 +14,9 @@ // reusable // -#define CL_OPTS \ -"/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX "\ +#define CL_OPTS \ +"/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 " \ +"/wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX " \ "/GR- /EHa- /nologo /FC" #if defined(_MSC_VER) @@ -35,21 +36,21 @@ static char cmd[1024]; static int32_t error_state = 0; -#define systemf(...) do{\ - int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__);\ - assert(n < sizeof(cmd));\ - if (system(cmd) != 0) error_state = 1;\ +#define systemf(...) do{ \ + int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__); \ + assert(n < sizeof(cmd)); \ + if (system(cmd) != 0) error_state = 1; \ }while(0) #if defined(IS_WINDOWS) typedef uint32_t DWORD; -typedef int32_t LONG; -typedef int64_t LONGLONG; -typedef char* LPTSTR; -typedef int32_t BOOL; -typedef union _LARGE_INTEGER { +typedef int32_t LONG; +typedef int64_t LONGLONG; +typedef char* LPTSTR; +typedef int32_t BOOL; +typedef union _LARGE_INTEGER { struct { DWORD LowPart; LONG HighPart; @@ -146,7 +147,8 @@ enum{ DEBUG_INFO = 0x20, SUPER = 0x40, INTERNAL = 0x80, - OPTIMIZATION = 0x100 + OPTIMIZATION = 0x100, + KEEP_ASSERT = 0x200 }; @@ -221,6 +223,11 @@ build_cl(uint32_t flags, swap_ptr(&build_options, &build_options_prev); } + if (flags & KEEP_ASSERT){ + snprintf(build_options, build_max, "%s /DFRED_KEEP_ASSERT", build_options_prev); + swap_ptr(&build_options, &build_options_prev); + } + swap_ptr(&build_options, &build_options_prev); systemf("pushd %s & cl %s %s\\%s /Fe%s /link /DEBUG /INCREMENTAL:NO %s", @@ -254,32 +261,22 @@ buildsuper(char *code_path, char *out_path, char *filename){ #endif } -#if defined(DEV_BUILD) - -int main(int argc, char **argv){ - init_time_system(); - - char cdir[256]; - - BEGIN_TIME_SECTION(); - int32_t n = get_current_directory(cdir, sizeof(cdir)); - assert(n < sizeof(cdir)); - END_TIME_SECTION("current directory"); - #define META_DIR "../meta" #define BUILD_DIR "../build" - + +static void +standard_build(char *cdir, uint32_t flags){ #if 1 { BEGIN_TIME_SECTION(); build(OPTS, cdir, "fsm_table_generator.cpp", - BUILD_DIR, "fsmgen", 0); + META_DIR, "fsmgen", 0); END_TIME_SECTION("build fsm generator"); } { BEGIN_TIME_SECTION(); - execute(cdir, BUILD_DIR"/fsmgen"); + execute(cdir, META_DIR"/fsmgen"); END_TIME_SECTION("run fsm generator"); } #endif @@ -307,8 +304,6 @@ int main(int argc, char **argv){ END_TIME_SECTION("build custom"); } - uint32_t flags = DEBUG_INFO | SUPER | INTERNAL; - { BEGIN_TIME_SECTION(); build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp", @@ -323,14 +318,33 @@ int main(int argc, char **argv){ END_TIME_SECTION("build 4ed"); } #endif +} + +#if defined(DEV_BUILD) + + +int main(int argc, char **argv){ + init_time_system(); + + char cdir[256]; + + BEGIN_TIME_SECTION(); + int32_t n = get_current_directory(cdir, sizeof(cdir)); + assert(n < sizeof(cdir)); + END_TIME_SECTION("current directory"); + + standard_build(cdir, DEBUG_INFO | SUPER | INTERNAL); return(error_state); } + #elif defined(PACKAGE) +#else +#error No build type specified #endif // BOTTOM diff --git a/filetrack/4tech_file_track_win32.c b/filetrack/4tech_file_track_win32.c index 855c7b94..5f3db59c 100644 --- a/filetrack/4tech_file_track_win32.c +++ b/filetrack/4tech_file_track_win32.c @@ -16,8 +16,8 @@ Created on: 20.07.2016 #include typedef struct { - char result[2048]; OVERLAPPED overlapped; + char result[2048]; HANDLE dir; int32_t user_count; } Win32_Directory_Listener; diff --git a/package.bat b/package.bat index 8f7078cb..c9753462 100644 --- a/package.bat +++ b/package.bat @@ -8,7 +8,7 @@ pushd W:\4ed\code ..\meta\readmegen -call "build_all.bat" /O2 /DFRED_KEEP_ASSERT +call "build_all.bat" /O2 /DFRED_KEEP_ASSERT /Zi del ..\current_dist\4coder\*.html copy ..\build\4ed.exe ..\current_dist\4coder\* copy ..\build\4ed.pdb ..\current_dist\4coder\* @@ -17,11 +17,9 @@ copy ..\build\4ed_app.pdb ..\current_dist\4coder\* copy ..\data\* ..\current_dist\4coder\* copy README.txt ..\current_dist\4coder\* copy TODO.txt ..\current_dist\4coder\* -del ..\current_dist\SUPERREADME.txt -del ..\current_dist\4coder\basic.cpp del ..\current_dist\4coder\.4coder_settings -call "build_all.bat" /O2 /DFRED_SUPER /DFRED_KEEP_ASSERT +call "build_all.bat" /O2 /DFRED_SUPER /DFRED_KEEP_ASSERT /Zi del ..\current_dist\4coder\*.html copy ..\build\4ed.exe ..\current_dist_super\4coder\* copy ..\build\4ed.pdb ..\current_dist_super\4coder\* @@ -34,7 +32,6 @@ copy 4coder_*.h ..\current_dist_super\4coder\* copy 4coder_*.cpp ..\current_dist_super\4coder\* copy README.txt ..\current_dist_super\4coder\* copy TODO.txt ..\current_dist_super\4coder\* -copy SUPERREADME.txt ..\current_dist_super\4coder\* copy ..\current_dist\4coder\3rdparty\* ..\current_dist_super\4coder\3rdparty\* REM del ..\current_dist_super\4coder\*.pdb del ..\current_dist_super\4coder\*.lib