@@ -542,12 +542,10 @@ bool GameActivity::CreateDelivery(int player, int mode, Vector& waypoint, Actor*
542
542
totalCost = pDeliveryCraft->GetGoldValue (nativeModule, foreignCostMult, nativeCostMult);
543
543
}
544
544
545
- // Go through the list of things ordered, and give any actors all the items that is present after them,
546
- // until the next actor. Also, the first actor gets all stuff in the list above him.
547
- MovableObject* pInventoryObject = 0 ;
548
- Actor* pPassenger = 0 ;
549
- Actor* pLastPassenger = 0 ;
550
- std::list<MovableObject*> cargoItems;
545
+ // Go through the list of things ordered, and give any actors all the items that is present after them, until the next actor.
546
+ MovableObject* pInventoryObject = nullptr ;
547
+ Actor* pPassenger = nullptr ;
548
+ Actor* pLastPassenger = nullptr ;
551
549
552
550
for (std::list<const SceneObject*>::iterator itr = purchaseList.begin (); itr != purchaseList.end (); ++itr) {
553
551
bool purchaseItem = true ;
@@ -568,66 +566,37 @@ bool GameActivity::CreateDelivery(int player, int mode, Vector& waypoint, Actor*
568
566
if (purchaseItem) {
569
567
// Make copy of the preset instance in the list
570
568
pInventoryObject = dynamic_cast <MovableObject*>((*itr)->Clone ());
571
- // See if it's actually a passenger, as opposed to a regular item
569
+
570
+ if (pPassenger) {
571
+ pLastPassenger = pPassenger;
572
+ }
573
+
572
574
pPassenger = dynamic_cast <Actor*>(pInventoryObject);
575
+
573
576
// If it's an actor, then set its team and add it to the Craft's inventory!
574
577
if (pPassenger) {
575
- if (dynamic_cast <AHuman*>(pPassenger)) {
576
- // If this is the first passenger, then give him all the shit found in the list before him
577
- if (!pLastPassenger) {
578
- for (std::list<MovableObject*>::iterator iItr = cargoItems.begin (); iItr != cargoItems.end (); ++iItr)
579
- pPassenger->AddInventoryItem (*iItr);
580
- }
581
- // This isn't the first passenger, so give the previous guy all the stuff that was found since processing him
582
- else {
583
- for (std::list<MovableObject*>::iterator iItr = cargoItems.begin (); iItr != cargoItems.end (); ++iItr)
584
- pLastPassenger->AddInventoryItem (*iItr);
585
- }
586
-
587
- // Now set the current passenger as the 'last passenger' so he'll eventually get everything found after him.
588
- pLastPassenger = pPassenger;
589
- } else if (pLastPassenger) {
590
- for (MovableObject* cargoItem: cargoItems) {
591
- pLastPassenger->AddInventoryItem (cargoItem);
592
- }
593
- pLastPassenger = nullptr ;
594
- }
595
- // Clear out the temporary cargo list since we've assign all the stuff in it to a passenger
596
- cargoItems.clear ();
597
578
// Set the team etc for the current passenger and stuff him into the craft
598
579
pPassenger->SetTeam (team);
599
580
pPassenger->SetControllerMode (Controller::CIM_AI);
600
581
pPassenger->SetAIMode ((Actor::AIMode)mode);
601
582
602
- if (pTargetMO != NULL ) {
603
- Actor* pTarget = dynamic_cast <Actor*>(pTargetMO);
604
- if (pTarget)
605
- pPassenger->AddAIMOWaypoint (pTarget);
583
+ if (Actor* pTarget = dynamic_cast <Actor*>(pTargetMO)) {
584
+ pPassenger->AddAIMOWaypoint (pTarget);
606
585
} else if (waypoint.m_X > 0 && waypoint.m_Y > 0 ) {
607
586
pPassenger->AddAISceneWaypoint (waypoint);
608
587
}
609
588
610
589
pDeliveryCraft->AddInventoryItem (pPassenger);
590
+ } else if (dynamic_cast <AHuman*>(pLastPassenger)) {
591
+ // Add ourselves to the last passenger's inventory
592
+ pLastPassenger->AddInventoryItem (pInventoryObject);
593
+ } else {
594
+ // No valid AHuman actor before us, just add ourself to the craft inventory
595
+ pDeliveryCraft->AddInventoryItem (pInventoryObject);
611
596
}
612
- // If not, then add it to the temp list of items which will be added to the last passenger's inventory
613
- else
614
- cargoItems.push_back (pInventoryObject);
615
597
}
616
598
}
617
599
618
- pPassenger = 0 ;
619
-
620
- // If there was a last passenger and things after him, stuff all the items into his inventory
621
- if (pLastPassenger) {
622
- for (std::list<MovableObject*>::iterator iItr = cargoItems.begin (); iItr != cargoItems.end (); ++iItr)
623
- pLastPassenger->AddInventoryItem (*iItr);
624
- }
625
- // Otherwise, stuff it all stuff directly into the craft instead
626
- else {
627
- for (std::list<MovableObject*>::iterator iItr = cargoItems.begin (); iItr != cargoItems.end (); ++iItr)
628
- pDeliveryCraft->AddInventoryItem (*iItr);
629
- }
630
-
631
600
float spawnY = 0 .0f ;
632
601
if (g_SceneMan.GetTerrain () && g_SceneMan.GetTerrain ()->GetOrbitDirection () == Directions::Down) {
633
602
spawnY = g_SceneMan.GetSceneHeight ();
0 commit comments