Puts player "slot" position info into the passed in buffer Returns the number of bytes used
| 2046 | // Puts player "slot" position info into the passed in buffer |
| 2047 | // Returns the number of bytes used |
| 2048 | int MultiSendRobotFireWeapon(uint16_t objectnum, vector *pos, vector *dir, uint16_t weaponnum) { |
| 2049 | int size; |
| 2050 | int count = 0; |
| 2051 | uint8_t data[MAX_GAME_DATA_SIZE]; |
| 2052 | // mprintf(0,"Sending Robot %d fired.\n",objectnum); |
| 2053 | // Check to make sure we're the server |
| 2054 | if (Netgame.local_role != LR_SERVER) { |
| 2055 | BailOnMultiplayer(NULL); |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
| 2059 | // mprintf(0,"@");//KBTEST |
| 2060 | object *obj = &Objects[objectnum]; |
| 2061 | ASSERT(obj->flags & OF_CLIENT_KNOWS); |
| 2062 | |
| 2063 | size = START_DATA(MP_ROBOT_FIRE, data, &count); |
| 2064 | MultiAddUshort(objectnum, data, &count); |
| 2065 | |
| 2066 | // Do position |
| 2067 | // memcpy (&data[count],pos,sizeof(vector)); |
| 2068 | // count+=sizeof(vector); |
| 2069 | MultiAddVector(*pos, data, &count); |
| 2070 | |
| 2071 | // Do orientation |
| 2072 | // memcpy (&data[count],dir,sizeof(vector)); |
| 2073 | // count+=sizeof(vector); |
| 2074 | MultiAddVector(*dir, data, &count); |
| 2075 | |
| 2076 | uint32_t index = MultiGetMatchChecksum(OBJ_WEAPON, weaponnum); |
| 2077 | MultiAddUint(index, data, &count); |
| 2078 | |
| 2079 | END_DATA(count, data, size); |
| 2080 | // Add it to the outgoing queue. The MultiSendRobotFireSound() function will actually send it |
| 2081 | for (int i = 0; i < MAX_NET_PLAYERS; i++) { |
| 2082 | if (i == Player_num) |
| 2083 | continue; |
| 2084 | |
| 2085 | if ((NetPlayers[i].flags & NPF_CONNECTED) && (NetPlayers[i].sequence == NETSEQ_PLAYING)) { |
| 2086 | if (Multi_send_size[i] + count >= MAX_GAME_DATA_SIZE) |
| 2087 | MultiSendFullPacket(i, 0); |
| 2088 | |
| 2089 | memcpy(&Multi_send_buffer[i][Multi_send_size[i]], data, count); |
| 2090 | Multi_send_size[i] += count; |
| 2091 | // Don't send because we are waiting for the robot fire sound to send |
| 2092 | } |
| 2093 | } |
| 2094 | return count; |
| 2095 | } |
| 2096 | |
| 2097 | void MultiDoRobotFire(uint8_t *data) { |
| 2098 | int count = 0; |
no test coverage detected