TShock icon indicating copy to clipboard operation
TShock copied to clipboard

Fix player buffs applied to other players through `PlayerAddBuff` packet

Open drunderscore opened this issue 3 years ago • 10 comments

Fixed HandlePlayerAddBuff data handler always being marked as Handled, and therefore never allowing the PlayerAddBuff to be sent to anyone.

Fixed OnPlayerBuff logic inside of Bouncer when checking WhitelistBuffMaxTime to determine if a buff being applied longer than allowed. This also marks the handler as Handled if the check fails, and resyncs the buffs with the PlayerAddBuff packet to the sender. (@drunderscore)

drunderscore avatar Sep 20 '21 20:09 drunderscore

The original bug is that when shooting another player with a Cursed Arrow (to apply Cursed Inferno), the check against WhitelistBuffMaxTime was using <= instead of >, which prevented the buff from being applied -- but never actually did because it was marked as not handled. Only a second bug within the HandlePlayerAddBuff data handler allowed this bug to continue.

Ichor Arrows (to apply Ichor) will fail simply because of the second bug.

drunderscore avatar Sep 20 '21 20:09 drunderscore

@bartico6 Yeah I see what you mean, definitely a good idea to only allow buffs that happen in vanilla to others (which should be a short list regardless)

I'll go through and update WhitelistBuffMaxTime with all buffs and their max time, and remove the > 0 check.

drunderscore avatar Sep 21 '21 14:09 drunderscore

Just commit a fix with the buffs you're currently seeing problems with.

bartico6 avatar Sep 21 '21 14:09 bartico6

@bartico6 fyi, this was updated, can you check again?

hakusaro avatar Mar 28 '22 00:03 hakusaro

Rebased, whitelisted more buffs, and added CanOnlyBeAppliedToSender, to indicate that the sender may only apply this buff to themself. This is used by BuffIDs.Campfire (aka Cozy Fire), BuffID.WaterCandle, and some others.

drunderscore avatar Apr 07 '22 03:04 drunderscore

@drunderscore still has merge conflicts on GitHub on web, can you fix with a rebase so that it runs CI?

hakusaro avatar Apr 07 '22 03:04 hakusaro

@hakusaro Fixed! Sorry about that, I actually didn't rebase even though I thought I did...

drunderscore avatar Apr 07 '22 04:04 drunderscore

https://github.com/Pryaxis/TShock/compare/c93cc7bb09d34c19fc908ca201061f5b9fc52f7d..b2214685ca3d49ea009112cb97a1d21e9cf9bd66

Arthri avatar Apr 28 '22 08:04 Arthri

Added buff limits for MonsterBanner, HeartLamp, PeaceCandle, StarInBottle, CatBast

drunderscore avatar May 29 '22 01:05 drunderscore

https://github.com/Pryaxis/TShock/compare/b2214685ca3d49ea009112cb97a1d21e9cf9bd66..f53367399fd1baa7aad55ca77f827fa3b2e2f8f6

Arthri avatar May 29 '22 06:05 Arthri

Anyone know the status on this?

hakusaro avatar Oct 06 '22 04:10 hakusaro

The Venom buff in Main.pvpBuff change will be removed, as it has been corrected by Re-Logic in 1.4.4. All of the existing buff limits will be checked to ensure they are still correct.

There are certainly still some missing buff limits, but I think it would be beneficial to review and merge this, as we would only gain more features.

I'll take another look at this today, and hopefully persuade some others to review.

drunderscore avatar Oct 06 '22 12:10 drunderscore

I've rebased this, and the only thing I've removed is the Main.pvpBuff[BuffID.Venom] = true patch as described earlier.

@hakusaro or @Arthri if you are able to review, I'd appreciate it -- I believe this to be ready to merge, other missing buff limits can be added in due time.

drunderscore avatar Oct 06 '22 15:10 drunderscore

Changed buff limits for Solar Armor (SolarShield1, SolarShield2, SolarShield3), to allow them to be applied by non-senders. Added limits for Hellfire (OnFire3), Hearty Meal, and Frostbite (Frostburn2).

drunderscore avatar Oct 08 '22 17:10 drunderscore