1
0

Merge pull request #1275 from Howaner/BlockEntitys

Verify beacon effects sent by the client before setting them.
This commit is contained in:
Mattes D 2014-08-02 11:10:02 +02:00
commit 543b0ccf75
2 changed files with 18 additions and 1 deletions

View File

@ -90,6 +90,7 @@ bool cBeaconEntity::SetPrimaryEffect(cEntityEffect::eType a_Effect)
{
if (!IsValidEffect(a_Effect, m_BeaconLevel))
{
m_PrimaryEffect = cEntityEffect::effNoEffect;
return false;
}
@ -111,6 +112,7 @@ bool cBeaconEntity::SetSecondaryEffect(cEntityEffect::eType a_Effect)
{
if (!IsValidEffect(a_Effect, m_BeaconLevel))
{
m_SecondaryEffect = cEntityEffect::effNoEffect;
return false;
}

View File

@ -795,7 +795,22 @@ void cClientHandle::HandleBeaconSelection(const char * a_Data, size_t a_Length)
Window->SetSlot(*m_Player, 0, cItem());
BeaconWindow->GetBeaconEntity()->SetPrimaryEffect(PrimaryEffect);
// Valid effect check. Vanilla don't check this, but we do it :)
if (
(SecondaryEffect == cEntityEffect::effNoEffect) ||
(SecondaryEffect == cEntityEffect::effRegeneration) ||
(SecondaryEffect == BeaconWindow->GetBeaconEntity()->GetPrimaryEffect())
)
{
BeaconWindow->GetBeaconEntity()->SetSecondaryEffect(SecondaryEffect);
}
else
{
BeaconWindow->GetBeaconEntity()->SetSecondaryEffect(cEntityEffect::effNoEffect);
}
m_Player->CloseWindow(true);
}