mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Clean up some player.c code.
git-svn-id: https://svn.eduke32.com/eduke32@3955 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9ecbd633aa
commit
d63939d820
2 changed files with 41 additions and 28 deletions
|
@ -189,11 +189,13 @@ int32_t A_GetHitscanRange(int32_t i)
|
|||
return (FindDistance2D(hit.pos.x-SX,hit.pos.y-SY));
|
||||
}
|
||||
|
||||
static int32_t A_FindTargetSprite(spritetype *s,int32_t aang,int32_t atwith)
|
||||
static int32_t A_FindTargetSprite(const spritetype *s, int32_t aang, int32_t atwith)
|
||||
{
|
||||
int32_t gotshrinker,gotfreezer;
|
||||
int32_t i, j, a, k, cans;
|
||||
static int32_t aimstats[] = { 10, 13, 1, 2 };
|
||||
static const int32_t aimstats[] = {
|
||||
STAT_PLAYER, STAT_DUMMYPLAYER, STAT_ACTOR, STAT_ZOMBIEACTOR
|
||||
};
|
||||
int32_t dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist;
|
||||
int32_t xv, yv;
|
||||
|
||||
|
@ -206,7 +208,8 @@ static int32_t A_FindTargetSprite(spritetype *s,int32_t aang,int32_t atwith)
|
|||
{
|
||||
if (A_CheckSpriteTileFlags(atwith,SPRITE_PROJECTILE) && (ProjectileData[atwith].workslike & PROJECTILE_RPG))
|
||||
return -1;
|
||||
else switch (DYNAMICTILEMAP(atwith))
|
||||
|
||||
switch (DYNAMICTILEMAP(atwith))
|
||||
{
|
||||
case TONGUE__STATIC:
|
||||
case FREEZEBLAST__STATIC:
|
||||
|
@ -1432,7 +1435,6 @@ int32_t A_ShootWithZvel(int32_t i, int32_t atwith, int32_t override_zvel)
|
|||
sprite[j].extra >>= 2;
|
||||
}
|
||||
}
|
||||
|
||||
else if (PWEAPON(0, g_player[p].ps->curr_weapon, WorksLike) == DEVISTATOR_WEAPON)
|
||||
{
|
||||
sprite[j].extra >>= 2;
|
||||
|
@ -1906,19 +1908,16 @@ static int32_t P_DisplayKnuckles(int32_t gs,int32_t snum)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if !defined LUNATIC
|
||||
// Set C-CON's WEAPON and WORKSLIKE gamevars.
|
||||
void P_SetWeaponGamevars(int32_t snum, const DukePlayer_t *p)
|
||||
{
|
||||
#ifdef LUNATIC
|
||||
UNREFERENCED_PARAMETER(snum);
|
||||
UNREFERENCED_PARAMETER(p);
|
||||
#else
|
||||
Gv_SetVar(g_iWeaponVarID, p->curr_weapon, p->i, snum);
|
||||
Gv_SetVar(g_iWorksLikeVarID,
|
||||
((unsigned)p->curr_weapon < MAX_WEAPONS) ? PWEAPON(snum, p->curr_weapon, WorksLike) : -1,
|
||||
p->i, snum);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void P_FireWeapon(DukePlayer_t *p)
|
||||
{
|
||||
|
@ -1954,6 +1953,7 @@ static void P_FireWeapon(DukePlayer_t *p)
|
|||
p->ammo_amount[p->curr_weapon]--;
|
||||
else break;
|
||||
}
|
||||
|
||||
A_Shoot(p->i,PWEAPON(snum, p->curr_weapon, Shoots));
|
||||
}
|
||||
}
|
||||
|
@ -1981,6 +1981,9 @@ static void P_DoWeaponSpawn(const DukePlayer_t *p)
|
|||
{
|
||||
int32_t j, snum = sprite[p->i].yvel;
|
||||
|
||||
// NOTE: For the 'Spawn' member, 0 means 'none', too (originally so,
|
||||
// i.e. legacy). The check for <0 was added to the check because mod
|
||||
// authors (rightly) assumed that -1 is the no-op value.
|
||||
if (PWEAPON(snum, p->curr_weapon, Spawn) <= 0) // <=0 : AMC TC beta/RC2 has WEAPONx_SPAWN -1
|
||||
return;
|
||||
|
||||
|
@ -3667,14 +3670,15 @@ static void P_ProcessWeapon(int32_t snum)
|
|||
|
||||
if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_HOLSTER_CLEARS_CLIP)
|
||||
{
|
||||
if (p->ammo_amount[p->curr_weapon] > PWEAPON(snum, p->curr_weapon, Clip)
|
||||
&& (p->ammo_amount[p->curr_weapon] % PWEAPON(snum, p->curr_weapon, Clip)) != 0)
|
||||
const int32_t cw=p->curr_weapon, clipcnt = PWEAPON(snum, cw, Clip);
|
||||
|
||||
if (p->ammo_amount[cw] > clipcnt && (p->ammo_amount[cw] % clipcnt) != 0)
|
||||
{
|
||||
p->ammo_amount[p->curr_weapon]-=
|
||||
p->ammo_amount[p->curr_weapon] % PWEAPON(snum, p->curr_weapon, Clip) ;
|
||||
(*kb) = PWEAPON(snum, p->curr_weapon, TotalTime);
|
||||
p->ammo_amount[cw] -= p->ammo_amount[cw] % clipcnt;
|
||||
(*kb) = PWEAPON(snum, cw, TotalTime);
|
||||
sb_snum &= ~BIT(SK_FIRE); // not firing...
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,6 +378,15 @@ void P_ProcessInput(int32_t snum);
|
|||
void P_QuickKill(DukePlayer_t *p);
|
||||
void P_SelectNextInvItem(DukePlayer_t *p);
|
||||
void P_UpdateScreenPal(DukePlayer_t *p);
|
||||
|
||||
#if !defined LUNATIC
|
||||
void P_SetWeaponGamevars(int32_t snum, const DukePlayer_t *p);
|
||||
#else
|
||||
static inline void P_SetWeaponGamevars(int32_t snum, const DukePlayer_t *p)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(snum);
|
||||
UNREFERENCED_PARAMETER(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue