- Exhumed: Move lambdas out of doPlayerPickupItems(), starting with doConsoleMessage().

This commit is contained in:
Mitchell Richters 2023-03-25 12:39:50 +11:00
parent 33cea4a7e1
commit 27534c433d

View file

@ -81,6 +81,26 @@ static DExhumedActor* feebtag(const DVector3& pos, sectortype* pSector, int nVal
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void doPickupNotification(Player* const pPlayer, const int nItem, const int nSound = -1, const int tintRed = 0, const int tintGreen = 16)
{
if (pPlayer->nPlayer == nLocalPlayer)
{
if (nItemText[nItem] > -1 && nTotalPlayers == 1)
pickupMessage(nItem);
if (nSound > -1)
PlayLocalSound(nSound, 0);
TintPalette(tintRed * 4, tintGreen * 4, 0);
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void doPlayerItemPickups(Player* const pPlayer) void doPlayerItemPickups(Player* const pPlayer)
{ {
const auto pPlayerActor = pPlayer->pActor; const auto pPlayerActor = pPlayer->pActor;
@ -99,19 +119,6 @@ void doPlayerItemPickups(Player* const pPlayer)
static constexpr int healArray[] = {40, 160, -200}; static constexpr int healArray[] = {40, 160, -200};
static constexpr int ammoArray[] = {1, 3, 2}; static constexpr int ammoArray[] = {1, 3, 2};
const auto doConsoleMessage = [=](const int nSound = -1, const int tintRed = 0, const int tintGreen = 16)
{
if (pPlayer->nPlayer == nLocalPlayer)
{
if (nItemText[nItem] > -1 && nTotalPlayers == 1)
pickupMessage(nItem);
if (nSound > -1)
PlayLocalSound(nSound, 0);
TintPalette(tintRed * 4, tintGreen * 4, 0);
}
};
const auto doProcessPickup = [=]() const auto doProcessPickup = [=]()
{ {
if (!mplevel || (nItem >= 25 && (nItem <= 25 || nItem == 50))) if (!mplevel || (nItem >= 25 && (nItem <= 25 || nItem == 50)))
@ -162,7 +169,7 @@ void doPlayerItemPickups(Player* const pPlayer)
doProcessPickup(); doProcessPickup();
} }
doConsoleMessage(StaticSound[nSound]); doPickupNotification(pPlayer, nItem, StaticSound[nSound]);
}; };
const auto doPickupHealth = [=](const int nAmount, int nSound) const auto doPickupHealth = [=](const int nAmount, int nSound)
{ {
@ -202,7 +209,7 @@ void doPlayerItemPickups(Player* const pPlayer)
doProcessPickup(); doProcessPickup();
} }
doConsoleMessage(nSound, tintRed, tintGreen); doPickupNotification(pPlayer, nItem, nSound, tintRed, tintGreen);
} }
}; };
@ -215,7 +222,7 @@ void doPlayerItemPickups(Player* const pPlayer)
{ {
if (nItem == 8) CheckClip(pPlayer->nPlayer); if (nItem == 8) CheckClip(pPlayer->nPlayer);
doProcessPickup(); doProcessPickup();
doConsoleMessage(StaticSound[kSoundAmmoPickup]); doPickupNotification(pPlayer, nItem, StaticSound[kSoundAmmoPickup]);
} }
break; break;
@ -242,13 +249,13 @@ void doPlayerItemPickups(Player* const pPlayer)
case 51: case 51:
case 58: case 58:
doProcessPickup(); doProcessPickup();
doConsoleMessage(); doPickupNotification(pPlayer, nItem);
break; break;
case 11: // Map case 11: // Map
GrabMap(); GrabMap();
doProcessPickup(); doProcessPickup();
doConsoleMessage(); doPickupNotification(pPlayer, nItem);
break; break;
case 12: // Berry Twig case 12: // Berry Twig
@ -279,7 +286,7 @@ void doPlayerItemPickups(Player* const pPlayer)
if (GrabItem(pPlayer->nPlayer, itemArray[nItem - 18])) if (GrabItem(pPlayer->nPlayer, itemArray[nItem - 18]))
{ {
doProcessPickup(); doProcessPickup();
doConsoleMessage(); doPickupNotification(pPlayer, nItem);
} }
break; break;
@ -288,7 +295,7 @@ void doPlayerItemPickups(Player* const pPlayer)
{ {
pPlayer->nLives++; pPlayer->nLives++;
doProcessPickup(); doProcessPickup();
doConsoleMessage(-1, 32, 32); doPickupNotification(pPlayer, nItem, -1, 32, 32);
} }
break; break;
@ -317,7 +324,7 @@ void doPlayerItemPickups(Player* const pPlayer)
if (AddAmmo(pPlayer->nPlayer, nItem - 32, (nItem == 38) ? pPickupActor->spr.hitag : 1)) if (AddAmmo(pPlayer->nPlayer, nItem - 32, (nItem == 38) ? pPickupActor->spr.hitag : 1))
{ {
doProcessPickup(); doProcessPickup();
doConsoleMessage(StaticSound[kSoundAmmoPickup]); doPickupNotification(pPlayer, nItem, StaticSound[kSoundAmmoPickup]);
} }
break; break;
@ -331,7 +338,7 @@ void doPlayerItemPickups(Player* const pPlayer)
{ {
pPlayer->keys |= keybit; pPlayer->keys |= keybit;
doProcessPickup(); doProcessPickup();
doConsoleMessage(); doPickupNotification(pPlayer, nItem);
} }
break; break;
} }
@ -346,7 +353,7 @@ void doPlayerItemPickups(Player* const pPlayer)
pPlayer->nMagic = 1000; pPlayer->nMagic = 1000;
doProcessPickup(); doProcessPickup();
doConsoleMessage(StaticSound[kSoundMana1]); doPickupNotification(pPlayer, nItem, StaticSound[kSoundMana1]);
} }
break; break;