[Tux4kids-commits] r1475 - tuxmath/branches/lan/src
David Bruce
dbruce-guest at alioth.debian.org
Tue Sep 1 17:55:15 UTC 2009
Author: dbruce-guest
Date: 2009-09-01 17:55:15 +0000 (Tue, 01 Sep 2009)
New Revision: 1475
Modified:
tuxmath/branches/lan/src/game.c
tuxmath/branches/lan/src/highscore.c
tuxmath/branches/lan/src/network.c
tuxmath/branches/lan/src/network.h
tuxmath/branches/lan/src/titlescreen.c
Log:
refinement of LAN connection screen
Modified: tuxmath/branches/lan/src/game.c
===================================================================
--- tuxmath/branches/lan/src/game.c 2009-09-01 14:18:17 UTC (rev 1474)
+++ tuxmath/branches/lan/src/game.c 2009-09-01 17:55:15 UTC (rev 1475)
@@ -519,11 +519,8 @@
comet_ques->y = 0;
comet_ques->answer = 0;
num_comets_alive--;
- comet_ques->flashcard.formula_string[0] = '\0';
- comet_ques->flashcard.answer_string[0] = '\0';
- comet_ques->flashcard.question_id = -1;
- comet_ques->flashcard.answer = 0;
- comet_ques->flashcard.difficulty = 0;
+ erase_flashcard(&(comet_ques->flashcard));
+
return 1;
}
@@ -571,13 +568,18 @@
return 0;
if(comet_screen)
+ {
erase_comet_on_screen(comet_screen);
-
+ playsound(SND_SIZZLE);
+ }
//NOTE: normally the question should no longer be in the queue,
- //so the next statement should not be needed:
+ //so the next statement should get executed:
if(fc)
+ {
+ tmdprintf("Note - request to erase question still in queue: %s\n",
+ fc->formula_string);
erase_flashcard(fc);
-
+ }
return 1;
}
Modified: tuxmath/branches/lan/src/highscore.c
===================================================================
--- tuxmath/branches/lan/src/highscore.c 2009-09-01 14:18:17 UTC (rev 1474)
+++ tuxmath/branches/lan/src/highscore.c 2009-09-01 17:55:15 UTC (rev 1475)
@@ -917,7 +917,7 @@
SDL_EnableUNICODE(SDL_ENABLE);
#ifdef TUXMATH_DEBUG
- fprintf(stderr, "\nEnter HighScoreNameEntry()\n" );
+ fprintf(stderr, "\nEnter detecting_servers()\n" );
#endif
@@ -995,10 +995,15 @@
FreeSprite(Tux);
return 0;
}
+
+
finished = 1;
break; //So we quit scanning as soon as we connect
printf("connected\n");
- }
+ } else if (servers_found > 1)
+ {
+ //TODO display list of servers for player to choose from:
+ }
while (SDL_PollEvent(&event))
Modified: tuxmath/branches/lan/src/network.c
===================================================================
--- tuxmath/branches/lan/src/network.c 2009-09-01 14:18:17 UTC (rev 1474)
+++ tuxmath/branches/lan/src/network.c 2009-09-01 17:55:15 UTC (rev 1475)
@@ -27,6 +27,7 @@
SDLNet_SocketSet set;
IPaddress serv_ip;
ServerEntry servers[MAX_SERVERS];
+static int connected_server = -1;
/* Local function prototypes: */
int say_to_server(char *statement);
@@ -34,6 +35,7 @@
int add_to_server_list(UDPpacket* pkt);
void print_server_list(void);
+
int LAN_DetectServers(void)
{
UDPsocket udpsock = NULL;
@@ -110,18 +112,18 @@
num_servers = add_to_server_list(in);
}
}
- //Make sure we always scan at least five but not more than ten seconds:
+ //Make sure we always scan at least one but not more than five seconds:
+ Throttle(1000); //repeat once per second
seconds++;
- if(seconds < 5)
+ if(seconds < 1)
done = 0;
- if(seconds > 10)
+ if(seconds > 5)
done = 1;
- Throttle(1000); //repeat once per second
+
}
printf("done\n\n");
-
SDLNet_FreePacket(out);
SDLNet_FreePacket(in);
print_server_list();
@@ -131,19 +133,27 @@
char* LAN_ServerName(int i)
{
+ if(i < 0 || i > MAX_SERVERS)
+ return NULL;
if(servers[i].ip.host != 0)
return servers[i].name;
else
return NULL;
}
+char* LAN_ConnectedServerName(void)
+{
+ return servers[connected_server].name;
+}
-
//For the simple case where a single server is found, i is
//always 0. Otherwise the player has to review the choices
//via LAN_ServerName(i) to get the index
int LAN_AutoSetup(int i)
{
+ if(i < 0 || i > MAX_SERVERS)
+ return 0;
+
/* Open a connection based on autodetection routine: */
if (!(sd = SDLNet_TCP_Open(&servers[i].ip)))
{
@@ -165,6 +175,8 @@
// perhaps you need to restart the set and make it bigger...
}
+ // Success - record the index for future reference:
+ connected_server = i;
return 1;
}
Modified: tuxmath/branches/lan/src/network.h
===================================================================
--- tuxmath/branches/lan/src/network.h 2009-09-01 14:18:17 UTC (rev 1474)
+++ tuxmath/branches/lan/src/network.h 2009-09-01 17:55:15 UTC (rev 1475)
@@ -30,9 +30,9 @@
int LAN_DetectServers(void);
int LAN_AutoSetup(int i);
char* LAN_ServerName(int i);
+char* LAN_ConnectedServerName(void);
int LAN_Setup(char* host, int port);
void LAN_Cleanup(void);
-
int LAN_SetName(char* name);
/* Network replacement functions for mathcards "API": */
Modified: tuxmath/branches/lan/src/titlescreen.c
===================================================================
--- tuxmath/branches/lan/src/titlescreen.c 2009-09-01 14:18:17 UTC (rev 1474)
+++ tuxmath/branches/lan/src/titlescreen.c 2009-09-01 17:55:15 UTC (rev 1475)
@@ -896,7 +896,9 @@
{
if(detecting_servers(_("Detecting Servers"), _("Please Wait")))
{
- NameEntry(player_name, _("Enter your Name:"), _(""));
+ char buf[256];
+ snprintf(buf, 256, _("Connected to server: %s"), LAN_ConnectedServerName());
+ NameEntry(player_name, buf, _("Enter your Name:"));
LAN_SetName(player_name);
Ready(_("Click OK when Ready"));
LAN_StartGame();
More information about the Tux4kids-commits
mailing list