Skip to content

Commit

Permalink
Combined the weapon, state number members of weaponmodeinfo_t into an…
Browse files Browse the repository at this point in the history
… array for convenience.
  • Loading branch information
danij committed May 5, 2009
1 parent c34e235 commit 2431524
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 557 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_player.c
Expand Up @@ -571,7 +571,7 @@ boolean P_CheckAmmo(player_t* plr)

// Now set appropriate weapon overlay.
if(plr->pendingWeapon != WT_NOCHANGE)
P_SetPsprite(plr, ps_weapon, wInfo->mode[fireMode].downState);
P_SetPsprite(plr, ps_weapon, wInfo->mode[fireMode].states[WSN_DOWN]);

return false;
}
Expand Down
12 changes: 6 additions & 6 deletions doomsday/plugins/common/src/r_common.c
Expand Up @@ -89,13 +89,13 @@ void R_PrecachePSprites(void)
{
pclass = players[CONSOLEPLAYER].class;

R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].upState);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].downState);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].readyState);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].attackState);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].flashState);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].states[WSN_UP]);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].states[WSN_DOWN]);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].states[WSN_READY]);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].states[WSN_ATTACK]);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].states[WSN_FLASH]);
#if __JHERETIC__ || __JHEXEN__
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].holdAttackState);
R_PrecacheSkinsForState(weaponInfo[i][pclass].mode[k].states[WSN_ATTACK_HOLD]);
#endif
}
}
Expand Down
15 changes: 10 additions & 5 deletions doomsday/plugins/jdoom/include/d_items.h
Expand Up @@ -37,19 +37,24 @@

#define WEAPON_INFO(weaponnum, pclass, fmode) (&weaponInfo[weaponnum][pclass].mode[fmode])

typedef enum {
WSN_UP,
WSN_DOWN,
WSN_READY,
WSN_ATTACK,
WSN_FLASH,
NUM_WEAPON_STATE_NAMES
} weaponstatename_t;

typedef struct {
int gameModeBits; // Game modes, weapon is available in.

int ammoType[NUM_AMMO_TYPES]; // required ammo types.
int perShot[NUM_AMMO_TYPES]; // Ammo used per shot of each type.
boolean autoFire; // (True)= fire when raised if fire held.
int upState;
int states[NUM_WEAPON_STATE_NAMES];
int raiseSound; // Sound played when weapon is raised.
int downState;
int readyState;
int readySound; // Sound played WHILE weapon is readyied
int attackState;
int flashState;
int staticSwitch; // Weapon is not lowered during switch.
} weaponmodeinfo_t;

Expand Down
78 changes: 21 additions & 57 deletions doomsday/plugins/jdoom/src/d_items.c
Expand Up @@ -58,13 +58,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 0, 0, 0}, // type: clip | shell | cell | misl
{0, 0, 0, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_PUNCHUP,
{ S_PUNCHUP, S_PUNCHDOWN, S_PUNCH, S_PUNCH1, S_NULL },
0, // raise sound id
S_PUNCHDOWN,
S_PUNCH,
0, // ready sound
S_PUNCH1,
S_NULL
0 // ready sound
}
},
{
Expand All @@ -73,13 +69,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{1, 0, 0, 0}, // type: clip | shell | cell | misl
{1, 0, 0, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_PISTOLUP,
{ S_PISTOLUP, S_PISTOLDOWN, S_PISTOL, S_PISTOL1, S_PISTOLFLASH },
0, // raise sound id
S_PISTOLDOWN,
S_PISTOL,
0, // ready sound
S_PISTOL1,
S_PISTOLFLASH
0 // ready sound
}
},
{
Expand All @@ -88,13 +80,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 1, 0, 0}, // type: clip | shell | cell | misl
{0, 1, 0, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_SGUNUP,
{ S_SGUNUP, S_SGUNDOWN, S_SGUN, S_SGUN1, S_SGUNFLASH1 },
0, // raise sound id
S_SGUNDOWN,
S_SGUN,
0, // ready sound
S_SGUN1,
S_SGUNFLASH1
0 // ready sound
}
},
{
Expand All @@ -103,13 +91,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{1, 0, 0, 0}, // type: clip | shell | cell | misl
{1, 0, 0, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_CHAINUP,
{ S_CHAINUP, S_CHAINDOWN, S_CHAIN, S_CHAIN1, S_CHAINFLASH1 },
0, // raise sound id
S_CHAINDOWN,
S_CHAIN,
0, // ready sound
S_CHAIN1,
S_CHAINFLASH1
}
},
{
Expand All @@ -118,13 +102,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 0, 0, 1}, // type: clip | shell | cell | misl
{0, 0, 0, 1}, // pershot: clip | shell | cell | misl
false, // autofire when raised if fire held
S_MISSILEUP,
{ S_MISSILEUP, S_MISSILEDOWN, S_MISSILE, S_MISSILE1, S_MISSILEFLASH1 },
0, // raise sound id
S_MISSILEDOWN,
S_MISSILE,
0, // ready sound
S_MISSILE1,
S_MISSILEFLASH1
}
},
{
Expand All @@ -133,13 +113,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 0, 1, 0}, // type: clip | shell | cell | misl
{0, 0, 1, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_PLASMAUP,
{ S_PLASMAUP, S_PLASMADOWN, S_PLASMA, S_PLASMA1, S_PLASMAFLASH1 },
0, // raise sound id
S_PLASMADOWN,
S_PLASMA,
0, // ready sound
S_PLASMA1,
S_PLASMAFLASH1
0 // ready sound
}
},
{
Expand All @@ -148,13 +124,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 0, 1, 0}, // type: clip | shell | cell | misl
{0, 0, 40, 0}, // pershot: clip | shell | cell | misl
false, // autofire when raised if fire held
S_BFGUP,
{ S_BFGUP, S_BFGDOWN, S_BFG, S_BFG1, S_BFGFLASH1 },
0, // raise sound id
S_BFGDOWN,
S_BFG,
0, // ready sound
S_BFG1,
S_BFGFLASH1
0 // ready sound
}
},
{
Expand All @@ -163,13 +135,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 0, 0, 0}, // type: clip | shell | cell | misl
{0, 0, 0, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_SAWUP,
{ S_SAWUP, S_SAWDOWN, S_SAW, S_SAW1, S_NULL },
SFX_SAWUP, // raise sound id
S_SAWDOWN,
S_SAW,
SFX_SAWIDL, // ready sound
S_SAW1,
S_NULL
SFX_SAWIDL // ready sound
}
},
{
Expand All @@ -178,13 +146,9 @@ weaponinfo_t weaponInfo[NUM_WEAPON_TYPES][NUM_PLAYER_CLASSES] = {
{0, 1, 0, 0}, // type: clip | shell | cell | misl
{0, 2, 0, 0}, // pershot: clip | shell | cell | misl
true, // autofire when raised if fire held
S_DSGUNUP,
{ S_DSGUNUP, S_DSGUNDOWN, S_DSGUN, S_DSGUN1, S_DSGUNFLASH1 },
0, // raise sound id
S_DSGUNDOWN,
S_DSGUN,
0, // ready sound
S_DSGUN1,
S_DSGUNFLASH1
0 // ready sound
}
}
};
Expand Down Expand Up @@ -262,15 +226,15 @@ void P_InitWeaponInfo(void)
// end todo

sprintf(buf, WPINF "%i|Up", i);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].upState);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].states[WSN_UP]);
sprintf(buf, WPINF "%i|Down", i);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].downState);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].states[WSN_DOWN]);
sprintf(buf, WPINF "%i|Ready", i);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].readyState);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].states[WSN_READY]);
sprintf(buf, WPINF "%i|Atk", i);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].attackState);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].states[WSN_ATTACK]);
sprintf(buf, WPINF "%i|Flash", i);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].flashState);
GetDefState(buf, &weaponInfo[i][pclass].mode[0].states[WSN_FLASH]);
sprintf(buf, WPINF "%i|Static", i);
weaponInfo[i][pclass].mode[0].staticSwitch = GetDefInt(buf, 0);
}
Expand Down
26 changes: 13 additions & 13 deletions doomsday/plugins/jdoom/src/p_pspr.c
Expand Up @@ -165,9 +165,9 @@ void P_BringUpWeapon(player_t *player)

#ifdef _DEBUG
Con_Message("P_BringUpWeapon: player %i, weapon pspr to %i\n",
player - players, wminfo->upState);
player - players, wminfo->states[WSN_UP]);
#endif
P_SetPsprite(player, ps_weapon, wminfo->upState);
P_SetPsprite(player, ps_weapon, wminfo->states[WSN_UP]);
}

void P_FireWeapon(player_t *player)
Expand All @@ -183,7 +183,7 @@ void P_FireWeapon(player_t *player)
player->plr->pSprites[0].state = DDPSP_FIRE;

P_MobjChangeState(player->plr->mo, PCLASS_INFO(player->class)->attackState);
newstate = weaponInfo[player->readyWeapon][player->class].mode[0].attackState;
newstate = weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_ATTACK];
P_SetPsprite(player, ps_weapon, newstate);
NetSv_PSpriteChange(player - players, newstate);
P_NoiseAlert(player->plr->mo, player->plr->mo);
Expand All @@ -194,7 +194,7 @@ void P_FireWeapon(player_t *player)
*/
void P_DropWeapon(player_t *player)
{
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].downState);
P_SetPsprite(player, ps_weapon, weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_DOWN]);
}

/**
Expand All @@ -220,13 +220,13 @@ void C_DECL A_WeaponReady(player_t *player, pspdef_t *psp)
wminfo = WEAPON_INFO(player->readyWeapon, player->class, 0);

// A weaponready sound?
if(psp->state == &STATES[wminfo->readyState] && wminfo->readySound)
if(psp->state == &STATES[wminfo->states[WSN_READY]] && wminfo->readySound)
S_StartSoundEx(wminfo->readySound, player->plr->mo);

// Check for weapon change, if player is dead, put the weapon away.
if(player->pendingWeapon != WT_NOCHANGE || !player->health)
{ // (pending weapon should already be validated)
P_SetPsprite(player, ps_weapon, wminfo->downState);
P_SetPsprite(player, ps_weapon, wminfo->states[WSN_DOWN]);
return;
}
}
Expand Down Expand Up @@ -358,15 +358,15 @@ void C_DECL A_Raise(player_t *player, pspdef_t *psp)

// The weapon has been raised all the way, so change to the ready state.
newstate =
weaponInfo[player->readyWeapon][player->class].mode[0].readyState;
weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_READY];

P_SetPsprite(player, ps_weapon, newstate);
}

void C_DECL A_GunFlash(player_t *player, pspdef_t *psp)
{
P_MobjChangeState(player->plr->mo, PCLASS_INFO(player->class)->attackEndState);
P_SetPsprite(player, ps_flash, weaponInfo[player->readyWeapon][player->class].mode[0].flashState);
P_SetPsprite(player, ps_flash, weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_FLASH]);
}

void C_DECL A_Punch(player_t *player, pspdef_t *psp)
Expand Down Expand Up @@ -477,7 +477,7 @@ void C_DECL A_FirePlasma(player_t *player, pspdef_t *psp)
P_ShotAmmo(player);

P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState +
weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_FLASH] +
(P_Random() & 1));

player->update |= PSF_AMMO;
Expand Down Expand Up @@ -545,7 +545,7 @@ void C_DECL A_FirePistol(player_t *player, pspdef_t *psp)
P_ShotAmmo(player);

P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState);
weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_FLASH]);

player->update |= PSF_AMMO;
if(IS_CLIENT)
Expand All @@ -566,7 +566,7 @@ void C_DECL A_FireShotgun(player_t *player, pspdef_t *psp)
P_ShotAmmo(player);

P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState);
weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_FLASH]);

player->update |= PSF_AMMO;
if(IS_CLIENT)
Expand All @@ -591,7 +591,7 @@ void C_DECL A_FireShotgun2(player_t *player, pspdef_t *psp)
P_ShotAmmo(player);

P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState);
weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_FLASH]);

player->update |= PSF_AMMO;
if(IS_CLIENT)
Expand Down Expand Up @@ -636,7 +636,7 @@ void C_DECL A_FireCGun(player_t *player, pspdef_t *psp)
P_ShotAmmo(player);

P_SetPsprite(player, ps_flash,
weaponInfo[player->readyWeapon][player->class].mode[0].flashState + psp->state -
weaponInfo[player->readyWeapon][player->class].mode[0].states[WSN_FLASH] + psp->state -
&STATES[S_CHAIN1]);

player->update |= PSF_AMMO;
Expand Down
15 changes: 10 additions & 5 deletions doomsday/plugins/jdoom64/include/d_items.h
Expand Up @@ -37,18 +37,23 @@

#define WEAPON_INFO(weaponnum, pclass, fmode) (&weaponInfo[weaponnum][pclass].mode[fmode])

typedef enum {
WSN_UP,
WSN_DOWN,
WSN_READY,
WSN_ATTACK,
WSN_FLASH,
NUM_WEAPON_STATE_NAMES
} weaponstatename_t;

typedef struct {
int gameModeBits; // Game modes, weapon is available in.
int ammoType[NUM_AMMO_TYPES]; // required ammo types.
int perShot[NUM_AMMO_TYPES]; // Ammo used per shot of each type.
boolean autoFire; // (True)= fire when raised if fire held.
int upState;
int states[NUM_WEAPON_STATE_NAMES];
int raiseSound; // Sound played when weapon is raised.
int downState;
int readyState;
int readySound; // Sound played WHILE weapon is readyied
int attackState;
int flashState;
int staticSwitch; // Weapon is not lowered during switch.
} weaponmodeinfo_t;

Expand Down

0 comments on commit 2431524

Please sign in to comment.