(svn r4292) - CodeChange: sprinkle some holy water on l'ugly code (braces, and pos is PacketSize not int)

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
Darkvater 19 years ago
parent a39f69b9bd
commit 558ecb1631

@ -270,24 +270,23 @@ uint64 NetworkRecv_uint64(NetworkClientState *cs, Packet *packet)
} }
// Reads a string till it finds a '\0' in the stream // Reads a string till it finds a '\0' in the stream
void NetworkRecv_string(NetworkClientState *cs, Packet *p, char* buffer, size_t size) void NetworkRecv_string(NetworkClientState *cs, Packet *p, char *buffer, size_t size)
{ {
int pos; PacketSize pos;
char *bufp = buffer; char *bufp = buffer;
/* Don't allow reading from a closed socket */ /* Don't allow reading from a closed socket */
if (cs->quited) if (cs->quited) return;
return;
pos = p->pos; pos = p->pos;
while (--size > 0 && pos < p->size && (*buffer++ = p->buffer[pos++]) != '\0') {} while (--size > 0 && pos < p->size && (*buffer++ = p->buffer[pos++]) != '\0') {}
if (size == 0 || pos == p->size)
{ if (size == 0 || pos == p->size) {
*buffer = '\0'; *buffer = '\0';
// If size was sooner to zero then the string in the stream // If size was sooner to zero then the string in the stream
// skip till the \0, so the packet can be read out correctly for the rest // skip till the \0, so the packet can be read out correctly for the rest
while (pos < p->size && p->buffer[pos] != '\0') ++pos; while (pos < p->size && p->buffer[pos] != '\0') pos++;
++pos; pos++;
} }
p->pos = pos; p->pos = pos;

Loading…
Cancel
Save