stub out enet_host_random_seed()

This commit is contained in:
lsalzman 2013-08-09 09:41:57 +03:00
parent 4697a58d53
commit 1658cf3a95
5 changed files with 16 additions and 18 deletions

7
host.c
View file

@ -4,7 +4,6 @@
*/ */
#define ENET_BUILDING_LIB 1 #define ENET_BUILDING_LIB 1
#include <string.h> #include <string.h>
#include <time.h>
#include "enet/enet.h" #include "enet/enet.h"
/** @defgroup host ENet host functions /** @defgroup host ENet host functions
@ -76,11 +75,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT; channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT;
host -> randomSeed = (enet_uint32) (size_t) host; host -> randomSeed = (enet_uint32) (size_t) host;
#ifdef WIN32 host -> randomSeed += enet_host_random_seed ();
host -> randomSeed += (enet_uint32) timeGetTime();
#else
host -> randomSeed += (enet_uint32) time(NULL);
#endif
host -> randomSeed = (host -> randomSeed << 16) | (host -> randomSeed >> 16); host -> randomSeed = (host -> randomSeed << 16) | (host -> randomSeed >> 16);
host -> channelLimit = channelLimit; host -> channelLimit = channelLimit;
host -> incomingBandwidth = incomingBandwidth; host -> incomingBandwidth = incomingBandwidth;

View file

@ -549,6 +549,7 @@ ENET_API int enet_host_compress_with_range_coder (ENetHost * host);
ENET_API void enet_host_channel_limit (ENetHost *, size_t); ENET_API void enet_host_channel_limit (ENetHost *, size_t);
ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32); ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
extern void enet_host_bandwidth_throttle (ENetHost *); extern void enet_host_bandwidth_throttle (ENetHost *);
extern void enet_host_random_seed (void);
ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *); ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID); ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID);

View file

@ -1666,12 +1666,7 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
enet_uint32 packetLoss = currentPeer -> packetsLost * ENET_PEER_PACKET_LOSS_SCALE / currentPeer -> packetsSent; enet_uint32 packetLoss = currentPeer -> packetsLost * ENET_PEER_PACKET_LOSS_SCALE / currentPeer -> packetsSent;
#ifdef ENET_DEBUG #ifdef ENET_DEBUG
#ifdef WIN32 printf ("peer %u: %f%%+-%f%% packet loss, %u+-%u ms round trip time, %f%% throttle, %u/%u outgoing, %u/%u incoming\n", currentPeer -> incomingPeerID, currentPeer -> packetLoss / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> packetLossVariance / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> roundTripTime, currentPeer -> roundTripTimeVariance, currentPeer -> packetThrottle / (float) ENET_PEER_PACKET_THROTTLE_SCALE, enet_list_size (& currentPeer -> outgoingReliableCommands), enet_list_size (& currentPeer -> outgoingUnreliableCommands), currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingReliableCommands) : 0, currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingUnreliableCommands) : 0);
printf (
#else
fprintf (stderr,
#endif
"peer %u: %f%%+-%f%% packet loss, %u+-%u ms round trip time, %f%% throttle, %u/%u outgoing, %u/%u incoming\n", currentPeer -> incomingPeerID, currentPeer -> packetLoss / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> packetLossVariance / (float) ENET_PEER_PACKET_LOSS_SCALE, currentPeer -> roundTripTime, currentPeer -> roundTripTimeVariance, currentPeer -> packetThrottle / (float) ENET_PEER_PACKET_THROTTLE_SCALE, enet_list_size (& currentPeer -> outgoingReliableCommands), enet_list_size (& currentPeer -> outgoingUnreliableCommands), currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingReliableCommands) : 0, currentPeer -> channels != NULL ? enet_list_size (& currentPeer -> channels -> incomingUnreliableCommands) : 0);
#endif #endif
currentPeer -> packetLossVariance -= currentPeer -> packetLossVariance / 4; currentPeer -> packetLossVariance -= currentPeer -> packetLossVariance / 4;
@ -1716,12 +1711,7 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
host -> headerFlags |= ENET_PROTOCOL_HEADER_FLAG_COMPRESSED; host -> headerFlags |= ENET_PROTOCOL_HEADER_FLAG_COMPRESSED;
shouldCompress = compressedSize; shouldCompress = compressedSize;
#ifdef ENET_DEBUG_COMPRESS #ifdef ENET_DEBUG_COMPRESS
#ifdef WIN32 printf ("peer %u: compressed %u -> %u (%u%%)\n", currentPeer -> incomingPeerID, originalSize, compressedSize, (compressedSize * 100) / originalSize);
printf (
#else
fprintf (stderr,
#endif
"peer %u: compressed %u -> %u (%u%%)\n", currentPeer -> incomingPeerID, originalSize, compressedSize, (compressedSize * 100) / originalSize);
#endif #endif
} }
} }

6
unix.c
View file

@ -68,6 +68,12 @@ enet_deinitialize (void)
{ {
} }
enet_uint32
enet_host_random_seed (void)
{
return (enet_uint32) time (NULL);
}
enet_uint32 enet_uint32
enet_time_get (void) enet_time_get (void)
{ {

View file

@ -40,6 +40,12 @@ enet_deinitialize (void)
WSACleanup (); WSACleanup ();
} }
enet_uint32
enet_host_random_seed (void)
{
return (enet_uint32) timeGetTime ();
}
enet_uint32 enet_uint32
enet_time_get (void) enet_time_get (void)
{ {