mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add server/client annotations to settingtypes.txt and make use of them (#15756)
This commit is contained in:
parent
6724068659
commit
c30c94dfaa
12 changed files with 231 additions and 96 deletions
|
@ -508,7 +508,7 @@ protected:
|
|||
bool init(const std::string &map_dir, const std::string &address,
|
||||
u16 port, const SubgameSpec &gamespec);
|
||||
bool initSound();
|
||||
bool createSingleplayerServer(const std::string &map_dir,
|
||||
bool createServer(const std::string &map_dir,
|
||||
const SubgameSpec &gamespec, u16 port);
|
||||
void copyServerClientCache();
|
||||
|
||||
|
@ -908,7 +908,6 @@ bool Game::startup(bool *kill,
|
|||
|
||||
g_client_translations->clear();
|
||||
|
||||
// address can change if simple_singleplayer_mode
|
||||
if (!init(start_data.world_spec.path, start_data.address,
|
||||
start_data.socket_port, start_data.game_spec))
|
||||
return false;
|
||||
|
@ -1138,7 +1137,7 @@ bool Game::init(
|
|||
|
||||
// Create a server if not connecting to an existing one
|
||||
if (address.empty()) {
|
||||
if (!createSingleplayerServer(map_dir, gamespec, port))
|
||||
if (!createServer(map_dir, gamespec, port))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1173,7 +1172,7 @@ bool Game::initSound()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Game::createSingleplayerServer(const std::string &map_dir,
|
||||
bool Game::createServer(const std::string &map_dir,
|
||||
const SubgameSpec &gamespec, u16 port)
|
||||
{
|
||||
showOverlayMessage(N_("Creating server..."), 0, 5);
|
||||
|
@ -1389,7 +1388,6 @@ bool Game::connectToServer(const GameStartData &start_data,
|
|||
{
|
||||
*connect_ok = false; // Let's not be overly optimistic
|
||||
*connection_aborted = false;
|
||||
bool local_server_mode = false;
|
||||
const auto &address_name = start_data.address;
|
||||
|
||||
showOverlayMessage(N_("Resolving address..."), 0, 15);
|
||||
|
@ -1409,7 +1407,6 @@ bool Game::connectToServer(const GameStartData &start_data,
|
|||
} else {
|
||||
connect_address.setAddress(127, 0, 0, 1);
|
||||
}
|
||||
local_server_mode = true;
|
||||
}
|
||||
} catch (ResolveError &e) {
|
||||
*error_message = fmtgettext("Couldn't resolve address: %s", e.what());
|
||||
|
@ -1455,13 +1452,13 @@ bool Game::connectToServer(const GameStartData &start_data,
|
|||
|
||||
client->migrateModStorage();
|
||||
client->m_simple_singleplayer_mode = simple_singleplayer_mode;
|
||||
client->m_internal_server = !!server;
|
||||
|
||||
/*
|
||||
Wait for server to accept connection
|
||||
*/
|
||||
|
||||
client->connect(connect_address, address_name,
|
||||
simple_singleplayer_mode || local_server_mode);
|
||||
client->connect(connect_address, address_name);
|
||||
|
||||
try {
|
||||
input->clear();
|
||||
|
@ -1508,12 +1505,11 @@ bool Game::connectToServer(const GameStartData &start_data,
|
|||
}
|
||||
|
||||
wait_time += dtime;
|
||||
if (local_server_mode) {
|
||||
if (server) {
|
||||
// never time out
|
||||
} else if (wait_time > GAME_FALLBACK_TIMEOUT && !did_fallback) {
|
||||
if (!client->hasServerReplied() && fallback_address.isValid()) {
|
||||
client->connect(fallback_address, address_name,
|
||||
simple_singleplayer_mode || local_server_mode);
|
||||
client->connect(fallback_address, address_name);
|
||||
}
|
||||
did_fallback = true;
|
||||
} else if (wait_time > GAME_CONNECTION_TIMEOUT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue