Takes a bunch of messages, check them for validity, and pass them to multi_process_data.
| 9953 | // Takes a bunch of messages, check them for validity, |
| 9954 | // and pass them to multi_process_data. |
| 9955 | void MultiProcessBigData(uint8_t *buf, int len, network_address *from_addr) { |
| 9956 | int type, bytes_processed = 0; |
| 9957 | int16_t sub_len; |
| 9958 | int slot = 0; |
| 9959 | int last_type = -1, last_len = -1; |
| 9960 | |
| 9961 | // Update timer stuff so we don't disconnect due to timeout |
| 9962 | if (Netgame.local_role == LR_CLIENT) { |
| 9963 | Netgame.last_server_time = timer_GetTime(); |
| 9964 | } else { |
| 9965 | slot = MultiMatchPlayerToAddress(from_addr); |
| 9966 | if (slot >= 0) { |
| 9967 | // This is to prevent clients who have disconnected on the client side |
| 9968 | // but not the server side from being credited with a recent packet |
| 9969 | // just because they are looking for a game |
| 9970 | if ((buf[0] != MP_GET_PXO_GAME_INFO) && (buf[0] != MP_GET_GAME_INFO)) { |
| 9971 | NetPlayers[slot].last_packet_time = timer_GetTime(); |
| 9972 | } else { |
| 9973 | // Someone who we think is still connected is looking for game info! |
| 9974 | // We aren't going to process this packet because otherwise they |
| 9975 | // might try to join which wouldn't work and they would be credited |
| 9976 | // with sending a packet and the server wouldn't disconnect them. |
| 9977 | mprintf(0, "Ignoring game info request from a currently connected user (%s)\n", Players[slot].callsign); |
| 9978 | return; |
| 9979 | } |
| 9980 | } |
| 9981 | } |
| 9982 | |
| 9983 | while (bytes_processed < len) { |
| 9984 | type = buf[bytes_processed]; |
| 9985 | sub_len = INTEL_SHORT((*(int16_t *)(buf + bytes_processed + 1))); |
| 9986 | |
| 9987 | if (sub_len < 3 || type == 0 || (len - bytes_processed) < 2) { |
| 9988 | mprintf(0, "Got a corrupted packet!\n"); |
| 9989 | Int3(); |
| 9990 | return; // just throw the rest out |
| 9991 | } |
| 9992 | |
| 9993 | if ((bytes_processed + sub_len) > len) { |
| 9994 | mprintf(1, "multi_process_bigdata: packet type %d too int16_t (%d>%d)!\n", type, (bytes_processed + sub_len), len); |
| 9995 | Int3(); |
| 9996 | return; |
| 9997 | } |
| 9998 | |
| 9999 | MultiProcessData(&buf[bytes_processed], sub_len, slot, from_addr); |
| 10000 | bytes_processed += sub_len; |
| 10001 | last_type = type; |
| 10002 | last_len = sub_len; |
| 10003 | } |
| 10004 | } |
no test coverage detected