Commit 0578f900 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Duke3d: reclaim a ridiculous amount of wasted space in the player struct

This converts the storage for LOOGIE sprite coordinates to vec2_16_t and reduces the storage to 6 sets of coordinates, the max the game uses.
parent c0241714
......@@ -2835,6 +2835,7 @@ ACTOR_STATIC void A_DoProjectileBounce(int const spriteNum)
pSprite->ang = getangle(vect.x, vect.y);
}
#ifndef EDUKE32_STANDALONE
ACTOR_STATIC void P_HandleBeingSpitOn(DukePlayer_t * const ps)
{
ps->q16horiz += F16(32);
......@@ -2849,12 +2850,10 @@ ACTOR_STATIC void P_HandleBeingSpitOn(DukePlayer_t * const ps)
int j = 3+(krand()&3);
ps->numloogs = j;
ps->loogcnt = 24*4;
for (bssize_t x=0; x < j; x++)
{
ps->loogiex[x] = krand()%320;
ps->loogiey[x] = krand()%200;
}
for (int x=0; x < j; x++)
ps->loogie[x] = { (int16_t)(krand()%320), (int16_t)(krand()%200) };
}
#endif
static void A_DoProjectileEffects(int spriteNum, const vec3_t *davect, bool radiusDamage = true)
{
......@@ -3110,10 +3109,13 @@ ACTOR_STATIC void Proj_MoveCustom(int const spriteNum)
#ifndef EDUKE32_STANDALONE
if (!FURY)
{
A_PlaySound(PISTOL_BODYHIT, otherSprite);
if (pProj->workslike & PROJECTILE_SPIT)
P_HandleBeingSpitOn(g_player[playerNum].ps);
}
#endif
if (pProj->workslike & PROJECTILE_SPIT)
P_HandleBeingSpitOn(g_player[playerNum].ps);
}
if (pProj->workslike & PROJECTILE_RPG_IMPACT)
......
......@@ -350,8 +350,8 @@ memberlabel_t const TsprLabels[] =
memberlabel_t const PlayerLabels[] =
{
MEMBER(g_player[0].ps, zoom, PLAYER_ZOOM),
{ "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, 64, -1 },
{ "loogiey", PLAYER_LOOGIEY, LABEL_HASPARM2, 64, -1 },
{ "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, (int16_t)ARRAY_SIZE(g_player[0].ps->loogie), -1 },
{ "loogiey", PLAYER_LOOGIEY, LABEL_HASPARM2, (int16_t)ARRAY_SIZE(g_player[0].ps->loogie), -1 },
MEMBER(g_player[0].ps, numloogs, PLAYER_NUMLOOGS),
MEMBER(g_player[0].ps, loogcnt, PLAYER_LOOGCNT),
LABEL(g_player[0].ps, pos.x, "posx", PLAYER_POSX),
......@@ -588,8 +588,8 @@ int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const
case PLAYER_DEATHS: labelNum = g_player[playerNum].frags[playerNum]; break;
case PLAYER_BSUBWEAPON: labelNum = (ps.subweapon & (1<<lParm2)) != 0; break;
case PLAYER_LOOGIEX: labelNum = ps.loogiex[lParm2]; break;
case PLAYER_LOOGIEY: labelNum = ps.loogiey[lParm2]; break;
case PLAYER_LOOGIEX: labelNum = ps.loogie[lParm2].x; break;
case PLAYER_LOOGIEY: labelNum = ps.loogie[lParm2].y; break;
case PLAYER_WEAPRECS: labelNum = ps.weaprecs[lParm2]; break;
......@@ -658,8 +658,8 @@ void __fastcall VM_SetPlayer(int const playerNum, int const labelNum, int const
else ps.subweapon &= ~(1 << lParm2);
break;
case PLAYER_LOOGIEX: ps.loogiex[lParm2] = newValue; break;
case PLAYER_LOOGIEY: ps.loogiey[lParm2] = newValue; break;
case PLAYER_LOOGIEX: ps.loogie[lParm2].x = newValue; break;
case PLAYER_LOOGIEY: ps.loogie[lParm2].y = newValue; break;
case PLAYER_WEAPRECS: ps.weaprecs[lParm2] = newValue; break;
......
......@@ -1737,6 +1737,7 @@ int A_ShootWithZvel(int const spriteNum, int const projecTile, int const forceZv
//////////////////// HUD WEAPON / MISC. DISPLAY CODE ////////////////////
#ifndef EDUKE32_STANDALONE
static void P_DisplaySpit(void)
{
auto const pPlayer = g_player[screenpeek].ps;
......@@ -1748,18 +1749,20 @@ static void P_DisplaySpit(void)
if (VM_OnEvent(EVENT_DISPLAYSPIT, pPlayer->i, screenpeek) != 0)
return;
int const rotY = loogCounter<<2;
int const rotY = loogCounter << 2;
int const loogs = min<int>(pPlayer->numloogs, ARRAY_SIZE(pPlayer->loogie));
for (bssize_t i=0; i < pPlayer->numloogs; i++)
for (int i=0; i < loogs; i++)
{
int const rotAng = klabs(sintable[((loogCounter + i) << 5) & 2047]) >> 5;
int const rotZoom = 4096 + ((loogCounter + i) << 9);
int const rotX = (-fix16_to_int(g_player[screenpeek].input.q16avel) >> 1) + (sintable[((loogCounter + i) << 6) & 2047] >> 10);
rotatesprite_fs((pPlayer->loogiex[i] + rotX) << 16, (200 + pPlayer->loogiey[i] - rotY) << 16, rotZoom - (i << 8),
rotatesprite_fs((pPlayer->loogie[i].x + rotX) << 16, (200 + pPlayer->loogie[i].y - rotY) << 16, rotZoom - (i << 8),
256 - rotAng, LOOGIE, 0, 0, 2);
}
}
#endif
int P_GetHudPal(const DukePlayer_t *p)
{
......@@ -2987,8 +2990,10 @@ void P_DisplayWeapon(void)
}
}
enddisplayweapon:
enddisplayweapon:;
#ifndef EDUKE32_STANDALONE
P_DisplaySpit();
#endif
}
#define TURBOTURNTIME (TICRATE/8) // 7
......
......@@ -161,7 +161,10 @@ typedef struct {
uint16_t frag, fraggedself;
int16_t loogiex[64], loogiey[64], sbs, sound_pitch;
vec2_16_t loogie[6];
int16_t filler[116]; // jesus fucking christ
int16_t sbs, sound_pitch;
int16_t cursectnum, look_ang, last_extra, subweapon;
int16_t max_ammo_amount[MAX_WEAPONS], ammo_amount[MAX_WEAPONS], inv_amount[GET_MAX];
......@@ -211,6 +214,7 @@ typedef struct {
} DukePlayer_t;
EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t) % 4 == 0);
EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t) == 640); // this needs to stay the same size for savegame compatibility
typedef struct
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment