1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
int main(int ac, char **av)
{
char *cmd;
char **list_cmd;
Game *this;
int i = 0;
int p_ac;
fd_set rfds;
struct timeval tv;
int retval;
char *bufi;
int l;
if (ac != 3)
return (-1);
bufi = malloc(1000);
bufi[900] = 0;
this = malloc(sizeof(Game));
init_game(this);
this->sock = get_socket(av[2], av[1]);
Vbuff(bufi);
printf("%d\n", this->sock);
while (this->end == 0)
{
tv.tv_sec = 0.02;
tv.tv_usec = 0;
list_cmd = NULL;
FD_ZERO(&rfds);
FD_SET(this->sock,&rfds);
retval = select(6, &rfds, NULL, NULL, &tv);
Vbuff(bufi);
if (retval)
{
if (recup_cmd(this->sock,bufi) == 0)
{
bufi[strlen(bufi)-1] = 0;
list_cmd = Cut_cmd(bufi);
Vbuff(bufi);
}
}
if (list_cmd != NULL)
{
i = 0;
p_ac = 0;
while (list_cmd[p_ac])
p_ac++;
while (list[i].name != NULL)
{
if (strcmp (list[i].name,list_cmd[0]) == 0 && p_ac-1 == list[i].argc)
list[i].func(p_ac,list_cmd,this);
i++;
}
}
aff_all(this);
}
printf("%d\n", this->end);
SDL_Quit();
return (0);
} |
Partager