Skip to content
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

Draft
wants to merge 9 commits into
base: general-devel
Choose a base branch
from

Conversation

hufang360
Copy link
Contributor

Fixed Server not tracks deaths, Now players can be viewed with the /death, /pvpdeath, /alldeath and /allpvpdeath commands.

…death`, `/pvpdeath`, `/alldeath` and `/allpvpdeath` commands.
hakusaro
hakusaro previously approved these changes Nov 1, 2022
Copy link
Member

@hakusaro hakusaro left a 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!

@hakusaro hakusaro requested a review from a team November 1, 2022 05:16
Copy link
Contributor

@drunderscore drunderscore left a 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.

Comment on lines 291 to 295
if (this.numberOfDeathsPVE > 0)
player.TPlayer.numberOfDeathsPVE = this.numberOfDeathsPVE;
if (this.numberOfDeathsPVP > 0)
player.TPlayer.numberOfDeathsPVP = this.numberOfDeathsPVP;

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Thank you so much. I'll fixed it.

Copy link
Contributor Author

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;
Copy link
Contributor Author

@hufang360 hufang360 Nov 9, 2022

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

hakusaro
hakusaro previously approved these changes Nov 10, 2022
@hakusaro
Copy link
Member

@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.

Copy link
Contributor

@drunderscore drunderscore left a 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.

Comment on lines 2709 to 2710
args.Player.Spawn(PlayerSpawnContext.SpawningIntoWorld);
return true;
Copy link
Contributor

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.

@ATFGK ATFGK mentioned this pull request Nov 27, 2022
@hakusaro
Copy link
Member

@drunderscore can you re-review this one?

@drunderscore
Copy link
Contributor

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.

  • Show that before login that local player has x deaths
  • Login to new user
  • Show new user has 0 deaths
  • Die
  • Before respawn, show user has 1 death
  • After respawn, show user does not still have 1 death as expected.
Screencast.from.11-28-2022.09.13.16.AM.webm

@sgkoishi
Copy link
Member

sgkoishi commented Dec 2, 2022

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?

@sgkoishi
Copy link
Member

sgkoishi commented Dec 3, 2022

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.

* Show that before login that local player has x deaths

* Login to new user

* Show new user has 0 deaths

* Die

* Before respawn, show user has 1 death

* After respawn, show user does not still have 1 death as expected.

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 🤔

@hakusaro hakusaro marked this pull request as draft December 6, 2022 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants