MCPcopy Create free account
hub / github.com/TASEmulators/fceux / KillClient

Function KillClient

fceux-server/server.cpp:544–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544static void KillClient(ClientEntry *client)
545{
546 GameEntry *game;
547 uint8 *mps;
548 char *bmsg;
549
550 game = (GameEntry *)client->game;
551 if(game)
552 {
553 int w;
554 int tc = 0;
555
556 for(w=0;w<game->MaxPlayers;w++)
557 if(game->Players[w]) tc++;
558
559 for(w=0;w<game->MaxPlayers;w++)
560 if(game->Players[w])
561 if(game->Players[w] == client)
562 game->Players[w] = NULL;
563
564 time_t curtime = time(0);
565 printf("Player <%s> disconnected from game %d on %s",client->nickname,game-Games,ctime(&curtime));
566 asprintf(&bmsg, "* Player %s <%s> left.",MakeMPS(client),client->nickname);
567 if(tc == client->localplayers) /* If total players for this game = total local
568 players for this client, destroy the game.
569 */
570 {
571 printf("Game %d destroyed.\n",game-Games);
572 memset(game, 0, sizeof(GameEntry));
573 game = 0;
574 }
575 }
576 else
577 {
578 time_t curtime = time(0);
579 printf("Unassigned client %d disconnected on %s",client->id, ctime(&curtime));
580 }
581
582 if(client->nbtcp)
583 free(client->nbtcp);
584
585 if(client->nickname)
586 free(client->nickname);
587
588 if(client->TCPSocket != -1)
589 close(client->TCPSocket);
590
591 memset(client, 0, sizeof(ClientEntry));
592 client->TCPSocket = -1;
593
594 if(game)
595 BroadcastText(game,"%s",bmsg);
596}
597
598static void AddClientToGame(ClientEntry *client, uint8 id[16], uint8 extra[64]) throw()
599{

Callers 4

CheckNBTCPReceiveFunction · 0.85
SendToAllFunction · 0.85
AddClientToGameFunction · 0.85
mainFunction · 0.85

Calls 4

asprintfFunction · 0.85
MakeMPSFunction · 0.85
closeFunction · 0.85
BroadcastTextFunction · 0.85

Tested by

no test coverage detected