src/server.c

changeset 46
4dcfb4c58b6d
parent 34
c4d4b8a8f902
child 51
84f2e380a434
equal deleted inserted replaced
45:e14a1d9aa91d 46:4dcfb4c58b6d
52 if (net_recieve_code(client->fd) != NETCODE_VERSION) { 52 if (net_recieve_code(client->fd) != NETCODE_VERSION) {
53 addstr("Client uses an incompatible software version."); 53 addstr("Client uses an incompatible software version.");
54 return 1; 54 return 1;
55 } 55 }
56 56
57 printw("Client connected - transmitting gameinfo..."); 57 addstr("Client connected - transmitting gameinfo...");
58 refresh(); 58 refresh();
59 59
60 return 0; 60 return 0;
61 } 61 }
62 62
76 } 76 }
77 77
78 int fd = server.client->fd; 78 int fd = server.client->fd;
79 net_send_data(fd, NETCODE_GAMEINFO, 79 net_send_data(fd, NETCODE_GAMEINFO,
80 &(settings->gameinfo), sizeof(GameInfo)); 80 &(settings->gameinfo), sizeof(GameInfo));
81 printw("\rClient connected - awaiting challenge acceptance..."); 81 addstr("\rClient connected - awaiting challenge acceptance...");
82 refresh(); 82 refresh();
83 int code = net_recieve_code(fd); 83 int code = net_recieve_code(fd);
84 if (code == NETCODE_ACCEPT) { 84 if (code == NETCODE_ACCEPT) {
85 printw("\rClient connected - challenge accepted."); 85 addstr("\rClient connected - challenge accepted.");
86 clrtoeol(); 86 clrtoeol();
87 87
88 game_start(settings, fd); 88 game_start(settings, fd);
89 } else if (code == NETCODE_DECLINE) { 89 } else if (code == NETCODE_DECLINE) {
90 printw("\rClient connected - challenge declined."); 90 addstr("\rClient connected - challenge declined.");
91 clrtoeol();
92 } else if (code == NETCODE_CONNLOST) {
93 addstr("\rClient connected - but gave no response.");
91 clrtoeol(); 94 clrtoeol();
92 } else { 95 } else {
93 addstr("\rInvalid client response"); 96 addstr("\rInvalid client response");
94 clrtoeol(); 97 clrtoeol();
95 98

mercurial