mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 03:00:38 +00:00
gameexec.c: factor out 2x occuring pattern into VM_GetZRange(), clean up 3 funcs.
- VM_GetZRange(), which updates actor[].{floor,ceiling}z, is called from A_GetZLimits() and A_Fall(). - Style-cleanup the following: A_Dodge(), A_GetFurthestAngle(), A_FurthestVisiblePoint(). DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@5015 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
120746322b
commit
b367d57845
1 changed files with 90 additions and 92 deletions
|
@ -298,51 +298,48 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *p)
|
||||||
|
|
||||||
int32_t A_Dodge(spritetype *s)
|
int32_t A_Dodge(spritetype *s)
|
||||||
{
|
{
|
||||||
int32_t bx,by,bxvect,byvect,i;
|
const int32_t mx = s->x, my = s->y;
|
||||||
int32_t mx = s->x, my = s->y;
|
const int32_t mxvect = sintable[(s->ang+512)&2047];
|
||||||
int32_t mxvect = sintable[(s->ang+512)&2047];
|
const int32_t myvect = sintable[s->ang&2047];
|
||||||
int32_t myvect = sintable[s->ang&2047];
|
|
||||||
|
|
||||||
if (A_CheckEnemySprite(s) && s->extra <= 0) // hack
|
if (A_CheckEnemySprite(s) && s->extra <= 0) // hack
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i=headspritestat[STAT_PROJECTILE]; i>=0; i=nextspritestat[i]) //weapons list
|
for (int32_t i=headspritestat[STAT_PROJECTILE]; i>=0; i=nextspritestat[i]) //weapons list
|
||||||
{
|
{
|
||||||
if (OW == i)
|
if (OW == i)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bx = SX-mx;
|
int32_t bx = SX-mx;
|
||||||
by = SY-my;
|
int32_t by = SY-my;
|
||||||
bxvect = sintable[(SA+512)&2047];
|
int32_t bxvect = sintable[(SA+512)&2047];
|
||||||
byvect = sintable[SA&2047];
|
int32_t byvect = sintable[SA&2047];
|
||||||
|
|
||||||
if ((mxvect * bx) + (myvect * by) >= 0 && (bxvect * bx) + (byvect * by) < 0)
|
if (mxvect*bx + myvect*by >= 0 && bxvect*bx + byvect*by < 0)
|
||||||
{
|
{
|
||||||
if (klabs((bxvect * by) - (byvect * bx)) < 65536<<6)
|
if (klabs(bxvect*by - byvect*bx) < 65536<<6)
|
||||||
{
|
{
|
||||||
s->ang -= 512+(krand()&1024);
|
s->ang -= 512+(krand()&1024);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs)
|
int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs)
|
||||||
{
|
{
|
||||||
spritetype *s = &sprite[iActor];
|
spritetype *const s = &sprite[iActor];
|
||||||
|
|
||||||
if (s->picnum != APLAYER && (AC_COUNT(actor[iActor].t_data)&63) > 2)
|
if (s->picnum != APLAYER && (AC_COUNT(actor[iActor].t_data)&63) > 2)
|
||||||
return s->ang + 1024;
|
return s->ang + 1024;
|
||||||
|
|
||||||
{
|
int32_t furthest_angle = 0, greatestd = INT32_MIN;
|
||||||
int32_t furthest_angle=0;
|
const int32_t angincs = tabledivide32_noinline(2048, angs);
|
||||||
int32_t d, j;
|
|
||||||
int32_t greatestd = INT32_MIN;
|
|
||||||
int32_t angincs=tabledivide32_noinline(2048, angs);
|
|
||||||
hitdata_t hit;
|
hitdata_t hit;
|
||||||
|
|
||||||
for (j=s->ang; j<(2048+s->ang); j+=angincs)
|
for (int32_t j=s->ang; j<(2048+s->ang); j+=angincs)
|
||||||
{
|
{
|
||||||
s->z -= (8<<8);
|
s->z -= (8<<8);
|
||||||
hitscan((const vec3_t *)s, s->sectnum,
|
hitscan((const vec3_t *)s, s->sectnum,
|
||||||
|
@ -350,7 +347,8 @@ int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs)
|
||||||
sintable[j&2047], 0,
|
sintable[j&2047], 0,
|
||||||
&hit, CLIPMASK1);
|
&hit, CLIPMASK1);
|
||||||
s->z += (8<<8);
|
s->z += (8<<8);
|
||||||
d = klabs(hit.pos.x-s->x) + klabs(hit.pos.y-s->y);
|
|
||||||
|
const int32_t d = klabs(hit.pos.x-s->x) + klabs(hit.pos.y-s->y);
|
||||||
|
|
||||||
if (d > greatestd)
|
if (d > greatestd)
|
||||||
{
|
{
|
||||||
|
@ -361,24 +359,21 @@ int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs)
|
||||||
|
|
||||||
return furthest_angle&2047;
|
return furthest_angle&2047;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int32_t A_FurthestVisiblePoint(int32_t iActor, tspritetype * const ts, int32_t *dax, int32_t *day)
|
int32_t A_FurthestVisiblePoint(int32_t iActor, tspritetype * const ts, int32_t *dax, int32_t *day)
|
||||||
{
|
{
|
||||||
if (AC_COUNT(actor[iActor].t_data)&63)
|
if (AC_COUNT(actor[iActor].t_data)&63)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
{
|
const spritetype *const s = &sprite[iActor];
|
||||||
int32_t d, da;//, d, cd, ca,tempx,tempy,cx,cy;
|
|
||||||
int32_t j, angincs;
|
const int32_t angincs =
|
||||||
spritetype *s = &sprite[iActor];
|
((!g_netServer && ud.multimode < 2) && ud.player_skill < 3) ? 2048/2 :
|
||||||
|
tabledivide32_noinline(2048, 1+(krand()&1));
|
||||||
|
|
||||||
hitdata_t hit;
|
hitdata_t hit;
|
||||||
|
|
||||||
if ((!g_netServer && ud.multimode < 2) && ud.player_skill < 3)
|
for (int32_t j=ts->ang; j<(2048+ts->ang); j+=(angincs-(krand()&511)))
|
||||||
angincs = 2048/2;
|
|
||||||
else angincs = tabledivide32_noinline(2048, 1+(krand()&1));
|
|
||||||
|
|
||||||
for (j=ts->ang; j<(2048+ts->ang); j+=(angincs-(krand()&511)))
|
|
||||||
{
|
{
|
||||||
ts->z -= (16<<8);
|
ts->z -= (16<<8);
|
||||||
hitscan((const vec3_t *)ts, ts->sectnum,
|
hitscan((const vec3_t *)ts, ts->sectnum,
|
||||||
|
@ -388,8 +383,8 @@ int32_t A_FurthestVisiblePoint(int32_t iActor, tspritetype * const ts, int32_t *
|
||||||
|
|
||||||
ts->z += (16<<8);
|
ts->z += (16<<8);
|
||||||
|
|
||||||
d = klabs(hit.pos.x-ts->x)+klabs(hit.pos.y-ts->y);
|
const int32_t d = klabs(hit.pos.x-ts->x)+klabs(hit.pos.y-ts->y);
|
||||||
da = klabs(hit.pos.x-s->x)+klabs(hit.pos.y-s->y);
|
const int32_t da = klabs(hit.pos.x-s->x)+klabs(hit.pos.y-s->y);
|
||||||
|
|
||||||
if (d < da && hit.sect > -1)
|
if (d < da && hit.sect > -1)
|
||||||
if (cansee(hit.pos.x,hit.pos.y,hit.pos.z,
|
if (cansee(hit.pos.x,hit.pos.y,hit.pos.z,
|
||||||
|
@ -400,36 +395,45 @@ int32_t A_FurthestVisiblePoint(int32_t iActor, tspritetype * const ts, int32_t *
|
||||||
return hit.sect;
|
return hit.sect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void VM_GetZRange(int32_t iActor, int32_t *ceilhit, int32_t *florhit, int walldist)
|
||||||
|
{
|
||||||
|
spritetype *const s = &sprite[iActor];
|
||||||
|
const int32_t ocstat = s->cstat;
|
||||||
|
|
||||||
|
s->cstat = 0;
|
||||||
|
s->z -= ZOFFSET;
|
||||||
|
|
||||||
|
getzrange((vec3_t *)s, s->sectnum,
|
||||||
|
&actor[iActor].ceilingz, ceilhit,
|
||||||
|
&actor[iActor].floorz, florhit,
|
||||||
|
walldist, CLIPMASK0);
|
||||||
|
|
||||||
|
s->z += ZOFFSET;
|
||||||
|
s->cstat = ocstat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void A_GetZLimits(int32_t iActor)
|
void A_GetZLimits(int32_t iActor)
|
||||||
{
|
{
|
||||||
spritetype *s = &sprite[iActor];
|
spritetype *const s = &sprite[iActor];
|
||||||
|
|
||||||
int32_t hz,lz,zr = 127;
|
int32_t ceilhit, florhit;
|
||||||
int32_t cstat = s->cstat;
|
const int walldist = (s->statnum == STAT_PROJECTILE) ? 4 : 127;
|
||||||
|
|
||||||
s->cstat = 0;
|
VM_GetZRange(iActor, &ceilhit, &florhit, walldist);
|
||||||
|
|
||||||
if (s->statnum == STAT_PROJECTILE)
|
|
||||||
zr = 4;
|
|
||||||
|
|
||||||
s->z -= ZOFFSET;
|
|
||||||
getzrange((vec3_t *)s,s->sectnum,&actor[iActor].ceilingz,&hz,&actor[iActor].floorz,&lz,zr,CLIPMASK0);
|
|
||||||
s->z += ZOFFSET;
|
|
||||||
|
|
||||||
s->cstat = cstat;
|
|
||||||
|
|
||||||
actor[iActor].flags &= ~SFLAG_NOFLOORSHADOW;
|
actor[iActor].flags &= ~SFLAG_NOFLOORSHADOW;
|
||||||
|
|
||||||
if ((lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0)
|
if ((florhit&49152) == 49152 && (sprite[florhit&(MAXSPRITES-1)].cstat&48) == 0)
|
||||||
{
|
{
|
||||||
const spritetype *hitspr = &sprite[lz&(MAXSPRITES-1)];
|
const spritetype *hitspr = &sprite[florhit&(MAXSPRITES-1)];
|
||||||
|
|
||||||
lz &= (MAXSPRITES-1);
|
florhit &= (MAXSPRITES-1);
|
||||||
|
|
||||||
|
// If a non-projectile would fall onto non-frozen enemy OR an enemy onto a player...
|
||||||
if ((A_CheckEnemySprite(hitspr) && hitspr->pal != 1 && s->statnum != STAT_PROJECTILE)
|
if ((A_CheckEnemySprite(hitspr) && hitspr->pal != 1 && s->statnum != STAT_PROJECTILE)
|
||||||
|| (hitspr->picnum == APLAYER && A_CheckEnemySprite(s)))
|
|| (hitspr->picnum == APLAYER && A_CheckEnemySprite(s)))
|
||||||
{
|
{
|
||||||
|
@ -437,7 +441,7 @@ void A_GetZLimits(int32_t iActor)
|
||||||
s->xvel = -256;
|
s->xvel = -256;
|
||||||
A_SetSprite(iActor, CLIPMASK0);
|
A_SetSprite(iActor, CLIPMASK0);
|
||||||
}
|
}
|
||||||
else if (s->statnum == STAT_PROJECTILE && hitspr->picnum == APLAYER && s->owner==lz)
|
else if (s->statnum == STAT_PROJECTILE && hitspr->picnum == APLAYER && s->owner==florhit)
|
||||||
{
|
{
|
||||||
actor[iActor].ceilingz = sector[s->sectnum].ceilingz;
|
actor[iActor].ceilingz = sector[s->sectnum].ceilingz;
|
||||||
actor[iActor].floorz = sector[s->sectnum].floorz;
|
actor[iActor].floorz = sector[s->sectnum].floorz;
|
||||||
|
@ -447,11 +451,9 @@ void A_GetZLimits(int32_t iActor)
|
||||||
|
|
||||||
void A_Fall(int32_t iActor)
|
void A_Fall(int32_t iActor)
|
||||||
{
|
{
|
||||||
spritetype *s = &sprite[iActor];
|
spritetype *const s = &sprite[iActor];
|
||||||
int32_t hz,lz,c = g_spriteGravity;
|
int c = g_spriteGravity;
|
||||||
#ifdef YAX_ENABLE
|
|
||||||
int16_t fbunch;
|
|
||||||
#endif
|
|
||||||
if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(s->sectnum)))
|
if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(s->sectnum)))
|
||||||
c = 0;
|
c = 0;
|
||||||
else if (sector[s->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(s->sectnum)))
|
else if (sector[s->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(s->sectnum)))
|
||||||
|
@ -459,12 +461,8 @@ void A_Fall(int32_t iActor)
|
||||||
|
|
||||||
if (s->statnum == STAT_ACTOR || s->statnum == STAT_PLAYER || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_STANDABLE)
|
if (s->statnum == STAT_ACTOR || s->statnum == STAT_PLAYER || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_STANDABLE)
|
||||||
{
|
{
|
||||||
int32_t cstat = s->cstat;
|
int32_t ceilhit, florhit;
|
||||||
s->cstat = 0;
|
VM_GetZRange(iActor, &ceilhit, &florhit, 127);
|
||||||
s->z -= ZOFFSET;
|
|
||||||
getzrange((vec3_t *)s,s->sectnum,&actor[iActor].ceilingz,&hz,&actor[iActor].floorz,&lz,127L,CLIPMASK0);
|
|
||||||
s->z += ZOFFSET;
|
|
||||||
s->cstat = cstat;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -473,7 +471,7 @@ void A_Fall(int32_t iActor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef YAX_ENABLE
|
#ifdef YAX_ENABLE
|
||||||
fbunch = (sector[s->sectnum].floorstat&512) ? -1 : yax_getbunch(s->sectnum, YAX_FLOOR);
|
int16_t fbunch = (sector[s->sectnum].floorstat&512) ? -1 : yax_getbunch(s->sectnum, YAX_FLOOR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s->z < actor[iActor].floorz-ZOFFSET
|
if (s->z < actor[iActor].floorz-ZOFFSET
|
||||||
|
|
Loading…
Reference in a new issue