| 316 | } |
| 317 | if (bodyInfo.hideTime > Glob.time) |
| 318 | { |
| 319 | continue; |
| 320 | } |
| 321 | |
| 322 | NET_ERROR(bodyInfo.body->IsLocal()); |
| 323 | bodyInfo.body->HideBody(); |
| 324 | _bodies.Delete(i); |
| 325 | _hideBodies--; |
| 326 | i--; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | void NetworkClient::DoRespawn(RespawnQueueItem& item) |
| 331 | { |
| 332 | if (_state < NGSPlay) |
| 333 | { |
| 334 | return; // send event messages only when playing |
| 335 | } |
| 336 | |
| 337 | Person* body = item.person; |
| 338 | if (!body) |
| 339 | { |
| 340 | Fail("Respawn failed - body disappeared"); |
| 341 | return; |
| 342 | } |
| 343 | AIUnit* unit = body->Brain(); |
| 344 | if (!unit) |
| 345 | { |
| 346 | Fail("Respawn failed - unit disappeared"); |
| 347 | return; |
| 348 | } |
| 349 | TargetSide side = body->Vehicle::GetTargetSide(); |
| 350 | int id = -1; |
| 351 | for (int i = 0; i < vehiclesMap.Size(); i++) |
| 352 | { |
| 353 | if (vehiclesMap[i] == body) |
| 354 | { |
| 355 | id = i; |
| 356 | break; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | // new body |
| 361 | Soldier* soldier = new Soldier(const_cast<VehicleType*>(body->GetType())); |
| 362 | |
| 363 | // move brain |
| 364 | soldier->SetBrain(unit); |
| 365 | body->SetBrain(nullptr); |
| 366 | GLOB_WORLD->RemoveSensor(body); |
| 367 | unit->SetPerson(soldier); |
| 368 | unit->SetVehicleIn(nullptr); |
| 369 | |
| 370 | // other parameters |
| 371 | soldier->SetTargetSide(side); |
| 372 | unit->SetLifeState(AIUnit::LSAlive); |
| 373 | |
| 374 | AIUnitInfo& info = body->GetInfo(); |
| 375 | saturateMax(info._experience, info._initExperience); |
nothing calls this directly
no test coverage detected