Jump to content
Returning Members: Password Reset Required ×

[5187] Ghost sequence - delaying the ghost sequence to allow character to faceplant triggers race condition


Recommended Posts

Posted

Hi there,

I've attempted to delay the death sequence and also preventing movement that I've seen on various public sources that happens after a player dies.

To achieve this I've done the following:

Player dies

Apply status Freeze

Set a flag on the player server side indicating the player is in transition to death.

Kick off an function to occur in 2 seconds via a timer which applies Freeze + Die status to character and causes the revive button to appear.

The problem I'm encountering is there are instances where multiple entities can attack the same target while it does not have the die status on causing it to die multiple times from the entities. Usually this happens when the separate threads handling the monster AI are "killing" the player at exactly the same time before the player's alive status changes to In transition.

Programmatically I'm not sure how I can handle this concurrency problem, I guess it's effectively a race condition :\.

Posted
Yep, that's a race condition alright! It sounds like you might need to partition your AI threads a bit better. I'm not sure how you're splitting up your threads right now, but you might want to partition them by map or something like that. That way, only one AI thread is running per map. Though, if players and monsters can also attack at the same time, that might also be bad. I wrote an article about multi-threaded game servers here if you're interested in a few solutions / ideas: https://spirited.io/multi-threaded-game-server-design/.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...