made dwarves more heavily armored.
Fixed 'reconnect forever' bug in networking
This commit is contained in:
parent
2d814ddd4c
commit
54b97c8332
8 changed files with 49 additions and 34 deletions
|
@ -14,6 +14,13 @@ ability=leadership
|
|||
usage=fighter
|
||||
unit_description="The dwarves are an ancient race of powerful fighters. Their berserker can wield a battle axe in a deadly manner, or throw himself into a mad frenzy that forgoes all defense to double his attack power, or even throw knives to hit his enemies from a distance. Besides all that, the mighty presence of the dwarvish berserker inspires the troops of lower level around him, giving them a boost in their attacks."
|
||||
get_hit_sound=groan.wav
|
||||
[resistance]
|
||||
blade=70
|
||||
pierce=80
|
||||
blunt=80
|
||||
fire=90
|
||||
cold=80
|
||||
[/resistance]
|
||||
[attack]
|
||||
name=battle axe
|
||||
type=blade
|
||||
|
|
|
@ -14,6 +14,13 @@ cost=15
|
|||
usage=fighter
|
||||
unit_description="The Dwarvish Fighters are excellent underground and in mountainous terrain. Skilled at close range combat, the sheer power of their battle axe makes them a feared opponent. Their power and endurance makes up for their slow speed."
|
||||
get_hit_sound=groan.wav
|
||||
[resistance]
|
||||
blade=70
|
||||
pierce=80
|
||||
impact=80
|
||||
fire=90
|
||||
cold=80
|
||||
[/resistance]
|
||||
[attack]
|
||||
name=axe
|
||||
type=blade
|
||||
|
|
|
@ -13,13 +13,11 @@ advanceto=null
|
|||
cost=100
|
||||
usage=fighter
|
||||
[resistance]
|
||||
blade=80
|
||||
[/resistance]
|
||||
[resistance]
|
||||
pierce=80
|
||||
[/resistance]
|
||||
[resistance]
|
||||
impact=80
|
||||
blade=60
|
||||
pierce=70
|
||||
impact=70
|
||||
fire=90
|
||||
cold=80
|
||||
[/resistance]
|
||||
unit_description="The dwarvish lord is the king under the mountains. His skill with the battle axe is unparalled, and he is able to even hit enemies that are far away from him. His armour is made by the fine alloys crafter by his kin."
|
||||
get_hit_sound=groan.wav
|
||||
|
|
|
@ -6,13 +6,11 @@ image_defensive=dwarf-warrior-defend.png
|
|||
hitpoints=48
|
||||
movement_type=mountainfoot
|
||||
[resistance]
|
||||
blade=80
|
||||
[/resistance]
|
||||
[resistance]
|
||||
pierce=80
|
||||
[/resistance]
|
||||
[resistance]
|
||||
impact=80
|
||||
blade=60
|
||||
pierce=70
|
||||
impact=70
|
||||
fire=90
|
||||
cold=80
|
||||
[/resistance]
|
||||
movement=4
|
||||
experience=58
|
||||
|
|
|
@ -15,6 +15,14 @@ usage=fighter
|
|||
unit_description="Dwarvish Thunderers provide the dwarvish armies with a much needed ranged support to their mighty yet slow close range fighters. Their heavy muskets are slower, ruder and noisier than the elegant and swift elvish bows, but their firepower and punch is unmatched."
|
||||
get_hit_sound=groan.wav
|
||||
|
||||
[resistance]
|
||||
blade=70
|
||||
pierce=80
|
||||
impact=80
|
||||
fire=90
|
||||
cold=80
|
||||
[/resistance]
|
||||
|
||||
[attack]
|
||||
name=knife
|
||||
type=blade
|
||||
|
@ -36,7 +44,7 @@ get_hit_sound=groan.wav
|
|||
[/attack]
|
||||
|
||||
[attack]
|
||||
name=musket
|
||||
name=thunderstick
|
||||
type=pierce
|
||||
range=long
|
||||
damage=18
|
||||
|
|
|
@ -168,7 +168,7 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
|
|||
|
||||
network::connection sock;
|
||||
|
||||
int pos = host.find_first_of(":");
|
||||
const int pos = host.find_first_of(":");
|
||||
|
||||
if(pos == -1) {
|
||||
sock = network::connect(host);
|
||||
|
@ -178,7 +178,6 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
|
|||
|
||||
config sides, data;
|
||||
|
||||
|
||||
network::connection data_res = gui::network_data_dialog(disp,string_table["connecting_remote"],data);
|
||||
check_response(data_res,data);
|
||||
|
||||
|
@ -188,7 +187,7 @@ void play_multiplayer_client(display& disp, game_data& units_data, config& cfg,
|
|||
const std::string& version = data["version"];
|
||||
if(version.empty() == false && version != game_config::version) {
|
||||
throw network::error("The server requires version '" + version
|
||||
+ "' while you are using version'" + game_config::version + "'");
|
||||
+ "' while you are using version '" + game_config::version + "'");
|
||||
}
|
||||
|
||||
bool logged_in = false;
|
||||
|
|
|
@ -28,7 +28,7 @@ partial_map::const_iterator current_connection = received_data.end();
|
|||
|
||||
TCPsocket server_socket;
|
||||
|
||||
std::queue<network::connection> disconnection_queue;
|
||||
std::deque<network::connection> disconnection_queue;
|
||||
std::set<network::connection> bad_sockets;
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,9 @@ namespace network {
|
|||
|
||||
error::error(const std::string& msg, connection sock) : message(msg), socket(sock)
|
||||
{
|
||||
bad_sockets.insert(socket);
|
||||
if(socket) {
|
||||
bad_sockets.insert(socket);
|
||||
}
|
||||
}
|
||||
|
||||
void error::disconnect()
|
||||
|
@ -106,9 +108,7 @@ connection connect(const std::string& host, int port)
|
|||
throw error(SDLNet_GetError());
|
||||
}
|
||||
|
||||
std::cerr << "opening connection\n";
|
||||
TCPsocket sock = SDLNet_TCP_Open(&ip);
|
||||
std::cerr << "opened connection okay\n";
|
||||
if(!sock) {
|
||||
throw error(SDLNet_GetError());
|
||||
}
|
||||
|
@ -144,8 +144,6 @@ connection accept_connection()
|
|||
|
||||
assert(sock != server_socket);
|
||||
sockets.push_back(sock);
|
||||
std::cerr << "new socket: " << sock << "\n";
|
||||
std::cerr << "server socket: " << server_socket << "\n";
|
||||
}
|
||||
|
||||
return sock;
|
||||
|
@ -154,27 +152,29 @@ connection accept_connection()
|
|||
void disconnect(connection s)
|
||||
{
|
||||
if(s == 0) {
|
||||
std::cerr << "closing all sockets " << sockets.size() << "\n";
|
||||
while(sockets.empty() == false) {
|
||||
assert(sockets.back() != 0);
|
||||
disconnect(sockets.back());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "closing socket " << (int)s << "\n";
|
||||
|
||||
bad_sockets.erase(s);
|
||||
received_data.erase(s);
|
||||
current_connection = received_data.end();
|
||||
|
||||
std::deque<network::connection>::iterator dqi = std::find(disconnection_queue.begin(),disconnection_queue.end(),s);
|
||||
if(dqi != disconnection_queue.end()) {
|
||||
disconnection_queue.erase(dqi);
|
||||
}
|
||||
|
||||
const sockets_list::iterator i = std::find(sockets.begin(),sockets.end(),s);
|
||||
if(i != sockets.end()) {
|
||||
sockets.erase(i);
|
||||
SDLNet_TCP_DelSocket(socket_set,s);
|
||||
SDLNet_TCP_Close(s);
|
||||
} else {
|
||||
std::cerr << "Could not find socket to close: " << (int)s << "\n";
|
||||
if(sockets.size() == 1) {
|
||||
std::cerr << "valid socket: " << (int)*sockets.begin() << "\n";
|
||||
}
|
||||
|
@ -183,19 +183,18 @@ void disconnect(connection s)
|
|||
|
||||
void queue_disconnect(network::connection sock)
|
||||
{
|
||||
disconnection_queue.push(sock);
|
||||
disconnection_queue.push_back(sock);
|
||||
}
|
||||
|
||||
connection receive_data(config& cfg, connection connection_num, int timeout)
|
||||
{
|
||||
if(disconnection_queue.empty() == false) {
|
||||
const network::connection sock = disconnection_queue.front();
|
||||
disconnection_queue.pop();
|
||||
disconnection_queue.pop_front();
|
||||
throw error("",sock);
|
||||
}
|
||||
|
||||
if(bad_sockets.count(connection_num) || bad_sockets.count(0))
|
||||
{
|
||||
if(bad_sockets.count(connection_num) || bad_sockets.count(0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ textbox::textbox(display& disp, int width, const std::string& text)
|
|||
{
|
||||
static const SDL_Rect area = disp.screen_area();
|
||||
const int height = font::draw_text(NULL,area,font_size,font::NORMAL_COLOUR,"ABCD",0,0).h;
|
||||
std::cerr << "initializing textbox with height " << height << "\n";
|
||||
const SDL_Rect starting_rect = {0,0,width,height};
|
||||
set_location(starting_rect);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue