Commit graph

103 commits

Author SHA1 Message Date
Lucas Nicodemus
b5f95d5918
Fragments: Separate out item bans (#1595)
* Remove commented out warning disable

* Add initial ItemBans segregation infrastructure

* Add shell for initial OnSecondUpdate stuff

* Add comments yo

* Remove duplicated logic

* Split out more item ban code

This part of the fragments work is primarily aimed at reducing the
complexity of OnSecondUpdate in TShock and moving that check out into
the ItemBans subsytem.

Of major note in this is the removal of "check", which was a string
variable that tracked state and replacement of many of the item ban
activities with sane private methods that are at least somewhat
sensible. Obviously there's a lot to be desired in this system and I'm
really going for a run here by trying to continue a branch from so long
ago that I barely even remember the whole point of existence.

Still to do: GetDataHandlers related item ban code needs to be moved
into its own hook in the ItemBan system. Finally, there is a downside to
some of this: we're basically iterating over players again and again if
we keep this pattern up, which is kinda lame for complexity purposes.

* alt j: comment changes

* Move item ban check out of main playerupdate check

Separates out item ban logic from the rest of GetDataHandlers so that
item bans is more isolated in terms of what fragments is asking for.

* alt-j: convert indentation to tabs

* alt-j: fix botching source code

* Move item ban related chest checks out of gdh

* Remove chest item change detection from item bans

It doesn't do anything. If a user removes an item from a chest, it
bypasses this check. If a user adds an item to a chest, the server seems
to persist the change anyway, even if the event is handled. That's a bug
for sure, but fundamentally, it's not the item ban system's fault.

* Revert "Remove chest item change detection from item bans"

This reverts commit 758541ac5c4d4096df2db05ba2a398968113e1e4.

* Fix logic issues related to item ban handling

Re-implements chest item handling and correctly handles events and
returns after setting handled event state.

* Remove TSPlayer.HasProjectilePermission

In infinite wisdom, it turns out this is not a good method for TSPlayer
to have. It just checks the states of things as per what the item ban
system says is banned and then creates implicit relationships to the
projectile ban system.

Doing this effectively knocks down another external reference to the
item ban system outside of the context of the implementation for the
system itself and its related hooks.

This commit also adds context around what the heck is going on with some
of our more interesting checks as per discussions in Telegram with @Ijwu
and @QuiCM.

* Update changelog

* Remove useless ref to Projectile.SetDefaults

* Change item ban to ban based on ID not strings

I think I was so confused as to why we were passing strings everywhere
that I just felt inclined to continue the trend in previous commits.
2020-05-16 16:27:34 -07:00
moisterrific
6007edeb77
Fix BoC false positive kick in NPCAddBuffTimeMax
360 ticks = 6 seconds, according to the wiki, the max possible duration is proportional to dmg taken, so 7.5 seconds would be the max duration (aka 450 ticks)
2020-02-07 16:14:27 -05:00
Chris
e3bac1871a
Update Bouncer.cs
Removes double occurrence of daybreak buff from dictionary.
Thanks for pointing this out @AxeelAnder
2019-07-18 13:54:20 +00:00
Chris
429a5051fd
Merge branch 'general-devel' into general-devel 2019-03-30 13:36:28 +10:30
Lucas Nicodemus
70dd72443d Update copyright to 2019 again
Fixes #1658, most likely.
2019-03-29 17:16:37 -07:00
Tyson Strange
6315086cb1 Added to Bouncer NPCAddBuffTimeMax for Solar Eruption Item ID: 3473, Daybreak Item ID: 3543 2019-02-03 17:41:23 +10:00
Tyson Strange
12c34256ac Added confused debuff for Brain of Confusion 2019-02-03 15:56:43 +10:00
Tyson Strange
2440e044b1 Added confused debuff for Brain of Confusion 2019-02-03 15:55:19 +10:00
AxeelAnder
eae1ba5a5c concrete reason when create banned projectile 2018-10-31 18:02:53 +08:00
AxeelAnder
210c95e5b1 sorted Bouncer and GetDataHandlers, ordered by packet type enum value 2018-10-26 14:06:46 +08:00
AxeelAnder
b2033d9eac update changelog 2018-10-25 22:10:33 +08:00
AxeelAnder
42e413012d added filter: only check when zones contains towers 2018-10-24 15:56:24 +08:00
AxeelAnder
2ea9a0161b added PlayerZone handler and bouncer, detect lunar towers cheat 2018-10-23 17:22:59 +08:00
AxeelAnder
f715d91dc6 disable -> kick 2018-10-21 11:01:08 +08:00
Lucas Nicodemus
e9372be276 Rename cheat var to detectedNPCBuffTimeCheat. 2018-10-20 09:14:38 -07:00
AxeelAnder
6efa0d2bb6 better code 2018-10-20 20:21:18 +08:00
AxeelAnder
b9dedd77dc add some anti-cheat code 2018-10-20 18:39:24 +08:00
AxeelAnder
fc38521dbd add NPCAddBuff bouncer 2018-10-20 18:39:07 +08:00
Chris
ae5d508989 Add filtering for packet 96.
Fixes #1605
2018-05-22 18:54:28 +09:30
Ivan
ec78a070a7 Move Region related code into a separate subsystem 2018-04-29 18:33:07 +02:00
Ziteng Wang
6266b47fb3 Fix tile entity placing 2018-02-18 16:35:26 -08:00
Lucas Nicodemus
569b350cea Update to Pryaxis, 2018 part 2
If there's one thing I learned in this exercise, it's that letting
people add random python scripts to the repo like gpltext.py that
promise to be easier than find and replace is a bad idea.
2018-01-01 02:20:56 -07:00
Lucas Nicodemus
8d934ef08f Update to 2018 2018-01-01 02:17:21 -07:00
Ziteng Wang
01a85a0758 Fix tile square checking in Bouncer 2018-01-01 16:40:07 +08:00
Lucas Nicodemus
4eebaf6c44 Rename methods that were ambiguous in meaning.
This renames some methods in the Utils class to better reflect what they
do or what they provide back. It should be clearer what these methods
are for now than before.
2017-12-29 08:50:48 -07:00
Lucas Nicodemus
2f7c146c89 Merge remote-tracking branch 'origin/general-devel' into oop 2017-12-27 19:01:38 -07:00
Lucas Nicodemus
1ea04ffd4f Remove Utils.ForceKick; use TSPlayer.Kick.
Some anti-cheat calls were changed to "You have been Bounced." I don't
think we need to tell clients why they were disconnected so they can
tune their hacks better.
2017-12-27 18:01:53 -07:00
Lucas Nicodemus
f79c6a2962 Move Utils.Kick to TSPlayer.Kick 2017-12-27 13:00:13 -07:00
Lucas Nicodemus
227125199a Merge remote-tracking branch 'origin/general-devel' into noclip 2017-12-26 20:33:22 -07:00
Lucas Nicodemus
793cfcb842 Remove broken noclip detection
See the changelog entry for this. Basically, it's worse to keep
confirmed broken noclip detection in, even if it detects noclip 90% of
the time, because a random hacker can make a better noclip system and
just evade it 100% of the time by exploiting holes.
2017-12-26 20:28:38 -07:00
Lucas Nicodemus
cfe8562e74
Merge branch 'general-devel' into fix-projectiles 2017-12-26 18:31:47 -07:00
Ziteng Wang
354d20bc1c Fix mass wire operation in Bouncer 2017-12-25 18:19:48 +08:00
Lucas Nicodemus
f2da3f6c83 Remove index check on Bouncer NewProjectiles
Note: even in the previous iteration of the code the search function
returned -1 if it couldn't find it in the system, which would have made
removal of projectiles by ident and owner impossible because they
weren't found anyway.

Either way, this is related to fixing #1584.
2017-12-24 20:13:53 -07:00
Lucas Nicodemus
848d3c4778 Merge branch 'hackedinventory' into crp 2017-12-22 10:18:51 -07:00
Lucas Nicodemus
e370873fff Warn players if they can't modify the world
This reimplements warnings that CheckTilePermissions previously had. It
defaults to on because every single call currently in TShock expects it
to be on.
2017-12-22 01:30:29 -07:00
Lucas Nicodemus
7b2a4494b5 Move ice tile processing to TSPlayer.
This moves ice tile placement and processing from
TShock.CheckTilePermissions to TSPlayer in the form of the new boolean
'HasModifiedIceSuccessfully.' This is such a stupid thing we have to
track, but we have to track it.

Previously, we duplicated all of the check permission code and inserted
special ice code paths. This duplicated a ton of code for little gain.
The result of moving everything is that the control flow is easier to
follow.

In Terraria ice tiles are placed and melt on a timer so it's necessary
to track them being placed and removed to permit tile events that would
otherwise be blocked due to region checks and stuff. They're usually
fairly harmless blocks, and without this code, ice wouldn't work
properly. It's not ideal for this to be in TShock at all.
2017-12-22 01:16:18 -07:00
Lucas Nicodemus
195a23a7e5 Migrate most of CheckTilePermission to TSPlayer
TShock.CheckTilePermission(ply, x, y, paint) has been replaced with
TSPlayer.HasPaintPermission and TSPlayer.HasBuildPermission
respectively. These two methods dramatically simplify the logic required
to process build permissions.

Still todo after this commit:

1. Implement warnings for when a player fails a permission check on
build. This is probably going to be accomplished by a default argument
to the HasBuildPermission signature.

2. Create a variant that checks for ice tile permission and use like
HasPaintPermission() so as to remove the other
TShock.CheckTilePermission method.

Annoyingly, all of the existing methods that start with Check seem to
"check" if they player _doesn't_ have permission (true = no permission),
which makes nearly every call negative.
2017-12-22 00:31:02 -07:00
Lucas Nicodemus
f93ffbc2e7 Implement named args in item stack hack check
This addresses feedback from @QuiCM and @ijwu, who pointed out that C#
allows you to specify the arguments that go into a call during
invocation, which dramatically improves readability.
2017-12-21 23:00:09 -07:00
Lucas Nicodemus
09121368e4 Move TShock.CheckRangePermission to TSPlayer
TShock.CheckRangePermission is now TSPlayer.IsInRange, but the most
important thing is that this method returns the opposite of what the
original did, so all of the calls that would go to it are now inverted.
2017-12-21 20:32:07 -07:00
Lucas Nicodemus
ef1486b78c Move OnGetSection to Bouncer
Bonus: Introduces a new GetDataHandledEventArgs for use in events that
have players, data, and need to be handled.

I was originally going to modify GetDataHandlerArgs, but that comes from
the EventArgs class of args that isn't handled, and changing that to
extend HandledEventArgs would imply we care or check to see if those are
handled and we don't so we're stuck with this implementation for a
teenie tiny bit.
2017-12-21 18:49:29 -07:00
Lucas Nicodemus
7730faf94f Change diction to refer to "saved data" on Disable 2017-12-21 08:22:51 -07:00
Lucas Nicodemus
ea630e5aa2 Rephrase SSC login message to avoid grammar choice 2017-12-20 21:32:56 -07:00
Chris
215970bab2
Merge branch 'general-devel' into checkignores 2017-12-21 13:28:06 +10:30
Lucas Nicodemus
e1e4f41118 Made disable message for login use specifier 2017-12-20 19:00:16 -07:00
Lucas Nicodemus
97f48d6d41 Renamed TSPlayer.CheckIgnores() -> TSPlayer.IsBeingDisabled()
Since all of the flags it was checking have been demystified, this
is pretty self explanatory now.
2017-12-20 17:42:59 -07:00
Lucas Nicodemus
8e5ee7d286 Renamed IgnoreActionsForClearingTrashCan to conform w/ changes
This just changes IgnoreActionsForClearingTrashCan to meet the
same naming scheme for the rest of the old ignore checks. For
consistency. Consistency is nice.
2017-12-20 17:33:18 -07:00
Lucas Nicodemus
4e186e7375 Replace TSPlayer.IgnoreActionsForDisabledArmor -> boolean
TSPlayer.IgnoreActionsForBannedArmor was useless because it only
stored the last armor/dye a player had. Replaced with a boolean.
2017-12-20 17:29:10 -07:00
Lucas Nicodemus
7efcfd055f Replace TSPlayer.IgnoreActionsForCheating w/ boolean
This replaces IgnoreActionsForCheating in TSPlayer with a new
IsDisabledForStackDetection field that tracks the same basic data.

The previous way we did this was storing a string as the "reason"
why a player was disabled for cheating, but it only stored the last
hacked item stack that caused the check to fail. Since we already
have OnSecondUpdate which notifies on _all_ items, we don't need
to store this info in such a useless way anyway. They'll find out
in one second what they need to remove in a more alarmist way.
2017-12-20 17:19:14 -07:00
Lucas Nicodemus
1ef28dfe0d Replace TSPlayer.IgnoreActionsForInventory => IsDisabledForSSC.
This is the first commit in a series to rewrite CheckIgnores()
into whatever its replacement becomes.

IgnoreActionsForInventory was probably used by the SSC system prior
to when we had in-game support for SSC (ergo, when we just checked
to make sure you had removed all items before joining and worked
our way up in inventory data to track it). I could be wrong about
this though.

Now, IsDisabledForSSC tracks only if a player is shut down due to
SSC, rather than a reason that gets broadcast.
2017-12-20 17:01:55 -07:00
Lucas Nicodemus
713dd2614a Fix regression where Bouncer would create dupe items on drop 2017-12-17 12:40:24 -07:00