Commit graph

442 commits

Author SHA1 Message Date
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
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
c1de974e16 Remove happiness.
http://rubyonrails.org/doctrine

The problem with most programmers is that they refuse to see any
logic in thinking about a problem from the other side, even just
once. You can't argue with someone over what opinionated "programmer
happiness" things are because logically you'll always be outmatched
with "well you can just do it this other way."

Take this example. How is !args.Player.HasProjectilePermission any
easier to understand than args.Player.LacksProjectilePermission?
 -> One is direct: it focuses on what a player doesn't have.
 -> The other is indirect: it's the inverse of have.

You can read one in a sentence and think "so if a player lacks a
permission then this happens" whereas the other is like "invert
if a player has a permission." In this soupy mess of a codebase
where you're trying to sort out what 300 magic numbers mean and
what everything else is trying to do, then it's kinda nice to
be able to read something and understand it immediately.
2017-12-17 01:10:32 -07:00
Lucas Nicodemus
1e9532a316 Create TSPlayer.IsBouncerThrottled() to avoid code copypasta 2017-12-16 01:14:39 -07:00
Lucas Nicodemus
1bee289daf Move TShock.CheckIgnores(TSPlayer) -> TSPlayer.CheckIgnores()
Note: This method really sucks and needs to be rebuilt anyway.
2017-12-16 01:03:05 -07:00
Lucas Nicodemus
ba851d3570 Remove TShock.CheckProjectilePermission
Add TSPlayer.HasProjectilePermission() and its inverse:
	TSPlayer.LacksProjectilePermission()
2017-12-10 23:38:03 -07:00
Lucas Nicodemus
031398591a Merge remote-tracking branch 'origin/general-devel' into fragments 2017-12-09 08:44:49 -07:00
Lucas Nicodemus
eed7b3fad2 Document what TSPlayer.SendTileSquare does 2017-12-09 01:35:27 -07:00
Edgar Luque
6589531868 Renamed TShockAPI.DB 'User' to 'UserAccount' 2017-12-08 01:38:15 +01:00
Lucas Nicodemus
3a8aa7fa29 Brilliant idea: Remove unused code instead of leaving it there. 2017-12-02 14:28:12 -07:00
Ruby Rose
685d9964f0 Change enum names for clarity 2017-07-17 09:06:29 +03:00
Ruby Rose
79f66f554f Turn the player hooks into a tristate 2017-07-17 09:06:29 +03:00
MarioE
ac8fe2a215 Remove netID handling of GiveItem, and provide a smaller overload 2017-07-15 13:32:35 -06:00
Ruby Rose
8ae0a3b5a6 Write proper docs 2017-06-08 17:18:38 +03:00
Ruby Rose
81cb1381b4 Add hooks for item/projectile/tile bans 2017-06-07 15:32:40 +03:00
ZIT WANG
85b0b7bc6a Fix an itemban issue due to localization 2017-04-26 19:26:54 +08:00
White
e1919adfb2 Fixes { and } breaking server message broadcasts 2017-04-25 11:32:39 +09:30