| 354 | } |
| 355 | |
| 356 | void CScore::LoadTeam(const char *pCode, int ClientId) |
| 357 | { |
| 358 | if(RateLimitPlayer(ClientId)) |
| 359 | return; |
| 360 | auto *pController = GameServer()->m_pController; |
| 361 | int Team = pController->Teams().m_Core.Team(ClientId); |
| 362 | if(pController->Teams().GetSaving(Team)) |
| 363 | { |
| 364 | GameServer()->SendChatTarget(ClientId, "Team load already in progress"); |
| 365 | return; |
| 366 | } |
| 367 | if(!pController->Teams().IsValidTeamNumber(Team) || (g_Config.m_SvTeam != SV_TEAM_FORCED_SOLO && Team == TEAM_FLOCK)) |
| 368 | { |
| 369 | GameServer()->SendChatTarget(ClientId, "You have to be in a team (from 1-63)"); |
| 370 | return; |
| 371 | } |
| 372 | if(pController->Teams().GetTeamState(Team) != ETeamState::OPEN) |
| 373 | { |
| 374 | GameServer()->SendChatTarget(ClientId, "Team can't be loaded while racing"); |
| 375 | return; |
| 376 | } |
| 377 | if(pController->Teams().TeamFlock(Team)) |
| 378 | { |
| 379 | GameServer()->SendChatTarget(ClientId, "Team can't be loaded while in team 0 mode"); |
| 380 | return; |
| 381 | } |
| 382 | if(pController->Teams().IsPractice(Team)) |
| 383 | { |
| 384 | GameServer()->SendChatTarget(ClientId, "Team can't be loaded while practice is enabled"); |
| 385 | return; |
| 386 | } |
| 387 | auto SaveResult = std::make_shared<CScoreSaveResult>(ClientId, Server()->ClientName(ClientId), g_Config.m_SvSqlServerName); |
| 388 | SaveResult->m_Status = CScoreSaveResult::LOAD_FAILED; |
| 389 | pController->Teams().SetSaving(Team, SaveResult); |
| 390 | auto Tmp = std::make_unique<CSqlTeamLoadRequest>(SaveResult); |
| 391 | str_copy(Tmp->m_aCode, pCode, sizeof(Tmp->m_aCode)); |
| 392 | str_copy(Tmp->m_aMap, GameServer()->Map()->BaseName(), sizeof(Tmp->m_aMap)); |
| 393 | str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientId), sizeof(Tmp->m_aRequestingPlayer)); |
| 394 | Tmp->m_NumPlayer = 0; |
| 395 | for(int i = 0; i < MAX_CLIENTS; i++) |
| 396 | { |
| 397 | if(pController->Teams().m_Core.Team(i) == Team) |
| 398 | { |
| 399 | // put all names at the beginning of the array |
| 400 | str_copy(Tmp->m_aClientNames[Tmp->m_NumPlayer], Server()->ClientName(i), sizeof(Tmp->m_aClientNames[Tmp->m_NumPlayer])); |
| 401 | Tmp->m_aClientId[Tmp->m_NumPlayer] = i; |
| 402 | Tmp->m_NumPlayer++; |
| 403 | } |
| 404 | } |
| 405 | m_pPool->ExecuteWrite(CScoreWorker::LoadTeam, std::move(Tmp), "load team"); |
| 406 | } |
| 407 | |
| 408 | void CScore::GetSaves(int ClientId) |
| 409 | { |
no test coverage detected