The great cleanup continues. This one also adds a new feature, SFLAG_WAKEUPBADGUYS. When awoken (changed to an active actor), any sprite with this flag set will wake up any enemy it has line of sight with.

git-svn-id: https://svn.eduke32.com/eduke32@5826 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-08-27 01:40:46 +00:00
parent 52f678a743
commit 5c6d8c96ad
17 changed files with 2913 additions and 2939 deletions

View file

@ -3,20 +3,21 @@ AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
ExperimentalAutoDetectBinPacking: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: false
BreakBeforeBinaryOperators: true
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 125
ColumnLimit: 140
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 0

View file

@ -287,10 +287,10 @@ SKIPWALLCHECK:
{
if (pOther->picnum == APLAYER)
{
DukePlayer_t *ps = g_player[P_GetP(pOther)].ps;
DukePlayer_t *pPlayer = g_player[P_GetP((uspritetype * const)pOther)].ps;
if (ps->newowner >= 0)
G_ClearCameraView(ps);
if (pPlayer->newowner >= 0)
G_ClearCameraView(pPlayer);
}
actor[otherSprite].owner = pSprite->owner;
@ -848,6 +848,37 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t
#endif
}
ACTOR_STATIC void A_MaybeAwakenBadGuys(int spriteNum)
{
if (sprite[spriteNum].sectnum == MAXSECTORS)
return;
if (A_CheckSpriteFlags(spriteNum, SFLAG_WAKEUPBADGUYS))
{
uspritetype *const pSprite = (uspritetype *)&sprite[spriteNum];
for (int nextSprite, SPRITES_OF_STAT_SAFE(STAT_ZOMBIEACTOR, spriteNum, nextSprite))
{
if (A_CheckEnemySprite(&sprite[spriteNum]))
{
if (sprite[spriteNum].sectnum == pSprite->sectnum
|| sprite[spriteNum].sectnum == nextsectorneighborz(pSprite->sectnum, sector[pSprite->sectnum].floorz, 1, 1)
|| cansee(pSprite->x, pSprite->y, pSprite->z - PHEIGHT, pSprite->sectnum, sprite[spriteNum].x, sprite[spriteNum].y,
sprite[spriteNum].z - PHEIGHT, sprite[spriteNum].sectnum))
{
actor[spriteNum].timetosleep = 0;
A_PlayAlertSound(spriteNum);
changespritestat(spriteNum, STAT_ACTOR);
if (A_CheckSpriteFlags(spriteNum, SFLAG_WAKEUPBADGUYS))
A_MaybeAwakenBadGuys(spriteNum);
}
}
}
}
}
// sleeping monsters, etc
ACTOR_STATIC void G_MoveZombieActors(void)
{
@ -870,8 +901,11 @@ ACTOR_STATIC void G_MoveZombieActors(void)
{
if (A_CheckEnemySprite(pSprite))
{
vec2_t const p = { g_player[playerNum].ps->opos.x + 64 - (krand() & 127),
g_player[playerNum].ps->opos.y + 64 - (krand() & 127) };
vec3_t const p = { g_player[playerNum].ps->pos.x + 64 - (krand() & 127),
g_player[playerNum].ps->pos.y + 64 - (krand() & 127),
g_player[playerNum].ps->pos.z - (krand() % (32 << 8))
};
int16_t pSectnum = g_player[playerNum].ps->cursectnum;
updatesector(p.x, p.y, &pSectnum);
@ -882,10 +916,13 @@ ACTOR_STATIC void G_MoveZombieActors(void)
continue;
}
vec2_t const s = { pSprite->x + 64 - (krand() & 127), pSprite->y + 64 - (krand() & 127) };
vec3_t const s = { pSprite->x + 64 - (krand() & 127),
pSprite->y + 64 - (krand() & 127),
pSprite->z - (krand() % (52 << 8)) };
int16_t sectNum = pSprite->sectnum;
updatesector(p.x,p.y,&sectNum);
updatesector(s.x, s.y, &sectNum);
if (sectNum == -1)
{
@ -893,14 +930,11 @@ ACTOR_STATIC void G_MoveZombieActors(void)
continue;
}
j = cansee(s.x, s.y, pSprite->z - (krand() % (52 << 8)), sectNum, p.x, p.y,
g_player[playerNum].ps->opos.z - (krand() % (32 << 8)), pSectnum);
j = cansee(s.x, s.y, s.z, sectNum, p.x, p.y, p.z, pSectnum);
}
else
j =
cansee(pSprite->x, pSprite->y, pSprite->z - ((krand() & 31) << 8), pSprite->sectnum,
g_player[playerNum].ps->opos.x, g_player[playerNum].ps->opos.y,
g_player[playerNum].ps->opos.z - ((krand() & 31) << 8), g_player[playerNum].ps->cursectnum);
j = cansee(pSprite->x, pSprite->y, pSprite->z - ((krand() & 31) << 8), pSprite->sectnum, g_player[playerNum].ps->pos.x,
g_player[playerNum].ps->pos.y, g_player[playerNum].ps->pos.z - ((krand() & 31) << 8), g_player[playerNum].ps->cursectnum);
if (j)
{
@ -934,9 +968,14 @@ ACTOR_STATIC void G_MoveZombieActors(void)
default:
if (A_CheckSpriteFlags(spriteNum, SFLAG_USEACTIVATOR) && sector[sprite[spriteNum].sectnum].lotag & 16384)
break;
actor[spriteNum].timetosleep = 0;
A_PlayAlertSound(spriteNum);
changespritestat(spriteNum, STAT_ACTOR);
if (A_CheckSpriteFlags(spriteNum, SFLAG_WAKEUPBADGUYS))
A_MaybeAwakenBadGuys(spriteNum);
break;
}
}
@ -946,9 +985,9 @@ ACTOR_STATIC void G_MoveZombieActors(void)
if (A_CheckEnemySprite(pSprite) && A_CheckSpriteFlags(spriteNum,SFLAG_NOSHADE) == 0)
{
if (sector[pSprite->sectnum].ceilingstat&1)
pSprite->shade = sector[pSprite->sectnum].ceilingshade;
else pSprite->shade = sector[pSprite->sectnum].floorshade;
pSprite->shade = (sector[pSprite->sectnum].ceilingstat & 1)
? sector[pSprite->sectnum].ceilingshade
: sector[pSprite->sectnum].floorshade;
}
}
@ -3219,7 +3258,7 @@ static int32_t P_Submerge(int32_t j, int32_t p, DukePlayer_t *ps, int32_t sect,
{
if (ps->on_ground &&
ps->pos.z >= sector[sect].floorz &&
(TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH) || ps->vel.z > 2048))
(TEST_SYNC_KEY(g_player[p].inputBits->bits, SK_CROUCH) || ps->vel.z > 2048))
// if( onfloorz && sectlotag == 1 && ps->pos.z > (sector[sect].floorz-(6<<8)) )
{
if (screenpeek == p)
@ -3233,7 +3272,7 @@ static int32_t P_Submerge(int32_t j, int32_t p, DukePlayer_t *ps, int32_t sect,
ps->opos.z = ps->pos.z = sector[othersect].ceilingz;
if (TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH))
if (TEST_SYNC_KEY(g_player[p].inputBits->bits, SK_CROUCH))
ps->vel.z += 512;
return 1;
@ -3390,13 +3429,13 @@ ACTOR_STATIC void G_MoveTransports(void)
else if (!(sectlotag == ST_1_ABOVE_WATER && ps->on_ground == 1)) break;
if (onfloorz == 0 && klabs(SZ(i)-ps->pos.z) < 6144)
if (!ps->jetpack_on || TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP) ||
TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH))
if (!ps->jetpack_on || TEST_SYNC_KEY(g_player[p].inputBits->bits, SK_JUMP) ||
TEST_SYNC_KEY(g_player[p].inputBits->bits, SK_CROUCH))
{
ps->bobpos.x = ps->opos.x = ps->pos.x += sprite[OW(i)].x-SX(i);
ps->bobpos.y = ps->opos.y = ps->pos.y += sprite[OW(i)].y-SY(i);
if (ps->jetpack_on && (TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP) || ps->jetpack_on < 11))
if (ps->jetpack_on && (TEST_SYNC_KEY(g_player[p].inputBits->bits, SK_JUMP) || ps->jetpack_on < 11))
ps->pos.z = sprite[OW(i)].z-6144;
else ps->pos.z = sprite[OW(i)].z+6144;
ps->opos.z = ps->pos.z;
@ -3773,7 +3812,7 @@ ACTOR_STATIC void G_MoveActors(void)
{
j = G_GetAngleDelta(ps->ang,getangle(pSprite->x-ps->pos.x,pSprite->y-ps->pos.y));
if (j > -64 && j < 64 && TEST_SYNC_KEY(g_player[p].sync->bits, SK_OPEN))
if (j > -64 && j < 64 && TEST_SYNC_KEY(g_player[p].inputBits->bits, SK_OPEN))
if (ps->toggle_key_flag == 1)
{
int32_t a;
@ -4181,7 +4220,7 @@ ACTOR_STATIC void G_MoveActors(void)
pSprite->ang = pPlayer->ang;
if ((TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_FIRE) || (pPlayer->quick_kick > 0)) && sprite[pPlayer->i].extra > 0)
if ((TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_FIRE) || (pPlayer->quick_kick > 0)) && sprite[pPlayer->i].extra > 0)
if (pPlayer->quick_kick > 0 ||
(PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) != HANDREMOTE_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) != HANDBOMB_WEAPON &&
PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) != TRIPBOMB_WEAPON && pPlayer->ammo_amount[pPlayer->curr_weapon] >= 0))
@ -4672,7 +4711,7 @@ DETONATEB:
pPlayer->weaprecs[pPlayer->weapreccnt++] = pSprite->picnum;
}
P_AddAmmo(HANDBOMB_WEAPON,pPlayer,1);
P_AddAmmo(pPlayer,HANDBOMB_WEAPON,1);
A_PlaySound(DUKE_GET,pPlayer->i);
if ((pPlayer->gotweapon & (1<<HANDBOMB_WEAPON)) == 0 || pSprite->owner == pPlayer->i)
@ -4838,7 +4877,7 @@ DETONATEB:
{
if (A_IncurDamage(spriteNum) >= 0)
{
pData[0] = 1; // static
pData[0] = 1; // static
pSprite->cstat = 32768;
for (x=0; x<5; x++) RANDOMSCRAP(pSprite, spriteNum);
goto next_sprite;
@ -4884,6 +4923,7 @@ DETONATEB:
A_Execute(spriteNum,p,x);
}
next_sprite:
A_MaybeAwakenBadGuys(spriteNum);
spriteNum = nextSprite;
}
}
@ -4921,93 +4961,90 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
actor[spriteNum].floorz = pSprite->z = getflorzofslope(pSprite->sectnum,pSprite->x,pSprite->y);
else switch (DYNAMICTILEMAP(switchPic))
{
case APLAYER__STATIC:
pSprite->cstat = 32768;
goto next_sprite;
case NEON1__STATIC:
case NEON2__STATIC:
case NEON3__STATIC:
case NEON4__STATIC:
case NEON5__STATIC:
case NEON6__STATIC:
case APLAYER__STATIC: pSprite->cstat = 32768; goto next_sprite;
case NEON1__STATIC:
case NEON2__STATIC:
case NEON3__STATIC:
case NEON4__STATIC:
case NEON5__STATIC:
case NEON6__STATIC:
pSprite->shade = ((tabledivide32_noinline(g_globalRandom, pSprite->lotag + 1) & 31) > 4) ? -127 : 127;
goto next_sprite;
if ((tabledivide32_noinline(g_globalRandom, pSprite->lotag+1)&31) > 4)
pSprite->shade = -127;
else pSprite->shade = 127;
goto next_sprite;
case BLOODSPLAT1__STATIC:
case BLOODSPLAT2__STATIC:
case BLOODSPLAT3__STATIC:
case BLOODSPLAT4__STATIC:
if (pData[0] == 3 * GAMETICSPERSEC)
goto next_sprite;
case BLOODSPLAT1__STATIC:
case BLOODSPLAT2__STATIC:
case BLOODSPLAT3__STATIC:
case BLOODSPLAT4__STATIC:
actor[spriteNum].bpos.z -= pSprite->z;
if (pData[0] == 3*GAMETICSPERSEC) goto next_sprite;
actor[spriteNum].bpos.z -= pSprite->z;
pData[0]++;
if ((pData[0]%9) == 0)
{
pSprite->yrepeat++;
pSprite->z += (tilesiz[pSprite->picnum].y*pSprite->yrepeat)>>2;
}
else pSprite->z += 16 + (krand() & 15);
actor[spriteNum].bpos.z += pSprite->z;
goto next_sprite;
case NUKEBUTTON__STATIC:
// case NUKEBUTTON+1:
// case NUKEBUTTON+2:
// case NUKEBUTTON+3:
if (pData[0])
{
pData[0]++;
if (pData[0] == 8) pSprite->picnum = NUKEBUTTON+1;
else if (pData[0] == 16)
if ((++pData[0] % 9) == 0)
{
pSprite->picnum = NUKEBUTTON+2;
g_player[P_Get(pSprite->owner)].ps->fist_incs = 1;
pSprite->yrepeat++;
pSprite->z += (tilesiz[pSprite->picnum].y * pSprite->yrepeat) >> 2;
}
if (g_player[P_Get(pSprite->owner)].ps->fist_incs == GAMETICSPERSEC)
pSprite->picnum = NUKEBUTTON+3;
}
goto next_sprite;
else
pSprite->z += 16 + (krand() & 15);
case FORCESPHERE__STATIC:
{
l = pSprite->xrepeat;
if (pData[1] > 0)
{
pData[1]--;
if (pData[1] == 0)
KILLIT(spriteNum);
}
if (actor[pSprite->owner].t_data[1] == 0)
{
if (pData[0] < 64)
actor[spriteNum].bpos.z += pSprite->z;
goto next_sprite;
case NUKEBUTTON__STATIC:
// case NUKEBUTTON+1:
// case NUKEBUTTON+2:
// case NUKEBUTTON+3:
if (pData[0])
{
pData[0]++;
l += 3;
if (pData[0] == 8)
pSprite->picnum = NUKEBUTTON + 1;
else if (pData[0] == 16)
{
pSprite->picnum = NUKEBUTTON + 2;
g_player[P_Get(pSprite->owner)].ps->fist_incs = 1;
}
if (g_player[P_Get(pSprite->owner)].ps->fist_incs == GAMETICSPERSEC)
pSprite->picnum = NUKEBUTTON + 3;
}
}
else if (pData[0] > 64)
goto next_sprite;
case FORCESPHERE__STATIC:
{
pData[0]--;
l -= 3;
}
l = pSprite->xrepeat;
if (pData[1] > 0)
{
pData[1]--;
if (pData[1] == 0)
KILLIT(spriteNum);
}
if (actor[pSprite->owner].t_data[1] == 0)
{
if (pData[0] < 64)
{
pData[0]++;
l += 3;
}
}
else if (pData[0] > 64)
{
pData[0]--;
l -= 3;
}
*(vec3_t *) pSprite = *(vec3_t *) &sprite[pSprite->owner];
pSprite->ang += actor[pSprite->owner].t_data[0];
*(vec3_t *)pSprite = *(vec3_t *)&sprite[pSprite->owner];
pSprite->ang += actor[pSprite->owner].t_data[0];
if (l > 64) l = 64;
else if (l < 1) l = 1;
l = clamp2(l, 1, 64);
pSprite->xrepeat = l;
pSprite->yrepeat = l;
pSprite->shade = (l>>1)-48;
pSprite->xrepeat = l;
pSprite->yrepeat = l;
pSprite->shade = (l >> 1) - 48;
for (int j = pData[0]; j > 0; j--)
A_SetSprite(spriteNum, CLIPMASK0);
goto next_sprite;
for (int j = pData[0]; j > 0; j--) A_SetSprite(spriteNum, CLIPMASK0);
goto next_sprite;
}
case WATERSPLASH2__STATIC:

View file

@ -261,7 +261,8 @@ enum sflags_t
SFLAG_NOWATERDIP = 0x00200000,
SFLAG_HURTSPAWNBLOOD = 0x00400000,
SFLAG_GREENSLIMEFOOD = 0x00800000,
SFLAG_REALCLIPDIST = 0x01000000
SFLAG_REALCLIPDIST = 0x01000000,
SFLAG_WAKEUPBADGUYS = 0x02000000
};
// Custom projectiles "workslike" flags.

View file

@ -310,7 +310,7 @@ void G_DoCheats(void)
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
{
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
P_AddAmmo(g_player[myconnectindex].ps, weapon, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
}
@ -402,7 +402,7 @@ void G_DoCheats(void)
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++)
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
P_AddAmmo(g_player[myconnectindex].ps, weapon, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
g_player[myconnectindex].ps->got_access = 7;
}
@ -435,7 +435,7 @@ void G_DoCheats(void)
g_player[myconnectindex].ps->gotweapon |= (1<<weapon);
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++)
P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
P_AddAmmo(g_player[myconnectindex].ps, weapon, g_player[myconnectindex].ps->max_ammo_amount[weapon]);
G_CheatGetInv();
g_player[myconnectindex].ps->got_access = 7;

View file

@ -293,7 +293,7 @@ void G_DemoRecord(void)
for (TRAVERSE_CONNECT(i))
{
Bmemcpy(&recsync[ud.reccnt], g_player[i].sync, sizeof(input_t));
Bmemcpy(&recsync[ud.reccnt], g_player[i].inputBits, sizeof(input_t));
ud.reccnt++;
}

View file

@ -150,21 +150,21 @@ EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES);
# include "lunatic_game.h"
#endif
static inline int32_t G_HaveActor(int32_t actortile)
static inline int32_t G_HaveActor(int spriteNum)
{
#ifdef LUNATIC
return El_HaveActor(actortile);
return El_HaveActor(spriteNum);
#else
return g_tile[actortile].execPtr!=NULL;
return g_tile[spriteNum].execPtr!=NULL;
#endif
}
static inline int32_t G_InitialActorStrength(int32_t actortile)
static inline int32_t G_DefaultActorHealth(int spriteNum)
{
#ifdef LUNATIC
return g_elActors[actortile].strength;
return g_elActors[spriteNum].strength;
#else
return G_HaveActor(actortile) ? g_tile[actortile].execPtr[0] : 0;
return G_HaveActor(spriteNum) ? g_tile[spriteNum].execPtr[0] : 0;
#endif
}

View file

@ -3476,7 +3476,7 @@ static inline void G_DoEventAnimSprites(int32_t j)
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothratio)
{
int32_t j, k, p;
int32_t j, k, playerNum;
intptr_t l;
if (spritesortcnt == 0)
@ -3614,15 +3614,15 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
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).
uspritetype *const s = (i < 0) ? &tsprite[j] : (uspritetype *)&sprite[i];
uspritetype *const pSprite = (i < 0) ? &tsprite[j] : (uspritetype *)&sprite[i];
if (ud.lockout && G_CheckAdultTile(DYNAMICTILEMAP(s->picnum)))
if (ud.lockout && G_CheckAdultTile(DYNAMICTILEMAP(pSprite->picnum)))
{
t->xrepeat = t->yrepeat = 0;
continue;
}
if (s->picnum == NATURALLIGHTNING)
if (pSprite->picnum == NATURALLIGHTNING)
{
t->shade = -127;
t->cstat |= 8192;
@ -3633,7 +3633,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
Bassert(i >= 0);
const DukePlayer_t *const ps = (s->statnum != STAT_ACTOR && s->picnum == APLAYER && s->owner >= 0) ? g_player[P_GetP((const spritetype *)s)].ps : NULL;
const DukePlayer_t *const ps = (pSprite->statnum != STAT_ACTOR && pSprite->picnum == APLAYER && pSprite->owner >= 0) ? g_player[P_GetP(pSprite)].ps : NULL;
if (ps && ps->newowner == -1)
{
t->x -= mulscale16(65536-smoothratio,ps->pos.x-ps->opos.x);
@ -3643,15 +3643,15 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
t->z += mulscale16(smoothratio,ps->pos.z-ps->opos.z) -
(ps->dead_flag ? 0 : PHEIGHT) + PHEIGHT;
}
else if ((s->statnum == STAT_DEFAULT && s->picnum != CRANEPOLE) || s->statnum == STAT_PLAYER ||
s->statnum == STAT_STANDABLE || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC || s->statnum == STAT_ACTOR)
else if ((pSprite->statnum == STAT_DEFAULT && pSprite->picnum != CRANEPOLE) || pSprite->statnum == STAT_PLAYER ||
pSprite->statnum == STAT_STANDABLE || pSprite->statnum == STAT_PROJECTILE || pSprite->statnum == STAT_MISC || pSprite->statnum == STAT_ACTOR)
{
t->x -= mulscale16(65536-smoothratio,s->x-actor[i].bpos.x);
t->y -= mulscale16(65536-smoothratio,s->y-actor[i].bpos.y);
t->z -= mulscale16(65536-smoothratio,s->z-actor[i].bpos.z);
t->x -= mulscale16(65536-smoothratio,pSprite->x-actor[i].bpos.x);
t->y -= mulscale16(65536-smoothratio,pSprite->y-actor[i].bpos.y);
t->z -= mulscale16(65536-smoothratio,pSprite->z-actor[i].bpos.z);
}
const int32_t sect = s->sectnum;
const int32_t sect = pSprite->sectnum;
curframe = AC_CURFRAME(actor[i].t_data);
#if !defined LUNATIC
@ -3660,12 +3660,12 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
startframe = actor[i].ac.startframe;
viewtype = actor[i].ac.viewtype;
#endif
switchpic = s->picnum;
switchpic = pSprite->picnum;
// Some special cases because dynamictostatic system can't handle
// addition to constants.
if ((s->picnum >= SCRAP6) && (s->picnum<=SCRAP6+7))
if ((pSprite->picnum >= SCRAP6) && (pSprite->picnum<=SCRAP6+7))
switchpic = SCRAP5;
else if ((s->picnum==MONEY+1) || (s->picnum==MAIL+1) || (s->picnum==PAPER+1))
else if ((pSprite->picnum==MONEY+1) || (pSprite->picnum==MAIL+1) || (pSprite->picnum==PAPER+1))
switchpic--;
switch (DYNAMICTILEMAP(switchpic))
@ -3687,7 +3687,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
//case MAIL+1__STATIC:
case PAPER__STATIC:
//case PAPER+1__STATIC:
if (ud.lockout && s->pal == 2)
if (ud.lockout && pSprite->pal == 2)
{
t->xrepeat = t->yrepeat = 0;
continue;
@ -3698,35 +3698,28 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
case FORCESPHERE__STATIC:
if (t->statnum == STAT_MISC)
{
int16_t sqa,sqb;
sqa =
getangle(
sprite[s->owner].x-g_player[screenpeek].ps->pos.x,
sprite[s->owner].y-g_player[screenpeek].ps->pos.y);
sqb =
getangle(
sprite[s->owner].x-t->x,
sprite[s->owner].y-t->y);
int16_t const sqa = getangle(sprite[pSprite->owner].x - g_player[screenpeek].ps->pos.x,
sprite[pSprite->owner].y - g_player[screenpeek].ps->pos.y);
int16_t const sqb = getangle(sprite[pSprite->owner].x - t->x, sprite[pSprite->owner].y - t->y);
if (klabs(G_GetAngleDelta(sqa,sqb)) > 512)
if (ldist(&sprite[s->owner],(const spritetype *)t) < ldist(&sprite[g_player[screenpeek].ps->i],&sprite[s->owner]))
if (ldist(&sprite[pSprite->owner],(const spritetype *)t) < ldist(&sprite[g_player[screenpeek].ps->i],&sprite[pSprite->owner]))
t->xrepeat = t->yrepeat = 0;
}
continue;
case BURNING__STATIC:
case BURNING2__STATIC:
if (sprite[s->owner].statnum == STAT_PLAYER)
if (sprite[pSprite->owner].statnum == STAT_PLAYER)
{
const int32_t snum = P_Get(s->owner);
int const playerNum = P_Get(pSprite->owner);
if (display_mirror == 0 && snum == screenpeek && g_player[snum].ps->over_shoulder_on == 0)
if (display_mirror == 0 && playerNum == screenpeek && g_player[playerNum].ps->over_shoulder_on == 0)
t->xrepeat = 0;
else
{
t->ang = getangle(ourx-t->x, oury-t->y);
t->x = sprite[s->owner].x + (sintable[(t->ang+512)&2047]>>10);
t->y = sprite[s->owner].y + (sintable[t->ang&2047]>>10);
t->ang = getangle(ourx - t->x, oury - t->y);
t->x = sprite[pSprite->owner].x + (sintable[(t->ang + 512) & 2047] >> 10);
t->y = sprite[pSprite->owner].y + (sintable[t->ang & 2047] >> 10);
}
}
break;
@ -3740,8 +3733,8 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
case VIEWSCREEN__STATIC:
case VIEWSCREEN2__STATIC:
{
const int viewscrShift = G_GetViewscreenSizeShift(t);
const int viewscrTile = TILE_VIEWSCR-viewscrShift;
int const viewscrShift = G_GetViewscreenSizeShift(t);
int const viewscrTile = TILE_VIEWSCR-viewscrShift;
if (g_curViewscreen >= 0 && actor[OW(i)].t_data[0] == 1)
{
@ -3794,7 +3787,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
break;
}
#endif
k = getofs_viewtype7(s, t, getangle(s->x-ourx, s->y-oury), 0);
k = getofs_viewtype7(pSprite, t, getangle(pSprite->x-ourx, pSprite->y-oury), 0);
t->picnum = RPG+k;
break;
@ -3806,7 +3799,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
break;
}
#endif
k = getofs_viewtype7(s, t, getangle(s->x-ourx, s->y-oury), 0);
k = getofs_viewtype7(pSprite, t, getangle(pSprite->x-ourx, pSprite->y-oury), 0);
// RECON_T4
if (klabs(curframe) > 64)
@ -3817,31 +3810,31 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
break;
case APLAYER__STATIC:
p = P_GetP((const spritetype *)s);
playerNum = P_GetP(pSprite);
if (t->pal == 1) t->z -= (18<<8);
if (g_player[p].ps->over_shoulder_on > 0 && g_player[p].ps->newowner < 0)
if (g_player[playerNum].ps->over_shoulder_on > 0 && g_player[playerNum].ps->newowner < 0)
{
t->ang = g_player[p].ps->ang +
mulscale16((((g_player[p].ps->ang+1024 - g_player[p].ps->oang)&2047)-1024),
t->ang = g_player[playerNum].ps->ang +
mulscale16((((g_player[playerNum].ps->ang+1024 - g_player[playerNum].ps->oang)&2047)-1024),
smoothratio);
#ifdef USE_OPENGL
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
static int32_t targetang = 0;
if (g_player[p].sync->extbits&(1<<1))
if (g_player[playerNum].inputBits->extbits&(1<<1))
{
if (g_player[p].sync->extbits&(1<<2))targetang += 16;
else if (g_player[p].sync->extbits&(1<<3)) targetang -= 16;
if (g_player[playerNum].inputBits->extbits&(1<<2))targetang += 16;
else if (g_player[playerNum].inputBits->extbits&(1<<3)) targetang -= 16;
else if (targetang > 0) targetang -= targetang>>2;
else if (targetang < 0) targetang += (-targetang)>>2;
}
else
{
if (g_player[p].sync->extbits&(1<<2))targetang -= 16;
else if (g_player[p].sync->extbits&(1<<3)) targetang += 16;
if (g_player[playerNum].inputBits->extbits&(1<<2))targetang -= 16;
else if (g_player[playerNum].inputBits->extbits&(1<<3)) targetang += 16;
else if (targetang > 0) targetang -= targetang>>2;
else if (targetang < 0) targetang += (-targetang)>>2;
}
@ -3854,13 +3847,13 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
t->cstat |= 2;
}
if ((g_netServer || ud.multimode > 1) && (display_mirror || screenpeek != p || s->owner == -1))
if ((g_netServer || ud.multimode > 1) && (display_mirror || screenpeek != playerNum || pSprite->owner == -1))
{
if (ud.showweapons && sprite[g_player[p].ps->i].extra > 0 && g_player[p].ps->curr_weapon > 0
if (ud.showweapons && sprite[g_player[playerNum].ps->i].extra > 0 && g_player[playerNum].ps->curr_weapon > 0
&& spritesortcnt < MAXSPRITESONSCREEN)
{
uspritetype *const newt = &tsprite[spritesortcnt];
int32_t curweap = g_player[p].ps->curr_weapon;
int32_t curweap = g_player[playerNum].ps->curr_weapon;
Bmemcpy(newt, t, sizeof(spritetype));
@ -3874,10 +3867,10 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
newt->picnum = (curweap==GROW_WEAPON ? GROWSPRITEICON : WeaponPickupSprites[curweap]);
if (s->owner >= 0)
newt->z = g_player[p].ps->pos.z-ZOFFSET4;
if (pSprite->owner >= 0)
newt->z = g_player[playerNum].ps->pos.z-ZOFFSET4;
else
newt->z = s->z-(51<<8);
newt->z = pSprite->z-(51<<8);
if (newt->picnum == HEAVYHBOMB)
newt->xrepeat = newt->yrepeat = 10;
@ -3887,63 +3880,61 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
spritesortcnt++;
}
if (g_player[p].sync->extbits & (1<<7) && !ud.pause_on && spritesortcnt<MAXSPRITESONSCREEN)
if (g_player[playerNum].inputBits->extbits & (1<<7) && !ud.pause_on && spritesortcnt<MAXSPRITESONSCREEN)
{
uspritetype *const newt = &tsprite[spritesortcnt];
uspritetype *const tSpawned = t;
Bmemcpy(newt, t, sizeof(spritetype));
tSpawned->statnum = TSPR_TEMP;
tSpawned->yrepeat = (t->yrepeat >> 3);
newt->statnum = TSPR_TEMP;
if (tSpawned->yrepeat < 4)
tSpawned->yrepeat = 4;
newt->yrepeat = (t->yrepeat>>3);
if (newt->yrepeat < 4) newt->yrepeat = 4;
tSpawned->cstat = 0;
tSpawned->picnum = RESPAWNMARKERGREEN;
newt->cstat = 0;
newt->picnum = RESPAWNMARKERGREEN;
tSpawned->z = (pSprite->owner >= 0)
? g_player[playerNum].ps->pos.z - (20 << 8)
: tSpawned->z = pSprite->z - (96 << 8);
if (s->owner >= 0)
newt->z = g_player[p].ps->pos.z-(20<<8);
else
newt->z = s->z-(96<<8);
newt->xrepeat = newt->yrepeat = 32;
newt->pal = 20;
tSpawned->xrepeat = tSpawned->yrepeat = 32;
tSpawned->pal = 20;
spritesortcnt++;
}
}
if (s->owner == -1)
if (pSprite->owner == -1)
{
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
}
else
#endif
k = getofs_viewtype5(s, t, oura, 0);
k = getofs_viewtype5(pSprite, t, oura, 0);
if (sector[s->sectnum].lotag == ST_2_UNDERWATER) k += 1795-1405;
else if ((actor[i].floorz-s->z) > (64<<8)) k += 60;
if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER) k += 1795-1405;
else if ((actor[i].floorz-pSprite->z) > (64<<8)) k += 60;
t->picnum += k;
t->pal = g_player[p].ps->palookup;
t->pal = g_player[playerNum].ps->palookup;
goto PALONLY;
}
if (g_player[p].ps->on_crane == -1 && (sector[s->sectnum].lotag&0x7ff) != 1) // ST_1_ABOVE_WATER ?
if (g_player[playerNum].ps->on_crane == -1 && (sector[pSprite->sectnum].lotag&0x7ff) != 1) // ST_1_ABOVE_WATER ?
{
l = s->z-actor[g_player[p].ps->i].floorz+(3<<8);
l = pSprite->z-actor[g_player[playerNum].ps->i].floorz+(3<<8);
// SET_SPRITE_NOT_TSPRITE
if (l > 1024 && s->yrepeat > 32 && s->extra > 0)
s->yoffset = (int8_t)tabledivide32_noinline(l, s->yrepeat<<2);
else s->yoffset=0;
if (l > 1024 && pSprite->yrepeat > 32 && pSprite->extra > 0)
pSprite->yoffset = (int8_t)tabledivide32_noinline(l, pSprite->yrepeat<<2);
else pSprite->yoffset=0;
}
if (g_player[p].ps->newowner > -1)
if (g_player[playerNum].ps->newowner > -1)
{
// Display APLAYER sprites with action PSTAND when viewed through
// a camera. Not implemented for Lunatic.
@ -3956,9 +3947,11 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
curframe = 0;
}
if (ud.camerasprite == -1 && g_player[p].ps->newowner == -1)
if (s->owner >= 0 && display_mirror == 0 && g_player[p].ps->over_shoulder_on == 0)
if ((!g_netServer && ud.multimode < 2) || ((g_netServer || ud.multimode > 1) && p == screenpeek))
if (ud.camerasprite == -1 && g_player[playerNum].ps->newowner == -1)
{
if (pSprite->owner >= 0 && display_mirror == 0 && g_player[playerNum].ps->over_shoulder_on == 0)
{
if ((!g_netServer && ud.multimode < 2) || ((g_netServer || ud.multimode > 1) && playerNum == screenpeek))
{
if (getrendermode() == REND_POLYMER)
t->cstat |= 16384;
@ -3970,25 +3963,27 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
}
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
}
else
#endif
k = getofs_viewtype5(s, t, oura, 0);
k = getofs_viewtype5(pSprite, t, oura, 0);
if (sector[t->sectnum].lotag == ST_2_UNDERWATER) k += 1795-1405;
else if ((actor[i].floorz-s->z) > (64<<8)) k += 60;
else if ((actor[i].floorz-pSprite->z) > (64<<8)) k += 60;
t->picnum += k;
t->pal = g_player[p].ps->palookup;
t->pal = g_player[playerNum].ps->palookup;
}
}
}
PALONLY:
G_MaybeTakeOnFloorPal(t, sect);
if (s->owner == -1) continue;
if (pSprite->owner == -1) continue;
if (t->z > actor[i].floorz && t->xrepeat < 32)
t->z = actor[i].floorz;
@ -4023,8 +4018,8 @@ PALONLY:
case SCRAP3__STATIC:
case SCRAP4__STATIC:
case SCRAP5__STATIC:
if (actor[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0)
t->picnum = s->yvel < MAXUSERTILES ? s->yvel : 0;
if (actor[i].picnum == BLIMP && t->picnum == SCRAP1 && pSprite->yvel >= 0)
t->picnum = pSprite->yvel < MAXUSERTILES ? pSprite->yvel : 0;
else t->picnum += T1(i);
t->shade -= 6;
@ -4042,7 +4037,7 @@ PALONLY:
break;
}
if (G_HaveActor(s->picnum))
if (G_HaveActor(pSprite->picnum))
{
#if !defined LUNATIC
if ((unsigned)scrofs_action + 2 >= (unsigned)g_scriptSize)
@ -4054,7 +4049,7 @@ PALONLY:
#endif
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
@ -4064,12 +4059,12 @@ PALONLY:
switch (l)
{
case 2:
k = (((s->ang+3072+128-oura)&2047)>>8)&1;
k = (((pSprite->ang+3072+128-oura)&2047)>>8)&1;
break;
case 3:
case 4:
k = (((s->ang+3072+128-oura)&2047)>>7)&7;
k = (((pSprite->ang+3072+128-oura)&2047)>>7)&7;
if (k > 3)
{
t->cstat |= 4;
@ -4080,18 +4075,18 @@ PALONLY:
case 5:
case -5:
k = getofs_viewtype5(s, t, getangle(s->x-ourx, s->y-oury), l<0);
k = getofs_viewtype5(pSprite, t, getangle(pSprite->x-ourx, pSprite->y-oury), l<0);
break;
case 7:
case -7:
k = getofs_viewtype7(s, t, getangle(s->x-ourx, s->y-oury), l<0);
k = getofs_viewtype7(pSprite, t, getangle(pSprite->x-ourx, pSprite->y-oury), l<0);
break;
case 8:
case -8:
if (l > 0)
k = (((s->ang+3072+128-oura)&2047)>>8)&7;
k = (((pSprite->ang+3072+128-oura)&2047)>>8)&7;
else
k = (((oura+3072+128-s->ang)&2047)>>8)&7;
k = (((oura+3072+128-pSprite->ang)&2047)>>8)&7;
t->cstat &= ~4;
break;
default:
@ -4128,15 +4123,15 @@ 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(pSprite) || A_CheckSpriteFlags(t->owner,SFLAG_NVG) || pSprite->picnum == APLAYER || pSprite->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 (t->statnum != TSPR_TEMP && s->picnum != EXPLOSION2 && s->picnum != HANGLIGHT && s->picnum != DOMELITE && s->picnum != HOTMEAT)
if (pSprite->statnum == STAT_DUMMYPLAYER || A_CheckEnemySprite(pSprite) || A_CheckSpriteFlags(t->owner,SFLAG_SHADOW) || (pSprite->picnum == APLAYER && pSprite->owner >= 0))
if (t->statnum != TSPR_TEMP && pSprite->picnum != EXPLOSION2 && pSprite->picnum != HANGLIGHT && pSprite->picnum != DOMELITE && pSprite->picnum != HOTMEAT)
{
if (actor[i].dispicnum < 0)
{
@ -4154,15 +4149,12 @@ skip:
if (ud.shadows && spritesortcnt < (MAXSPRITESONSCREEN-2) && getrendermode() != REND_POLYMER)
{
int32_t daz;
int32_t daz = ((sector[sect].lotag & 0xff) > 2 || pSprite->statnum == STAT_PROJECTILE ||
pSprite->statnum == STAT_MISC || pSprite->picnum == DRONE || pSprite->picnum == COMMANDER)
? sector[sect].floorz
: daz = actor[i].floorz;
if ((sector[sect].lotag&0xff) > 2 || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC
|| s->picnum == DRONE || s->picnum == COMMANDER)
daz = sector[sect].floorz;
else
daz = actor[i].floorz;
if ((s->z-daz) < ZOFFSET3 && g_player[screenpeek].ps->pos.z < daz)
if ((pSprite->z-daz) < ZOFFSET3 && g_player[screenpeek].ps->pos.z < daz)
{
uspritetype *const newt = &tsprite[spritesortcnt];
@ -4206,11 +4198,11 @@ skip:
}
}
switch (DYNAMICTILEMAP(s->picnum))
switch (DYNAMICTILEMAP(pSprite->picnum))
{
case LASERLINE__STATIC:
if (sector[t->sectnum].lotag == ST_2_UNDERWATER) t->pal = 8;
t->z = sprite[s->owner].z-(3<<8);
t->z = sprite[pSprite->owner].z-(3<<8);
if (g_tripbombLaserMode == 2 && g_player[screenpeek].ps->heat_on == 0)
t->yrepeat = 0;
case EXPLOSION2__STATIC:
@ -4237,7 +4229,7 @@ skip:
t->cstat |= 128;
case BURNING__STATIC:
case BURNING2__STATIC:
if (sprite[s->owner].picnum != TREE1 && sprite[s->owner].picnum != TREE2)
if (sprite[pSprite->owner].picnum != TREE1 && sprite[pSprite->owner].picnum != TREE2)
t->z = actor[t->owner].floorz;
t->shade = -127;
case SMALLSMOKE__STATIC:
@ -4246,11 +4238,11 @@ skip:
case COOLEXPLOSION1__STATIC:
t->shade = -127;
t->cstat |= 8192+1024;
t->picnum += (s->shade>>1);
t->picnum += (pSprite->shade>>1);
break;
case PLAYERONWATER__STATIC:
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,pSprite->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
@ -4259,8 +4251,8 @@ skip:
#endif
k = getofs_viewtype5(t, t, oura, 0);
t->picnum = s->picnum+k+((T1(i)<4)*5);
t->shade = sprite[s->owner].shade;
t->picnum = pSprite->picnum+k+((T1(i)<4)*5);
t->shade = sprite[pSprite->owner].shade;
break;
@ -4269,7 +4261,7 @@ skip:
t->picnum = WATERSPLASH2+T2(i);
break;
case SHELL__STATIC:
t->picnum = s->picnum+(T1(i)&1);
t->picnum = pSprite->picnum+(T1(i)&1);
case SHOTGUNSHELL__STATIC:
t->cstat |= 12;
if (T1(i) > 2) t->cstat &= ~16;
@ -4278,27 +4270,27 @@ skip:
case FRAMEEFFECT1_13__STATIC:
if (PLUTOPAK) break;
case FRAMEEFFECT1__STATIC:
if (s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS)
if (pSprite->owner >= 0 && sprite[pSprite->owner].statnum < MAXSTATUS)
{
if (sprite[s->owner].picnum == APLAYER)
if (sprite[pSprite->owner].picnum == APLAYER)
if (ud.camerasprite == -1)
if (screenpeek == P_Get(s->owner) && display_mirror == 0)
if (screenpeek == P_Get(pSprite->owner) && display_mirror == 0)
{
t->owner = -1;
break;
}
if ((sprite[s->owner].cstat&32768) == 0)
if ((sprite[pSprite->owner].cstat&32768) == 0)
{
if (!actor[s->owner].dispicnum)
if (!actor[pSprite->owner].dispicnum)
t->picnum = actor[i].t_data[1];
else t->picnum = actor[s->owner].dispicnum;
else t->picnum = actor[pSprite->owner].dispicnum;
if (!G_MaybeTakeOnFloorPal(t, sect))
t->pal = sprite[s->owner].pal;
t->pal = sprite[pSprite->owner].pal;
t->shade = sprite[s->owner].shade;
t->ang = sprite[s->owner].ang;
t->cstat = 2|sprite[s->owner].cstat;
t->shade = sprite[pSprite->owner].shade;
t->ang = sprite[pSprite->owner].ang;
t->cstat = 2|sprite[pSprite->owner].cstat;
}
}
break;
@ -4306,14 +4298,14 @@ skip:
case CAMERA1__STATIC:
case RAT__STATIC:
#ifdef USE_OPENGL
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,pSprite->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
t->cstat &= ~4;
break;
}
#endif
k = getofs_viewtype5(t, t, oura, 0);
t->picnum = s->picnum+k;
t->picnum = pSprite->picnum+k;
break;
}
@ -5463,7 +5455,7 @@ static void G_Cleanup(void)
for (i=MAXPLAYERS-1; i>=0; i--)
{
Bfree(g_player[i].ps);
Bfree(g_player[i].sync);
Bfree(g_player[i].inputBits);
}
for (i=MAXSOUNDS-1; i>=0; i--)
@ -6028,8 +6020,8 @@ void G_MaybeAllocPlayer(int32_t pnum)
{
if (g_player[pnum].ps == NULL)
g_player[pnum].ps = (DukePlayer_t *)Xcalloc(1, sizeof(DukePlayer_t));
if (g_player[pnum].sync == NULL)
g_player[pnum].sync = (input_t *)Xcalloc(1, sizeof(input_t));
if (g_player[pnum].inputBits == NULL)
g_player[pnum].inputBits = (input_t *)Xcalloc(1, sizeof(input_t));
#ifdef LUNATIC
g_player_ps[pnum] = g_player[pnum].ps;
@ -6602,12 +6594,12 @@ MAIN_LOOP_RESTART:
P_GetInput(myconnectindex);
}
avg.fvel += loc.fvel;
avg.svel += loc.svel;
avg.avel += loc.avel;
avg.horz += loc.horz;
avg.bits |= loc.bits;
avg.extbits |= loc.extbits;
avg.fvel += localInput.fvel;
avg.svel += localInput.svel;
avg.avel += localInput.avel;
avg.horz += localInput.horz;
avg.bits |= localInput.bits;
avg.extbits |= localInput.extbits;
Bmemcpy(&inputfifo[0][myconnectindex], &avg, sizeof(input_t));
Bmemset(&avg, 0, sizeof(input_t));
@ -6794,7 +6786,7 @@ int32_t G_DoMoveThings(void)
randomseed = ticrandomseed;
for (TRAVERSE_CONNECT(i))
Bmemcpy(g_player[i].sync, &inputfifo[(g_netServer && myconnectindex == i)][i],
Bmemcpy(g_player[i].inputBits, &inputfifo[(g_netServer && myconnectindex == i)][i],
sizeof(input_t));
G_UpdateInterpolations();
@ -6830,7 +6822,7 @@ int32_t G_DoMoveThings(void)
for (TRAVERSE_CONNECT(i))
{
if (g_player[i].sync->extbits&(1<<6))
if (g_player[i].inputBits->extbits&(1<<6))
{
g_player[i].ps->team = g_player[i].pteam;
if (GametypeFlags[ud.coop] & GAMETYPE_TDM)

View file

@ -387,86 +387,86 @@ static inline int32_t calc_smoothratio(int32_t totalclk, int32_t ototalclk)
}
// sector effector lotags
enum {
SE_0_ROTATING_SECTOR = 0,
SE_1_PIVOT = 1,
SE_2_EARTHQUAKE = 2,
enum
{
SE_0_ROTATING_SECTOR = 0,
SE_1_PIVOT = 1,
SE_2_EARTHQUAKE = 2,
SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT = 3,
SE_4_RANDOM_LIGHTS = 4,
SE_5 = 5,
SE_6_SUBWAY = 6,
SE_4_RANDOM_LIGHTS = 4,
SE_5 = 5,
SE_6_SUBWAY = 6,
// ^^ potentially incomplete substitution in code
// vv almost surely complete substitution
SE_7_TELEPORT = 7,
SE_8_UP_OPEN_DOOR_LIGHTS = 8,
SE_9_DOWN_OPEN_DOOR_LIGHTS = 9,
SE_10_DOOR_AUTO_CLOSE = 10,
SE_11_SWINGING_DOOR = 11,
SE_12_LIGHT_SWITCH = 12,
SE_13_EXPLOSIVE = 13,
SE_14_SUBWAY_CAR = 14,
SE_15_SLIDING_DOOR = 15,
SE_16_REACTOR = 16,
SE_17_WARP_ELEVATOR = 17,
SE_7_TELEPORT = 7,
SE_8_UP_OPEN_DOOR_LIGHTS = 8,
SE_9_DOWN_OPEN_DOOR_LIGHTS = 9,
SE_10_DOOR_AUTO_CLOSE = 10,
SE_11_SWINGING_DOOR = 11,
SE_12_LIGHT_SWITCH = 12,
SE_13_EXPLOSIVE = 13,
SE_14_SUBWAY_CAR = 14,
SE_15_SLIDING_DOOR = 15,
SE_16_REACTOR = 16,
SE_17_WARP_ELEVATOR = 17,
SE_18_INCREMENTAL_SECTOR_RISE_FALL = 18,
SE_19_EXPLOSION_LOWERS_CEILING = 19,
SE_20_STRETCH_BRIDGE = 20,
SE_21_DROP_FLOOR = 21,
SE_22_TEETH_DOOR = 22,
SE_23_ONE_WAY_TELEPORT = 23,
SE_24_CONVEYOR = 24,
SE_25_PISTON = 25,
SE_26 = 26,
SE_27_DEMO_CAM = 27,
SE_28_LIGHTNING = 28,
SE_29_WAVES = 29,
SE_30_TWO_WAY_TRAIN = 30,
SE_31_FLOOR_RISE_FALL = 31,
SE_32_CEILING_RISE_FALL = 32,
SE_33_QUAKE_DEBRIS = 33,
SE_34 = 34, // XXX
SE_35 = 35, // XXX
SE_36_PROJ_SHOOTER = 36,
SE_49_POINT_LIGHT = 49,
SE_50_SPOT_LIGHT = 50,
SE_130 = 130,
SE_131 = 131,
SE_19_EXPLOSION_LOWERS_CEILING = 19,
SE_20_STRETCH_BRIDGE = 20,
SE_21_DROP_FLOOR = 21,
SE_22_TEETH_DOOR = 22,
SE_23_ONE_WAY_TELEPORT = 23,
SE_24_CONVEYOR = 24,
SE_25_PISTON = 25,
SE_26 = 26,
SE_27_DEMO_CAM = 27,
SE_28_LIGHTNING = 28,
SE_29_WAVES = 29,
SE_30_TWO_WAY_TRAIN = 30,
SE_31_FLOOR_RISE_FALL = 31,
SE_32_CEILING_RISE_FALL = 32,
SE_33_QUAKE_DEBRIS = 33,
SE_34 = 34, // XXX
SE_35 = 35, // XXX
SE_36_PROJ_SHOOTER = 36,
SE_49_POINT_LIGHT = 49,
SE_50_SPOT_LIGHT = 50,
SE_130 = 130,
SE_131 = 131,
};
// sector lotags
enum {
enum
{
ST_0_NO_EFFECT = 0,
ST_1_ABOVE_WATER = 1,
ST_2_UNDERWATER = 2,
ST_3 = 3,
ST_2_UNDERWATER = 2,
ST_3 = 3,
// ^^^ maybe not complete substitution in code
ST_9_SLIDING_ST_DOOR = 9,
ST_15_WARP_ELEVATOR = 15,
ST_16_PLATFORM_DOWN = 16,
ST_17_PLATFORM_UP = 17,
ST_18_ELEVATOR_DOWN = 18,
ST_19_ELEVATOR_UP = 19,
ST_20_CEILING_DOOR = 20,
ST_21_FLOOR_DOOR = 21,
ST_22_SPLITTING_DOOR = 22,
ST_23_SWINGING_DOOR = 23,
ST_25_SLIDING_DOOR = 25,
ST_26_SPLITTING_ST_DOOR = 26,
ST_27_STRETCH_BRIDGE = 27,
ST_28_DROP_FLOOR = 28,
ST_29_TEETH_DOOR = 29,
ST_9_SLIDING_ST_DOOR = 9,
ST_15_WARP_ELEVATOR = 15,
ST_16_PLATFORM_DOWN = 16,
ST_17_PLATFORM_UP = 17,
ST_18_ELEVATOR_DOWN = 18,
ST_19_ELEVATOR_UP = 19,
ST_20_CEILING_DOOR = 20,
ST_21_FLOOR_DOOR = 21,
ST_22_SPLITTING_DOOR = 22,
ST_23_SWINGING_DOOR = 23,
ST_25_SLIDING_DOOR = 25,
ST_26_SPLITTING_ST_DOOR = 26,
ST_27_STRETCH_BRIDGE = 27,
ST_28_DROP_FLOOR = 28,
ST_29_TEETH_DOOR = 29,
ST_30_ROTATE_RISE_BRIDGE = 30,
ST_31_TWO_WAY_TRAIN = 31,
ST_31_TWO_WAY_TRAIN = 31,
// left: ST 32767, 65534, 65535
};
# define G_ModDirSnprintf(buf, size, basename, ...) \
( \
( \
(g_modDir[0] != '/') ? \
Bsnprintf(buf, size, "%s/" basename, g_modDir, ## __VA_ARGS__) : \
Bsnprintf(buf, size, basename, ## __VA_ARGS__) \
) >= ((int32_t)size)-1 \
#define G_ModDirSnprintf(buf, size, basename, ...) \
\
(((g_modDir[0] != '/') ? Bsnprintf(buf, size, "%s/" basename, g_modDir, ##__VA_ARGS__) \
: Bsnprintf(buf, size, basename, ##__VA_ARGS__)) >= ((int32_t)size) - 1\
)
static inline void G_NewGame_EnterLevel(void)
@ -477,14 +477,14 @@ static inline void G_NewGame_EnterLevel(void)
G_BackToMenu();
}
static inline int32_t G_GetMusicIdx(const char *str)
static inline int G_GetMusicIdx(const char *str)
{
int32_t lev, ep;
char b1, b2;
char b1, b2;
int32_t matches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
int numMatches = sscanf(str, "%c%d%c%d", &b1,&ep, &b2,&lev);
if (matches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
return -1;
if ((unsigned)--lev >= MAXLEVELS || (unsigned)--ep >= MAXVOLUMES)

View file

@ -878,7 +878,7 @@ void P_AddWeaponMaybeSwitchI(int32_t snum, int32_t weap)
#else
static void P_AddWeaponAmmoCommon(DukePlayer_t *pPlayer, int weaponNum, int nAmount)
{
P_AddAmmo(weaponNum, pPlayer, nAmount);
P_AddAmmo(pPlayer, weaponNum, nAmount);
if (PWEAPON(vm.playerNum, pPlayer->curr_weapon, WorksLike) == KNEE_WEAPON && (pPlayer->gotweapon & (1 << weaponNum)))
P_AddWeaponMaybeSwitch(pPlayer, weaponNum);
@ -3604,7 +3604,7 @@ nullquote:
int const moveFlags = *(++insptr);
int nResult = 0;
int const playerXVel = sprite[pPlayer->i].xvel;
int const syncBits = g_player[vm.playerNum].sync->bits;
int const syncBits = g_player[vm.playerNum].inputBits->bits;
if (((moveFlags & pducking) && pPlayer->on_ground && TEST_SYNC_KEY(syncBits, SK_CROUCH)) ||
((moveFlags & pfalling) && pPlayer->jumping_counter == 0 && !pPlayer->on_ground && pPlayer->vel.z > 2048) ||
@ -3700,7 +3700,7 @@ nullquote:
continue;
case CON_IFHITSPACE:
VM_CONDITIONAL(TEST_SYNC_KEY(g_player[vm.playerNum].sync->bits, SK_OPEN));
VM_CONDITIONAL(TEST_SYNC_KEY(g_player[vm.playerNum].inputBits->bits, SK_OPEN));
continue;
case CON_IFOUTSIDE:

View file

@ -775,7 +775,7 @@ int32_t __fastcall VM_GetPlayerInput(register int32_t const playerNum, register
return -1;
}
input_t * const i = g_player[playerNum].sync;
input_t * const i = g_player[playerNum].inputBits;
switch (labelNum)
{
@ -799,7 +799,7 @@ void __fastcall VM_SetPlayerInput(register int32_t const playerNum, register int
return;
}
input_t * const i = g_player[playerNum].sync;
input_t * const i = g_player[playerNum].inputBits;
switch (labelNum)
{

View file

@ -85,7 +85,7 @@ G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],menutextbuf[128],buf[
G_EXTERN char typebuf[TYPEBUFSIZE];
G_EXTERN input_t avg;
G_EXTERN input_t loc;
G_EXTERN input_t localInput;
G_EXTERN input_t recsync[RECSYNCBUFSIZ];
G_EXTERN int16_t SpriteDeletionQueue[1024],g_spriteDeleteQueuePos;
G_EXTERN int16_t animatesect[MAXANIMATES];

View file

@ -828,9 +828,9 @@ void Net_ReceiveNewPlayer(uint8_t *pbuf, int32_t packbufleng)
{
g_player[pbuf[4]].ps = (DukePlayer_t *) Xcalloc(1,sizeof(DukePlayer_t));
}
if (!g_player[pbuf[4]].sync)
if (!g_player[pbuf[4]].inputBits)
{
g_player[pbuf[4]].sync = (input_t *) Xcalloc(1,sizeof(input_t));
g_player[pbuf[4]].inputBits = (input_t *) Xcalloc(1,sizeof(input_t));
}
}

View file

@ -781,7 +781,7 @@ static int32_t osdcmd_give(const osdfuncparm_t *parm)
else if (!Bstrcasecmp(parm->parms[0], "ammo"))
{
for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1; i>=PISTOL_WEAPON; i--)
P_AddAmmo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]);
P_AddAmmo(g_player[myconnectindex].ps,i,g_player[myconnectindex].ps->max_ammo_amount[i]);
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "armor"))

File diff suppressed because it is too large Load diff

View file

@ -209,7 +209,7 @@ typedef struct {
// KEEPINSYNC lunatic/defs.ilua
typedef struct {
DukePlayer_t *ps;
input_t *sync;
input_t *inputBits;
int32_t netsynctime;
int16_t ping, filler;
@ -338,63 +338,59 @@ static inline void P_PalFrom(DukePlayer_t *p, uint8_t f, uint8_t r, uint8_t g, u
}
}
int32_t A_GetHitscanRange(int32_t i);
void P_GetInput(int32_t snum);
void P_AddAmmo(int32_t weapon,DukePlayer_t *p,int32_t amount);
void P_AddWeapon(DukePlayer_t *p,int32_t weapon, int32_t doswitch);
void P_CheckWeapon(DukePlayer_t *p);
void P_DisplayScuba(void);
void P_DisplayWeapon(void);
void P_DropWeapon(int32_t snum);
int32_t P_FindOtherPlayer(int32_t p, int32_t *d);
void P_FragPlayer(int32_t snum);
void P_UpdatePosWhenViewingCam(DukePlayer_t *p);
void P_ProcessInput(int32_t snum);
void P_QuickKill(DukePlayer_t *p);
void P_SelectNextInvItem(DukePlayer_t *p);
void P_UpdateScreenPal(DukePlayer_t *p);
void P_EndLevel(void);
void P_CheckWeaponI(int32_t snum);
int P_GetHudPal(const DukePlayer_t *p);
int32_t A_GetHitscanRange(int spriteNum);
void P_GetInput(int playerNum);
void P_AddAmmo(DukePlayer_t *pPlayer, int weaponNum, int addAmount);
void P_AddWeapon(DukePlayer_t *pPlayer,int weaponNum, int switchWeapon);
void P_CheckWeapon(DukePlayer_t *pPlayer);
void P_DisplayScuba(void);
void P_DisplayWeapon(void);
void P_DropWeapon(int playerNum);
int P_FindOtherPlayer(int playerNum, int32_t *d);
void P_FragPlayer(int playerNum);
void P_UpdatePosWhenViewingCam(DukePlayer_t *pPlayer);
void P_ProcessInput(int playerNum);
void P_QuickKill(DukePlayer_t *pPlayer);
void P_SelectNextInvItem(DukePlayer_t *pPlayer);
void P_UpdateScreenPal(DukePlayer_t *pPlayer);
void P_EndLevel(void);
void P_CheckWeaponI(int32_t playerNum);
int P_GetHudPal(const DukePlayer_t *pPlayer);
int32_t Proj_GetDamage(projectile_t const * pProj);
#if !defined LUNATIC
void P_SetWeaponGamevars(int snum, const DukePlayer_t *p);
void P_SetWeaponGamevars(int playerNum, const DukePlayer_t *pPlayer);
#else
void P_SetWeaponGamevars(int snum, const DukePlayer_t *p)
void P_SetWeaponGamevars(int playerNum, const DukePlayer_t *pPlayer)
{
UNREFERENCED_PARAMETER(snum);
UNREFERENCED_PARAMETER(p);
UNREFERENCED_PARAMETER(playerNum);
UNREFERENCED_PARAMETER(pPlayer);
}
#endif
// Get the player index given an APLAYER sprite pointer.
static inline int32_t P_GetP(const spritetype *spr)
static inline int P_GetP(const void *pSprite)
{
#if 0 // unprotected player index retrieval
return spr->yvel;
#elif defined NETCODE_DISABLE
UNREFERENCED_PARAMETER(spr); // for NDEBUG build
UNREFERENCED_PARAMETER(pSprite); // for NDEBUG build
// NOTE: In the no-netcode build, there's no point to pass player indices
// at all since there is ever only one player. However, merely returning 0
// would mean making this build less strict than the normal one.
Bassert(spr->yvel == 0);
Bassert(pSprite->yvel == 0);
return 0;
#else
int32_t pidx = spr->yvel;
if ((unsigned)pidx >= (unsigned)playerswhenstarted)
pidx = 0;
return pidx;
int playerNum = ((const uspritetype *)pSprite)->yvel;
if ((unsigned)playerNum >= (unsigned)playerswhenstarted)
playerNum = 0;
return playerNum;
#endif
}
// Get the player index given an APLAYER sprite index.
static inline int32_t P_Get(int32_t spritenum)
{
return P_GetP(&sprite[spritenum]);
}
static inline int P_Get(int32_t spriteNum) { return P_GetP((const uspritetype *)&sprite[spriteNum]); }
#ifdef __cplusplus
}

View file

@ -1662,13 +1662,13 @@ void G_ClearFIFO(void)
Bmemset(&avg, 0, sizeof(input_t));
clearbufbyte(&loc,sizeof(input_t),0L);
clearbufbyte(&localInput,sizeof(input_t),0L);
clearbufbyte(&inputfifo,sizeof(input_t)*MOVEFIFOSIZ*MAXPLAYERS,0L);
for (; i >= 0; i--)
{
if (g_player[i].sync != NULL)
Bmemset(g_player[i].sync, 0, sizeof(input_t));
if (g_player[i].inputBits != NULL)
Bmemset(g_player[i].inputBits, 0, sizeof(input_t));
g_player[i].vote = g_player[i].gotvote = 0;
}
}

View file

@ -1966,7 +1966,7 @@ void A_DamageObject(int32_t spriteNum, int32_t damageSrc)
case FUELPOD__STATIC:
case SOLARPANNEL__STATIC:
case ANTENNA__STATIC:
if (sprite[damageSrc].extra != G_InitialActorStrength(SHOTSPARK1))
if (sprite[damageSrc].extra != G_DefaultActorHealth(SHOTSPARK1))
{
for (int j=15; j>0; j--)
A_InsertSprite(SECT(spriteNum),SX(spriteNum),SY(spriteNum),sector[SECT(spriteNum)].floorz-ZOFFSET4-(j<<9),SCRAP1+(krand()&15),-8,64,64,
@ -2344,7 +2344,7 @@ void P_HandleSharedKeys(int32_t playerNum)
if (pPlayer->cheat_phase == 1) return;
uint32_t playerBits = g_player[playerNum].sync->bits, weaponNum;
uint32_t playerBits = g_player[playerNum].inputBits->bits, weaponNum;
// 1<<0 = jump
// 1<<1 = crouch
@ -2922,25 +2922,25 @@ void P_CheckSectors(int playerNum)
if (pPlayer->gm &MODE_TYPE || sprite[pPlayer->i].extra <= 0)
return;
if (TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_OPEN))
if (TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_OPEN))
{
if (VM_OnEvent(EVENT_USE, pPlayer->i, playerNum) != 0)
g_player[playerNum].sync->bits &= ~BIT(SK_OPEN);
g_player[playerNum].inputBits->bits &= ~BIT(SK_OPEN);
}
if (ud.cashman && TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_OPEN))
if (ud.cashman && TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_OPEN))
A_SpawnMultiple(pPlayer->i, MONEY, 2);
if (pPlayer->newowner >= 0)
{
if (klabs(g_player[playerNum].sync->svel) > 768 || klabs(g_player[playerNum].sync->fvel) > 768)
if (klabs(g_player[playerNum].inputBits->svel) > 768 || klabs(g_player[playerNum].inputBits->fvel) > 768)
{
G_ClearCameras(pPlayer);
return;
}
}
if (!TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_OPEN) && !TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_ESCAPE))
if (!TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_OPEN) && !TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_ESCAPE))
pPlayer->toggle_key_flag = 0;
else if (!pPlayer->toggle_key_flag)
{
@ -2949,7 +2949,7 @@ void P_CheckSectors(int playerNum)
int16_t neartagsector, neartagwall, neartagsprite;
int32_t neartaghitdist;
if (TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_ESCAPE))
if (TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_ESCAPE))
{
if (pPlayer->newowner >= 0)
G_ClearCameras(pPlayer);
@ -3150,7 +3150,7 @@ void P_CheckSectors(int playerNum)
} // switch
}
if (TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_OPEN) == 0)
if (TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_OPEN) == 0)
return;
if (pPlayer->newowner >= 0)