-
-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Server not tracks deaths, Now players can be viewed with the /death
, /pvpdeath
, /alldeath
and /allpvpdeath
commands.
#2768
base: general-devel
Are you sure you want to change the base?
Conversation
…death`, `/pvpdeath`, `/alldeath` and `/allpvpdeath` commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your contributions! This looks good to me, but another person needs to review this besides me before merging!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like logging into a brand-new user (never before logged into) will allow the player to retain the death counter they previously had (be it from our SSC of another user after /logout
, or the character they are joining with), instead of defaulting to 0
.
Reproduction steps:
- Execute
/user add bruh bruh default
in console - Join server
- Execute
/login bruh bruh
- Observe that the death counts from the joining character are preserved.
Otherwise, once the user has existed, it seems it counts properly, and logging in and out to different users properly updates the count.
TShockAPI/PlayerData.cs
Outdated
if (this.numberOfDeathsPVE > 0) | ||
player.TPlayer.numberOfDeathsPVE = this.numberOfDeathsPVE; | ||
if (this.numberOfDeathsPVP > 0) | ||
player.TPlayer.numberOfDeathsPVP = this.numberOfDeathsPVP; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks suspicious... why are only death counts that are greater than 0
allowed to override the player's data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like logging into a brand-new user (never before logged into) will allow the player to retain the death counter they previously had (be it from our SSC of another user after
/logout
, or the character they are joining with), instead of defaulting to0
.Reproduction steps:
- Execute
/user add bruh bruh default
in console- Join server
- Execute
/login bruh bruh
- Observe that the death counts from the joining character are preserved.
Otherwise, once the user has existed, it seems it counts properly, and logging in and out to different users properly updates the count.
Thank you so much. I'll fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks suspicious... why are only death counts that are greater than
0
allowed to override the player's data?
Because, the this.numberOfDeathsPVE
variable may be null, When "HandleSpawn" event can read the value is 9985.
It isn't always good, i need make change.
Refer: #2758 (comment)
@@ -140,6 +142,8 @@ public void CopyCharacter(TSPlayer player) | |||
this.usedAmbrosia = player.TPlayer.usedAmbrosia ? 1 : 0; | |||
this.unlockedSuperCart = player.TPlayer.unlockedSuperCart ? 1 : 0; | |||
this.enabledSuperCart = player.TPlayer.enabledSuperCart ? 1 : 0; | |||
this.numberOfDeathsPVE = player.TPlayer.numberOfDeathsPVE; | |||
this.numberOfDeathsPVP = player.TPlayer.numberOfDeathsPVP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change this, It seems work. Can you review it agrain. @drunderscore
@hufang360 I'm happy with this but it probably won't make 5.1, likely 5.2. This is because of the newest terraria release. Sorry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue of newly-created users inheriting the previous death count is fixed now, but something is still wrong unfortunately...
Dying will properly increment the death counter (executing /deaths
whilst dead shows the correct number), but once the player respawns, their local death count will override the server's.
TShockAPI/GetDataHandlers.cs
Outdated
args.Player.Spawn(PlayerSpawnContext.SpawningIntoWorld); | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dangerous change here -- when SpawningIntoWorld
with non-matching death counts (which is likely), we will no longer call the OnPlayerSpawn
handler, which is very much unexpected and will cause issue with plugins.
This entire check should be moved below the OnPlayerSpawn
handler call.
@drunderscore can you re-review this one? |
Something still isn't correct -- the same issue as above persists, where in death the counter holds the expected value, but once the player respawns, their local player's death count is respected. I've attached a video to show exactly what I'm talking about.
Screencast.from.11-28-2022.09.13.16.AM.webm |
From the video, it seems that the player starts with 12544 times and ended up with 12545, which probably indicates that the client is maintaining their local count and send to the server and overwrite it. Does the server side 0-1 count ever reach the client? |
The player initiates the Spawn process, and sends the local count to the server; to overwrite we need to let the server send Spawn again (double spawn!). We could initiate an extra server Spawn once per (after) login, or once after death. This might look awkward but probably the only way 🤔 |
Fixed Server not tracks deaths, Now players can be viewed with the
/death
,/pvpdeath
,/alldeath
and/allpvpdeath
commands.