Sends existing players to a joining player Sends to "slot" and describes player "which" Server only
| 1114 | // Sends to "slot" and describes player "which" |
| 1115 | // Server only |
| 1116 | void MultiSendPlayer(int slot, int which) { |
| 1117 | ASSERT(Netgame.local_role == LR_SERVER); |
| 1118 | |
| 1119 | uint8_t data[MAX_GAME_DATA_SIZE]; |
| 1120 | int count = 0; |
| 1121 | int size_offset; |
| 1122 | |
| 1123 | mprintf(0, "Sending MP_PLAYER packet to player %d!\n", slot); |
| 1124 | |
| 1125 | size_offset = START_DATA(MP_PLAYER, data, &count); |
| 1126 | |
| 1127 | MultiAddByte(which, data, &count); |
| 1128 | |
| 1129 | // Add name |
| 1130 | int len = strlen(Players[which].callsign) + 1; |
| 1131 | MultiAddByte(len, data, &count); |
| 1132 | memcpy(&data[count], Players[which].callsign, len); |
| 1133 | count += len; |
| 1134 | |
| 1135 | // Add name |
| 1136 | len = strlen(Ships[Players[which].ship_index].name) + 1; |
| 1137 | MultiAddByte(len, data, &count); |
| 1138 | memcpy(&data[count], Ships[Players[which].ship_index].name, len); |
| 1139 | count += len; |
| 1140 | |
| 1141 | // Add flags, shields, inventory |
| 1142 | MultiAddInt(Players[which].flags, data, &count); |
| 1143 | MultiAddInt(Players[which].weapon_flags, data, &count); |
| 1144 | MultiAddInt(NetPlayers[which].flags, data, &count); |
| 1145 | MultiAddFloat(Objects[Players[which].objnum].shields, data, &count); |
| 1146 | |
| 1147 | // Add position, roomnum, and terrain flag |
| 1148 | |
| 1149 | // Just for safety sake add the object number |
| 1150 | MultiAddShort(Players[which].objnum, data, &count); |
| 1151 | |
| 1152 | // If this is a team game, get the first start position |
| 1153 | if (slot == which) { |
| 1154 | int myteam = GameDLLGetConnectingPlayersTeam(slot); |
| 1155 | |
| 1156 | uint8_t temp_team = (myteam == -1) ? 255 : myteam; |
| 1157 | MultiAddByte(temp_team, data, &count); |
| 1158 | |
| 1159 | if (myteam >= 0 && myteam <= 4) |
| 1160 | Players[slot].team = myteam; |
| 1161 | |
| 1162 | if (temp_team == 255) |
| 1163 | Players[slot].start_index = slot; |
| 1164 | else |
| 1165 | Players[slot].start_index = PlayerGetRandomStartPosition(slot); |
| 1166 | |
| 1167 | MultiAddShort(Players[slot].start_index, data, &count); |
| 1168 | } else { |
| 1169 | uint8_t temp_team = (Players[which].team == -1) ? 255 : Players[which].team; |
| 1170 | MultiAddByte(temp_team, data, &count); |
| 1171 | } |
| 1172 | |
| 1173 | // Tell them if this player is currently observing |
no test coverage detected