equal
deleted
inserted
replaced
189 // Again, the next couple of functions are endian-safe |
189 // Again, the next couple of functions are endian-safe |
190 // see the comment around NetworkSend_uint8 for more info. |
190 // see the comment around NetworkSend_uint8 for more info. |
191 uint8 NetworkRecv_uint8(NetworkClientState *cs, Packet *packet) |
191 uint8 NetworkRecv_uint8(NetworkClientState *cs, Packet *packet) |
192 { |
192 { |
193 /* Don't allow reading from a closed socket */ |
193 /* Don't allow reading from a closed socket */ |
194 if (cs->quited) return 0; |
194 if (cs->has_quit) return 0; |
195 |
195 |
196 /* Check if variable is within packet-size */ |
196 /* Check if variable is within packet-size */ |
197 if (packet->pos + 1 > packet->size) { |
197 if (packet->pos + 1 > packet->size) { |
198 CloseConnection(cs); |
198 CloseConnection(cs); |
199 return 0; |
199 return 0; |
205 uint16 NetworkRecv_uint16(NetworkClientState *cs, Packet *packet) |
205 uint16 NetworkRecv_uint16(NetworkClientState *cs, Packet *packet) |
206 { |
206 { |
207 uint16 n; |
207 uint16 n; |
208 |
208 |
209 /* Don't allow reading from a closed socket */ |
209 /* Don't allow reading from a closed socket */ |
210 if (cs->quited) return 0; |
210 if (cs->has_quit) return 0; |
211 |
211 |
212 /* Check if variable is within packet-size */ |
212 /* Check if variable is within packet-size */ |
213 if (packet->pos + 2 > packet->size) { |
213 if (packet->pos + 2 > packet->size) { |
214 CloseConnection(cs); |
214 CloseConnection(cs); |
215 return 0; |
215 return 0; |
223 uint32 NetworkRecv_uint32(NetworkClientState *cs, Packet *packet) |
223 uint32 NetworkRecv_uint32(NetworkClientState *cs, Packet *packet) |
224 { |
224 { |
225 uint32 n; |
225 uint32 n; |
226 |
226 |
227 /* Don't allow reading from a closed socket */ |
227 /* Don't allow reading from a closed socket */ |
228 if (cs->quited) return 0; |
228 if (cs->has_quit) return 0; |
229 |
229 |
230 /* Check if variable is within packet-size */ |
230 /* Check if variable is within packet-size */ |
231 if (packet->pos + 4 > packet->size) { |
231 if (packet->pos + 4 > packet->size) { |
232 CloseConnection(cs); |
232 CloseConnection(cs); |
233 return 0; |
233 return 0; |
243 uint64 NetworkRecv_uint64(NetworkClientState *cs, Packet *packet) |
243 uint64 NetworkRecv_uint64(NetworkClientState *cs, Packet *packet) |
244 { |
244 { |
245 uint64 n; |
245 uint64 n; |
246 |
246 |
247 /* Don't allow reading from a closed socket */ |
247 /* Don't allow reading from a closed socket */ |
248 if (cs->quited) return 0; |
248 if (cs->has_quit) return 0; |
249 |
249 |
250 /* Check if variable is within packet-size */ |
250 /* Check if variable is within packet-size */ |
251 if (packet->pos + 8 > packet->size) { |
251 if (packet->pos + 8 > packet->size) { |
252 CloseConnection(cs); |
252 CloseConnection(cs); |
253 return 0; |
253 return 0; |
269 { |
269 { |
270 PacketSize pos; |
270 PacketSize pos; |
271 char *bufp = buffer; |
271 char *bufp = buffer; |
272 |
272 |
273 /* Don't allow reading from a closed socket */ |
273 /* Don't allow reading from a closed socket */ |
274 if (cs->quited) return; |
274 if (cs->has_quit) return; |
275 |
275 |
276 pos = p->pos; |
276 pos = p->pos; |
277 while (--size > 0 && pos < p->size && (*buffer++ = p->buffer[pos++]) != '\0') {} |
277 while (--size > 0 && pos < p->size && (*buffer++ = p->buffer[pos++]) != '\0') {} |
278 |
278 |
279 if (size == 0 || pos == p->size) { |
279 if (size == 0 || pos == p->size) { |