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

Method AssignAsDriver

engine/Poseidon/AI/AIUnitImpl.cpp:2602–2637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2600bool AIUnit::AssignAsDriver(Transport* veh)
2601{
2602 if (!veh->GetType()->HasDriver())
2603 {
2604 return false;
2605 }
2606
2607 if (veh && veh == _vehicleAssigned && veh->GetDriverAssigned() == this)
2608 {
2609 return true; // already assigned as driver
2610 }
2611
2612 if (_vehicleAssigned) // unassign
2613 {
2614 _vehicleAssigned->RemoveAssignement(this);
2615 _vehicleAssigned = nullptr;
2616 }
2617
2618 if (veh)
2619 {
2620 AIUnit* oldDriver = veh->GetDriverAssigned();
2621 if (oldDriver) // unassign
2622 {
2623 if (veh->Driver() && !veh->Driver()->IsDammageDestroyed())
2624 { // cannot assign - driver is inside
2625 AI_ERROR(veh->DriverBrain() == oldDriver);
2626 return false;
2627 }
2628 veh->RemoveAssignement(oldDriver);
2629 oldDriver->_vehicleAssigned = nullptr;
2630 }
2631 veh->AssignDriver(this);
2632 _vehicleAssigned = veh;
2633 }
2634 return true;
2635}
2636
2637bool AIUnit::AssignAsGunner(Transport* veh)
2638{
2639 if (!veh->GetType()->HasGunner())
2640 {

Callers 9

TransferMsgMethod · 0.80
ArcadeGetInGetInFunction · 0.80
AssignVehiclesMethod · 0.80
CreateUnitMethod · 0.80
IssueCommandMethod · 0.80
IssueGetInMethod · 0.80
ProcessMethod · 0.80
ObjAssignAsDriverFunction · 0.80
ObjMoveInDriverFunction · 0.80

Calls 8

GetDriverAssignedMethod · 0.80
RemoveAssignementMethod · 0.80
DriverMethod · 0.80
DriverBrainMethod · 0.80
AssignDriverMethod · 0.80
HasDriverMethod · 0.45
GetTypeMethod · 0.45
IsDammageDestroyedMethod · 0.45

Tested by

no test coverage detected