src/client.c

changeset 59
3fa1de896666
parent 55
54ea19938d57
child 64
4eda5df55f86
equal deleted inserted replaced
58:7ba8a97a8b6e 59:3fa1de896666
63 int client_run(Settings *settings) { 63 int client_run(Settings *settings) {
64 Server server; 64 Server server;
65 65
66 if (client_connect(&server, settings->serverhost, settings->port)) { 66 if (client_connect(&server, settings->serverhost, settings->port)) {
67 net_destroy(&server); 67 net_destroy(&server);
68 return EXIT_FAILURE; 68 return 1;
69 } 69 }
70 70
71 if (client_handshake(&server)) { 71 if (client_handshake(&server)) {
72 net_destroy(&server); 72 net_destroy(&server);
73 return EXIT_FAILURE; 73 return 1;
74 } 74 }
75 75
76 uint8_t code = net_recieve_code(server.fd); 76 uint8_t code = net_recieve_code(server.fd);
77 if (code == NETCODE_GAMEINFO) { 77 if (code == NETCODE_GAMEINFO) {
78 // Start new game 78 // Start new game
107 net_send_code(server.fd, NETCODE_DECLINE); 107 net_send_code(server.fd, NETCODE_DECLINE);
108 } 108 }
109 } else { 109 } else {
110 addstr("Server sent invalid gameinfo."); 110 addstr("Server sent invalid gameinfo.");
111 net_destroy(&server); 111 net_destroy(&server);
112 return EXIT_FAILURE; 112 return 1;
113 } 113 }
114 114
115 net_destroy(&server); 115 net_destroy(&server);
116 return EXIT_SUCCESS; 116 return 0;
117 } 117 }

mercurial