Closed hlqkj closed 4 months ago
I think I may have worked this out, but not sure at all.
Curiosity time. Why do we have the cur_hp stored in the player meta at all? Is this to cover for some hack able to circumvent the engine persisting the player's HP?
IIRC it's actually because the engine DOESN'T persist the player's HP. I don't know if this behavior is vanilla or is being triggered by something else in musttest_game
, but it was certainly something I discovered and had to code around the last time the server had a major version update. OR, this could potentially be due to the engine refusing to persist an HP that's higher than the default 20.
If you've got time and interest, could you do some more tests? I can't see how this can be happening unless the xp.update_players_max_hp
function is somehow resurrecting you (hp > 0
) before you can press the respawn button.
cur_hp = max_hp
on line 82 should only ever be happening for new players. Established players should be ignoring that line per the condition on line 80.
The condition on line 80 actually pass for everyone logging in with zero hp: when reaching there cur_hp
is zero, both line 71 and 76 assign it like that (see also line 119).
I'll do another test later today, but I think I've already tried to comment out line 82 yesterday and the respawn button was then working as expected: that is, login in the outback with no hearts, then respawn in bed with full hearts when pressing the button. (Without commenting, when logging in dead I already had a full hp bar even before pressing the respawn button, instead.)
Sorry for waiting. I did another test and confirm all the above: line 82 do happen for any player (incl. non-new) if they join while dead, aka zero hp.
The problem commenting that line, is that makes things work for non-new players, but breaks them for new players joining.
I challenged my creativity and ended up with this (below): seems to work for both new, and dead non-new joins.
The trick seems to use the last_login
parameter passed to the on_joinplayer()
callback to know for sure if a join is new or not, ref. API docs.
D'oh! Somehow I misread if max_hp == 0 or cur_hp == 0 then
as if max_hp == 0 and cur_hp == 0 then
!
I don't think I knew about that bit in the API docs, could be useful.
Ok, I think I've got some stuff to work with. Thanks for the info!
Can I get away with a one-word fix? 974ba5a2e498f8dbe4e60dbcc4440cba66180a5f
Apologies - I didn't see this. Just tested it but somehow this didn't work. (It should have, though?) Doing more testing...
I'm arrogant, they say. So let me give you a suggestion: when you pull new code, also restart the server!
Edit, translation for others: it actually works, my bad: I forgot to restart the server after pulling the new code before testing it. Thank you very much BluebirdGreycoat! :)
This is actually not happening:
https://github.com/BluebirdGreycoat/musttest_game/blob/b8e3ebfa3d39176f4027ae066f71670b8a4b9e73/mods/welcome_msg/joinspec.lua#L58-L59
Happened to me yesterday: I somehow got disconnected while AFK, and dead. (Uh...) When I got back, the respawn form was correctly shown but hitting the button didn't help.
Seems the
on_respawnplayer
callback doesn't get called at all, with all the related consequences: no respawn in bed; no starting items in the Outback; permanent bones nohack state; anything else?Official Minetest 5.8.0 (uncracked, of course. Me no like cracks...)
Edit: there actually is a way out of this, that is dying again, possibly without picking anything up so to avoid coffin deployment and thus preserve XP. However, I'm reporting because non-tech players wouldn't even realize what happened, and eventually try to get back on their tracks using the Outback gate.