|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: ogcache-client.c,v 1.3 2004/01/06 04:49:36 stpohle Exp $
|
|
|
|
|
/* $Id: ogcache-client.c,v 1.4 2004/01/06 19:52:02 stpohle Exp $
|
|
|
|
|
* OpenGameCache-Client: this file will hold the protocol for the gameserver communication
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
@ -9,9 +9,9 @@
|
|
|
|
|
|
|
|
|
|
int ogc_sock = -1;
|
|
|
|
|
struct game_entry ogc_array[MAX_OGC_ENTRYS];
|
|
|
|
|
char ogc_host[LEN_OGCHOST];
|
|
|
|
|
char ogc_port[LEN_OGCPORT];
|
|
|
|
|
char ogc_game[LEN_GAME];
|
|
|
|
|
char ogc_host[LEN_OGCHOST+1];
|
|
|
|
|
char ogc_port[LEN_OGCPORT+1];
|
|
|
|
|
char ogc_game[LEN_GAME+1];
|
|
|
|
|
int ogc_ai_family;
|
|
|
|
|
struct _sockaddr ogc_addr;
|
|
|
|
|
int ogc_browsing = 0;
|
|
|
|
@ -165,18 +165,19 @@ static int ogc_do_inpacket (char *in, int len, struct _sockaddr *addr) {
|
|
|
|
|
int ogc_init (char *localport, char *server, char *port, char *game, int ai_family) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* check if the socket is still open, if so close it */
|
|
|
|
|
if (ogc_sock != -1) ogc_shutdown ();
|
|
|
|
|
ogc_sock = -1;
|
|
|
|
|
|
|
|
|
|
ogc_sock = udp_server (localport, ai_family);
|
|
|
|
|
d_printf ("ogc_init (Localport: %s, Server %s:%s Game %s socket=%d)\n", localport, server, port, game, ogc_sock);
|
|
|
|
|
if (ogc_sock <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
strncpy (ogc_host, server, LEN_OGCHOST);
|
|
|
|
|
strncpy (ogc_port, port, LEN_OGCHOST);
|
|
|
|
|
strncpy (ogc_port, port, LEN_OGCPORT);
|
|
|
|
|
strncpy (ogc_game, game, LEN_GAME);
|
|
|
|
|
ogc_ai_family = ai_family;
|
|
|
|
|
|
|
|
|
|
d_printf ("ogc_host:%s ogc_port:%s ogc_game:%s ogc_ai_family:%d\n", ogc_host, ogc_port, ogc_game, ogc_ai_family);
|
|
|
|
|
dns_filladdr (ogc_host, LEN_OGCHOST, ogc_port, LEN_OGCPORT, ogc_ai_family, &ogc_addr);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_OGC_ENTRYS; i++)
|
|
|
|
@ -224,7 +225,9 @@ void ogc_shutdown () {
|
|
|
|
|
if (ogc_sock <= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ogc_browsestop ();
|
|
|
|
|
d_printf ("ogc_shutdown\n");
|
|
|
|
|
if (ogc_browsing)
|
|
|
|
|
ogc_browsestop ();
|
|
|
|
|
udp_close (ogc_sock);
|
|
|
|
|
|
|
|
|
|
ogc_sock = -1;
|
|
|
|
@ -261,6 +264,8 @@ int ogc_loop () {
|
|
|
|
|
void ogc_browsestart () {
|
|
|
|
|
char data[BUF_SIZE];
|
|
|
|
|
|
|
|
|
|
d_printf ("ogc_browsestart\n");
|
|
|
|
|
|
|
|
|
|
if (ogc_sock <= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -277,6 +282,8 @@ void ogc_browsestart () {
|
|
|
|
|
void ogc_browsestop () {
|
|
|
|
|
char data[BUF_SIZE];
|
|
|
|
|
|
|
|
|
|
d_printf ("ogc_browsestop\n");
|
|
|
|
|
|
|
|
|
|
ogc_browsing = 0;
|
|
|
|
|
if (ogc_sock <= 0)
|
|
|
|
|
return;
|
|
|
|
|