[enet-cvs] CVS: enet host.c,1.5,1.6 packet.c,1.1,1.2 peer.c,1.6,1.7 protocol.c,1.8,1.9 unix.c,1.5,1.6 win32.c,1.4,1.5
Lee Salzman
enet-discuss@lists.puremagic.com
Fri, 7 Mar 2003 15:10:10 -0700
Update of /home/enet/cvsroot/enet
In directory sferik:/tmp/cvs-serv5952/enet
Modified Files:
host.c packet.c peer.c protocol.c unix.c win32.c
Log Message:
Modified ENet to have cleaner typedefs.
Index: host.c
===================================================================
RCS file: /home/enet/cvsroot/enet/host.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- host.c 2002/07/28 21:26:06 1.5
+++ host.c 2003/03/07 22:10:08 1.6
@@ -2,7 +2,7 @@
#include <enet/enet.h>
ENetHost *
-enet_host_create (const ENetAddress * address, size_t peerCount, uint32 incomingBandwidth, uint32 outgoingBandwidth)
+enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth)
{
ENetHost * host = (ENetHost *) enet_malloc (sizeof (ENetHost));
ENetPeer * currentPeer;
@@ -133,7 +133,7 @@
}
void
-enet_host_broadcast (ENetHost * host, uint8 channelID, ENetPacket * packet)
+enet_host_broadcast (ENetHost * host, enet_uint8 channelID, ENetPacket * packet)
{
ENetPeer * currentPeer;
@@ -152,7 +152,7 @@
}
void
-enet_host_bandwidth_limit (ENetHost * host, uint32 incomingBandwidth, uint32 outgoingBandwidth)
+enet_host_bandwidth_limit (ENetHost * host, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth)
{
host -> incomingBandwidth = incomingBandwidth;
host -> outgoingBandwidth = outgoingBandwidth;
@@ -162,7 +162,7 @@
void
enet_host_bandwidth_throttle (ENetHost * host)
{
- uint32 timeCurrent = enet_time_get (),
+ enet_uint32 timeCurrent = enet_time_get (),
elapsedTime = timeCurrent - host -> bandwidthThrottleEpoch,
peersTotal = 0,
dataTotal = 0,
@@ -212,7 +212,7 @@
peer < & host -> peers [host -> peerCount];
++ peer)
{
- uint32 peerBandwidth;
+ enet_uint32 peerBandwidth;
if (peer -> state != ENET_PEER_STATE_CONNECTED ||
peer -> incomingBandwidth == 0 ||
Index: packet.c
===================================================================
RCS file: /home/enet/cvsroot/enet/packet.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- packet.c 2002/02/10 21:27:03 1.1
+++ packet.c 2003/03/07 22:10:08 1.2
@@ -3,11 +3,11 @@
#include <enet/enet.h>
ENetPacket *
-enet_packet_create (const void * data, size_t dataLength, uint32 flags)
+enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags)
{
ENetPacket * packet = (ENetPacket *) enet_malloc (sizeof (ENetPacket));
- packet -> data = (uint8 *) enet_malloc (dataLength);
+ packet -> data = (enet_uint8 *) enet_malloc (dataLength);
if (data != NULL)
memcpy (packet -> data, data, dataLength);
@@ -29,7 +29,7 @@
int
enet_packet_resize (ENetPacket * packet, size_t dataLength)
{
- uint8 * newData;
+ enet_uint8 * newData;
if (dataLength <= packet -> dataLength)
{
@@ -38,7 +38,7 @@
return 0;
}
- newData = (uint8 *) enet_realloc (packet -> data, dataLength);
+ newData = (enet_uint8 *) enet_realloc (packet -> data, dataLength);
packet -> data = newData;
packet -> dataLength = dataLength;
Index: peer.c
===================================================================
RCS file: /home/enet/cvsroot/enet/peer.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- peer.c 2002/07/28 21:26:06 1.6
+++ peer.c 2003/03/07 22:10:08 1.7
@@ -2,7 +2,7 @@
#include <enet/enet.h>
void
-enet_peer_throttle_configure (ENetPeer * peer, uint32 interval, uint32 acceleration, uint32 deceleration)
+enet_peer_throttle_configure (ENetPeer * peer, enet_uint32 interval, enet_uint32 acceleration, enet_uint32 deceleration)
{
ENetProtocol command;
@@ -23,7 +23,7 @@
}
int
-enet_peer_throttle (ENetPeer * peer, uint32 rtt)
+enet_peer_throttle (ENetPeer * peer, enet_uint32 rtt)
{
if (peer -> bestRoundTripTime <= peer -> roundTripTimeVariance)
{
@@ -54,7 +54,7 @@
}
int
-enet_peer_send (ENetPeer * peer, uint8 channelID, ENetPacket * packet)
+enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet)
{
ENetChannel * channel = & peer -> channels [channelID];
ENetProtocol command;
@@ -67,7 +67,7 @@
if (packet -> dataLength > fragmentLength)
{
- uint32 fragmentCount = ENET_HOST_TO_NET_32 ((packet -> dataLength + fragmentLength - 1) / fragmentLength),
+ enet_uint32 fragmentCount = ENET_HOST_TO_NET_32 ((packet -> dataLength + fragmentLength - 1) / fragmentLength),
startSequenceNumber = ENET_HOST_TO_NET_32 (channel -> outgoingReliableSequenceNumber + 1),
fragmentNumber,
fragmentOffset;
@@ -121,7 +121,7 @@
}
ENetPacket *
-enet_peer_receive (ENetPeer * peer, uint8 channelID)
+enet_peer_receive (ENetPeer * peer, enet_uint8 channelID)
{
ENetChannel * channel = & peer -> channels [channelID];
ENetIncomingCommand * incomingCommand = NULL;
@@ -354,7 +354,7 @@
}
ENetAcknowledgement *
-enet_peer_queue_acknowledgement (ENetPeer * peer, const ENetProtocol * command, uint32 sentTime)
+enet_peer_queue_acknowledgement (ENetPeer * peer, const ENetProtocol * command, enet_uint32 sentTime)
{
ENetAcknowledgement * acknowledgement;
@@ -371,7 +371,7 @@
}
ENetOutgoingCommand *
-enet_peer_queue_outgoing_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, uint32 offset, uint16 length)
+enet_peer_queue_outgoing_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 offset, enet_uint16 length)
{
ENetChannel * channel = & peer -> channels [command -> header.channelID];
ENetOutgoingCommand * outgoingCommand;
@@ -424,10 +424,10 @@
}
ENetIncomingCommand *
-enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, uint32 fragmentCount)
+enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 fragmentCount)
{
ENetChannel * channel = & peer -> channels [command -> header.channelID];
- uint32 unreliableSequenceNumber = 0;
+ enet_uint32 unreliableSequenceNumber = 0;
ENetIncomingCommand * incomingCommand;
ENetListIterator currentCommand;
@@ -485,7 +485,7 @@
incomingCommand -> packet = packet;
if (fragmentCount > 0)
- incomingCommand -> fragments = (uint32 *) enet_calloc ((fragmentCount + 31) / 32, sizeof (uint32));
+ incomingCommand -> fragments = (enet_uint32 *) enet_calloc ((fragmentCount + 31) / 32, sizeof (enet_uint32));
else
incomingCommand -> fragments = NULL;
Index: protocol.c
===================================================================
RCS file: /home/enet/cvsroot/enet/protocol.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- protocol.c 2003/03/07 06:37:36 1.8
+++ protocol.c 2003/03/07 22:10:08 1.9
@@ -3,7 +3,7 @@
#include <enet/time.h>
#include <enet/enet.h>
-static uint32 timeCurrent;
+static enet_uint32 timeCurrent;
static int
enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event)
@@ -50,7 +50,7 @@
event -> type = ENET_EVENT_TYPE_RECEIVE;
event -> peer = currentPeer;
- event -> channelID = (uint8) (channel - currentPeer -> channels);
+ event -> channelID = (enet_uint8) (channel - currentPeer -> channels);
host -> lastServicedPeer = currentPeer;
@@ -85,7 +85,7 @@
}
static void
-enet_protocol_remove_sent_reliable_command (ENetPeer * peer, uint32 reliableSequenceNumber, uint8 channelID)
+enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint32 reliableSequenceNumber, enet_uint8 channelID)
{
ENetOutgoingCommand * outgoingCommand;
ENetListIterator currentCommand;
@@ -129,8 +129,8 @@
static ENetPeer *
enet_protocol_handle_connect (ENetHost * host, const ENetProtocolHeader * header, const ENetProtocol * command)
{
- uint16 packetSize;
- uint32 windowSize;
+ enet_uint16 packetSize;
+ enet_uint32 windowSize;
ENetChannel * channel;
size_t channelCount;
ENetPeer * currentPeer;
@@ -229,7 +229,7 @@
if (command -> header.commandLength <= sizeof (ENetProtocolSendReliable))
return;
- packet = enet_packet_create ((const uint8 *) command + sizeof (ENetProtocolSendReliable),
+ packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendReliable),
command -> header.commandLength - sizeof (ENetProtocolSendReliable),
ENET_PACKET_FLAG_RELIABLE);
@@ -244,7 +244,7 @@
if (command -> header.commandLength <= sizeof (ENetProtocolSendUnreliable))
return;
- packet = enet_packet_create ((const uint8 *) command + sizeof (ENetProtocolSendUnreliable),
+ packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable),
command -> header.commandLength - sizeof (ENetProtocolSendUnreliable),
0);
@@ -254,7 +254,7 @@
static void
enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
{
- uint32 fragmentNumber,
+ enet_uint32 fragmentNumber,
fragmentCount,
fragmentOffset,
fragmentLength,
@@ -312,7 +312,7 @@
fragmentLength = startCommand -> packet -> dataLength - fragmentOffset;
memcpy (startCommand -> packet -> data + fragmentOffset,
- (uint8 *) command + sizeof (ENetProtocolSendFragment),
+ (enet_uint8 *) command + sizeof (ENetProtocolSendFragment),
fragmentLength);
}
@@ -356,7 +356,7 @@
static int
enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * peer, const ENetProtocol * command)
{
- uint32 roundTripTime,
+ enet_uint32 roundTripTime,
receivedSentTime,
receivedReliableSequenceNumber;
@@ -436,8 +436,8 @@
static void
enet_protocol_handle_verify_connect (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
{
- uint16 packetSize;
- uint32 windowSize;
+ enet_uint16 packetSize;
+ enet_uint32 windowSize;
if (command -> header.commandLength < sizeof (ENetProtocolVerifyConnect))
return;
@@ -486,7 +486,7 @@
ENetProtocolHeader * header;
ENetProtocol * command;
ENetPeer * peer;
- uint8 * currentData;
+ enet_uint8 * currentData;
size_t commandCount;
if (host -> receivedDataLength < sizeof (ENetProtocolHeader))
@@ -842,15 +842,15 @@
if (outgoingCommand -> packet != NULL)
{
- if ((uint16) (peer -> packetSize - host -> packetSize) <
- (uint16) (outgoingCommand -> command.header.commandLength +
+ if ((enet_uint16) (peer -> packetSize - host -> packetSize) <
+ (enet_uint16) (outgoingCommand -> command.header.commandLength +
outgoingCommand -> fragmentLength) ||
peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > peer -> windowSize)
break;
}
else
if (outgoingCommand -> command.header.command == ENET_PROTOCOL_COMMAND_CONNECT)
- peer -> challenge = (uint32) rand ();
+ peer -> challenge = (enet_uint32) rand ();
if (outgoingCommand -> roundTripTimeout == 0)
{
@@ -956,7 +956,7 @@
if (ENET_TIME_DIFFERENCE (timeCurrent, currentPeer -> packetLossEpoch) >= ENET_PEER_PACKET_LOSS_INTERVAL &&
currentPeer -> packetsSent > 0)
{
- 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
fprintf (stderr, "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), enet_list_size (& currentPeer -> channels -> incomingReliableCommands), enet_list_size (& currentPeer -> channels -> incomingUnreliableCommands));
@@ -1013,9 +1013,9 @@
}
int
-enet_host_service (ENetHost * host, ENetEvent * event, uint32 timeout)
+enet_host_service (ENetHost * host, ENetEvent * event, enet_uint32 timeout)
{
- uint32 waitCondition;
+ enet_uint32 waitCondition;
event -> type = ENET_EVENT_TYPE_NONE;
event -> peer = NULL;
Index: unix.c
===================================================================
RCS file: /home/enet/cvsroot/enet/unix.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- unix.c 2002/10/28 23:45:28 1.5
+++ unix.c 2003/03/07 22:10:08 1.6
@@ -23,7 +23,7 @@
#define MSG_NOSIGNAL 0
#endif
-static uint32 timeBase = 0;
+static enet_uint32 timeBase = 0;
int
enet_initialize (void)
@@ -36,7 +36,7 @@
{
}
-uint32
+enet_uint32
enet_time_get (void)
{
struct timeval timeVal;
@@ -47,7 +47,7 @@
}
void
-enet_time_set (uint32 newTimeBase)
+enet_time_set (enet_uint32 newTimeBase)
{
struct timeval timeVal;
@@ -78,7 +78,7 @@
hostEntry -> h_addrtype != AF_INET)
return -1;
- address -> host = * (uint32 *) hostEntry -> h_addr_list [0];
+ address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
return 0;
}
@@ -191,7 +191,7 @@
if (address != NULL)
{
- address -> host = (uint32) sin.sin_addr.s_addr;
+ address -> host = (enet_uint32) sin.sin_addr.s_addr;
address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
}
@@ -280,7 +280,7 @@
if (address != NULL)
{
- address -> host = (uint32) sin.sin_addr.s_addr;
+ address -> host = (enet_uint32) sin.sin_addr.s_addr;
address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
}
@@ -288,7 +288,7 @@
}
int
-enet_socket_wait (ENetSocket socket, uint32 * condition, uint32 timeout)
+enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
{
#ifdef HAS_POLL
struct pollfd pollSocket;
Index: win32.c
===================================================================
RCS file: /home/enet/cvsroot/enet/win32.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- win32.c 2002/10/10 20:34:49 1.4
+++ win32.c 2003/03/07 22:10:08 1.5
@@ -3,7 +3,7 @@
#include <time.h>
#include <enet/enet.h>
-static uint32 timeBase = 0;
+static enet_uint32 timeBase = 0;
int
enet_initialize (void)
@@ -31,16 +31,16 @@
WSACleanup ();
}
-uint32
+enet_uint32
enet_time_get (void)
{
- return (uint32) GetTickCount () - timeBase;
+ return (enet_uint32) GetTickCount () - timeBase;
}
void
-enet_time_set (uint32 newTimeBase)
+enet_time_set (enet_uint32 newTimeBase)
{
- timeBase = (uint32) GetTickCount () - newTimeBase;
+ timeBase = (enet_uint32) GetTickCount () - newTimeBase;
}
int
@@ -53,7 +53,7 @@
hostEntry -> h_addrtype != AF_INET)
return -1;
- address -> host = * (uint32 *) hostEntry -> h_addr_list [0];
+ address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
return 0;
}
@@ -153,7 +153,7 @@
if (address != NULL)
{
- address -> host = (uint32) sin.sin_addr.s_addr;
+ address -> host = (enet_uint32) sin.sin_addr.s_addr;
address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
}
@@ -237,7 +237,7 @@
if (address != NULL)
{
- address -> host = (uint32) sin.sin_addr.s_addr;
+ address -> host = (enet_uint32) sin.sin_addr.s_addr;
address -> port = ENET_NET_TO_HOST_16 (sin.sin_port);
}
@@ -245,7 +245,7 @@
}
int
-enet_socket_wait (ENetSocket socket, uint32 * condition, uint32 timeout)
+enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
{
fd_set readSet, writeSet;
struct timeval timeVal;