Revise C++ structure trackers for performance and introduce "tspritetype", for temporary sprites or other usages where using the trackers would be invalid or undesired. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@4898 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-01-11 04:55:07 +00:00
parent 655bbed3b1
commit 4911b9a949
19 changed files with 176 additions and 165 deletions

View file

@ -153,12 +153,12 @@ const char *getjoyname(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=
char bgetchar(void);
#define bkbhit() (keyasciififoplc != keyasciififoend)
static inline int keyascfifo_isfull(void)
FORCE_INLINE int keyascfifo_isfull(void)
{
return ((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc;
}
static inline void keyascfifo_insert(char code)
FORCE_INLINE void keyascfifo_insert(char code)
{
keyasciififo[keyasciififoend] = code;
keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1));
@ -182,7 +182,7 @@ int32_t inittimer(int32_t);
void uninittimer(void);
void sampletimer(void);
#if defined RENDERTYPESDL && !defined LUNATIC
static inline uint32_t getticks(void) { return (uint32_t)SDL_GetTicks(); }
FORCE_INLINE uint32_t getticks(void) { return (uint32_t)SDL_GetTicks(); }
#else
uint32_t getticks(void);
#endif

View file

@ -177,7 +177,7 @@ extern int32_t r_tror_nomaskpass;
// Moved below declarations of sector, wall, sprite.
# else
int16_t yax_getbunch(int16_t i, int16_t cf);
static inline void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
FORCE_INLINE void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
{
*cb = yax_getbunch(i, YAX_CEILING);
*fb = yax_getbunch(i, YAX_FLOOR);
@ -192,7 +192,7 @@ int16_t yax_vnextsec(int16_t line, int16_t cf);
void yax_update(int32_t resetstat);
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf);
static inline int32_t yax_waltosecmask(int32_t walclipmask)
FORCE_INLINE int32_t yax_waltosecmask(int32_t walclipmask)
{
// blocking: walstat&1 --> secstat&512
// hitscan: walstat&64 --> secstat&2048
@ -249,9 +249,9 @@ enum {
#ifdef __cplusplus
static inline void sector_tracker_hook(uintptr_t address);
static inline void wall_tracker_hook(uintptr_t address);
static inline void sprite_tracker_hook(uintptr_t address);
FORCE_INLINE void sector_tracker_hook(uintptr_t address);
FORCE_INLINE void wall_tracker_hook(uintptr_t address);
FORCE_INLINE void sprite_tracker_hook(uintptr_t address);
}
@ -411,6 +411,21 @@ typedef struct
Tracker(Sprite, int16_t) extra;
} spritetype;
typedef struct
{
int32_t x, y, z;
uint16_t cstat;
int16_t picnum;
int8_t shade;
uint8_t pal, clipdist, blend;
uint8_t xrepeat, yrepeat;
int8_t xoffset, yoffset;
int16_t sectnum, statnum;
int16_t ang, owner, xvel, yvel, zvel;
uint16_t lotag, hitag;
int16_t extra;
} tspritetype;
//////////////////// END Version 7 map format ////////////////
#ifdef NEW_MAP_FORMAT
@ -620,7 +635,7 @@ typedef struct {
uint8_t filler;
float alpha;
// NOTE: keep 'tspr' on an 8-byte boundary:
spritetype *tspr;
tspritetype *tspr;
#if !defined UINTPTR_MAX
# error Need UINTPTR_MAX define to select between 32- and 64-bit structs
#endif
@ -667,7 +682,7 @@ EXTERN spritesmooth_t *spritesmooth;
EXTERN sectortype *sector;
EXTERN walltype *wall;
EXTERN spritetype *sprite;
EXTERN spritetype *tsprite;
EXTERN tspritetype *tsprite;
#else
EXTERN spriteext_t spriteext[MAXSPRITES+MAXUNIQHUDID];
EXTERN spritesmooth_t spritesmooth[MAXSPRITES+MAXUNIQHUDID];
@ -683,71 +698,65 @@ EXTERN uint32_t wallchanged[MAXWALLS + M32_FIXME_WALLS];
EXTERN uint32_t spritechanged[MAXSPRITES];
#ifdef NEW_MAP_FORMAT
static inline int16_t yax_getbunch(int16_t i, int16_t cf)
FORCE_INLINE int16_t yax_getbunch(int16_t i, int16_t cf)
{
return cf ? sector[i].floorbunch : sector[i].ceilingbunch;
}
static inline void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
FORCE_INLINE void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
{
*cb = yax_getbunch(i, YAX_CEILING);
*fb = yax_getbunch(i, YAX_FLOOR);
}
static inline int16_t yax_getnextwall(int16_t wal, int16_t cf)
FORCE_INLINE int16_t yax_getnextwall(int16_t wal, int16_t cf)
{
return cf ? wall[wal].dnwall : wall[wal].upwall;
}
static inline void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
FORCE_INLINE void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
{
YAX_NEXTWALL(wal, cf) = thenextwall;
}
#endif
static inline void sector_tracker_hook(uintptr_t address)
FORCE_INLINE void sector_tracker_hook(uintptr_t address)
{
uintptr_t const usector = (uintptr_t) sector;
uintptr_t const usector = address - (uintptr_t)sector;
if (EDUKE32_PREDICT_FALSE((address - usector) >= (MAXSECTORS+M32_FIXME_SECTORS * sizeof(sectortype))))
return;
#if DEBUGGINGAIDS
Bassert(usector < ((MAXSECTORS + M32_FIXME_SECTORS) * sizeof(sectortype)));
#endif
address = (address - usector);
address /= sizeof(sectortype);
sectorchanged[address]++;
sectorchanged[usector / sizeof(sectortype)]++;
}
static inline void wall_tracker_hook(uintptr_t address)
FORCE_INLINE void wall_tracker_hook(uintptr_t address)
{
uintptr_t const uwall = (uintptr_t) wall;
uintptr_t const uwall = address - (uintptr_t)wall;
if (EDUKE32_PREDICT_FALSE((address - uwall) >= (MAXWALLS+M32_FIXME_WALLS * sizeof(walltype))))
return;
#if DEBUGGINGAIDS
Bassert(uwall < ((MAXWALLS + M32_FIXME_WALLS) * sizeof(walltype)));
#endif
address = (address - uwall);
address /= sizeof(walltype);
wallchanged[address]++;
wallchanged[uwall / sizeof(walltype)]++;
}
static inline void sprite_tracker_hook(uintptr_t address)
FORCE_INLINE void sprite_tracker_hook(uintptr_t address)
{
uintptr_t const usprite = (uintptr_t)sprite;
uintptr_t const usprite = address - (uintptr_t)sprite;
if (EDUKE32_PREDICT_FALSE((address - usprite) >= (MAXSPRITES * sizeof(spritetype))))
return;
#if DEBUGGINGAIDS
Bassert(usprite < (MAXSPRITES * sizeof(spritetype)));
#endif
address = (address - usprite);
address /= sizeof(spritetype);
spritechanged[address]++;
spritechanged[usprite / sizeof(spritetype)]++;
}
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
EXTERN int16_t thewall[MAXWALLSB];
EXTERN spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
EXTERN tspritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
EXTERN int32_t xdim, ydim, numpages;
EXTERN int32_t yxaspect, viewingrange;
@ -827,7 +836,7 @@ EXTERN psky_t multipsky[MAXPSKYMULTIS];
// Mapping of multi-sky index to base sky tile number:
EXTERN int32_t multipskytile[MAXPSKYMULTIS];
static inline int32_t getpskyidx(int32_t picnum)
FORCE_INLINE int32_t getpskyidx(int32_t picnum)
{
int32_t j;
@ -952,7 +961,7 @@ extern const char *engineerrstr;
EXTERN int32_t editorzrange[2];
static inline int32_t getrendermode(void)
FORCE_INLINE int32_t getrendermode(void)
{
#ifndef USE_OPENGL
return REND_CLASSIC;
@ -1133,20 +1142,20 @@ void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol,
const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
////////// specialized rotatesprite wrappers for (very) often used cases //////////
static inline void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
FORCE_INLINE void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
int8_t dashade, char dapalnum, int32_t dastat,
int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2)
{
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, cx1, cy1, cx2, cy2);
}
// Don't clip at all, i.e. the whole screen real estate is available:
static inline void rotatesprite_fs(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
FORCE_INLINE void rotatesprite_fs(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
int8_t dashade, char dapalnum, int32_t dastat)
{
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0,0,xdim-1,ydim-1);
}
static inline void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
FORCE_INLINE void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
int8_t dashade, char dapalnum, int32_t dastat)
{
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowx1,windowy1,windowx2,windowy2);
@ -1202,12 +1211,12 @@ int32_t krand(void);
int32_t ksqrt(uint32_t num);
int32_t __fastcall getangle(int32_t xvect, int32_t yvect);
static inline uint32_t uhypsq(int32_t dx, int32_t dy)
FORCE_INLINE uint32_t uhypsq(int32_t dx, int32_t dy)
{
return (uint32_t)dx*dx + (uint32_t)dy*dy;
}
static inline int32_t logapproach(int32_t val, int32_t targetval)
FORCE_INLINE int32_t logapproach(int32_t val, int32_t targetval)
{
int32_t dif = targetval - val;
return (dif>>1) ? val + (dif>>1) : targetval;
@ -1223,29 +1232,29 @@ int32_t getflorzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) AT
void getzsofslopeptr(const sectortype *sec, int32_t dax, int32_t day,
int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5)));
static inline int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
FORCE_INLINE int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
{
return getceilzofslopeptr(&sector[sectnum], dax, day);
}
static inline int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day)
FORCE_INLINE int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day)
{
return getflorzofslopeptr(&sector[sectnum], dax, day);
}
static inline void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
FORCE_INLINE void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
{
getzsofslopeptr(&sector[sectnum], dax, day, ceilz, florz);
}
// Is <wal> a red wall in a safe fashion, i.e. only if consistency invariant
// ".nextsector >= 0 iff .nextwall >= 0" holds.
static inline int32_t redwallp(const walltype *wal)
FORCE_INLINE int32_t redwallp(const walltype *wal)
{
return (wal->nextwall >= 0 && wal->nextsector >= 0);
}
static inline int32_t E_SpriteIsValid(const int32_t i)
FORCE_INLINE int32_t E_SpriteIsValid(const int32_t i)
{
return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS);
}
@ -1279,7 +1288,7 @@ int32_t setsprite(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
int32_t spriteheightofsptr(const spritetype *spr, int32_t *height, int32_t alsotileyofs);
static inline int32_t spriteheightofs(int16_t i, int32_t *height, int32_t alsotileyofs)
FORCE_INLINE int32_t spriteheightofs(int16_t i, int32_t *height, int32_t alsotileyofs)
{
return spriteheightofsptr(&sprite[i], height, alsotileyofs);
}
@ -1288,7 +1297,7 @@ int32_t screencapture(const char *filename, char inverseit, const char *versio
int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol);
static inline int32_t getclosestcol(int32_t r, int32_t g, int32_t b)
FORCE_INLINE int32_t getclosestcol(int32_t r, int32_t g, int32_t b)
{
return getclosestcol_lim(r, g, b, 255);
}
@ -1409,10 +1418,9 @@ typedef struct
EXTERN int32_t mdinited;
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
static inline int32_t md_tilehasmodel(int32_t tilenume,int32_t pal)
FORCE_INLINE int32_t md_tilehasmodel(int32_t tilenume,int32_t pal)
{
if (!mdinited) return -1;
return tile2model[Ptile2tile(tilenume,pal)].modelid;
return mdinited ? tile2model[Ptile2tile(tilenume,pal)].modelid : -1;
}
#endif // defined USE_OPENGL
@ -1464,7 +1472,7 @@ void hash_delete(hashtable_t *t, const char *s);
# endif
#endif
static inline void push_nofog(void)
FORCE_INLINE void push_nofog(void)
{
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST)
@ -1475,7 +1483,7 @@ static inline void push_nofog(void)
#endif
}
static inline void pop_nofog(void)
FORCE_INLINE void pop_nofog(void)
{
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST)

View file

@ -414,15 +414,12 @@ enum SaveBoardFlags
#define M32_MAXPALOOKUPS (MAXPALOOKUPS-RESERVEDPALS-1)
static inline int32_t atoi_safe(const char *str)
{
return (int32_t)strtol(str, NULL, 10);
}
FORCE_INLINE int32_t atoi_safe(const char *str) { return (int32_t)Bstrtol(str, NULL, 10); }
static inline void inpclamp(int32_t *x, int32_t mi, int32_t ma)
FORCE_INLINE void inpclamp(int32_t *x, int32_t mi, int32_t ma)
{
if (*x>ma) *x=ma;
if (*x<mi) *x=mi;
if (*x > ma) *x = ma;
if (*x < mi) *x = mi;
}
#ifdef __cplusplus

View file

@ -204,13 +204,13 @@ typedef struct
EXTERN mdmodel_t **models;
void updateanimation(md2model_t *m, const spritetype *tspr, uint8_t lpal);
void updateanimation(md2model_t *m, const tspritetype *tspr, uint8_t lpal);
int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf);
void mdinit(void);
void freeallmodels(void);
void clearskins(void);
int32_t polymost_mddraw(const spritetype *tspr);
EXTERN void md3_vox_calcmat_common(const spritetype *tspr, const vec3f_t *a0, float f, float mat[16]);
int32_t polymost_mddraw(const tspritetype *tspr);
EXTERN void md3_vox_calcmat_common(const tspritetype *tspr, const vec3f_t *a0, float f, float mat[16]);
typedef struct { vec3f_t add; int16_t angadd, flags, fov; } hudtyp;
@ -222,7 +222,7 @@ EXTERN voxmodel_t *voxmodels[MAXVOXELS];
void voxfree(voxmodel_t *m);
voxmodel_t *voxload(const char *filnam);
int32_t polymost_voxdraw(voxmodel_t *m, const spritetype *tspr);
int32_t polymost_voxdraw(voxmodel_t *m, const tspritetype *tspr);
int md3postload_polymer(md3model_t* m);
//int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap);

View file

@ -382,7 +382,7 @@ static inline void polymer_normalize(float* vec);
static inline void polymer_pokesector(int16_t sectnum);
static void polymer_extractfrustum(GLfloat* modelview, GLfloat* projection, float* frustum);
static inline int32_t polymer_planeinfrustum(_prplane *plane, float* frustum);
static inline void polymer_scansprites(int16_t sectnum, spritetype* tsprite, int32_t* spritesortcnt);
static inline void polymer_scansprites(int16_t sectnum, tspritetype* tsprite, int32_t* spritesortcnt);
static void polymer_updatesprite(int32_t snum);
// SKIES
static void polymer_getsky(void);
@ -392,7 +392,7 @@ static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shad
static void polymer_drawartskyquad(int32_t p1, int32_t p2, GLfloat height);
static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shade);
// MDSPRITES
static void polymer_drawmdsprite(spritetype *tspr);
static void polymer_drawmdsprite(tspritetype *tspr);
static void polymer_loadmodelvbos(md3model_t* m);
// MATERIALS
static void polymer_getscratchmaterial(_prmaterial* material);

View file

@ -3078,7 +3078,7 @@ int32_t wallfront(int32_t l1, int32_t l2)
//
// spritewallfront (internal)
//
static inline int32_t spritewallfront(const spritetype *s, int32_t w)
static inline int32_t spritewallfront(const tspritetype *s, int32_t w)
{
const walltype *const wal = &wall[w];
const walltype *wal2 = &wall[wal->point2];
@ -3298,24 +3298,32 @@ static void prepwall(int32_t z, const walltype *wal)
//
// animateoffs (internal)
//
int32_t animateoffs(int16_t tilenum, int16_t fakevar)
#ifdef DEBUGGINGAIDS
int32_t animateoffs(int const tilenum, int fakevar)
#else
int32_t animateoffs(int const tilenum)
#endif
{
int i, k, offs = 0;
int const animnum = picanm[tilenum].num;
#ifdef DEBUGGINGAIDS
UNREFERENCED_PARAMETER(fakevar);
#endif
int const animnum = picanm[tilenum].num;
if (animnum <= 0)
return 0;
i = totalclocklock >> (picanm[tilenum].sf & PICANM_ANIMSPEED_MASK);
int const i = totalclocklock >> (picanm[tilenum].sf & PICANM_ANIMSPEED_MASK);
int offs = 0;
switch (picanm[tilenum].sf & PICANM_ANIMTYPE_MASK)
{
case PICANM_ANIMTYPE_OSC:
k = (i % (animnum << 1));
{
int k = (i % (animnum << 1));
offs = (k < animnum) ? k : (animnum << 1) - k;
break;
}
break;
case PICANM_ANIMTYPE_FWD: offs = i % (animnum + 1); break;
case PICANM_ANIMTYPE_BACK: offs = -(i % (animnum + 1)); break;
}
@ -3336,22 +3344,20 @@ static inline void wallmosts_finish(int16_t *mostbuf, int32_t z1, int32_t z2,
if (ix2-ix1 < 0)
swaplong(&ix1, &ix2);
#endif
{
// PK 20110423: a bit consistency checking is a good thing:
int32_t tmp = (ix2-ix1 >= 0) ? (ix2-ix1+1) : 1;
int32_t yinc = tabledivide32((scale(z2, xdimenscale, iy2)<<4) - y, tmp);
// PK 20110423: a bit consistency checking is a good thing:
int32_t tmp = (ix2 - ix1 >= 0) ? (ix2 - ix1 + 1) : 1;
int32_t yinc = tabledivide32((scale(z2, xdimenscale, iy2) << 4) - y, tmp);
qinterpolatedown16short((intptr_t)&mostbuf[ix1], tmp, y+(globalhoriz<<16), yinc);
}
qinterpolatedown16short((intptr_t)&mostbuf[ix1], tmp, y + (globalhoriz << 16), yinc);
if (mostbuf[ix1] < 0)
mostbuf[ix1] = 0;
if (mostbuf[ix1] > ydimen)
else if (mostbuf[ix1] > ydimen)
mostbuf[ix1] = ydimen;
if (mostbuf[ix2] < 0)
mostbuf[ix2] = 0;
if (mostbuf[ix2] > ydimen)
else if (mostbuf[ix2] > ydimen)
mostbuf[ix2] = ydimen;
}
@ -5673,7 +5679,7 @@ static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasp
}
static void setup_globals_sprite1(const spritetype *tspr, const sectortype *sec,
static void setup_globals_sprite1(const tspritetype *tspr, const sectortype *sec,
int32_t yspan, int32_t yoff, int32_t tilenum,
int32_t cstat, int32_t *z1ptr, int32_t *z2ptr)
{
@ -5765,7 +5771,8 @@ static void drawsprite_classic(int32_t snum)
int32_t dax, day, dax1, dax2, y;
int32_t vtilenum = 0;
spritetype *const tspr = tspriteptr[snum];
tspritetype *const tspr = tspriteptr[snum];
const int32_t sectnum = tspr->sectnum;
if (sectnum < 0)
@ -9024,7 +9031,7 @@ static spritesmooth_t spritesmooth_s[MAXSPRITES+MAXUNIQHUDID];
static sectortype sector_s[MAXSECTORS + M32_FIXME_SECTORS];
static walltype wall_s[MAXWALLS + M32_FIXME_WALLS];
static spritetype sprite_s[MAXSPRITES];
static spritetype tsprite_s[MAXSPRITESONSCREEN];
static tspritetype tsprite_s[MAXSPRITESONSCREEN];
# endif
#else
void *blockptr = NULL;
@ -9782,7 +9789,7 @@ killsprite:
{
for (int32_t k=i; k<j; k++)
{
const spritetype *const s = tspriteptr[k];
const tspritetype *const s = tspriteptr[k];
spritesxyz[k].z = s->z;
if ((s->cstat&48) != 32)
@ -9874,7 +9881,7 @@ killsprite:
if (tspriteptr[i] != NULL)
{
vec2f_t spr;
const spritetype *tspr = tspriteptr[i];
const tspritetype *tspr = tspriteptr[i];
spr.x = (float)tspr->x;
spr.y = (float)tspr->y;
@ -9903,7 +9910,7 @@ killsprite:
if ((tspr->cstat & 48) == 32)
{
numpts = 4;
get_floorspr_points(tspr, 0, 0,
get_floorspr_points((const spritetype *)tspr, 0, 0,
&xx[0], &xx[1], &xx[2], &xx[3],
&yy[0], &yy[1], &yy[2], &yy[3]);
}
@ -9917,7 +9924,7 @@ killsprite:
if ((tspr->cstat & 48) != 16)
tspriteptr[i]->ang = globalang;
get_wallspr_points(tspr, &xx[0], &xx[1], &yy[0], &yy[1]);
get_wallspr_points((const spritetype *)tspr, &xx[0], &xx[1], &yy[0], &yy[1]);
if ((tspr->cstat & 48) == 0)
tspriteptr[i]->ang = oang;

View file

@ -34,7 +34,7 @@ extern uint8_t curbasepal;
extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB];
extern int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
extern int16_t maskwall[MAXWALLSB], maskwallcnt;
extern spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
extern tspritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen;
extern float fxdimen;
extern intptr_t frameoffset;
@ -84,15 +84,22 @@ void calc_and_apply_fog_factor(int32_t tile, int32_t shade, int32_t vis, int32_t
// int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
int32_t wallfront(int32_t l1, int32_t l2);
int32_t animateoffs(int16_t tilenum, int16_t fakevar);
void set_globalang(int16_t ang);
#ifdef DEBUGGINGAIDS
int32_t animateoffs(int const tilenum, int fakevar);
#define DO_TILE_ANIM(Picnum, Fakevar) do { \
if (picanm[Picnum].sf&PICANM_ANIMTYPE_MASK) Picnum += animateoffs(Picnum, Fakevar); \
} while (0)
#else
int32_t animateoffs(int const tilenum);
#define DO_TILE_ANIM(Picnum, Fakevar) do { \
if (picanm[Picnum].sf&PICANM_ANIMTYPE_MASK) Picnum += animateoffs(Picnum); \
} while (0)
#endif
static inline int32_t bad_tspr(const spritetype *tspr)
FORCE_INLINE int32_t bad_tspr(const tspritetype *tspr)
{
// NOTE: tspr->owner >= MAXSPRITES (could be model) has to be handled by
// caller.
@ -102,15 +109,12 @@ static inline int32_t bad_tspr(const spritetype *tspr)
//
// getpalookup (internal)
//
static inline int32_t getpalookup(int32_t davis, int32_t dashade)
FORCE_INLINE int32_t getpalookup(int32_t davis, int32_t dashade)
{
return(min(max(dashade+(davis>>8),0),numshades-1));
return (min(max(dashade + (davis >> 8), 0), numshades - 1));
}
static inline int32_t getpalookupsh(int32_t davis)
{
return getpalookup(davis, globalshade)<<8;
}
FORCE_INLINE int32_t getpalookupsh(int32_t davis) { return getpalookup(davis, globalshade) << 8; }
void dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t *z, int32_t dastat,
int32_t cx1_plus_cx2, int32_t cy1_plus_cy2,
@ -128,10 +132,7 @@ extern int32_t yax_globalcf, yax_nomaskpass, yax_nomaskdidit;
extern uint8_t haveymost[YAX_MAXBUNCHES>>3];
extern uint8_t yax_gotsector[MAXSECTORS>>3];
static inline int32_t yax_isislandwall(int32_t line, int32_t cf)
{
return (yax_vnextsec(line, cf)>=0);
}
FORCE_INLINE int32_t yax_isislandwall(int32_t line, int32_t cf) { return (yax_vnextsec(line, cf) >= 0); }
#endif
#ifdef YAX_DEBUG
@ -192,7 +193,7 @@ skipit:
#else // __GNUC__ && __i386__
static inline void setgotpic(int32_t tilenume)
FORCE_INLINE void setgotpic(int32_t tilenume)
{
if (walock[tilenume] < 200) walock[tilenume] = 199;
gotpic[tilenume>>3] |= pow2char[tilenume&7];
@ -230,7 +231,7 @@ static inline const int8_t *getpsky(int32_t picnum, int32_t *dapyscale, int32_t
return multipsky[j].tileofs;
}
static inline void set_globalpos(int32_t x, int32_t y, int32_t z)
FORCE_INLINE void set_globalpos(int32_t const x, int32_t const y, int32_t const z)
{
globalposx = x, fglobalposx = (float)x;
globalposy = y, fglobalposy = (float)y;

View file

@ -908,7 +908,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
}
//Note: even though it says md2model, it works for both md2model&md3model
void updateanimation(md2model_t *m, const spritetype *tspr, uint8_t lpal)
void updateanimation(md2model_t *m, const tspritetype *tspr, uint8_t lpal)
{
const mdanim_t *anim;
int32_t i, j, k;
@ -1861,7 +1861,7 @@ int md3postload_polymer(md3model_t *m)
}
void md3_vox_calcmat_common(const spritetype *tspr, const vec3f_t *a0, float f, float mat[16])
void md3_vox_calcmat_common(const tspritetype *tspr, const vec3f_t *a0, float f, float mat[16])
{
float g;
float k0, k1, k2, k3, k4, k5, k6, k7;
@ -1943,7 +1943,7 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle,
bglEnd();
}
static int32_t polymost_md3draw(md3model_t *m, const spritetype *tspr)
static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
{
vec3f_t m0, m1, a0;
md3xyzn_t *v0, *v1;
@ -2527,7 +2527,7 @@ void md_allocvbos(void)
}
}
int32_t polymost_mddraw(const spritetype *tspr)
int32_t polymost_mddraw(const tspritetype *tspr)
{
mdmodel_t *vm;

View file

@ -1424,7 +1424,7 @@ void polymer_drawsprite(int32_t snum)
int32_t i, j, cs;
_prsprite *s;
spritetype *const tspr = tspriteptr[snum];
tspritetype *const tspr = tspriteptr[snum];
const sectortype *sec;
if (pr_verbosity >= 3) OSD_Printf("PR : Sprite %i...\n", snum);
@ -1706,7 +1706,7 @@ static void polymer_displayrooms(const int16_t dacursectnum)
GLfloat localprojectionmatrix[16];
float frustum[5 * 4];
int32_t localspritesortcnt;
spritetype localtsprite[MAXSPRITESONSCREEN];
tspritetype localtsprite[MAXSPRITESONSCREEN];
int16_t localmaskwall[MAXWALLSB];
int16_t localmaskwallcnt;
_prmirror mirrorlist[10];
@ -3509,7 +3509,7 @@ static inline int32_t polymer_planeinfrustum(_prplane *plane, float* frustum)
return 1;
}
static inline void polymer_scansprites(int16_t sectnum, spritetype* localtsprite, int32_t* localspritesortcnt)
static inline void polymer_scansprites(int16_t sectnum, tspritetype* localtsprite, int32_t* localspritesortcnt)
{
int32_t i;
spritetype *spr;
@ -3533,7 +3533,7 @@ void polymer_updatesprite(int32_t snum)
{
int32_t curpicnum, xsize, ysize, i, j;
int32_t tilexoff, tileyoff, xoff, yoff, centeryoff=0;
spritetype *tspr = tspriteptr[snum];
tspritetype *tspr = tspriteptr[snum];
float xratio, yratio, ang, f;
float spos[3];
const GLfloat *inbuffer;
@ -3993,7 +3993,7 @@ static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shad
}
// MDSPRITES
static void polymer_drawmdsprite(spritetype *tspr)
static void polymer_drawmdsprite(tspritetype *tspr)
{
md3model_t* m;
mdskinmap_t* sk;

View file

@ -944,16 +944,14 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth
}
else
{
const int32_t dofullbright = !(picanm[dapic].sf&PICANM_NOFULLBRIGHT_BIT);
int32_t y;
const int dofullbright = !(picanm[dapic].sf & PICANM_NOFULLBRIGHT_BIT);
for (y=0; y<siz.y; y++)
for (int y = 0; y < siz.y; y++)
{
coltype *wpptr = &pic[y*siz.x];
int32_t x;
int32_t y2 = (y < tsiz.y) ? y : y-tsiz.y;
coltype *wpptr = &pic[y * siz.x];
int32_t y2 = (y < tsiz.y) ? y : y - tsiz.y;
for (x=0; x<siz.x; x++,wpptr++)
for (int x = 0; x < siz.x; x++, wpptr++)
{
int32_t dacol;
int32_t x2 = (x < tsiz.x) ? x : x-tsiz.x;
@ -1809,7 +1807,7 @@ static void drawpoly(vec2f_t *dpxy, int32_t n, int32_t method)
}
static void vsp_finalize_init(vsptyp *vsp, int32_t vcnt)
static inline void vsp_finalize_init(vsptyp *vsp, int32_t vcnt)
{
int32_t i;
@ -1948,8 +1946,7 @@ void domost(float x0, float y0, float x1, float y1)
for (z=0; z<=scnt; z++,i=vcnt)
{
float dx0, dx1, t;
int32_t ni;
float t;
if (z == scnt)
goto skip;
@ -1964,9 +1961,9 @@ void domost(float x0, float y0, float x1, float y1)
vsp[vcnt].tag = spt[z];
skip:
ni = vsp[i].n; if (!ni) continue; //this 'if' fixes many bugs!
dx0 = vsp[i].x; if (x0 > dx0) continue;
dx1 = vsp[ni].x; if (x1 < dx1) continue;
int32_t ni = vsp[i].n; if (!ni) continue; //this 'if' fixes many bugs!
float dx0 = vsp[i].x; if (x0 > dx0) continue;
float dx1 = vsp[ni].x; if (x1 < dx1) continue;
n0.y = (dx0-x0)*slop + y0;
n1.y = (dx1-x0)*slop + y0;
@ -2167,7 +2164,7 @@ void polymost_editorfunc(void)
if (preview_mouseaim && spritesortcnt < MAXSPRITESONSCREEN)
{
spritetype *tsp = &tsprite[spritesortcnt];
tspritetype *tsp = &tsprite[spritesortcnt];
double dadist, x, y, z;
Bmemcpy(tsp, &hit.pos, sizeof(vec3_t));
x = tsp->x-globalposx; y=tsp->y-globalposy; z=(tsp->z-globalposz)/16.0;
@ -3801,7 +3798,7 @@ void polymost_drawsprite(int32_t snum)
int32_t oldsizx, oldsizy;
int32_t tsizx, tsizy;
spritetype *const tspr = tspriteptr[snum];
tspritetype *const tspr = tspriteptr[snum];
const sectortype *sec;
if (EDUKE32_PREDICT_FALSE(bad_tspr(tspr)))
@ -4298,7 +4295,7 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
float ogxyaspect;
vec3f_t vec1;
spritetype tspr;
tspritetype tspr;
Bmemset(&tspr, 0, sizeof(spritetype));
if (hudmem[(dastat&4)>>2][picnum].flags & HUDFLAG_HIDE)

View file

@ -895,7 +895,7 @@ voxmodel_t *voxload(const char *filnam)
}
//Draw voxel model as perfect cubes
int32_t polymost_voxdraw(voxmodel_t *m, const spritetype *tspr)
int32_t polymost_voxdraw(voxmodel_t *m, const tspritetype *tspr)
{
// float clut[6] = {1.02,1.02,0.94,1.06,0.98,0.98};
float f, g, k0;

View file

@ -8192,11 +8192,6 @@ void A_PlayAlertSound(int32_t i)
}
}
int32_t A_CheckEnemyTile(int32_t pn)
{
return ((g_tile[pn].flags & (SFLAG_HARDCODED_BADGUY|SFLAG_BADGUY)) != 0);
}
int32_t A_CheckSwitchTile(int32_t i)
{
int32_t j;

View file

@ -310,7 +310,6 @@ extern projectile_t SpriteProjectile[MAXSPRITES];
void A_AddToDeleteQueue(int32_t i);
int32_t A_CheckEnemyTile(int32_t pn);
int32_t A_CheckSwitchTile(int32_t i);
void A_DeleteSprite(int32_t s);
void A_DoGuts(int32_t sp,int32_t gtype,int32_t n);

View file

@ -29,6 +29,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "duke3d.h"
#include "actors_inline.h"
ACTOR_INLINE int A_CheckEnemyTile(int32_t pn)
{
return ((g_tile[pn].flags & (SFLAG_HARDCODED_BADGUY | SFLAG_BADGUY)) != 0);
}
ACTOR_INLINE int32_t A_SetSprite(int32_t i,uint32_t cliptype)
{
vec3_t davect = {(sprite[i].xvel*(sintable[(sprite[i].ang+512)&2047]))>>14,
@ -45,11 +50,9 @@ ACTOR_INLINE int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint3
EXTERN_INLINE void G_UpdateInterpolations(void) //Stick at beginning of G_DoMoveThings
{
int32_t i=g_numInterpolations-1;
for (; i>=0; i--) oldipos[i] = *curipos[i];
for (int i=g_numInterpolations-1; i>=0; i--) oldipos[i] = *curipos[i];
}
EXTERN_INLINE void G_RestoreInterpolations(void) //Stick at end of drawscreen
{
int32_t i=g_numInterpolations-1;

View file

@ -36,7 +36,7 @@ extern "C" {
#endif
extern int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t cliptype, int32_t clipdist);
ACTOR_INLINE_HEADER int A_CheckEnemyTile(int32_t pn);
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);

View file

@ -10237,7 +10237,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr)
{
int32_t i, k;
spritetype *tspr;
tspritetype *tspr;
int32_t frames=0, sh;
UNREFERENCED_PARAMETER(ourx);

View file

@ -4954,7 +4954,7 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3
int32_t p;
int32_t i;
spritetype *s;
spritetype spr_temp;
tspritetype spr_temp;
// NetAlloc
if (Net_IsRelevantStat(s_ss))
@ -7035,7 +7035,7 @@ SPAWN_END:
return i;
}
static int32_t G_MaybeTakeOnFloorPal(spritetype *datspr, int32_t sect)
static int32_t G_MaybeTakeOnFloorPal(tspritetype *datspr, int32_t sect)
{
int32_t dapal = sector[sect].floorpal;
@ -7049,7 +7049,7 @@ static int32_t G_MaybeTakeOnFloorPal(spritetype *datspr, int32_t sect)
return 0;
}
static int32_t getofs_viewtype5(const spritetype *s, spritetype *t, int32_t a, uint8_t invertp)
static int32_t getofs_viewtype5(const tspritetype *s, tspritetype *t, int32_t a, uint8_t invertp)
{
int32_t angdif = invertp ? a-s->ang : s->ang-a;
int32_t k = (((angdif+3072+128)&2047)>>8)&7;
@ -7064,7 +7064,7 @@ static int32_t getofs_viewtype5(const spritetype *s, spritetype *t, int32_t a, u
return k;
}
static int32_t getofs_viewtype7(const spritetype *s, spritetype *t, int32_t a, uint8_t invertp)
static int32_t getofs_viewtype7(const tspritetype *s, tspritetype *t, int32_t a, uint8_t invertp)
{
int32_t angdif = invertp ? a-s->ang : s->ang-a;
int32_t k = ((angdif+3072+128)&2047)/170;
@ -7180,7 +7180,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
#endif
for (j=spritesortcnt-1; j>=0; j--)
{
spritetype *const t = &tsprite[j];
tspritetype *const t = &tsprite[j];
const int32_t i = t->owner;
const spritetype *const s = &sprite[i];
@ -7209,7 +7209,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
for (j=spritesortcnt-1; j>=0; j--)
{
spritetype *const t = &tsprite[j];
tspritetype *const t = &tsprite[j];
const int32_t i = t->owner;
const spritetype *const s = &sprite[i];
@ -7267,7 +7267,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
continue;
default:
// NOTE: wall-aligned sprites will never take on ceiling/floor shade...
if ((t->cstat&16) || (A_CheckEnemySprite(t) && t->extra > 0) || t->statnum == STAT_PLAYER)
if ((t->cstat&16) || (A_CheckEnemySprite((const spritetype *)t) && t->extra > 0) || t->statnum == STAT_PLAYER)
continue;
}
@ -7298,11 +7298,11 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
int32_t startframe, viewtype;
#endif
//is the perfect time to animate sprites
spritetype *const t = &tsprite[j];
tspritetype *const t = &tsprite[j];
const int32_t i = t->owner;
// XXX: what's up with the (i < 0) check?
// NOTE: not const spritetype because set at SET_SPRITE_NOT_TSPRITE (see below).
spritetype *const s = (i < 0) ? &tsprite[j] : &sprite[i];
tspritetype *const s = (i < 0) ? &tsprite[j] : (tspritetype *)&sprite[i];
if (ud.lockout && G_CheckAdultTile(DYNAMICTILEMAP(s->picnum)))
{
@ -7322,7 +7322,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
Bassert(i >= 0);
{
int32_t snum = P_GetP(s);
int32_t snum = P_GetP((const spritetype *)s);
const DukePlayer_t *const ps = g_player[snum].ps;
if (s->statnum != STAT_ACTOR && s->picnum == APLAYER && ps->newowner == -1 && s->owner >= 0)
@ -7402,7 +7402,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
sprite[s->owner].y-t->y);
if (klabs(G_GetAngleDelta(sqa,sqb)) > 512)
if (ldist(&sprite[s->owner],t) < ldist(&sprite[g_player[screenpeek].ps->i],&sprite[s->owner]))
if (ldist(&sprite[s->owner],(const spritetype *)t) < ldist(&sprite[g_player[screenpeek].ps->i],&sprite[s->owner]))
t->xrepeat = t->yrepeat = 0;
}
continue;
@ -7503,7 +7503,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
break;
case APLAYER__STATIC:
p = P_GetP(s);
p = P_GetP((const spritetype *)s);
if (t->pal == 1) t->z -= (18<<8);
@ -7545,7 +7545,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
if (ud.showweapons && sprite[g_player[p].ps->i].extra > 0 && g_player[p].ps->curr_weapon > 0
&& spritesortcnt < MAXSPRITESONSCREEN)
{
spritetype *const newt = &tsprite[spritesortcnt];
tspritetype *const newt = &tsprite[spritesortcnt];
int32_t curweap = g_player[p].ps->curr_weapon;
Bmemcpy(newt, t, sizeof(spritetype));
@ -7575,7 +7575,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
if (g_player[p].sync->extbits & (1<<7) && !ud.pause_on && spritesortcnt<MAXSPRITESONSCREEN)
{
spritetype *const newt = &tsprite[spritesortcnt];
tspritetype *const newt = &tsprite[spritesortcnt];
Bmemcpy(newt, t, sizeof(spritetype));
@ -7810,14 +7810,14 @@ skip:
// player has nightvision on. We should pass stuff like "from which player is this view
// supposed to be" as parameters ("drawing context") instead of relying on globals.
if (g_player[screenpeek].ps->inv_amount[GET_HEATS] > 0 && g_player[screenpeek].ps->heat_on &&
(A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SFLAG_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER))
(A_CheckEnemySprite((const spritetype *)s) || A_CheckSpriteFlags(t->owner,SFLAG_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER))
{
t->pal = 6;
t->shade = 0;
}
// Fake floor shadow, implemented by inserting a new tsprite.
if (s->statnum == STAT_DUMMYPLAYER || A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SFLAG_SHADOW) || (s->picnum == APLAYER && s->owner >= 0))
if (s->statnum == STAT_DUMMYPLAYER || A_CheckEnemySprite((const spritetype *)s) || A_CheckSpriteFlags(t->owner,SFLAG_SHADOW) || (s->picnum == APLAYER && s->owner >= 0))
if (t->statnum != TSPR_TEMP && s->picnum != EXPLOSION2 && s->picnum != HANGLIGHT && s->picnum != DOMELITE && s->picnum != HOTMEAT)
{
if (actor[i].dispicnum < 0)
@ -7846,7 +7846,7 @@ skip:
if ((s->z-daz) < (8<<8) && g_player[screenpeek].ps->pos.z < daz)
{
spritetype *const newt = &tsprite[spritesortcnt];
tspritetype *const newt = &tsprite[spritesortcnt];
Bmemcpy(newt, t, sizeof(spritetype));

View file

@ -1358,10 +1358,12 @@ skip_check:
case ITER_DRAWNSPRITES:
for (ii=0; ii<spritesortcnt && !vm.flags; ii++)
{
vm.g_sp = &tsprite[ii];
vm.g_sp = &sprite[MAXSPRITES-1];
Bmemcpy(&sprite[MAXSPRITES-1], &tsprite[ii], sizeof(tspritetype));
Gv_SetVarX(var, ii);
insptr = beg;
VM_Execute(1);
Bmemcpy(&tsprite[ii], &sprite[MAXSPRITES-1], sizeof(tspritetype));
}
break;
case ITER_SPRITESOFSECTOR:
@ -1722,8 +1724,10 @@ badindex:
{
Bmemcpy(&tsprite[spritesortcnt], &sprite[ospritenum], sizeof(spritetype));
tsprite[spritesortcnt].owner = ospritenum;
/* FIXME
vm.g_i = -1;
vm.g_sp = &tsprite[spritesortcnt];
*/
spritesortcnt++;
}
}

View file

@ -388,7 +388,7 @@ static int32_t __fastcall VM_AccessTsprite(int32_t how, int32_t lVar1, int32_t l
{
int32_t lightp = (lLabelID >= LIGHT_X);
int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
spritetype *datspr = NULL;
tspritetype *datspr = NULL;
const memberlabel_t *dalabel = lightp ? &LightLabels[lLabelID-LIGHT_X] : &SpriteLabels[lLabelID];
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)