Filewatcher File Search
FTP Search
  
Directory 
  
Content Search 
   
pkg://xoth-1.0-2.src.rpm:10403/xoth-1.0.tgz  info  downloads

xoth-1.0/Imakefile   640  14125  75616         356  6115340170   7317 
XCOMM Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr
            
             CC = gcc
        DEFINES = -Wall
         LDLIBS = -lX11 -lc
    CDEBUGFLAGS = -O
           SRCS = xoth.c
           OBJS = xoth.o

ComplexProgramTarget(xoth)

ct 0 0
helios:(pid138) /usr/share/man ignore ro,intr,port=732,map=/etc/auto.direct,direct 0 0
helios:(pid138) /usr/local ignore ro,intr,port=732,map=/etc/auto.direct,direct 0 0
helios:(pid138) /usr/local2 ignore ro,intr,port=732,map=/etc/auto.direct,direct 0 0
helios:(pid13xoth-1.0/README   640  14125  75616        3423  6115340170   6404 
Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr

-------------------------------------------------------------------------------

(Sorry for my poor English...)

Xoth is an Othello game under X11, which allows two people to play through
a network.

To compile, use "xmkmf" then "make" with gcc. This program has been
successfully tested under Linux 1.3.45 and SunOS 4.1.3.

To start a game, if both players are on the same host, they just need to
launch the program : "xoth".

-------------------------------------------------------------------------------

When it starts, the program tries to find another player on ports from
9999 to 9980 in this order. If it can't find any other player waiting,
it will itself wait on the first available port. Several games can take
place at the same time on the same host.

You can specify a port number with the option -port, for example
	"xoth -port 9876"

You can specify a host name with the option -server. This option is only
used by the second player if he isn't on the same host than the first one.
For example, il the first player started the program on his host called
"helios", the second may type "xoth -server helios". Of course, "-server"
means that you specify where is the server, NOT that you are the server,
because, in fact, you're the client (as the 2nd player).

The -debug option prints out debugging messages (in french, sorry...)

The -nocolor option provides a B&W display. 

The -nohelp option disables the "rules of the game" printing (in french...)

You can modify some parameters in the xoth.h file, especially the "friends"
structure which allows a conversion from logins to nicknames.

-------------------------------------------------------------------------------

For any comments, write me at : "sellin@ifsic.univ-rennes1.fr"

Have fun !

xoth-1.0/LISEZMOI   640  14125  75616        3330  6115340170   6677 
Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr

-------------------------------------------------------------------------------

Xoth est un jeu d'Othello sous X11 qui permet a deux personnes de jouer
ensemble a travers un reseau. 

Pour la compilation, utilisez "xmkmf" puis "make" avec gcc. Ce programme
a ete teste avec succes sous Linux 1.3.45 et SunOS 4.1.3.

Pour demarrer une partie, si les deux joueurs se trouvent sur la meme
machine, il leur suffit de lancer le programme : "xoth".

-------------------------------------------------------------------------------

Quand il demarre, le programme essaie de trouver un autre joueur sur les
ports 9999 a 9980 dans cet ordre. S'il ne trouve aucun joueur en train
d'attendre, il se met lui-meme en attente sur le premier port disponible.
Plusieurs parties peuvent se derouler simultanement sur une meme machine.

Vous pouvez specifier un port avec l'option -port, par exemple 
	"xoth -port 9876"

Vous pouvez specifier un nom de machine avec l'option -server. Cette option
ne sert qu'au deuxieme joueur s'il n'est pas sur la meme machine que celle du
premier joueur. Par exemple, si le premier joueur a lance le programme sur sa
machine appelee "helios", le deuxieme joueur tape "xoth -server helios".

L'option -debug affiche des messages de debugging.

L'option -nocolor genere un affichage noir et blanc.

L'option -nohelp empeche l'affichage de la regle du jeu en debut de partie.

Vous pouvez modifier quelques parametres dans le fichier xoth.h, notamment
la structure "friends" qui etablit une equivalence entre logins et prenoms.

-------------------------------------------------------------------------------

Pour toutes remarques, ecrivez-moi a "sellin@ifsic.univ-rennes1.fr"

Have fun !

 write me at : "sellin@ifsic.univ-rennes1.fr"

Have fun !

xoth-1.0/xoth.c   640  14125  75616       54175  6115340170   6704 /*
 *	Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr
 *	Jeu d'Othello pour X11
 *
 */
 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <netdb.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include "xoth.h"

char			server[32];	
int			userport = 0;
int			sock;
char			disp[32];

Display			*display;				
int			ecran;
Window			fenetre;
GC			cont_graph;
Cursor			c_fleche,c_montre,c_croix;
int			CurrentCursor = C_UNKNOWN;
int			x1,y1,x2,y2;			/* Coordonnées extremes grille		*/
int			lx,ly;				/* Dernières coordonnées du curseur */
unsigned long		couleur_fond,couleur_joueur[2];
unsigned long		couleur_scfg,couleur_scbg;
Pixmap			numero[10];				/* Les chiffres de 0 à 9 */
XFontStruct		*copyright_font;
XFontStruct		*title_font;
XFontStruct		*pseudo_font;
XFontStruct		*message_font;
unsigned int		h,w;					/* Taille courante de la fenetre */

int			board[8][8];
int			whoami,turn;
char			pseudo[2][32];
char			message[2][100];
int			score[2];
char			blink = 1;
char			msg_valid = 0;
char			debug_mode = 0;
char			nocolor = 0;
char			nohelp = 0;

void TheEnd(void)
{
	int	i;
	for (i=0;i<10;i++)
		XFreePixmap(display,numero[i]);
	XFreeCursor(display,c_montre);
	XFreeCursor(display,c_fleche);
	XFreeCursor(display,c_croix);
	XFreeFont(display,copyright_font);
	XFreeFont(display,title_font);
	XFreeFont(display,pseudo_font);
	XFreeFont(display,message_font);
	XFreeGC(display,cont_graph);
	XDestroyWindow(display,fenetre);
	XCloseDisplay(display);
	exit(0);
}

void Trace(int abandon)
{
	FILE	*f;
	time_t	now;
	char	buff[30];
	if ( score[0]+score[1] < 10 )
		return;
	if ( (f=fopen(TRACE_FILE,"a+")) == NULL )
		return;
	time(&now);
	strcpy(buff,ctime(&now));
	buff[strlen(buff)-1] = '\0';
	fprintf(f,"%s       %c %-16s %2u / %2u %16s %c\n",
		buff,
		(abandon==0)?'*':' ',
		pseudo[0],score[0],
		score[1],pseudo[1],
		(abandon==1)?'*':' ');
	fclose(f);
}

char *GetPseudo(void)
{
	int		i; 
	for (i=0;friends[i];i+=2)
		if ( strcmp(getenv("LOGNAME"),friends[i]) == 0 )
			return(friends[i+1]);
	return(getenv("LOGNAME"));
}

void Initializations(void)
{
	int c,l;
	if ( getenv("DISPLAY") )
		strcpy(disp,getenv("DISPLAY"));
	else
		strcpy(disp,"");
	for (c=0;c<8;c++)
		for (l=0;l<8;l++)
			board[c][l] = -1;
	board[3][3] = 1;
	board[3][4] = 0;
	board[4][3] = 0;
	board[4][4] = 1;
	strcpy(server,DEFAULT_SERVER);
	strcpy(message[0],"");
	strcpy(message[1],"");
	score[0] = score[1] = 2;
	turn = 0;
}

void SocketWrite(char *msg,...)
{
	static char	s[1000];
	va_list		ap;
	/* Récupère le millier de paramètres (au moins...) */
	va_start(ap,msg);
	vsprintf(s,msg,ap);
	/* Rajoute le '\n' final s'il n'y est pas déjà */
	if ( s[strlen(s)-1] != '\n' )
	{
		s[strlen(s)+1] = '\0';
		s[strlen(s)  ] = '\n';
	}
	/* Envoie au client */
	write(sock,s,strlen(s));
	if ( debug_mode )
		printf("> %s",s);
	/* Et c'est la fin */
	va_end(ap);
}

char *SocketRead(void)		
{
	static char	s[1000];
	unsigned char	c;
	strcpy(s,"");
	while ( 1 )
	{
		if ( read(sock,&c,1) <= 0 )
		{
			if ( debug_mode )
				fprintf(stderr,"Connection closed by foreign host !?\n\n");
			Trace(1-whoami);
			TheEnd();
		} 
		if ( c == '\n' ) break;
		if ( c >= 0x20 )
		{
			s[strlen(s)+1] = '\0';
			s[strlen(s)  ] = c;
		}
	}
	if ( debug_mode )
		printf("< %s\n",s);
	return s;
}

void ParseCommandLine(int argc,char **argv)
{
	int i;
	for (i=1;i<argc;i++)
	{
		if ( strcmp(argv[i],"-nocolor") == 0 )
		{
			nocolor = 1;
			if ( debug_mode )
				printf("-nocolor\n");
		}
		if ( strcmp(argv[i],"-debug") == 0 )
		{
			debug_mode = 1;
			printf("-debug\n");
		}
		if ( strcmp(argv[i],"-noblink") == 0 )
		{
			blink = 0;
			if ( debug_mode )
				printf("-noblink\n");
		}
		if ( strcmp(argv[i],"-nohelp") == 0 )
		{
			nohelp = 1;
			if ( debug_mode )
				printf("-nohelp\n");
		}
		if ( strcmp(argv[i],"-display") == 0 )
		{
			strcpy(disp,argv[++i]);
			if ( debug_mode )
				printf("-display %s\n",disp);
		}
		if ( strcmp(argv[i],"-port") == 0 )
		{
			userport = atoi(argv[++i]);
			if ( debug_mode )
				printf("-port %u\n",userport);
		}			
		if ( strcmp(argv[i],"-server") == 0 )
		{
			strcpy(server,argv[++i]);
			if ( debug_mode )
				printf("-server %s\n",server);
		}						
	}
}

int SetConnection(int port)
{
	struct sockaddr_in	adresse;
	int			socket_ecoute;
	if ( debug_mode )
		printf("Tentative d'installation sur le port %u\n",port);
	if ( (socket_ecoute=socket(AF_INET,SOCK_STREAM,0)) == -1 )
	{
		perror("socket");
		exit(-1);
	}
	adresse.sin_family = AF_INET;
	adresse.sin_addr.s_addr = htonl(INADDR_ANY);
	adresse.sin_port = htons(port);
	if ( bind(socket_ecoute,(struct sockaddr *)&adresse,sizeof(struct sockaddr_in)) == -1 )
	{
		if ( debug_mode )
			printf("Il y a deja un serveur sur ce port !\n");
		return 0;
	}
	if ( listen(socket_ecoute,0) == -1 )
	{
		perror("listen");
		exit(-1);
	}
	if ( debug_mode )
		printf("Attente de connexion\n");
	if ( (sock=accept(socket_ecoute,(struct sockaddr*)NULL,(int *)NULL)) == -1 )
	{
		perror("socket");
		exit(-1);
	}
	if ( debug_mode )
		printf("Connexion établie\n");
	close(socket_ecoute);
	SocketWrite(":%s",strcpy(pseudo[0],GetPseudo()));
	strcpy(pseudo[1],SocketRead());
	if ( debug_mode )
		printf("L'autre s'appelle %s\n",pseudo[1]);
	whoami = 0;
	return 1;
}

int GetConnection(int port)
{
	struct sockaddr_in	adresse_serveur,adresse_client;
	struct hostent		*hp;
	char			*p;
	if ( debug_mode )
		printf("Tentative de connexion sur le port %u\n",port);
	if ( (hp=gethostbyname(server)) == NULL )
	{
		perror("gethostbyname");
		exit(-1);
	}
	if ( (sock=socket(AF_INET,SOCK_STREAM,0)) == -1 )
	{
		perror("socket");
		exit(-1);
	}
	adresse_client.sin_family = AF_INET;
	adresse_client.sin_addr.s_addr = htonl(INADDR_ANY);
	adresse_client.sin_port = htons(0);
	if ( bind(sock,(struct sockaddr *)&adresse_client,sizeof(adresse_client)) == -1 )
	{
		perror("bind");
		close(sock);
		exit(-1);
	}
	adresse_serveur.sin_family = AF_INET;
	adresse_serveur.sin_port = htons(port);
	memcpy(&adresse_serveur.sin_addr.s_addr,hp->h_addr,hp->h_length);
	if ( connect(sock,(struct sockaddr*)&adresse_serveur,sizeof(adresse_serveur)) == -1 )
	{
		if ( debug_mode )
			printf("Connexion refusee (pas de serveur ou serveur occupe) !\n");
		return 0;
	}
	if ( debug_mode )
		printf("Connexion établie\n");
	if ( *(p=SocketRead()) != ':' )
	{
		/* Il se passe des choses bizarres sur ce port... */
		fprintf(stderr,"Caaaaaarburant !\n");
		exit(-1);
	}
	strcpy(pseudo[0],p+1);
	if ( debug_mode )
		printf("L'autre s'appelle %s\n",pseudo[0]);
	SocketWrite(strcpy(pseudo[1],GetPseudo()));
	whoami = 1;
	return 1;
}

void AlloueCouleurs(void)
{
	Colormap	default_colormap;
	XColor		color;
	default_colormap = DefaultColormap(display,ecran);
	if ( nocolor )
	{
		couleur_fond = WhitePixel(display,ecran);
		couleur_joueur[0] = BlackPixel(display,ecran);
		couleur_joueur[1] = WhitePixel(display,ecran);
		couleur_scbg = BlackPixel(display,ecran);
		couleur_scfg = WhitePixel(display,ecran);
		return;
	}
	XParseColor(display,default_colormap,COULEUR_FOND,&color);
	if ( (!XAllocColor(display,default_colormap,&color)) && (debug_mode) )
		printf("Couldn't allocate color \"%s\"\n",COULEUR_FOND); 
	couleur_fond = color.pixel ;
	XParseColor(display,default_colormap,COULEUR_JOUEUR0,&color);
	if ( (!XAllocColor(display,default_colormap,&color)) && (debug_mode) )
		printf("Couldn't allocate color \"%s\"\n",COULEUR_JOUEUR0); 
	couleur_joueur[0] = color.pixel ;
	XParseColor(display,default_colormap,COULEUR_JOUEUR1,&color);
	if ( (!XAllocColor(display,default_colormap,&color)) && (debug_mode) )
		printf("Couldn't allocate color \"%s\"\n",COULEUR_JOUEUR1); 
	couleur_joueur[1] = color.pixel ;
	XParseColor(display,default_colormap,COULEUR_SCFG,&color);
	if ( (!XAllocColor(display,default_colormap,&color)) && (debug_mode) )
		printf("Couldn't allocate color \"%s\"\n",COULEUR_SCFG); 
	couleur_scfg = color.pixel ;
	XParseColor(display,default_colormap,COULEUR_SCBG,&color);
	if ( (!XAllocColor(display,default_colormap,&color)) && (debug_mode) )
		printf("Couldn't allocate color \"%s\"\n",COULEUR_SCBG); 
	couleur_scbg = color.pixel ;
}

XFontStruct *ChargeFont(char *font_name)
{
	XFontStruct 	*f;
	if ( (f=XLoadQueryFont(display,font_name)) == NULL )
	{
		fprintf(stderr,"Couldn't load font \"%s\"\n",font_name);
		exit(-1);
	}
	return f;
}

void CreePixmaps(void)
{
	Window			root_window;
	unsigned int		default_depth;
	int			i;
	root_window = RootWindow(display,ecran);
	if ( (default_depth=DefaultDepth(display,ecran)) == 1 )
	{
		for (i=0;i<10;i++)
		{
			numero[i]=XCreateBitmapFromData(display,root_window ,
							chiffres[i],
							DIGIT_WIDTH,
							DIGIT_HEIGHT);
		}
	}
	else
	{
		for (i=0;i<10;i++)
		{
			numero[i]=XCreatePixmapFromBitmapData(display,root_window ,
							      chiffres[i],
							      DIGIT_WIDTH,
							      DIGIT_HEIGHT,
							      couleur_scbg,
							      couleur_scfg,
							      default_depth);
		}
	}
}

void Start(int argc,char **argv)
{
	XSizeHints	indic;
	if ( (display=XOpenDisplay(disp)) == NULL )
	{
		fprintf(stderr,"Can't open display: %s\n",disp);
		exit(-1);
	}
	ecran = DefaultScreen(display);
	indic.width = DEFAULT_WIDTH;
	indic.height = DEFAULT_HEIGHT;
	indic.flags = PSize;
	if ( DefaultDepth(display,ecran) == 1 )
	{
		if ( (debug_mode) && (!nocolor) )
			printf("-nocolor forced\n");
		nocolor = 1;
	}
	AlloueCouleurs();
	CreePixmaps();
	copyright_font = ChargeFont(COPYRIGHT_FONT);
	title_font     = ChargeFont(TITLE_FONT);
	pseudo_font    = ChargeFont(PSEUDO_FONT);
	message_font   = ChargeFont(MESSAGE_FONT);
	fenetre = XCreateSimpleWindow(display,DefaultRootWindow(display),
				      indic.x,indic.y,indic.width,indic.height,
				      5,BlackPixel(display,ecran),couleur_fond);
	XSetStandardProperties(display,fenetre,"Xoth","Xoth",None,argv,argc,&indic);
	cont_graph = XCreateGC(display,fenetre,0,NULL);
	XSetBackground(display,cont_graph,couleur_fond);
	XSetForeground(display,cont_graph,BlackPixel(display,ecran));
	XSelectInput(display,fenetre,KeyPressMask|
				     ExposureMask|
				     PointerMotionMask|
				     ButtonReleaseMask|
	/* Necessaire sur SGI */     ButtonPressMask);
	c_montre = XCreateFontCursor(display,XC_watch);
	c_fleche = XCreateFontCursor(display,XC_arrow);
	c_croix  = XCreateFontCursor(display,XC_X_cursor);
}

void Pion(int j,int c,int l)
{
	if ( board[c][l] != -1 )
		score[board[c][l]]--;
	board[c][l] = j;
	if ( j == -1 )
	{
		XSetForeground(display,cont_graph,couleur_fond);
		XFillRectangle(display,fenetre,cont_graph,
			x1+(x2-x1)*c/8+2,
			y1+(y2-y1)*l/8+2,
			(x2-x1)/8-4,
			(y2-y1)/8-3);
		XFlush(display);
		return;		
	}
	score[j]++;
	XSetForeground(display,cont_graph,couleur_joueur[j]);
	XFillArc(display,fenetre,cont_graph,
		x1+(x2-x1)*c/8+3,
		y1+(y2-y1)*l/8+3,
		(x2-x1)/8-6,
		(y2-y1)/8-5,
		0,64*360);
	if ( (nocolor) && (j==1) )
	{
		XSetForeground(display,cont_graph,BlackPixel(display,ecran));
		XDrawArc(display,fenetre,cont_graph,
			x1+(x2-x1)*c/8+3,
			y1+(y2-y1)*l/8+3,
			(x2-x1)/8-6,
			(y2-y1)/8-5,
			0,64*360);
	}
      	XFlush(display);
}

void Scores(void)
{
	XCopyArea(display,numero[score[0]/10],fenetre,cont_graph,
				0,0,DIGIT_WIDTH,DIGIT_HEIGHT,
				10,h-120);
	XCopyArea(display,numero[score[0]%10],fenetre,cont_graph,
				0,0,DIGIT_WIDTH,DIGIT_HEIGHT,
				10+DIGIT_WIDTH,h-120);
	XCopyArea(display,numero[score[1]/10],fenetre,cont_graph,
				0,0,DIGIT_WIDTH,DIGIT_HEIGHT,
				w-10-2*DIGIT_WIDTH,h-120);
	XCopyArea(display,numero[score[1]%10],fenetre,cont_graph,
				0,0,DIGIT_WIDTH,DIGIT_HEIGHT,
				w-10-DIGIT_WIDTH,h-120);
	XFlush(display);
}

void XPaint(void)
{
	Window		root_fen;
	int		i,c,l;
	unsigned int	junk;

	/* Recupère la taille de la fenêtre */
	XGetGeometry(display,fenetre,&root_fen,(int*)&junk,(int*)&junk,&w,&h,&junk,&junk);
	
	/* Couleurs */
	XSetForeground(display,cont_graph,BlackPixel(display,ecran));
	XSetBackground(display,cont_graph,couleur_fond);

	/* Affiche le copyright en bas */
	XSetFont(display,cont_graph,copyright_font->fid);
	XDrawImageString(display,fenetre,cont_graph,(w-XTextWidth(copyright_font,COPYRIGHT_TEXT,strlen(COPYRIGHT_TEXT)))/2,h-10,COPYRIGHT_TEXT,strlen(COPYRIGHT_TEXT));

	/* Affiche le titre en haut */
	XSetFont(display,cont_graph,title_font->fid);
	XDrawImageString(display,fenetre,cont_graph,(w-XTextWidth(title_font,TITLE_TEXT,strlen(TITLE_TEXT)))/2,28,TITLE_TEXT,strlen(TITLE_TEXT));
	
	/* Messages */
	XSetFont(display,cont_graph,message_font->fid);
	XDrawImageString(display,fenetre,cont_graph,10,h-65,message[whoami],strlen(message[whoami]));
	XDrawImageString(display,fenetre,cont_graph,10,h-40,message[1-whoami],strlen(message[1-whoami]));
	
	/* Pseudos des joueurs et petits pions */
	XSetFont(display,cont_graph,pseudo_font->fid);
	XDrawImageString(display,fenetre,cont_graph,45+2*DIGIT_WIDTH,h-105,pseudo[0],strlen(pseudo[0]));
	XDrawImageString(display,fenetre,cont_graph,w-45-2*DIGIT_WIDTH-XTextWidth(pseudo_font,pseudo[1],strlen(pseudo[1])),h-90,pseudo[1],strlen(pseudo[1]));
	XSetForeground(display,cont_graph,couleur_joueur[0]);
	XFillArc(display,fenetre,cont_graph,
		25+2*DIGIT_WIDTH,
		h-120,
		15,15,
		0,64*360);
	if ( nocolor )
	{
		XSetForeground(display,cont_graph,BlackPixel(display,ecran));
		XDrawArc(display,fenetre,cont_graph,
			w-40-2*DIGIT_WIDTH,
			h-105,
			15,15,
			0,64*360);
	}
	else
	{
		XSetForeground(display,cont_graph,couleur_joueur[1]);
		XFillArc(display,fenetre,cont_graph,
			w-40-2*DIGIT_WIDTH,
			h-105,
			15,15,
			0,64*360);
	}
			
	/* Scores */
	Scores();

	/* Coordonnées de la grille */
	x1 = 10;	/* gauche */
	x2 = w-11;	/* droite */
	y1 = 40;	/* haut	  */
	y2 = h-140;	/* bas    */

	/* Tracé de la grille */
	for (i=0;i<=8;i++)
	{
		XSetForeground(display,cont_graph,BlackPixel(display,ecran));
		XDrawLine(display,fenetre,cont_graph,x1,y1+(y2-y1)*i/8  ,x2,y1+(y2-y1)*i/8  );
		XDrawLine(display,fenetre,cont_graph,x1,y1+(y2-y1)*i/8+1,x2,y1+(y2-y1)*i/8+1);
		XDrawLine(display,fenetre,cont_graph,x1+(x2-x1)*i/8  ,y1,x1+(x2-x1)*i/8  ,y2);
		XDrawLine(display,fenetre,cont_graph,x1+(x2-x1)*i/8+1,y1,x1+(x2-x1)*i/8+1,y2);
	}
	
	/* Affichage des pions */
	for (c=0;c<8;c++)
		for (l=0;l<8;l++)
			Pion(board[c][l],c,l);

}

int GoodMove(int j,int c,int l)
{
	static int		dc[8] = {-1,0,1,1,1,0,-1,-1};
	static int		dl[8] = {-1,-1,-1,0,1,1,1,0};
	int			d,i;
	if ( board[c][l] != -1 )
		return 0;
	for (d=0;d<8;d++)
	{
		for (i=1;;i++)
		{
			if ( (c+i*dc[d]<0) ||
				 (c+i*dc[d]>7) ||
				 (l+i*dl[d]<0) ||
				 (l+i*dl[d]>7) )
				break;
			if ( (i==1) && (board[c+i*dc[d]][l+i*dl[d]]!=1-j) )
				break;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==j) )
				return 1;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==-1) )
				break;
		}
	}
	return 0;		/* Mauvaise case... */
}

void Play(int j,int c,int l)
{
	static int		dc[8] = {-1,0,1,1,1,0,-1,-1};
	static int		dl[8] = {-1,-1,-1,0,1,1,1,0};
	int			d,i;
	char			ok_dir;

	if ( ! GoodMove(j,c,l) )
		return;

	if ( blink )
	{
		Pion(j,c,l);
		usleep(500000);
		Pion(-1,c,l);
		usleep(500000);
	}
	Pion(j,c,l);

	for (d=0;d<8;d++)
	{
		ok_dir = 0;
		for (i=1;;i++)
		{
			if ( (c+i*dc[d]<0) ||
				 (c+i*dc[d]>7) ||
				 (l+i*dl[d]<0) ||
				 (l+i*dl[d]>7) )
				break;
			if ( (i==1) && (board[c+i*dc[d]][l+i*dl[d]]!=1-j) )
				break;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==j) )
				ok_dir = 1;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==-1) )
				break;
		}
		if ( ! ok_dir )
			continue;
		for (i=1;;i++)
		{
			if ( (c+i*dc[d]<0) ||
				 (c+i*dc[d]>7) ||
				 (l+i*dl[d]<0) ||
				 (l+i*dl[d]>7) )
				break;
			if ( (i==1) && (board[c+i*dc[d]][l+i*dl[d]]!=1-j) )
				break;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==j) )
				break;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==-1) )
				break;
			Pion(j,c+i*dc[d],l+i*dl[d]);
		}
	}
	Scores();
	if ( debug_mode )
		printf("Joueur0:%u Joueur1:%u\n",score[0],score[1]);
	if ( (score[0]+score[1]==64) ||
		 (score[0]==0) ||
		 (score[1]==0) )
	{
		/* Je crois que c'est la fin... */
		sleep(5);
		if ( whoami )
			Trace(-1);
		TheEnd();
	}
}

void UpdateCursor(int x,int y)
{
	int		i;
	lx=x;
	ly=y;
	if ( whoami == turn )
	{
		if ( (x>=x1) && (x<=x2) && (y>=y1) && (y<=y2) )
			i = GoodMove(whoami,(x-x1)*8/(x2-x1),(y-y1)*8/(y2-y1))?C_FLECHE:C_CROIX;
		else
			i = C_CROIX;
	}
	else i = C_MONTRE;
	/* Le curseur a changé ? */
	if ( CurrentCursor != i )
	{
		CurrentCursor = i;
		switch ( i )
		{
			case C_FLECHE :
				XDefineCursor(display,fenetre,c_fleche);
				break;
			case C_MONTRE :
				XDefineCursor(display,fenetre,c_montre);
				break;
			case C_CROIX :
				XDefineCursor(display,fenetre,c_croix);
				break;
		}
	}
}

void Loop(void)
{
	XEvent			event;
	KeySym			touche;
	int			i,c,l,n;
	unsigned char		s[100];
	fd_set			fdset;
	struct timeval		tv;
	char			*p;
	int			sc,sl;

	/* Et c'est parti... */
	XMapRaised(display,fenetre);

	while ( 1 )
	{
		while ( XPending(display) )
		{
			XNextEvent(display,&event);
			switch ( event.type )
			{
				case ButtonRelease :
					if ( (event.xbutton.button==Button1) &&
						 (turn==whoami) &&
						 (event.xbutton.x>=x1) &&
						 (event.xbutton.x<=x2) &&
						 (event.xbutton.y>=y1) &&
						 (event.xbutton.y<=y2) )
					{
						sc = (event.xbutton.x-x1)*8/(x2-x1);
						sl = (event.xbutton.y-y1)*8/(y2-y1);	
						if ( GoodMove(whoami,sc,sl) )
						{
							if ( debug_mode )
								printf("Coup accepté\n");
							SocketWrite("%c%c",'A'+sc,'1'+sl);
							Play(whoami,sc,sl);
							turn = 1 - turn;
						}
						else if ( debug_mode )
							printf("Coup refusé\n");
						UpdateCursor(event.xbutton.x,event.xbutton.y);	
					}
					break;
				case MotionNotify :
					/* Détermine le curseur à utiliser */
					UpdateCursor(event.xmotion.x,event.xmotion.y);
					break;
				case Expose :
 					XPaint();
					break;
				case KeyPress :
					i = XLookupString((XKeyEvent*)&event,s,3,&touche,NULL);
					if ( touche == XK_Escape )
						TheEnd();
					else if ( (touche==XK_Return) && (strlen(message[whoami])) && (!msg_valid) )
					{
						SocketWrite("!%s",message[whoami]);
						msg_valid = 1;
					}
					else if ( (touche==XK_BackSpace) && (strlen(message[whoami])) && (!msg_valid) )
					{
						message[whoami][strlen(message[whoami])-1] = '\0';
						sprintf(s,"%s      ",message[whoami]);
						XSetForeground(display,cont_graph,BlackPixel(display,ecran));
						XSetBackground(display,cont_graph,couleur_fond);
						XSetFont(display,cont_graph,message_font->fid);
						XDrawImageString(display,fenetre,cont_graph,10,h-65,s,strlen(s));
					}						
					else if ( (i==1) && (*s>=32) && (strlen(message[whoami])<90) )
					{
						if ( msg_valid )
						{
							msg_valid = 0;
							strcpy(message[whoami],"");
							XSetForeground(display,cont_graph,couleur_fond);
							XSetBackground(display,cont_graph,couleur_fond);
							XFillRectangle(display,fenetre,cont_graph,0,h-77,w,24);
						}
						s[1] = '\0';
						strcat(message[whoami],s);
						XSetForeground(display,cont_graph,BlackPixel(display,ecran));
						XSetBackground(display,cont_graph,couleur_fond);
						XSetFont(display,cont_graph,message_font->fid);
						XDrawImageString(display,fenetre,cont_graph,10,h-65,message[whoami],strlen(message[whoami]));
					}
					break;
			}
		}
		FD_ZERO(&fdset);
		FD_SET(sock,&fdset);
		tv.tv_sec = 0;
		tv.tv_usec = 100000L;				/* 0,1s */
		select(255,&fdset,NULL,NULL,&tv);
		if ( FD_ISSET(sock,&fdset) )
		{
			if ( *(p=SocketRead()) == '!' )
			{
				/* Voila un message */
				XSetForeground(display,cont_graph,couleur_fond);
				XSetBackground(display,cont_graph,couleur_fond);
				XFillRectangle(display,fenetre,cont_graph,0,h-52,w,22);
				XSetForeground(display,cont_graph,BlackPixel(display,ecran));
				XSetBackground(display,cont_graph,couleur_fond);
				XSetFont(display,cont_graph,message_font->fid);
				XDrawImageString(display,fenetre,cont_graph,10,h-40,p+1,strlen(p+1));
				strcpy(message[1-whoami],p+1);
			}
			else if ( *p == '/' )
			{
				if ( debug_mode )
					printf("Il ne peut pas jouer non plus !\n");
				sleep(5);
				TheEnd();
			}
			else if ( *p == '#' )
			{
				if ( debug_mode )
					printf("Il ne peut pas jouer !\n");
				for (n=0,c=0;c<8;c++)
					for (l=0;l<8;l++)
						n += GoodMove(whoami,c,l);
				if ( ! n )
				{
					if ( debug_mode )
						printf("Je ne peux pas jouer non plus !\n");
					SocketWrite("/");
					sleep(5);
					Trace(-1);
					TheEnd();
				}	
				turn = whoami;
			}
			else
			{
				Play(1-whoami,p[0]-'A',p[1]-'1');
				for (n=0,c=0;c<8;c++)
					for (l=0;l<8;l++)
						n += GoodMove(whoami,c,l);
				if ( ! n )
				{
					if ( debug_mode )
						printf("Je ne peux pas jouer !\n");
					SocketWrite("#");
				}
				else turn = whoami;
			}
			UpdateCursor(lx,ly);	
		}
	}
}

void Help(void)
{
	printf("%s\n\n",COPYRIGHT_TEXT);
	printf("But du jeu :\n");
	printf("  - Obtenir plus de pions que son adversaire.\n\n");
	printf("Regles :\n");
	printf("  - A chaque tour, le joueur doit poser un pion\n");
	printf("    de maniere a encadrer une (ou plusieurs) ligne(s)\n");
	printf("    adverse(s) avec les pions deja presents sur le plateau\n");
	printf("  - Les pions ainsi encadres changent de couleur.\n");
	printf("  - Lorsqu'un joueur ne peut pas jouer, il passe son tour.\n");
	printf("  - La partie se termine lorsqu'aucun des joueurs ne\n");
	printf("    peut poser de pion. Le joueur possedant le plus de pions\n");
	printf("    est alors designe gagnant.\n\n");
	printf("Strategie :\n");
	printf("  - Il est fort interessant de prendre les coins.\n");
	printf("  - Il est fort dommageable de donner les coins...\n\n");
	printf("Ethique :\n");
	printf("  - L'abandon est une preuve d'impolitesse vis-a-vis\n");
	printf("    de l'adversaire. Il est de toute maniere enregistre,\n");
	printf("    tout comme une defaite, dans la table des scores.\n\n");
}

void main(int argc,char **argv)
{
	int	port;
	Initializations();
	ParseCommandLine(argc,argv);
	Start(argc,argv);
	if ( ! userport )
	{
		for (port=DEFAULT_PORT;port>DEFAULT_PORT-MAX_TRIES;port--)
			if ( GetConnection(port) ) break;
		if ( port == DEFAULT_PORT-MAX_TRIES )
		{
			for (port=DEFAULT_PORT;port>DEFAULT_PORT-MAX_TRIES;port--)
				if ( SetConnection(port) ) break;
			if ( port == DEFAULT_PORT-MAX_TRIES )
			{
				fprintf(stderr,"Impossible de trouver un port ?!\n");
				exit(-1);
			}
		}
	}
	else
	{
		if ( (!GetConnection(userport)) && (!SetConnection(userport)) )
		{
			fprintf(stderr,"Il y a deja une partie sur ce port !\n");
			exit(-1);
		}
	}
	if ( ! nohelp )
		Help();
	Loop();
}
oard[c][l] != -1 )
		return 0;
	for (d=0;d<8;d++)
	{
		for (i=1;;i++)
		{
			if ( (c+i*dc[d]<0) ||
				 (c+i*dc[d]>7) ||
				 (l+i*dl[d]<0) ||
				 (l+i*dl[d]>7) )
				break;
			if ( (i==1) && (board[c+i*dc[d]][l+i*dl[d]]!=1-j) )
				break;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==j) )
				return 1;
			if ( (i>=2) && (board[c+i*dc[d]][l+i*dl[d]]==-1) )
				break;
		}
	}
	returnxoth-1.0/xoth.h   640  14125  75616       15362  6115340170   6704 /*
 *	Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr
 *	Jeu d'Othello pour X11
 *
 */

#define DEFAULT_SERVER		"localhost"
#define DEFAULT_PORT		9999
#define MAX_TRIES		20

#define DEFAULT_WIDTH		380
#define DEFAULT_HEIGHT		460

#define COPYRIGHT_TEXT		"Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr"
#define TITLE_TEXT		"OTHELLO"

#define COPYRIGHT_FONT		"-adobe-times-*-r-*-*-14-*-*-*-*-*-*-*"
#define TITLE_FONT		"-adobe-new century schoolbook-*-r-*-*-24-*-*-*-*-*-*-*"
#define PSEUDO_FONT		"-adobe-helvetica-*-o-*-*-18-*-*-*-*-*-*-*"
#define MESSAGE_FONT		"-adobe-courier-*-r-*-*-18-*-*-*-*-*-*-*"

#define C_FLECHE		1
#define C_MONTRE		2
#define C_CROIX			3
#define C_UNKNOWN		-1

#define TRACE_FILE		"/travail_temp/xoth_scores"

#define COULEUR_FOND		"gray60"
#define COULEUR_JOUEUR0		"black"
#define COULEUR_JOUEUR1		"white"
#define COULEUR_SCFG		"red"
#define COULEUR_SCBG		"black"

char				*friends[] =
				{
					"sellin",	"Eric",
					"salmon",	"Emeric",
					"marliot",	"Christophe",
					"kyheng",	"Arnaud",
					"lemouel",	"Fred",
					"thomas",	"Franck",
					"bougeard",	"Dede",
					"jaffres",	"Laurent",
					"pouilly",	"Sylvain",
					NULL
				};

#define DIGIT_WIDTH		20
#define DIGIT_HEIGHT		30

static char chiffres[10][90] = {
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xfd,
   0x13, 0x80, 0xfc, 0x23, 0x40, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xe3, 0x7f, 0xfc,
   0xf3, 0xff, 0xfc, 0xfb, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xfd,
   0xf3, 0xff, 0xfc, 0xe3, 0x7f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0x23, 0x40, 0xfc, 0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd,
   0xff, 0xff, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc,
   0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd,
   0xff, 0xff, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x7f, 0xfc, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0x3f, 0x40, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc,
   0x1f, 0x80, 0xfc, 0x0f, 0x00, 0xfd, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xff,
   0x13, 0x80, 0xff, 0xe3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff,
   0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff,
   0x23, 0xc0, 0xff, 0x13, 0x80, 0xff, 0x0b, 0x00, 0xff, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0x3f, 0x40, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc,
   0x1f, 0x80, 0xfc, 0x0f, 0x00, 0xfd, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0x3f, 0x40, 0xfc, 0x1f, 0x80, 0xfc, 0x0f, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xfd,
   0xf3, 0xff, 0xfc, 0xe3, 0x7f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xe3, 0x7f, 0xfc,
   0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x7f, 0xfc, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xff,
   0x13, 0x80, 0xff, 0x23, 0xc0, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff,
   0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xe3, 0xff, 0xff,
   0x13, 0x80, 0xff, 0x0b, 0x00, 0xff, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0x3f, 0x40, 0xfc, 0x1f, 0x80, 0xfc, 0x0f, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xff,
   0x13, 0x80, 0xff, 0x23, 0xc0, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff,
   0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xe3, 0xff, 0xff,
   0x13, 0x80, 0xff, 0x0b, 0x00, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xfd,
   0x13, 0x80, 0xfc, 0xe3, 0x7f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0x23, 0x40, 0xfc, 0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0x3f, 0x40, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc,
   0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd,
   0xff, 0xff, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x7f, 0xfc, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xfd,
   0x13, 0x80, 0xfc, 0x23, 0x40, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xe3, 0x7f, 0xfc,
   0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xfd,
   0x13, 0x80, 0xfc, 0xe3, 0x7f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0x23, 0x40, 0xfc, 0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xfd,
   0x13, 0x80, 0xfc, 0x23, 0x40, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xe3, 0x7f, 0xfc,
   0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0x3f, 0x40, 0xfc, 0x1f, 0x80, 0xfc, 0x0f, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
};

FAULT_PORT-MAX_TRIES;port--)
				if ( SetConnection(port) ) break;
			if ( port == DEFAULT_PORT-MAX_TRIES )
			{
				fprintf(stderr,"Impossible de trouver un port ?!\n");
				exit(-1);
			}
		}
	}
	else
	{
		if ( (!GetConnection(userport)) && (!SetConnection(userport)) /*
 *	Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr
 *	Jeu d'Othello pour X11
 *
 */

#define DEFAULT_SERVER		"localhost"
#define DEFAULT_PORT		9999
#define MAX_TRIES		20

#define DEFAULT_WIDTH		380
#define DEFAULT_HEIGHT		460

#define COPYRIGHT_TEXT		"Xoth, (c) 1996 sellin@ifsic.univ-rennes1.fr"
#define TITLE_TEXT		"OTHELLO"

#define COPYRIGHT_FONT		"-adobe-times-*-r-*-*-14-*-*-*-*-*-*-*"
#define TITLE_FONT		"-adobe-new century schoolbook-*-r-*-*-24-*-*-*-*-*-*-*"
#define PSEUDO_FONT		"-adobe-helvetica-*-o-*-*-18-*-*-*-*-*-*-*"
#define MESSAGE_FONT		"-adobe-courier-*-r-*-*-18-*-*-*-*-*-*-*"

#define C_FLECHE		1
#define C_MONTRE		2
#define C_CROIX			3
#define C_UNKNOWN		-1

#define TRACE_FILE		"/travail_temp/xoth_scores"

#define COULEUR_FOND		"gray60"
#define COULEUR_JOUEUR0		"black"
#define COULEUR_JOUEUR1		"white"
#define COULEUR_SCFG		"red"
#define COULEUR_SCBG		"black"

char				*friends[] =
				{
					"sellin",	"Eric",
					"salmon",	"Emeric",
					"marliot",	"Christophe",
					"kyheng",	"Arnaud",
					"lemouel",	"Fred",
					"thomas",	"Franck",
					"bougeard",	"Dede",
					"jaffres",	"Laurent",
					"pouilly",	"Sylvain",
					NULL
				};

#define DIGIT_WIDTH		20
#define DIGIT_HEIGHT		30

static char chiffres[10][90] = {
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0b, 0x00, 0xfd,
   0x13, 0x80, 0xfc, 0x23, 0x40, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xe3, 0x7f, 0xfc,
   0xf3, 0xff, 0xfc, 0xfb, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xfd,
   0xf3, 0xff, 0xfc, 0xe3, 0x7f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc, 0xc3, 0x3f, 0xfc,
   0x23, 0x40, 0xfc, 0x13, 0x80, 0xfc, 0x0b, 0x00, 0xfd, 0x07, 0x00, 0xfe,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd,
   0xff, 0xff, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x7f, 0xfc,
   0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd,
   0xff, 0xff, 0xfc, 0xff, 0x7f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x7f, 0xfc, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
  {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0xfe, 0x0f, 0x00, 0xfd,
   0x1f, 0x80, 0xfc, 0x3f, 0x40, 0xfc, 0xff, 0x3f, 0xfc, 0xff, 0x3f, 0xfc,
   0xff, 0x3f, 0xfc, 0xff, 0x3f, 0x
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2009 MARUHN Internet Solutions