diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 22d9a9b8b..9d6a28b76 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -409,7 +409,7 @@ static int32_t A_CheckNeedZUpdate(int32_t spritenum, int32_t changez, int32_t *d return 0; } -int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) +int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t cliptype, int32_t clipdist) { spritetype *const spr = &sprite[spritenum]; int32_t retval, daz, dozupdate; @@ -435,9 +435,12 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) { const int32_t oldz=spr->z; - int32_t clipdist; - if (bg) + if (clipdist >= 0) + { + // use that value + } + else if (bg) { if (spr->xrepeat > 60) clipdist = 1024; diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index f4bd20fce..317772b54 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -314,7 +314,6 @@ void A_DoGutsDir(int32_t sp,int32_t gtype,int32_t n); int32_t A_IncurDamage(int32_t sn); void A_MoveCyclers(void); void A_MoveDummyPlayers(void); -int32_t A_MoveSprite(int32_t spritenum,const vec3_t *change,uint32_t cliptype); void A_PlayAlertSound(int32_t i); void A_RadiusDamage(int32_t i,int32_t r,int32_t hp1,int32_t hp2,int32_t hp3,int32_t hp4); void A_SpawnMultiple(int32_t sp,int32_t pic,int32_t n); diff --git a/polymer/eduke32/source/actors_inline.c b/polymer/eduke32/source/actors_inline.c index 460181bcb..55d626694 100644 --- a/polymer/eduke32/source/actors_inline.c +++ b/polymer/eduke32/source/actors_inline.c @@ -38,6 +38,10 @@ ACTOR_INLINE int32_t A_SetSprite(int32_t i,uint32_t cliptype) return (A_MoveSprite(i,&davect,cliptype)==0); } +ACTOR_INLINE int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) +{ + return A_MoveSpriteClipdist(spritenum, change, cliptype, -1); +} EXTERN_INLINE void G_UpdateInterpolations(void) //Stick at beginning of G_DoMoveThings { diff --git a/polymer/eduke32/source/actors_inline.h b/polymer/eduke32/source/actors_inline.h index a08f413df..9a1ec2919 100644 --- a/polymer/eduke32/source/actors_inline.h +++ b/polymer/eduke32/source/actors_inline.h @@ -31,7 +31,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # define ACTOR_INLINE_HEADER EXTERN_INLINE_HEADER #endif +extern int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t cliptype, int32_t clipdist); + ACTOR_INLINE_HEADER int32_t A_SetSprite(int32_t i,uint32_t cliptype); +ACTOR_INLINE_HEADER int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype); EXTERN_INLINE_HEADER void G_UpdateInterpolations(void); EXTERN_INLINE_HEADER void G_RestoreInterpolations(void); diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 6e362329b..0e5a91f04 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1552,7 +1552,7 @@ end function _movesprite(spritenum, x, y, z, cliptype) check_sprite_idx(spritenum) local vel = ivec3(x, y, z) - return ffiC.A_MoveSprite(spritenum, vel, cliptype) + return ffiC.A_MoveSpriteClipdist(spritenum, vel, cliptype, -1) end -- Also known as A_SetSprite(). @@ -1563,7 +1563,7 @@ function _ssp(i, cliptype) local ivec = vec:toivec3() ivec.z = spr.zvel - return (ffiC.A_MoveSprite(i, ivec, cliptype)==0) + return (ffiC.A_MoveSpriteClipdist(i, ivec, cliptype, -1)==0) end -- CON's 'setsprite' function on top of the Lunatic-provided ones. diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index b48054cf0..00154cad1 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -413,6 +413,7 @@ end --- default defines etc. local con_lang = require("con_lang") +local xmath = require("xmath") ffi.cdef([[ typedef struct { int32_t _p; } weaponaccess_t; @@ -672,7 +673,7 @@ char CheatKeys[2]; int32_t A_IncurDamage(int32_t sn); // not bound-checked! int32_t G_CheckActivatorMotion(int32_t lotag); int32_t A_Dodge(spritetype *s); -int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype); +int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t cliptype, int32_t clipdist); void P_DoQuote(int32_t q, DukePlayer_t *p); void P_SetGamePalette(DukePlayer_t *player, uint8_t palid, int32_t set); void G_AddUserQuote(const char *daquote); @@ -823,6 +824,7 @@ player_static_members._INPUT_EXT_BITS = defs_c.conststruct local band = bit.band local lsh = bit.lshift +local ivec3 = xmath.ivec3 do -- player.all() iterator @@ -924,6 +926,13 @@ function actor_static_members.fall(i) CF.VM_FallSprite(i) end +-- actor.move(i, vec, cliptype [, clipdist]) +function actor_static_members.move(i, vec, cliptype, clipdist) + check_sprite_idx(i) + local vel = ivec3(vec.x, vec.y, vec.z) + return ffiC.A_MoveSpriteClipdist(spritenum, vel, cliptype, clipdist or -1) +end + -- Delete sprite with index . function actor_static_members.delete(i) check_sprite_idx(i) @@ -969,15 +978,19 @@ local g_tile = setmtonce({}, defs_c.GenStructMetatable("g_tile", "MAXTILES", til -- Among other things, declares struct action and struct move, and their -- ID-wrapped types con_action_t and con_move_t local con = require("control") -local isenemytile = con.isenemytile --- Add game-side metamethods to "spritetype" and register it with "metatype" -local spr_mt_index_add = { - isenemy = function(s) - return isenemytile(s.picnum) - end, -} -defs_c.finish_spritetype(spr_mt_index_add) +do + local isenemytile = con.isenemytile + + -- Add game-side metamethods to "spritetype" and register it with "metatype" + local spr_mt_index_add = { + isenemy = function(s) + return isenemytile(s.picnum) + end, + } + + defs_c.finish_spritetype(spr_mt_index_add) +end -- Check a literal numeric action or move value. local function check_literal_am(am, typename) @@ -1600,7 +1613,7 @@ local allowed_modules = { engine = require("engine"), stat = require("stat"), bitar = require("bitar"), - xmath = require("xmath"), + xmath = xmath, fs = require("fs"), con = con, @@ -1623,8 +1636,8 @@ do return type(v)=="cdata" and ctype_cansave[tonumber(ffi.typeof(v))] end - reg_serializable_cv(allowed_modules.xmath.vec3()) - reg_serializable_cv(allowed_modules.xmath.ivec3()) + reg_serializable_cv(xmath.vec3()) + reg_serializable_cv(ivec3()) end -- Protect base modules. diff --git a/polymer/eduke32/source/lunatic/doc/lunatic.txt b/polymer/eduke32/source/lunatic/doc/lunatic.txt index 9e96e5187..284704bc9 100644 --- a/polymer/eduke32/source/lunatic/doc/lunatic.txt +++ b/polymer/eduke32/source/lunatic/doc/lunatic.txt @@ -790,6 +790,8 @@ claiming them for oneself. `wal:set_picnum(tilenum)`, `wal:set_overpicnum(tilenum)`:: Set the tile number of the wall or its masked portion. +// TODO: the predicates + ===== `wall` static functions `wall.dragto(i, pos)`:: @@ -947,6 +949,9 @@ _`index_of_spr`_ is the sprite index corresponding to `spr`. This method is provided for convenience, but may be slower than the static function `updatesect`. +`spr:isenemy()`:: +*TODO* + ===== `sprite` iterators +*for* i *in* sprite.all()+:: @@ -1122,6 +1127,9 @@ index. Otherwise, returns *nil*. Causes the actor with index `i` to fall in a ``hard-coded'', not further specified fashion. +`actor.move(i, vec, cliptype [, clipdist])`:: +*TODO* + [[actor_static_data]] ===== `actor` static data diff --git a/polymer/eduke32/source/lunatic/dynsymlist b/polymer/eduke32/source/lunatic/dynsymlist index 109dc7992..c40905c07 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist +++ b/polymer/eduke32/source/lunatic/dynsymlist @@ -211,7 +211,7 @@ rand_jkiss_dbl; A_IncurDamage; G_CheckActivatorMotion; A_Dodge; -A_MoveSprite; +A_MoveSpriteClipdist; P_DoQuote; P_SetGamePalette; G_AddUserQuote;