| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | void NetworkServer::OnCreatePlayer(int player, bool botClient, const char* name) |
| 224 | { |
| 225 | if (_state >= NGSTransferMission && !_missionHeader.joinInProgress) |
| 226 | { |
| 227 | // Game is loading or in progress and JIP is not enabled — reject late joiners |
| 228 | LOG_INFO(Network, "Rejecting player {} — game in progress without JIP (state={})", name, (int)_state); |
| 229 | _server->KickOff(player, NTRKicked); |
| 230 | return; |
| 231 | } |
| 232 | if (_sessionLocked && !_missionHeader.joinInProgress) |
| 233 | { |
| 234 | // session is locked and JIP is not enabled |
| 235 | _server->KickOff(player, NTRKicked); |
| 236 | return; |
| 237 | } |
| 238 | |
| 239 | // Check if player is joining mid-game (JIP). Transfer/load/briefing count as |
| 240 | // mid-game: the lobby role broadcast is over, so a player created here only |
| 241 | // receives the mission and role data through the JIP bootstrap — without it the |
| 242 | // client waits forever in the setup screen with an empty role list. |
| 243 | bool isJip = _state >= NGSTransferMission && _missionHeader.joinInProgress; |
| 244 | |
| 245 | if (botClient) |
| 246 | { |
| 247 | _botClient = player; |
| 248 | } |
| 249 | |
| 250 | bool server = _dedicated && player == _botClient; |
| 251 | if (server) |
| 252 | { |
| 253 | name = "__SERVER__"; |
| 254 | } |
| 255 | |
| 256 | NetworkPlayerInfo* pInfo = OnPlayerCreate(player, name); |
| 257 | |
| 258 | if (isJip) |
| 259 | { |
| 260 | pInfo->jip = true; |
| 261 | // Set state to NGSCreate so player participates in broadcasts and state checks |
| 262 | pInfo->state = NGSCreate; |
| 263 | LOG_INFO(Network, "Player {} joining in progress (JIP)", (const char*)pInfo->name); |
| 264 | } |
| 265 | |
| 266 | // send player int and name to himself |
| 267 | if (_dedicated) |
| 268 | { |
| 269 | if (server) |
| 270 | { |
| 271 | LOG_INFO(Network, "Server identity created"); |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | LOG_INFO(Network, "Player {} connecting", (const char*)pInfo->name); |
| 276 | } |
| 277 | } |
| 278 |
no test coverage detected