Commit graph

376 commits

Author SHA1 Message Date
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
Lucas Nicodemus
9b419467d6
Replace NetworkText.FromLiteral("") with NetworkText.Empty
Thanks @deadsurgeon42
2017-04-20 00:31:33 -06:00
Lucas Nicodemus
2d14533172
Terraria 1.3.5 changes compile (NO GUARANTEES ON EXECUTING) 2017-04-19 18:21:34 -06:00
Lucas Nicodemus
b8dbdb9ff4
Final batch of .name changes 2017-04-19 17:41:15 -06:00
White
c4a3a9fb67 Updated Copyright for 2017 2017-03-13 12:17:16 +10:30
White
86c180c156 Spawning items by ID now actually uses the ID properly.
Fixes #1398
2017-03-13 11:45:32 +10:30
ProfessorXZ
7c8bf7712a Added TSPlayer.Logout() 2016-12-18 12:37:15 +01:00
White
739892a611 Added TSPlayer.KillPlayer() which uses NetMessage.SendPlayerDeath(...).
Changed /kill to use `TSPlayer.KillPlayer()`
2016-12-11 13:46:57 +10:30
Lucas Nicodemus
678f6c7cf8
Update to Mintaka (thanks @enerdy) 2016-12-06 17:36:44 -07:00
Zaicon Kiroshu
50d8b0db30 1.3.4.3 Update (API 1.26) 2016-11-19 17:05:08 -06:00
Hussein Farran
7d323f253a Merge pull request #1321 from DogooFalchion/ssc_join_inv
Enable user to upload their data from when they join as SSC
2016-10-23 20:58:40 -04:00
DogooFalchion
f1ce158efd Implement logic to store the data of a player when they join, and allow for a command to be run that will upload that data in place of their existing SSC data. 2016-10-23 18:11:44 -04:00
Lucas Nicodemus
a0c4864567
Removed all obsolete methods from TShock 2016-10-23 06:09:17 -06:00
Lucas Nicodemus
dce26d6928 Merge pull request #1310 from Simon311/general-devel
Fix for HealOtherPlayer exploit, also fix #1309
2016-10-17 08:51:19 -06:00
Simon
1460a7ad91 Fix for HealOtherPlayer exploit, also fix #1309 2016-10-17 15:51:49 +03:00
Adilson Carvalho
49b4effe74 Changed year to 2016 on all GPL headers 2016-10-16 17:06:02 -02:00
ProfessorXZ
e0f17b82ef SyncExtraValue validation. Fixes #1024 2016-08-10 11:25:03 +02:00