mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-18 16:21:40 +00:00
remember network host connected to
This commit is contained in:
parent
bcb5ba5ad7
commit
798d4ca3bd
@ -3,6 +3,7 @@
|
||||
#include "multiplayer.hpp"
|
||||
#include "multiplayer_client.hpp"
|
||||
#include "playlevel.hpp"
|
||||
#include "preferences.hpp"
|
||||
#include "replay.hpp"
|
||||
#include "show_dialog.hpp"
|
||||
|
||||
@ -94,7 +95,7 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
|
||||
|
||||
const network::manager net_manager;
|
||||
|
||||
std::string host;
|
||||
std::string host = preferences::network_host();
|
||||
const int res = gui::show_dialog(disp,NULL,"","",
|
||||
gui::OK_CANCEL,NULL,NULL,
|
||||
string_table["remote_host"] + ": ",&host);
|
||||
@ -112,6 +113,8 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
|
||||
throw network::error(string_table["connection_timeout"]);
|
||||
}
|
||||
|
||||
preferences::set_network_host(host);
|
||||
|
||||
//if we got a gamelist back - otherwise we have
|
||||
//got a description of the game back
|
||||
const config* const gamelist = data.child("gamelist");
|
||||
|
@ -180,8 +180,7 @@ connection receive_data(config& cfg, connection connection_num, int timeout)
|
||||
}
|
||||
|
||||
if(buffer == "") {
|
||||
std::cerr << "error receiving data: " << (int)*i << "\n";
|
||||
throw error("error receiving data",*i);
|
||||
throw error("remote host closed connection",*i);
|
||||
}
|
||||
|
||||
if(buffer[buffer.size()-1] != 0) {
|
||||
|
@ -215,6 +215,16 @@ void set_grid(bool ison)
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& network_host()
|
||||
{
|
||||
return prefs["host"];
|
||||
}
|
||||
|
||||
void set_network_host(const std::string& host)
|
||||
{
|
||||
prefs["host"] = host;
|
||||
}
|
||||
|
||||
namespace {
|
||||
double scroll = 0.2;
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ namespace preferences {
|
||||
bool grid();
|
||||
void set_grid(bool ison);
|
||||
|
||||
const std::string& network_host();
|
||||
void set_network_host(const std::string& host);
|
||||
|
||||
double scroll_speed();
|
||||
double get_scroll_speed();
|
||||
void set_scroll_speed(double scroll);
|
||||
|
@ -183,7 +183,7 @@ int main()
|
||||
if(!e.socket) {
|
||||
std::cerr << "fatal network error: " << e.message << "\n";
|
||||
} else {
|
||||
std::cerr << "error with socket: " << e.message << "\n";
|
||||
std::cerr << "socket closed: " << e.message << "\n";
|
||||
|
||||
lobby_players.remove_player(e.socket);
|
||||
for(std::vector<game>::iterator i = games.begin();
|
||||
@ -191,8 +191,14 @@ int main()
|
||||
if(i->is_member(e.socket)) {
|
||||
i->disconnect();
|
||||
games.erase(i);
|
||||
e.socket = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(e.socket) {
|
||||
e.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user