Commit graph

408 commits

Author SHA1 Message Date
Chris
d46f534533 Standardize permission rejection messages 2020-06-02 10:18:40 +09:30
Chris
badba523e7
Merge branch 'general-devel' into projectilestruct-addition 2020-06-01 19:12:38 +09:30
Chris
9fb27543b9 Some refactoring from feedback 2020-06-01 18:35:58 +09:30
Chris
36089d96bb Fix doors for real this time.
Should also fix tile entities (such as item frames, pylons) and other tile objects.
Further, fixes a longstanding issue with SendTileSquare that resulted in half squares being sent instead of full squares, causing visual bugs and desyncs most noticeable with doors
2020-06-01 15:12:45 +09:30
Patrikkk
9934a3935d ProjectileStruct - Adding extra data
Can we store the type of the recent projectile as well? This could be used in my upcoming PR regarding the golf packet where I check for recently created projectiles, and their types. Having only the index is not useful in this scenario, because the projectile can already be killed, so cannot access the Main.projectile array to get the projectile type.

Can this be public instead of internal? Developers could make good use of it, instead of having to implement their own version of RecentProjectiles in their plugins.
2020-05-30 11:22:50 +02:00
Chris
d4a0f47e45 WIP - splitting STS into new class and processing methods 2020-05-29 14:05:43 +09:30
Chris
6e4b6e1f5e Fix paint permission check 2020-05-29 13:58:44 +09:30
Zack
9209ac0b73
Apply suggestions from code review
Co-authored-by: Lucas Nicodemus <shank@shanked.me>
2020-05-24 04:19:00 -04:00
Olink
965361c406 Add a projectile tracker, so that we can allow fluid bombs. 2020-05-24 03:48:08 -04:00
Lucas Nicodemus
dbc4bd4747
Add verbose debug log for rangechecks 2020-05-22 22:16:41 -07:00
Chris
5d2945ab1f Change SendMessage & SendMessageFromPlayer to use FromLiteral not FromFormattable. Solves #1856 2020-05-23 13:05:22 +09:30
Chris
83eb707761 Update SendMessage and SendMessageFromPlayer to use inbuilt Terraria chat messaging 2020-05-22 13:27:03 +09:30
Axeel
56a9e27365
Fix player respawn again (#1830)
* fix respawn time unit, add spawn bouncer, add respawn time config warning

Co-authored-by: Lucas Nicodemus <shank@shanked.me>
2020-05-21 13:37:31 +08:00
鱼鱼
946d54b69e fix player spawn stuff 2020-05-20 21:27:49 +08:00
Patrikkk
2d5166cfa4 Updating SpawnPlayer and PlayerUpdate packet
Fixing the HasHackedItemStacks method by adding missing Void Vault check.
2020-05-18 00:04:49 +02:00
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
Lucas Nicodemus
70dd72443d Update copyright to 2019 again
Fixes #1658, most likely.
2019-03-29 17:16:37 -07:00
Egor
1eae5ae671 Remove TSPlayer.InitSpawn 2018-04-27 08:41:57 +03:00
Egor
ec44ae6ff6 Don't send PlayerTeam packet twice in SetTeam 2018-04-26 22:29:41 +03: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
Lucas Nicodemus
cb2ed84038 Revert "Add TSPlayer.ActivePlayers"
This reverts commit 17cfdc3a16.
2017-12-31 01:25:05 -07:00
Lucas Nicodemus
17cfdc3a16 Add TSPlayer.ActivePlayers 2017-12-31 01:13:03 -07:00
Lucas Nicodemus
3ac52091ea Move SendFileToUser to TSP.SendFileTextAsMessage.
This is not a great method, but it's actually the only method in TShock
that interpolates the %map% and %players% variables and it used in at
least three places in the codebase. Since it's already so specialized,
it's not worth changing it to take an actual File object, in my humble
opinion.

This also clarifies what the method does and what makes it special, as
opposed to being fairly generic.
2017-12-29 08:40:44 -07:00
Lucas Nicodemus
48393d60c7 Move SendMultipleMatchError to TSPlayer.
This is a great method for a player to have and not for the Utils class
to have.
2017-12-29 08:15:04 -07:00
Lucas Nicodemus
152c67f27c Move Utils.Ban -> TSPlayer.Ban.
Arguably, this is one of the more controversial methods that's being
kept. Because it kicks and bans a target player, it's more useful than
removing it and requiring people to interface with the TShock Ban
Manager directly (not a good move for the future). Whether or not this
method sucks is up for debate, but right now I think it's totally fine
to keep it around in a different location.
2017-12-29 08:00:30 -07:00
Lucas Nicodemus
f74a0f6a70 Merge remote-tracking branch 'origin/general-devel' into oop 2017-12-27 19:03:03 -07:00
Lucas Nicodemus
fc689dbbc5 Remove TSPlayer.KickAll
" Ivan - Today at 6:20 PM
@ ハクサロ wouldnt TSPlayer.All.Kick() do the trick?"
2017-12-27 18:21:16 -07:00
Lucas Nicodemus
8301d6a6f3 Remove Utils.ForceKickAll; add TSPlayer.KickAll. 2017-12-27 18:07:28 -07:00
Lucas Nicodemus
f79c6a2962 Move Utils.Kick to TSPlayer.Kick 2017-12-27 13:00:13 -07:00
Lucas Nicodemus
11920cde48 Move Utils.FindPlayer -> TSPlayer.FindByNameOrID.
This makes TShock more OOP like (get the matching players from the
player as opposed to getting the players from a random class that
shouldn't exist).
2017-12-26 20:53:00 -07:00
Lucas Nicodemus
5362389e71 Remove obsolete GiveItem call. 2017-12-26 20:04:22 -07:00
Lucas Nicodemus
3e6cc78a2c Remove obsolete GiveItemCheck. 2017-12-26 19:59:53 -07:00
Lucas Nicodemus
5e7cb92de0 Re-apply some changes 2017-12-22 21:18:47 -07:00
Lucas Nicodemus
5991802dce Revert "Clarify summary of TSPlayer.IsInRange"
This reverts commit c501a128ff.
2017-12-22 21:15:26 -07:00
Lucas Nicodemus
604b386cba Rescue lost work 2017-12-22 21:12:56 -07:00
Lucas Nicodemus
848d3c4778 Merge branch 'hackedinventory' into crp 2017-12-22 10:18:51 -07:00
Lucas Nicodemus
bfbe58e9ed Implement cooldown warnings on build permissions 2017-12-22 10:03:59 -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
f9a1819e26 Update grammar on stack cheat messages. 2017-12-21 17:16:57 -07:00
Lucas Nicodemus
8a43c701a3 Merge remote-tracking branch 'origin/general-devel' into hackedinventory 2017-12-21 16:59:12 -07:00
Lucas Nicodemus
b316ba8200 Move inventory stack hack detection to TSPlayer
Only called in one method, the stack hack detection can move to
TSPlayer as it only ever operates on one player.

In a future commit, this will replace the stack hack detection
OnSecondUpdate() and also set the disabled flag if a player has
a hacked stack when called.
2017-12-21 16:50:20 -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