|
|
|
@ -78,6 +78,7 @@ void server(void *data)
|
|
|
|
|
switch (event.type)
|
|
|
|
|
{
|
|
|
|
|
case ENET_EVENT_TYPE_CONNECT:
|
|
|
|
|
{
|
|
|
|
|
Log("A new client connected from %x:%u.\n",
|
|
|
|
|
event.peer->address.host,
|
|
|
|
|
event.peer->address.port);
|
|
|
|
@ -104,7 +105,10 @@ void server(void *data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case ENET_EVENT_TYPE_RECEIVE:
|
|
|
|
|
{
|
|
|
|
|
// Log("A packet of length %zu was received on channel %u.\n",
|
|
|
|
|
// event.packet->dataLength,
|
|
|
|
|
// event.channelID);
|
|
|
|
@ -156,13 +160,19 @@ void server(void *data)
|
|
|
|
|
enet_packet_destroy(event.packet);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ENET_EVENT_TYPE_DISCONNECT:
|
|
|
|
|
{
|
|
|
|
|
int player_index = (int64_t)event.peer->data;
|
|
|
|
|
Log("%" PRId64 " disconnected player index %d.\n", (int64_t)event.peer->data, player_index);
|
|
|
|
|
gs.players[player_index].connected = false;
|
|
|
|
|
// box_destroy(&gs.players[player_index].box);
|
|
|
|
|
event.peer->data = NULL;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|