[Tux4kids-commits] r1280 - in tuxmath/branches/lan: server src
David Bruce
dbruce-guest at alioth.debian.org
Mon Jul 27 02:32:00 UTC 2009
Author: dbruce-guest
Date: 2009-07-27 02:31:58 +0000 (Mon, 27 Jul 2009)
New Revision: 1280
Modified:
tuxmath/branches/lan/server/server.c
tuxmath/branches/lan/server/testclient.c
tuxmath/branches/lan/src/network.c
Log:
minor tweaks of autodetection code
Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c 2009-07-26 20:24:48 UTC (rev 1279)
+++ tuxmath/branches/lan/server/server.c 2009-07-27 02:31:58 UTC (rev 1280)
@@ -111,7 +111,7 @@
}
printf("Enter the SERVER's NAME: \n");
- fgets(server_name,NAME_SIZE,stdin);
+ fgets(server_name, NAME_SIZE, stdin);
/* ------------- Main server loop: ------------------ */
while (!quit)
Modified: tuxmath/branches/lan/server/testclient.c
===================================================================
--- tuxmath/branches/lan/server/testclient.c 2009-07-26 20:24:48 UTC (rev 1279)
+++ tuxmath/branches/lan/server/testclient.c 2009-07-27 02:31:58 UTC (rev 1280)
@@ -66,7 +66,7 @@
char buf[NET_BUF_LEN]; // for network messages from server
char buffer[NET_BUF_LEN]; // for command-line input
int servers_found = 0;
- int server_number=-1;
+ int server_number= -1;
Uint32 server_ip = 0;
Uint16 server_port = DEFAULT_PORT;
@@ -90,13 +90,17 @@
printf("connected\n");
}
- else // More than one server - will have to get player selection
+ else // More than one server - will have to get player selection:
{
- printf("Following are the server's available\n");
- print_server_list();
- printf("Enter the SERVER NUMBER you would like to connect to:\n");
- scanf("%d",&server_number);
-
+ while(server_number < 0 || server_number >= servers_found)
+ {
+ printf("The following TuxMath servers were detected:\n");
+ print_server_list();
+ printf("Enter the SERVER NUMBER you would like to connect to:\n");
+ scanf("%d", &server_number);
+ if(server_number < 0 || server_number >= servers_found)
+ printf("Illegal value - try again.\n");
+ }
if(!LAN_AutoSetup(server_number)) //i.e.first (and only) entry in list
{
printf("setup_client() failed - exiting.\n");
Modified: tuxmath/branches/lan/src/network.c
===================================================================
--- tuxmath/branches/lan/src/network.c 2009-07-26 20:24:48 UTC (rev 1279)
+++ tuxmath/branches/lan/src/network.c 2009-07-27 02:31:58 UTC (rev 1280)
@@ -494,7 +494,7 @@
printf("Detected servers:\n");
while(i < MAX_SERVERS && servers[i].ip.host != 0)
{
- printf("Host %d:Tuxmath Server's NAME-------- %s\n", i,servers[i].name);
+ printf("SERVER NUMBER %d: %s\n", i, servers[i].name);
i++;
}
}
More information about the Tux4kids-commits
mailing list