| 513 | } |
| 514 | |
| 515 | NetworkPlayerInfo* NetworkServer::OnPlayerCreate(int dpid, const char* name) |
| 516 | { |
| 517 | char playerName[256]; |
| 518 | snprintf(playerName, sizeof(playerName), "%s", (const char*)name); |
| 519 | |
| 520 | bool ok = false; |
| 521 | int suffix = 1; |
| 522 | while (!ok) |
| 523 | { |
| 524 | ok = true; |
| 525 | for (int i = 0; i < _players.Size(); i++) |
| 526 | { |
| 527 | NetworkPlayerInfo& info = _players[i]; |
| 528 | if (info.dpid == dpid) |
| 529 | { |
| 530 | continue; |
| 531 | } |
| 532 | if (stricmp(info.name, playerName) == 0) |
| 533 | { |
| 534 | snprintf(playerName, sizeof(playerName), "%s (%d)", name, ++suffix); |
| 535 | ok = false; |
| 536 | break; |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | { |
| 542 | NetworkPlayerInfo* info = GetPlayerInfo(dpid); |
| 543 | if (info) |
| 544 | { |
| 545 | NET_ERROR(strcmp(info->name, playerName) == 0); |
| 546 | return info; |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | int index = _players.Add(); |
| 551 | NetworkPlayerInfo& info = _players[index]; |
| 552 | info.dpid = dpid; |
| 553 | info.dvid = 0; |
| 554 | info.channel = CCNone; |
| 555 | info.name = playerName; |
| 556 | info.cameraPosition = InvalidCamPos; |
| 557 | info.cameraPositionTime = TIME_MIN; |
| 558 | info.integrityCheckNext = UINT_MAX; |
| 559 | info.connectionProblemsReported = false; |
| 560 | info.jip = false; |
| 561 | info.kickedOff = false; |
| 562 | info.nextQuestionId = 1; |
| 563 | |
| 564 | #if LOG_PLAYERS |
| 565 | RptF("Server: Player info added - name %s, id %d (total %d identities, %d players)", (const char*)playerName, dpid, |
| 566 | _identities.Size(), _players.Size()); |
| 567 | #endif |
| 568 | |
| 569 | if (_dedicated) |
| 570 | { |
| 571 | info.motdIndex = -1; |
| 572 | if (dpid != _botClient && _motd.Size() > 0) |
nothing calls this directly
no test coverage detected