[Tux4kids-commits] r1239 - tuxmath/branches/lan/server
David Bruce
dbruce-guest at alioth.debian.org
Mon Jul 20 12:23:33 UTC 2009
Author: dbruce-guest
Date: 2009-07-20 12:23:33 +0000 (Mon, 20 Jul 2009)
New Revision: 1239
Modified:
tuxmath/branches/lan/server/server.c
tuxmath/branches/lan/server/testclient.c
Log:
implement question counter in client
Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c 2009-07-20 01:57:32 UTC (rev 1238)
+++ tuxmath/branches/lan/server/server.c 2009-07-20 12:23:33 UTC (rev 1239)
@@ -802,6 +802,7 @@
{
printf("Unable to send Question to %s\n", client[j].name);
}
+ send_counter_updates();
}
}
Modified: tuxmath/branches/lan/server/testclient.c
===================================================================
--- tuxmath/branches/lan/server/testclient.c 2009-07-20 01:57:32 UTC (rev 1238)
+++ tuxmath/branches/lan/server/testclient.c 2009-07-20 12:23:33 UTC (rev 1239)
@@ -65,6 +65,7 @@
/* Start out with our "comets" empty: */
erase_flashcard(&comets[0]);
erase_flashcard(&comets[1]);
+ printf("comets[0].question_id is %d\n", comets[0].question_id);
/* Connect to server, create socket set, get player nickname, etc: */
if(!LAN_Setup(argv[1], DEFAULT_PORT))
@@ -215,6 +216,7 @@
else if(strncmp(buf, "TOTAL_QUESTIONS", strlen("TOTAL_QUESTIONS")) == 0)
{
//update the "questions remaining" counter
+ total_quests_recvd(buf);
}
else if(strncmp(buf, "MISSION_ACCOMPLISHED", strlen("MISSION_ACCOMPLISHED")) == 0)
{
@@ -230,6 +232,8 @@
}
+
+
/* This function prints the 'msg' part of the buffer (i.e. everything */
/* after the first '\t') to stdout. */
int player_msg_recvd(char* buf)
@@ -249,6 +253,21 @@
}
+int total_quests_recvd(char* buf)
+{
+ char* p;
+ if(buf == NULL)
+ return 0;
+ p = strchr(buf, '\t');
+ if(p)
+ {
+ p++;
+ remaining_quests = atoi(p);
+ return 1;
+ }
+ else
+ return 0;
+}
@@ -378,8 +397,8 @@
return 0;
fc->formula_string[0] = '\0';
fc->answer_string[0] = '\0';
- int question_id = -1;
- int answer = 0;
- int difficulty = 0;
+ fc->question_id = -1;
+ fc->answer = 0;
+ fc->difficulty = 0;
return 1;
}
\ No newline at end of file
More information about the Tux4kids-commits
mailing list