mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Optional reconnect functionality
Enable the server to request the client to reconnect. This can be done with the now extended minetest.request_shutdown([reason], [reconnect]) setting.
This commit is contained in:
parent
1e0e85f82e
commit
3b50b2766a
25 changed files with 232 additions and 109 deletions
26
src/game.cpp
26
src/game.cpp
|
@ -1417,8 +1417,7 @@ struct VolatileRunFlags {
|
|||
* hides most of the stuff in this class (nothing in this class is required
|
||||
* by any other file) but exposes the public methods/data only.
|
||||
*/
|
||||
class Game
|
||||
{
|
||||
class Game {
|
||||
public:
|
||||
Game();
|
||||
~Game();
|
||||
|
@ -1434,6 +1433,7 @@ public:
|
|||
std::string *address,
|
||||
u16 port,
|
||||
std::string &error_message,
|
||||
bool *reconnect,
|
||||
ChatBackend *chat_backend,
|
||||
const SubgameSpec &gamespec, // Used for local game
|
||||
bool simple_singleplayer_mode);
|
||||
|
@ -1588,6 +1588,7 @@ private:
|
|||
scene::ISceneManager *smgr;
|
||||
bool *kill;
|
||||
std::string *error_message;
|
||||
bool *reconnect_requested;
|
||||
IGameDef *gamedef; // Convenience (same as *client)
|
||||
scene::ISceneNode *skybox;
|
||||
|
||||
|
@ -1716,17 +1717,19 @@ bool Game::startup(bool *kill,
|
|||
std::string *address, // can change if simple_singleplayer_mode
|
||||
u16 port,
|
||||
std::string &error_message,
|
||||
bool *reconnect,
|
||||
ChatBackend *chat_backend,
|
||||
const SubgameSpec &gamespec,
|
||||
bool simple_singleplayer_mode)
|
||||
{
|
||||
// "cache"
|
||||
this->device = device;
|
||||
this->kill = kill;
|
||||
this->error_message = &error_message;
|
||||
this->random_input = random_input;
|
||||
this->input = input;
|
||||
this->chat_backend = chat_backend;
|
||||
this->device = device;
|
||||
this->kill = kill;
|
||||
this->error_message = &error_message;
|
||||
this->reconnect_requested = reconnect;
|
||||
this->random_input = random_input;
|
||||
this->input = input;
|
||||
this->chat_backend = chat_backend;
|
||||
this->simple_singleplayer_mode = simple_singleplayer_mode;
|
||||
|
||||
driver = device->getVideoDriver();
|
||||
|
@ -2239,6 +2242,7 @@ bool Game::connectToServer(const std::string &playername,
|
|||
if (client->accessDenied()) {
|
||||
*error_message = "Access denied. Reason: "
|
||||
+ client->accessDeniedReason();
|
||||
*reconnect_requested = client->reconnectRequested();
|
||||
errorstream << *error_message << std::endl;
|
||||
break;
|
||||
}
|
||||
|
@ -2376,6 +2380,7 @@ inline bool Game::checkConnection()
|
|||
if (client->accessDenied()) {
|
||||
*error_message = "Access denied. Reason: "
|
||||
+ client->accessDeniedReason();
|
||||
*reconnect_requested = client->reconnectRequested();
|
||||
errorstream << *error_message << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -4330,6 +4335,7 @@ void the_game(bool *kill,
|
|||
|
||||
std::string &error_message,
|
||||
ChatBackend &chat_backend,
|
||||
bool *reconnect_requested,
|
||||
const SubgameSpec &gamespec, // Used for local game
|
||||
bool simple_singleplayer_mode)
|
||||
{
|
||||
|
@ -4344,8 +4350,8 @@ void the_game(bool *kill,
|
|||
try {
|
||||
|
||||
if (game.startup(kill, random_input, input, device, map_dir,
|
||||
playername, password, &server_address, port,
|
||||
error_message, &chat_backend, gamespec,
|
||||
playername, password, &server_address, port, error_message,
|
||||
reconnect_requested, &chat_backend, gamespec,
|
||||
simple_singleplayer_mode)) {
|
||||
game.run();
|
||||
game.shutdown();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue