"Stylistic changes"

Translation: I made some stuff const because I felt like it.

git-svn-id: https://svn.eduke32.com/eduke32@5067 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-03-24 00:40:05 +00:00
parent c725da4829
commit 7845f5e2fe
2 changed files with 33 additions and 42 deletions

View file

@ -38,14 +38,12 @@ extern int32_t g_noEnemies;
int32_t otherp; int32_t otherp;
int32_t G_SetInterpolation(int32_t *posptr) int32_t G_SetInterpolation(int32_t * const posptr)
{ {
int32_t i=g_numInterpolations-1;
if (g_numInterpolations >= MAXINTERPOLATIONS) if (g_numInterpolations >= MAXINTERPOLATIONS)
return 1; return 1;
for (; i>=0; i--) for (int i = 0; i < g_numInterpolations; ++i)
if (curipos[i] == posptr) if (curipos[i] == posptr)
return 0; return 0;
@ -55,11 +53,9 @@ int32_t G_SetInterpolation(int32_t *posptr)
return 0; return 0;
} }
void G_StopInterpolation(int32_t *posptr) void G_StopInterpolation(int32_t * const posptr)
{ {
int32_t i=g_numInterpolations-1; for (int i = startofdynamicinterpolations; i < g_numInterpolations; ++i)
for (; i>=startofdynamicinterpolations; i--)
if (curipos[i] == posptr) if (curipos[i] == posptr)
{ {
g_numInterpolations--; g_numInterpolations--;
@ -71,20 +67,19 @@ void G_StopInterpolation(int32_t *posptr)
void G_DoInterpolations(int32_t smoothratio) //Stick at beginning of drawscreen void G_DoInterpolations(int32_t smoothratio) //Stick at beginning of drawscreen
{ {
int32_t i=g_numInterpolations-1, j = 0, odelta, ndelta = 0;
if (g_interpolationLock++) if (g_interpolationLock++)
{
return; return;
}
for (; i>=0; i--) int32_t odelta, ndelta = 0;
for (int i = 0, j = 0; i < g_numInterpolations; ++i)
{ {
bakipos[i] = *curipos[i];
odelta = ndelta; odelta = ndelta;
ndelta = (*curipos[i])-oldipos[i]; bakipos[i] = *curipos[i];
if (odelta != ndelta) j = mulscale16(ndelta,smoothratio); ndelta = (*curipos[i]) - oldipos[i];
*curipos[i] = oldipos[i]+j; if (odelta != ndelta)
j = mulscale16(ndelta, smoothratio);
*curipos[i] = oldipos[i] + j;
} }
} }
@ -93,10 +88,7 @@ void G_ClearCameraView(DukePlayer_t *ps)
int32_t k; int32_t k;
ps->newowner = -1; ps->newowner = -1;
ps->pos = ps->opos;
ps->pos.x = ps->opos.x;
ps->pos.y = ps->opos.y;
ps->pos.z = ps->opos.z;
ps->ang = ps->oang; ps->ang = ps->oang;
updatesector(ps->pos.x, ps->pos.y, &ps->cursectnum); updatesector(ps->pos.x, ps->pos.y, &ps->cursectnum);
@ -313,29 +305,28 @@ BOLT:
// <spritenum>: the projectile // <spritenum>: the projectile
// <i>: the SE7 // <i>: the SE7
// <fromunderp>: below->above change? // <fromunderp>: below->above change?
static int32_t Proj_MaybeDoTransport(int32_t spritenum, int32_t i, int32_t fromunderp, int32_t daz) static int32_t Proj_MaybeDoTransport(int32_t spritenum, const tspritetype * const effector, int32_t fromunderp, int32_t daz)
{ {
if (totalclock > actor[spritenum].lasttransport) if (totalclock <= actor[spritenum].lasttransport)
{ return 0;
spritetype *const spr = &sprite[spritenum]; spritetype *const spr = &sprite[spritenum];
const spritetype *const otherse = &sprite[OW]; const tspritetype *const otherse = (tspritetype *)&sprite[effector->owner];
actor[spritenum].lasttransport = totalclock + (TICSPERFRAME<<2); actor[spritenum].lasttransport = totalclock + (TICSPERFRAME<<2);
spr->x += (otherse->x-SX); spr->x += (otherse->x - effector->x);
spr->y += (otherse->y-SY); spr->y += (otherse->y - effector->y);
if (!fromunderp) // above->below
spr->z = sector[otherse->sectnum].ceilingz - daz + sector[sprite[i].sectnum].floorz;
else // below->above
spr->z = sector[otherse->sectnum].floorz - daz + sector[sprite[i].sectnum].ceilingz;
Bmemcpy(&actor[spritenum].bpos, &sprite[spritenum], sizeof(vec3_t)); // above->below
spr->z = (!fromunderp) ? sector[otherse->sectnum].ceilingz - daz + sector[effector->sectnum].floorz :
sector[otherse->sectnum].floorz - daz + sector[effector->sectnum].ceilingz;
// below->above
actor[spritenum].bpos = *(vec3_t *)&sprite[spritenum];
changespritesect(spritenum, otherse->sectnum); changespritesect(spritenum, otherse->sectnum);
return 1; return 1;
}
return 0;
} }
// Check whether sprite <s> is on/in a non-SE7 water sector. // Check whether sprite <s> is on/in a non-SE7 water sector.
@ -548,12 +539,12 @@ int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t c
if (lotag == ST_1_ABOVE_WATER) if (lotag == ST_1_ABOVE_WATER)
if (daz >= actor[spritenum].floorz) if (daz >= actor[spritenum].floorz)
if (Proj_MaybeDoTransport(spritenum, i, 0, daz)) if (Proj_MaybeDoTransport(spritenum, (tspritetype *)&sprite[i], 0, daz))
return 0; return 0;
if (lotag == ST_2_UNDERWATER) if (lotag == ST_2_UNDERWATER)
if (daz <= actor[spritenum].ceilingz) if (daz <= actor[spritenum].ceilingz)
if (Proj_MaybeDoTransport(spritenum, i, 1, daz)) if (Proj_MaybeDoTransport(spritenum, (tspritetype *)&sprite[i], 1, daz))
return 0; return 0;
} }
} }

View file

@ -326,8 +326,8 @@ void G_AddGameLight(int32_t radius,int32_t srcsprite,int32_t zoff
void G_ClearCameraView(DukePlayer_t *ps); void G_ClearCameraView(DukePlayer_t *ps);
void G_DoInterpolations(int32_t smoothratio); void G_DoInterpolations(int32_t smoothratio);
void G_MoveWorld(void); void G_MoveWorld(void);
int32_t G_SetInterpolation(int32_t *posptr); int32_t G_SetInterpolation(int32_t * const posptr);
void G_StopInterpolation(int32_t *posptr); void G_StopInterpolation(int32_t * const posptr);
// PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly // PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly
void Sect_ToggleInterpolation(int sectnum, int doset); void Sect_ToggleInterpolation(int sectnum, int doset);