network_data.c
changeset 3456 a270834d610f
parent 2989 916f9443345f
child 3457 5d0f8539dfb6
equal deleted inserted replaced
3455:fc1fb215e35b 3456:a270834d610f
   271 
   271 
   272 // Reads a string till it finds a '\0' in the stream
   272 // Reads a string till it finds a '\0' in the stream
   273 void NetworkRecv_string(NetworkClientState *cs, Packet *p, char* buffer, size_t size)
   273 void NetworkRecv_string(NetworkClientState *cs, Packet *p, char* buffer, size_t size)
   274 {
   274 {
   275 	int pos;
   275 	int pos;
       
   276 	char *bufp = buffer;
   276 
   277 
   277 	/* Don't allow reading from a closed socket */
   278 	/* Don't allow reading from a closed socket */
   278 	if (cs->quited)
   279 	if (cs->quited)
   279 		return;
   280 		return;
   280 
   281 
   287 		//  skip till the \0, so the packet can be read out correctly for the rest
   288 		//  skip till the \0, so the packet can be read out correctly for the rest
   288 		while (pos < p->size && p->buffer[pos] != '\0') ++pos;
   289 		while (pos < p->size && p->buffer[pos] != '\0') ++pos;
   289 		++pos;
   290 		++pos;
   290 	}
   291 	}
   291 	p->pos = pos;
   292 	p->pos = pos;
       
   293 
       
   294 	str_validate(bufp);
   292 }
   295 }
   293 
   296 
   294 // If PacketSize changes of size, you have to change the 2 packet->size
   297 // If PacketSize changes of size, you have to change the 2 packet->size
   295 //   lines below matching the size of packet->size/PacketSize!
   298 //   lines below matching the size of packet->size/PacketSize!
   296 // (the line: 'p->size = (uint16)p->buffer[0];' and below)
   299 // (the line: 'p->size = (uint16)p->buffer[0];' and below)