[Tux4kids-commits] r1003 - tuxmath/branches/lan/src
akash gangil
gangil-guest at alioth.debian.org
Fri May 29 18:18:41 UTC 2009
Author: gangil-guest
Date: 2009-05-29 18:18:41 +0000 (Fri, 29 May 2009)
New Revision: 1003
Modified:
tuxmath/branches/lan/src/highscore.c
tuxmath/branches/lan/src/highscore.h
tuxmath/branches/lan/src/network.c
tuxmath/branches/lan/src/network.h
tuxmath/branches/lan/src/titlescreen.c
Log:
Just an update , still not working , trying to debug using gdb
Modified: tuxmath/branches/lan/src/highscore.c
===================================================================
--- tuxmath/branches/lan/src/highscore.c 2009-05-29 11:17:00 UTC (rev 1002)
+++ tuxmath/branches/lan/src/highscore.c 2009-05-29 18:18:41 UTC (rev 1003)
@@ -19,6 +19,7 @@
#include "options.h"
#include "SDL_extras.h"
#include "convert_utf.h"
+#include "network.h"
typedef struct high_score_entry {
@@ -353,185 +354,8 @@
NameEntry(pl_name, _("You Are In The Hall of Fame!"), _("Enter Your Name:"));
}
-void Standby(const char* heading, const char* sub)
-{
-
- SDL_Rect loc;
- SDL_Rect TuxRect,
- stopRect;
-
- int finished = 0;
- int tux_frame = 0;
- Uint32 frame = 0;
- Uint32 start = 0;
-
- const int BG_Y = 100;
- const int BG_WIDTH = 400;
- const int BG_HEIGHT = 200;
- sprite* Tux = LoadSprite("tux/bigtux", IMG_ALPHA);
-
-
-
- /* We need to get Unicode vals from SDL keysyms */
- SDL_EnableUNICODE(SDL_ENABLE);
-
-
- /* Draw background: */
- if (current_bkg())
- SDL_BlitSurface(current_bkg(), NULL, screen, NULL);
-
- /* Red "Stop" circle in upper right corner to go back to main menu: */
- if (images[IMG_STOP])
- {
- stopRect.w = images[IMG_STOP]->w;
- stopRect.h = images[IMG_STOP]->h;
- stopRect.x = screen->w - images[IMG_STOP]->w;
- stopRect.y = 0;
- SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
- }
-
- if (Tux && Tux->frame[0]) /* make sure sprite has at least one frame */
- {
- TuxRect.w = Tux->frame[0]->w;
- TuxRect.h = Tux->frame[0]->h;
- TuxRect.x = 0;
- TuxRect.y = screen->h - Tux->frame[0]->h;
- }
-
- /* Draw translucent background for text: */
- {
- SDL_Rect bg_rect;
- bg_rect.x = (screen->w)/2 - BG_WIDTH/2;
- bg_rect.y = BG_Y;
- bg_rect.w = BG_WIDTH;
- bg_rect.h = BG_HEIGHT;
- DrawButton(&bg_rect, 15, REG_RGBA);
-
- bg_rect.x += 10;
- bg_rect.y += 10;
- bg_rect.w -= 20;
- bg_rect.h = 180;
- DrawButton(&bg_rect, 10, SEL_RGBA);
- }
-
- /* Draw heading: */
- {
- SDL_Surface* s = BlackOutline(_(heading),
- DEFAULT_MENU_FONT_SIZE, &white);
- if (s)
- {
- loc.x = (screen->w/2) - (s->w/2);
- loc.y = 150;
- SDL_BlitSurface(s, NULL, screen, &loc);
- SDL_FreeSurface(s);
- }
-
- s = BlackOutline(_(sub),
- DEFAULT_MENU_FONT_SIZE, &white);
- if (s)
- {
- loc.x = (screen->w/2) - (s->w/2);
- loc.y = 170;
- SDL_BlitSurface(s, NULL, screen, &loc);
- SDL_FreeSurface(s);
- }
- }
-
- /* and update: */
- SDL_UpdateRect(screen, 0, 0, 0, 0);
-
-
-
- while (!finished)
- {
- start = SDL_GetTicks();
-
- while (SDL_PollEvent(&event))
- {
- switch (event.type)
- {
- case SDL_QUIT:
- {
- cleanup();
- }
-
- case SDL_MOUSEBUTTONDOWN:
- /* "Stop" button - go to main menu: */
- {
- if (inRect(stopRect, event.button.x, event.button.y ))
- {
- finished = 1;
- playsound(SND_TOCK);
- break;
- }
- }
- case SDL_KEYDOWN:
- {
-#ifdef TUXMATH_DEBUG
- fprintf(stderr, "Before keypress, string is %S\tlength = %d\n",
- wchar_buf, (int)wcslen(wchar_buf));
-#endif
- switch (event.key.keysym.sym)
- {
- case SDLK_ESCAPE:
-
- {
- finished = 1;
- playsound(SND_TOCK);
- break;
- }
-
- default:
- continue;
- /* For any other keys, if the key has a Unicode value, */
- /* we add it to our string: */
-
-
- } /* end 'switch (event.key.keysym.sym)' */
-
-
- /* --- make tux blink --- */
- switch (frame % TUX6)
- {
- case 0: tux_frame = 1; break;
- case TUX1: tux_frame = 2; break;
- case TUX2: tux_frame = 3; break;
- case TUX3: tux_frame = 4; break;
- case TUX4: tux_frame = 3; break;
- case TUX5: tux_frame = 2; break;
- default: tux_frame = 0;
- }
-
- if (Tux && tux_frame)
- {
- SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &TuxRect);
- SDL_UpdateRect(screen, TuxRect.x, TuxRect.y, TuxRect.w, TuxRect.h);
- }
-
- /* Wait so we keep frame rate constant: */
- while ((SDL_GetTicks() - start) < 33)
- {
- SDL_Delay(20);
- }
- frame++;
- }
-}
-}
-} // End of while (!finished) loop
-
- FreeSprite(Tux);
-
- /* Turn off SDL Unicode lookup (because has some overhead): */
- SDL_EnableUNICODE(SDL_DISABLE);
-
-}
-
-
-
-
-
void NameEntry(char* pl_name, const char* heading, const char* sub)
{
char UTF8_buf[HIGH_SCORE_NAME_LENGTH * 3] = {'\0'};
Modified: tuxmath/branches/lan/src/highscore.h
===================================================================
--- tuxmath/branches/lan/src/highscore.h 2009-05-29 11:17:00 UTC (rev 1002)
+++ tuxmath/branches/lan/src/highscore.h 2009-05-29 18:18:41 UTC (rev 1003)
@@ -16,7 +16,7 @@
#include "globals.h"
-void Standby(const char* heading, const char* sub);
+
void DisplayHighScores(int level);
void HighScoreNameEntry(char* pl_name);
void NameEntry(char* pl_name, const char* heading, const char* sub);
Modified: tuxmath/branches/lan/src/network.c
===================================================================
--- tuxmath/branches/lan/src/network.c 2009-05-29 11:17:00 UTC (rev 1002)
+++ tuxmath/branches/lan/src/network.c 2009-05-29 18:18:41 UTC (rev 1003)
@@ -78,9 +78,8 @@
// shutdown SDL_net
SDLNet_Quit();
- // shutdown SDL
- SDL_Quit();
+
return(0);
}
@@ -128,7 +127,7 @@
if(!server)
{
printf("SDLNet_TCP_Open: %s\n",SDLNet_GetError());
-exit(4);
+return 1;
}
game_set_start_message(waiting, "", "", "");
@@ -164,15 +163,13 @@
}
break;
}
+
SDLNet_TCP_Close(client);
SDLNet_TCP_Close(server);
// shutdown SDL_net
SDLNet_Quit();
- // shutdown SDL
- SDL_Quit();
-
return 0;
}
Modified: tuxmath/branches/lan/src/network.h
===================================================================
--- tuxmath/branches/lan/src/network.h 2009-05-29 11:17:00 UTC (rev 1002)
+++ tuxmath/branches/lan/src/network.h 2009-05-29 18:18:41 UTC (rev 1003)
@@ -9,7 +9,7 @@
*/
-int lan_server_connect(int port);
-int lan_client_connect(char *host,int port);
+int lan_server_connect(char *port);
+int lan_client_connect(char *host,char *port);
#endif // NETWORK_H
Modified: tuxmath/branches/lan/src/titlescreen.c
===================================================================
--- tuxmath/branches/lan/src/titlescreen.c 2009-05-29 11:17:00 UTC (rev 1002)
+++ tuxmath/branches/lan/src/titlescreen.c 2009-05-29 18:18:41 UTC (rev 1003)
@@ -21,8 +21,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
-
-
+
// titlescreen.h has all of the tuxtype-related stuff:
#include "titlescreen.h"
@@ -43,6 +42,8 @@
#include "convert_utf.h" // for wide char to UTF-8 conversion
#include "SDL_extras.h"
+
+
//#include "lan_client.h"
/* --- Data Structure for Dirty Blitting --- */
@@ -194,9 +195,9 @@
int run_lan_menu(void);
int run_server_menu(void);
int handle_easter_egg(const SDL_Event* evt);
+void Standby(const char* heading, const char* sub,char *host,char *port);
-
/***********************************************************/
/* */
/* "Public functions" (callable throughout program) */
@@ -854,9 +855,10 @@
int run_lan_menu(void)
{
- int mode = -1,l;
- char host[HIGH_SCORE_NAME_LENGTH * 3];
- char port[HIGH_SCORE_NAME_LENGTH * 3];
+ int mode = -1;
+ char host[1024]="NULL";
+ char port[1024];
+
const char* menu_text[3] =
{N_("Host"),
@@ -888,7 +890,7 @@
// lan_client_set_parameter(HOST, host);
// lan_client_set_parameter(PORT, port);
// if((lan_client_connect(host,port))==0)
- Standby(_("No Host...=("),_("Press Esc to go back")); // this function is defined in highscore.c...
+ Standby(_("No Host...=("),_("Press Esc to go back"),host,port); // this function is defined in highscore.c...
@@ -907,7 +909,7 @@
{
int difficulty = -1;
- char port[HIGH_SCORE_NAME_LENGTH * 3];
+ char port[1024];
//just leech settings from arcade modes
@@ -940,7 +942,7 @@
else
{NameEntry(port, _("Enter the PORT"),
_(""));
- Standby(_("Waiting for other player"),_("Press Esc to go back"));
+ Standby(_("Waiting for other player"),_("Press Esc to go back"),NULL,port);
// lan_server_connect(port);
game();}
break;
@@ -2718,3 +2720,195 @@
return 0;
}
}
+
+
+
+void Standby(const char* heading, const char* sub,char *host,char *port)
+{
+
+ SDL_Rect loc;
+ SDL_Rect TuxRect,
+ stopRect;
+
+
+ int finished = 0,l;
+ int tux_frame = 0;
+ Uint32 frame = 0;
+ Uint32 start = 0;
+
+ const int BG_Y = 100;
+ const int BG_WIDTH = 400;
+ const int BG_HEIGHT = 200;
+
+ sprite* Tux = LoadSprite("tux/bigtux", IMG_ALPHA);
+
+
+
+ /* We need to get Unicode vals from SDL keysyms */
+ SDL_EnableUNICODE(SDL_ENABLE);
+
+
+ /* Draw background: */
+ if (current_bkg())
+ SDL_BlitSurface(current_bkg(), NULL, screen, NULL);
+
+ /* Red "Stop" circle in upper right corner to go back to main menu: */
+ if (images[IMG_STOP])
+ {
+ stopRect.w = images[IMG_STOP]->w;
+ stopRect.h = images[IMG_STOP]->h;
+ stopRect.x = screen->w - images[IMG_STOP]->w;
+ stopRect.y = 0;
+ SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
+ }
+
+ if (Tux && Tux->frame[0]) /* make sure sprite has at least one frame */
+ {
+ TuxRect.w = Tux->frame[0]->w;
+ TuxRect.h = Tux->frame[0]->h;
+ TuxRect.x = 0;
+ TuxRect.y = screen->h - Tux->frame[0]->h;
+ }
+
+ /* Draw translucent background for text: */
+ {
+ SDL_Rect bg_rect;
+ bg_rect.x = (screen->w)/2 - BG_WIDTH/2;
+ bg_rect.y = BG_Y;
+ bg_rect.w = BG_WIDTH;
+ bg_rect.h = BG_HEIGHT;
+ DrawButton(&bg_rect, 15, REG_RGBA);
+
+ bg_rect.x += 10;
+ bg_rect.y += 10;
+ bg_rect.w -= 20;
+ bg_rect.h = 180;
+ DrawButton(&bg_rect, 10, SEL_RGBA);
+ }
+
+ /* Draw heading: */
+ {
+ SDL_Surface* s = BlackOutline(_(heading),
+ DEFAULT_MENU_FONT_SIZE, &white);
+ if (s)
+ {
+ loc.x = (screen->w/2) - (s->w/2);
+ loc.y = 150;
+ SDL_BlitSurface(s, NULL, screen, &loc);
+ SDL_FreeSurface(s);
+ }
+
+ s = BlackOutline(_(sub),
+ DEFAULT_MENU_FONT_SIZE, &white);
+ if (s)
+ {
+ loc.x = (screen->w/2) - (s->w/2);
+ loc.y = 170;
+ SDL_BlitSurface(s, NULL, screen, &loc);
+ SDL_FreeSurface(s);
+ }
+ }
+
+ /* and update: */
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+
+
+ while (!finished)
+ {
+ printf("I AM HERE!!!!!!!!!!!!!!!!!!!!!!!!");
+ start = SDL_GetTicks();
+
+ while (SDL_PollEvent(&event))
+ {
+ if(host==NULL)
+ {l=lan_server_connect(port);
+ printf("%d\n",l);
+ }
+ else
+ {l=lan_client_connect(host,port);
+ printf("%d\n",l);
+ }
+ while(1)
+ {
+ if(!l)
+ printf("HOORAAAAAAAAAAAY!!!!!!!!!!");
+ break;
+ }
+
+ switch (event.type)
+ {
+ case SDL_QUIT:
+ {
+ cleanup();
+ }
+
+ case SDL_MOUSEBUTTONDOWN:
+ /* "Stop" button - go to main menu: */
+ {
+ if (inRect(stopRect, event.button.x, event.button.y ))
+ {
+ finished = 1;
+ playsound(SND_TOCK);
+ break;
+ }
+ }
+ case SDL_KEYDOWN:
+ {
+
+ switch (event.key.keysym.sym)
+ {
+ case SDLK_ESCAPE:
+
+ {
+ finished = 1;
+ playsound(SND_TOCK);
+ break;
+ }
+
+ default:
+ continue;
+ /* For any other keys, if the key has a Unicode value, */
+ /* we add it to our string: */
+
+
+ } /* end 'switch (event.key.keysym.sym)' */
+
+
+ /* --- make tux blink --- */
+ switch (frame % TUX6)
+ {
+ case 0: tux_frame = 1; break;
+ case TUX1: tux_frame = 2; break;
+ case TUX2: tux_frame = 3; break;
+ case TUX3: tux_frame = 4; break;
+ case TUX4: tux_frame = 3; break;
+ case TUX5: tux_frame = 2; break;
+ default: tux_frame = 0;
+ }
+
+ if (Tux && tux_frame)
+ {
+ SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &TuxRect);
+ SDL_UpdateRect(screen, TuxRect.x, TuxRect.y, TuxRect.w, TuxRect.h);
+ }
+
+ /* Wait so we keep frame rate constant: */
+ while ((SDL_GetTicks() - start) < 33)
+ {
+ SDL_Delay(20);
+ }
+ frame++;
+ }
+}
+}
+} // End of while (!finished) loop
+
+ FreeSprite(Tux);
+
+ /* Turn off SDL Unicode lookup (because has some overhead): */
+ SDL_EnableUNICODE(SDL_DISABLE);
+
+}
+
+
More information about the Tux4kids-commits
mailing list