MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DoRespawn

Method DoRespawn

engine/Poseidon/Network/NetworkClient.cpp:318–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
330void 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);

Callers

nothing calls this directly

Calls 15

saturateMaxFunction · 0.85
GameValueExtClass · 0.85
CreateVehicleFunction · 0.85
BrainMethod · 0.80
SetBrainMethod · 0.80
RemoveSensorMethod · 0.80
SetPersonMethod · 0.80
SetVehicleInMethod · 0.80
SetTargetSideMethod · 0.80
SetLifeStateMethod · 0.80
SetInfoMethod · 0.80
GetVarNameMethod · 0.80

Tested by

no test coverage detected