veloren / veloren

An open world, open source voxel RPG inspired by Dwarf Fortress and Cube World. This repository is a mirror. Please submit all PRs and issues on our GitLab page.

Home Page:https://www.veloren.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server should remove player entity when player disconnects

zesterer opened this issue · comments

This is caused by the client failing to send a Disconnect packet to the server, due to the fact that the main thread ending in voxygen never gives the client threads time to do so.

Possible solution: refactor connection status to be a state machine rather than a simple boolean. The main thread should only shutdown once a terminal state is reached (i.e: with something like Client::wait_for_shutdown(client)).

Suggested states:

enum ClientState {
    PortNotBound,
    PendingConnection,
    DisconnectSent,
    Disconnected,
}

Removed 'good first issue' because solving this properly is something that requires refactoring a fair few things within the client.

I've partially solved this by fixing the client connection status system. It's now more of a state machine than a boolean "is/is not connected" thing. This means it does actually send a disconnect packet.

This also needs to be fixed server-side, but I feel like this plays into @terahxluna's event dispatching and server refactoring efforts now.