4080: Fix collecting weapon in solo part not making any sound. r=Jupeyy a=edg-l

fixes #3822
fixes #2219

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Edgar Luque <git@edgarluque.com>
This commit is contained in:
bors[bot] 2021-08-16 09:52:45 +00:00 committed by GitHub
commit 6b9bdbc259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -2356,3 +2356,8 @@ void CCharacter::Rescue()
m_pPlayer->Pause(CPlayer::PAUSE_NONE, true);
}
}
int64_t CCharacter::TeamMask()
{
return Teams()->TeamMask(Team(), -1, GetPlayer()->GetCID());
}

View file

@ -80,6 +80,7 @@ public:
bool IsAlive() const { return m_Alive; }
bool IsPaused() const { return m_Paused; }
class CPlayer *GetPlayer() { return m_pPlayer; }
int64_t TeamMask();
private:
// player controlling this character

View file

@ -54,6 +54,7 @@ void CPickup::Tick()
for(int i = 0; i < Num; ++i)
{
CCharacter *pChr = apEnts[i];
if(pChr && pChr->IsAlive())
{
if(m_Layer == LAYER_SWITCH && m_Number > 0 && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pChr->Team()])
@ -64,7 +65,7 @@ void CPickup::Tick()
{
case POWERUP_HEALTH:
if(pChr->Freeze())
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH, pChr->Teams()->TeamMask(pChr->Team()));
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH, pChr->TeamMask());
break;
case POWERUP_ARMOR:
@ -85,7 +86,7 @@ void CPickup::Tick()
if(Sound)
{
pChr->SetLastWeapon(WEAPON_GUN);
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR, pChr->Teams()->TeamMask(pChr->Team()));
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR, pChr->TeamMask());
}
if(pChr->GetActiveWeapon() >= WEAPON_SHOTGUN)
pChr->SetActiveWeapon(WEAPON_HAMMER);
@ -100,11 +101,11 @@ void CPickup::Tick()
//RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->Teams()->TeamMask(pChr->Team()));
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->TeamMask());
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team()));
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->TeamMask());
else if(m_Subtype == WEAPON_LASER)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team()));
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->TeamMask());
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);