[Tux4kids-commits] r1500 - in tuxmath/trunk: server src
David Bruce
dbruce-guest at alioth.debian.org
Wed Sep 9 22:28:09 UTC 2009
Author: dbruce-guest
Date: 2009-09-09 22:28:09 +0000 (Wed, 09 Sep 2009)
New Revision: 1500
Modified:
tuxmath/trunk/server/server.c
tuxmath/trunk/src/game.c
tuxmath/trunk/src/transtruct.h
Log:
progress on lan play bug
Modified: tuxmath/trunk/server/server.c
===================================================================
--- tuxmath/trunk/server/server.c 2009-09-09 16:56:46 UTC (rev 1499)
+++ tuxmath/trunk/server/server.c 2009-09-09 22:28:09 UTC (rev 1500)
@@ -1036,40 +1036,6 @@
-
-
-
-//function to send a flashcard(question) from the server to the client
-// int SendQuestion(MC_FlashCard flash, TCPsocket client_sock)
-// {
-// int x;
-//
-// char buf[NET_BUF_LEN];
-//
-// if(client_sock == NULL)
-// return 0;
-//
-// snprintf(buf, NET_BUF_LEN,
-// "%s\t%d\t%d\t%d\t%s\t%s\n",
-// "SEND_QUESTION",
-// flash.question_id,
-// flash.difficulty,
-// flash.answer,
-// flash.answer_string,
-// flash.formula_string);
-// x = SDLNet_TCP_Send(client_sock, buf, sizeof(buf));
-//
-// #ifdef LAN_DEBUG
-// printf("SendQuestion() - buf sent:::: %d bytes\n", x);
-// printf("buf is: %s\n", buf);
-// #endif
-//
-// if (x == 0)
-// return 0;
-// return 1;
-// }
-
-
/*Function to send any messages to the client be it any warnings
or anything the client is made to be informed */
int SendMessage(int message, int ques_id, char *name, TCPsocket client_sock)
Modified: tuxmath/trunk/src/game.c
===================================================================
--- tuxmath/trunk/src/game.c 2009-09-09 16:56:46 UTC (rev 1499)
+++ tuxmath/trunk/src/game.c 2009-09-09 22:28:09 UTC (rev 1500)
@@ -42,6 +42,7 @@
#include "titlescreen.h"
#include "options.h"
#include "SDL_extras.h"
+#include "pixels.h"
#include "throttle.h"
/* Make sure we don't try to call network code if we built without */
@@ -103,7 +104,6 @@
static int tux_anim;
static int tux_anim_frame;
static int num_cities_alive;
-//static int num_comets_alive;
static int tux_img;
static int old_tux_img;
static int frame;
@@ -206,9 +206,7 @@
static void game_recalc_positions(void);
void putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
-void seperate_commmand_and_buf(char command[NET_BUF_LEN],char buf[NET_BUF_LEN]);
-
/*****************************************************/
#ifdef HAVE_LIBSDL_NET
int add_quest_recvd(char* buf);
@@ -235,7 +233,6 @@
int game(void)
{
char buf[NET_BUF_LEN];
- char command[NET_BUF_LEN];
DEBUGMSG(debug_game, "Entering game():\n");
@@ -250,9 +247,6 @@
if (!game_initialize())
{
fprintf(stderr, "\ngame_initialize() failed!");
- /* return 0 so we go back to Options screen - maybe */
- /* player simply has all operations deselected */
-// free_on_exit();
return 0;
}
@@ -307,10 +301,9 @@
}
else
{
- if (add_comet())
- {
- num_attackers--;
- }
+ if(num_attackers > 0)
+ if(add_comet())
+ num_attackers--;
}
/* Most code now in smaller functions: */
@@ -572,6 +565,12 @@
DEBUGCODE(debug_game) print_current_quests();
+ /* If we have an open comet slot, put question in: */
+
+ if(num_attackers > 0)
+ if(add_comet())
+ num_attackers--;
+
return 1;
}
@@ -582,6 +581,9 @@
char* p = NULL;
MC_FlashCard* fc = NULL;
comet_type* comet_screen;
+
+ return 0;
+
if(!buf)
return 0;
@@ -693,12 +695,11 @@
printf("buf is %s\n", buf);
}
- else if(strncmp(buf, "SEND_QUESTION", strlen("SEND_QUESTION")) == 0)
+ else if(strncmp(buf, "ADD_QUESTION", strlen("ADD_QUESTION")) == 0)
{
if(!add_quest_recvd(buf))
- printf("SEND_QUESTION received but could not add question\n");
- else
- // If we successfully added question, show new questions to user:
+ printf("ADD_QUESTION received but could not add question\n");
+ else
DEBUGCODE(debug_game) print_current_quests();
}
@@ -710,14 +711,6 @@
DEBUGCODE(debug_game) print_current_quests();
}
- else if(strncmp(buf, "ADD_QUESTION", strlen("ADD_QUESTION")) == 0)
- {
- if(!add_quest_recvd(buf))
- printf("ADD_QUESTION received but could not add question\n");
- else
- DEBUGCODE(debug_game) print_current_quests();
- }
-
else if(strncmp(buf,"TOTAL_QUESTIONS", strlen("TOTAL_QUESTIONS"))==0)
{
sscanf(buf,"%*s %d", &total_questions_left);
@@ -2709,13 +2702,18 @@
int i;
int next_wave_comets;
int use_feedback;
- float comet_avg_height,height_differential;
+ float comet_avg_height, height_differential;
/* Clear all comets: */
for (i = 0; i < MAX_COMETS; i++)
{
+ DEBUGCODE(debug_game)
+ {
+ if(comets[i].alive)
+ printf("Warning - resetting comets but comet[%d| still alive\n", i);
+ }
comets[i].alive = 0;
}
// num_comets_alive = 0;
@@ -2887,10 +2885,9 @@
if (comets[i].alive)
if (comets[i].y < y_spacing)
{
-// DEBUGMSG(debug_game, "add_comet() - returning because comet[%d] not"static int found;
-
-// " far enough down: %f\n", i, comets[i].y);
-// return 0;
+ DEBUGMSG(debug_game, "add_comet() - returning because comet[%d] not"
+ " far enough down: %f\n", i, comets[i].y);
+ return 0;
}
}
@@ -2936,7 +2933,6 @@
{
DEBUGMSG(debug_game, "add_comet() called but no question available in queue\n");
return 0; DEBUGCODE(debug_game) print_current_quests();
-
}
#endif
}
@@ -2946,8 +2942,8 @@
if(Opts_LanMode())
{
- copy_card(&(comets_questions[i]), &(comets[com_found].flashcard));
- erase_flashcard(&(comets_questions[i]));
+ copy_card(&(comets_questions[q_found]), &(comets[com_found].flashcard));
+ erase_flashcard(&(comets_questions[q_found]));
}
else // Not LAN mode - just get question with direct call:
{
@@ -3789,21 +3785,7 @@
}
}
-/* Copy the command name out of the tab-delimited buffer: */
-void seperate_commmand_and_buf(char command[NET_BUF_LEN],char buf[NET_BUF_LEN])
-{
- int i;
- for (i = 0;
- buf[i] != '\0' && buf[i] != '\t' && i < NET_BUF_LEN;
- i++)
- {
- command[i] = buf[i];
- }
- command[i] = '\0';
-}
-
-
void copy_card(MC_FlashCard* src, MC_FlashCard* dest)
{
if (!src || !dest)
Modified: tuxmath/trunk/src/transtruct.h
===================================================================
--- tuxmath/trunk/src/transtruct.h 2009-09-09 16:56:46 UTC (rev 1499)
+++ tuxmath/trunk/src/transtruct.h 2009-09-09 22:28:09 UTC (rev 1500)
@@ -24,7 +24,7 @@
#define MC_FORMULA_LEN 40
#define MC_ANSWER_LEN 5
-#define TEST_COMETS 4
+#define TEST_COMETS 10
typedef struct _MC_FlashCard {
More information about the Tux4kids-commits
mailing list