forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Don't delete players on death

Open nekiro opened this issue 4 years ago • 23 comments

Players shouldn't get logged out on death.

Would be great if this could get thoroughly tested.

nekiro avatar Dec 26 '20 03:12 nekiro

I like it, I'm going to try it

MillhioreBT avatar Dec 26 '20 06:12 MillhioreBT

Dont work and produce the following error: image this happens if you decide to log out instead of continuing, and if you continue, another violation occurs in any call to lua call protection function: image

MillhioreBT avatar Dec 26 '20 06:12 MillhioreBT

@MillhioreBT

Didn't happen to me on linux, didn't test on windows. But I see one possible reason for this. Check if it's better with new commit.

nekiro avatar Dec 26 '20 10:12 nekiro

The first error no longer occurs, but the second continues to appear every time I die with the character, it seems as if from lua it was trying to read a dead pointer or something like that, I will try to compile it with the base files instead of those from my sources to rule out possible errors in my sources

MillhioreBT avatar Dec 26 '20 13:12 MillhioreBT

I give up, I did more than 50 tests, in half the cases it seemed to work fine, but when reappearing, you would get guild shields and sometimes some npc icons, some actions such as seeing objects cause the crash, it is quite strange, and in the other half the server it just crashed when trying to move the character from its spawn location.

We hope someone else can check this, the truth is I feel sad that I can not have this functionality at first sight

MillhioreBT avatar Dec 26 '20 14:12 MillhioreBT

I give up, I did more than 50 tests, in half the cases it seemed to work fine, but when reappearing, you would get guild shields and sometimes some npc icons, some actions such as seeing objects cause the crash, it is quite strange, and in the other half the server it just crashed when trying to move the character from its spawn location.

We hope someone else can check this, the truth is I feel sad that I can not have this functionality at first sight

That's very odd. I tested with moving and generally still playing after dying and it didn't crash even once... It must be your custom source.

nekiro avatar Dec 26 '20 14:12 nekiro

I give up, I did more than 50 tests, in half the cases it seemed to work fine, but when reappearing, you would get guild shields and sometimes some npc icons, some actions such as seeing objects cause the crash, it is quite strange, and in the other half the server it just crashed when trying to move the character from its spawn location. We hope someone else can check this, the truth is I feel sad that I can not have this functionality at first sight

That's very odd. I tested with moving and generally still playing after dying and it didn't crash even once... It must be your custom source.

If it is surely that, since my sources support versions higher than 10.98, I should probably add something else to the changes you made so that then it can also work for me, in the meantime I will wait, I really don't have much idea how to make it work for me

MillhioreBT avatar Dec 26 '20 16:12 MillhioreBT

This would be the first PR that does not work for me in my custom fonts, it is quite rare, I hope that other people can try this and confirm if everything is fine or if they are also doing just as badly as me

my problem is related to the lua stack, in case someone else gives them an error and they relate it to the lua stack!

MillhioreBT avatar Dec 28 '20 17:12 MillhioreBT

This would be the first PR that does not work for me in my custom fonts, it is quite rare, I hope that other people can try this and confirm if everything is fine or if they are also doing just as badly as me

my problem is related to the lua stack, in case someone else gives them an error and they relate it to the lua stack!

It's probably related to your onDeath or onPrepareDeath events or maybe onThink events? If you could debug this and find the issue, it would be great. This might be issue with something you use (in lua) while tfs does not.

nekiro avatar Dec 28 '20 17:12 nekiro

This would be the first PR that does not work for me in my custom fonts, it is quite rare, I hope that other people can try this and confirm if everything is fine or if they are also doing just as badly as me my problem is related to the lua stack, in case someone else gives them an error and they relate it to the lua stack!

It's probably related to your onDeath or onPrepareDeath events or maybe onThink events? If you could debug this and find the issue, it would be great. This might be issue with something you use (in lua) while tfs does not.

i opened my server in debug mode, and put a breakpoint in the function here: image Then I started doing the tests, and indeed at this point the process was interrupted twice, it was enough to give it twice to continue and then everything happened according to your changes, everything perfect, then it disable the breakpoint and then the error happened , and it was always related to the lua stack, it seems like some lua script is running on a different thread and thus not syncing.

I'll try to keep checking this when I can, because I really want this, and I feel sad that I can't add this PR to my custom sources now

MillhioreBT avatar Dec 28 '20 23:12 MillhioreBT

I can't test but I have a question.

Will it fire onLogout after player click logout in client after death? Or how does it work? Because AFAIK before it didn't fire onLogout after death.

slawkens avatar Dec 29 '20 20:12 slawkens

I can't test but I have a question.

Will it fire onLogout after player click logout in client after death? Or how does it work? Because AFAIK before it didn't fire onLogout after death.

No it wont, because you aren't logging out. It will fire onLogout when you really logout, so when you are getting kicked for inactivity or when you decide to click cancel and not "OK" in the prompt.

nekiro avatar Dec 29 '20 22:12 nekiro

Try it: Die -> click to open Store (it will dont open nothing in case) -> make some right-clicks in the map or move with your keyboard I can't reproduce that 100% but if I keep trying, it will crash after few attempts

Diego-OT avatar Jan 05 '21 22:01 Diego-OT

Try it: Die -> click to open Store (it will dont open nothing in case) -> make some right-clicks in the map or move with your keyboard I can't reproduce that 100% but if I keep trying, it will crash after few attempts

Clicking "store" should probably kick out or respawn, cause it's not used atm, so clicking might have some unintended behaviour, good catch

nekiro avatar Jan 05 '21 23:01 nekiro

So I checked it and clicking store actually acts like clicking OK. So not sure what are you talking about. Client 1098.

nekiro avatar Jan 06 '21 12:01 nekiro

The store button works for me, in my case I use client 10 to this day it still works wonderfully

MillhioreBT avatar Jan 07 '21 05:01 MillhioreBT

I reviewed the changes and it's working fine (with store), I was confused the isRemoved() function with isDead() (I was sleepy) - I had some crashes with the players playing, I'm trying to reproduce the error myself but I couldn't sorry for the bad feedback

Edited: I reproduced some try it: crash 1: 1- Die with a normal player and do nothing 2- With GM use the command /c player

crash 2: 1- Die with a normal player and do nothing 2- With GM use the command /kick player

debbug and probably crash 3: 1- Die with a normal player and do nothing 2- With GM use the command /c player and the player should enter in one teleport (close all sqms near to player goes inside of it) 3- it's like cloning the player, will generate few debbugs

Also I think this function should have one check https://github.com/opentibiabr/otservbr-global/blob/develop/src/creature.cpp#L80 because I reproduced one of crashs in my test server with creature nullptr

Diego-OT avatar Jan 07 '21 15:01 Diego-OT

Works great, I'll be testing all night, then give my aprove 😍

MillhioreBT avatar Jan 10 '21 00:01 MillhioreBT

@Diego-OT could you check again after the latest changes please?

EPuncker avatar Jan 15 '21 20:01 EPuncker

@nekiro new problem to deal with, when you die your ID is deleted from the table: nextUseStaminaTime and therefore it will produce an error when receiving experience with the stamina option activated.

The problem is here: https://github.com/otland/forgottenserver/blob/7c0d29d95fe69a1d817c77fd5e752643243287f1/data/creaturescripts/scripts/playerdeath.lua#L6-L8

My temporary solution was to create a 30 second scheduled event to remove the key from the table, since 30 seconds is the maximum time the reconnect window can wait before automatically disconnecting completely, I think there are better ways to deal with this anyway.

MillhioreBT avatar Feb 13 '21 00:02 MillhioreBT

needs rebase

Any progress on this?

Zbizu avatar Sep 10 '21 07:09 Zbizu

I tested and:

1- Global when player dies, the player goes to the temple instantly, so when we exiva, the exiva will tell us that he is in the temple. Currently the exiva points to the location where the player died 2- Crash: Die with a normal player and do nothing. With GM use the command /c player 3- Player never logout if no button is pressed (not even after 60 seconds) due to sent/receive ping. Also, the byte 0x14 is only called at the time of death and therefore impossible to check after 60 seconds in the case. The bytes that keep sending are 0x1D 0x1C 0x1E

Diego-OT avatar Apr 19 '22 00:04 Diego-OT

is this buggy or does works?

pasturryx avatar Feb 15 '23 03:02 pasturryx