diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 6b6208313..b0d111ce7 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -43,12 +43,15 @@ enum rendmode_t { #ifdef LUNATIC # define NEW_MAP_FORMAT -// Merely a marker for LuaJIT C function callbacks: -# define LUNATIC_CB +// A marker for LuaJIT C function callbacks, but not merely: +# define LUNATIC_CB ATTRIBUTE((used)) +// Used for variables and functions referenced from Lua: +# define LUNATIC_EXTERN ATTRIBUTE((used)) #else # ifdef NEW_MAP_FORMAT # error "New map format can only be used with Lunatic" # endif +# define LUNATIC_EXTERN static #endif // additional space beyond wall, in walltypes: diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 27644e1eb..d35d49228 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -63,16 +63,18 @@ L_State g_engState; //#define DEBUG_TILESIZY_512 //#define DEBUG_TILEOFFSETS -#if !defined DEBUG_MAIN_ARRAYS -const int32_t engine_main_arrays_are_static = 0; // for Lunatic -#else -const int32_t engine_main_arrays_are_static = 1; +#ifdef LUNATIC +# if !defined DEBUG_MAIN_ARRAYS +LUNATIC_EXTERN const int32_t engine_main_arrays_are_static = 0; // for Lunatic +# else +LUNATIC_EXTERN const int32_t engine_main_arrays_are_static = 1; +# endif #endif #if MAXSECTORS==MAXSECTORSV8 -const int32_t engine_v8 = 1; +LUNATIC_EXTERN const int32_t engine_v8 = 1; #else -const int32_t engine_v8 = 0; +LUNATIC_EXTERN const int32_t engine_v8 = 0; #endif #ifdef DEBUGGINGAIDS diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index f8924d55a..dfb038e3a 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -134,9 +134,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef LUNATIC # include "lunatic_game.h" -# define LUNATIC_EXTERN -#else -# define LUNATIC_EXTERN static #endif static inline int32_t G_HaveEvent(int32_t iEventID) diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 32ef9b327..500df88f1 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -181,8 +181,8 @@ __attribute__((packed)) struct { int16_t cgg; const int16_t lightId, lightcount, lightmaxrange; + // NOTE: on 32-bit, C's lightptr+filler <=> this dummy: const union { intptr_t ptr; uint64_t dummy; } _light; -// XXX: 32-bit has filler } ]] diff --git a/polymer/eduke32/source/lunatic/doc/lunatic.txt b/polymer/eduke32/source/lunatic/doc/lunatic.txt index 134236016..ebf372647 100644 --- a/polymer/eduke32/source/lunatic/doc/lunatic.txt +++ b/polymer/eduke32/source/lunatic/doc/lunatic.txt @@ -323,12 +323,12 @@ Returns one value from the global engine-side pseudo-random number generator in the integer range [0{nbsp}..{nbsp}65535]. [[timing_funcs]] -`gv.getticks()`, `gv.gethiticksms()`:: +`gv.getticks()`, `gv.gethitickms()`:: Each of these functions return a number that increases at a rate of 1 per millisecond. Their only intended application is to profile bits of code; they should not be used to control the game world. The two functions differ in their precision: `getticks()` always returns integral values, while the result of -`gethiticksms()` also has an unspecified precision in the fractional part. (It +`gethitickms()` also has an unspecified precision in the fractional part. (It can be expected to give a time precision of at least one microsecond.) `gv.doQuake(gametics [, snd])`:: diff --git a/polymer/eduke32/source/lunatic/lunatic_game.c b/polymer/eduke32/source/lunatic/lunatic_game.c index 13e0a8c5a..c5d9e49df 100644 --- a/polymer/eduke32/source/lunatic/lunatic_game.c +++ b/polymer/eduke32/source/lunatic/lunatic_game.c @@ -53,7 +53,7 @@ typedef struct { // See: Good Practice in (Pseudo) Random Number Generation for // Bioinformatics Applications, by David Jones ATTRIBUTE_OPTIMIZE("O2") -uint32_t rand_jkiss_u32(rng_jkiss_t *s) +LUNATIC_EXTERN uint32_t rand_jkiss_u32(rng_jkiss_t *s) { uint64_t t; s->x = 314527869 * s->x + 1234567; @@ -63,7 +63,7 @@ uint32_t rand_jkiss_u32(rng_jkiss_t *s) } ATTRIBUTE_OPTIMIZE("O2") -double rand_jkiss_dbl(rng_jkiss_t *s) +LUNATIC_EXTERN double rand_jkiss_dbl(rng_jkiss_t *s) { double x; unsigned int a, b; diff --git a/polymer/eduke32/source/lunatic/randgen.lua b/polymer/eduke32/source/lunatic/randgen.lua index 1d1b04acf..733c7665b 100644 --- a/polymer/eduke32/source/lunatic/randgen.lua +++ b/polymer/eduke32/source/lunatic/randgen.lua @@ -45,8 +45,8 @@ local mt = { getu32 = ffiC.rand_jkiss_u32, getdbl = ffiC.rand_jkiss_dbl, - -- Initialize the JKISS PRNG using the MD4 of the lower bits of the - -- profiling timer. + -- Initialize the JKISS PRNG using the CRC32 of the result of several + -- profiling timer calls interpreted as byte sequence. init_time_md4 = function(s) local tin = ffi.new("uchar_double_u_t") local tout = ffi.new("uint32_t [4]")