Example #1
0
/* read from the fd, then parse the data */
TEG_STATUS client_recv( int fd )
{
	int i,j;
	PARSER p;
	char str[PROT_MAX_LEN];
	DELIM igualador={ '=', '=', '=' };
	DELIM separador={ ';', ';', ';' };

	p.igualador = &igualador;
	p.separador = &separador;

	memset(str,0,sizeof(str));
	j=net_readline( fd, str, PROT_MAX_LEN );

	if( j<1 ) {
		teg_disconnect();
		return TEG_STATUS_CONNCLOSED;
	}

	p.data = str;

	do {
		if( (i=parser_call( &p )) ) {
			if( client_lookup( fd,&p ) == TEG_STATUS_CONNCLOSED ) {
				return TEG_STATUS_CONNCLOSED;
			}
		}
	} while( i && p.hay_otro);

	return TEG_STATUS_SUCCESS;
}
Example #2
0
/* a players lost the connection of just quit the game */
TEG_STATUS clitok_exit( char *str )
{
	int numjug;
	PCPLAYER pJ;

	numjug = atoi( str );
	if( player_whois( numjug, &pJ) != TEG_STATUS_SUCCESS) {
		/* no lo tengo en la base */
		textmsg( M_IMP,_("Player %d exit the game"), numjug );
		return TEG_STATUS_SUCCESS;
	}

	textmsg( M_IMP,_("Player %s(%s) exit the game"),
				pJ->name,
				_(g_colores[pJ->color])
				);

	/* dont delete the player, I need the status */
	/* player_del( pJ ); */

	if( WHOAMI() == numjug ) {
		/* por alguna razon el server quiere que abandone el game */
		teg_disconnect();
	}

	return TEG_STATUS_SUCCESS;
}
Example #3
0
/* Servers's Protocol version. HIVER MUST be equal, otherwise wont work */
TEG_STATUS clitok_pversion( char *str)
{
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	int hi,lo;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( strlen(str)==0 )
		goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		hi = atoi( p.token );
	} else goto error;

	if( parser_call( &p ) && !p.hay_otro ) {
		lo = atoi( p.token );
	} else goto error;

	if( hi != PROTOCOL_HIVER ) {
		textmsg(M_ERR,_("Aborting: Different protocols version. Server:%d Client:%d"),hi,PROTOCOL_HIVER);
		teg_disconnect();
		return TEG_STATUS_ERROR;
	}

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_pversion()");
	return TEG_STATUS_ERROR;
}
Example #4
0
void on_exit_activate (GtkWidget *widget, gpointer user_data)
{
	teg_disconnect();
	cards_free();
	colors_free();
	gtk_main_quit();
}
Example #5
0
/* the game is already started. you cant join it */
TEG_STATUS clitok_started( void )
{
	textmsg( M_ERR, _("The game has already started. Try connecting as an observer."));
	teg_disconnect();
	return TEG_STATUS_SUCCESS;
}
Example #6
0
/* the server is full */
TEG_STATUS clitok_serverfull( void )
{
	textmsg( M_ERR, _("The server is full. Try connecting as an observer"));
	teg_disconnect();
	return TEG_STATUS_SUCCESS;
}
Example #7
0
void on_disconnect_activate (GtkMenuItem *menuitem, gpointer user_data)
{
	teg_disconnect();
}