Instructions Jenkins Doxygen

[Fixed] trading a droid's control device now checks the number in the 55/1055/1
authorIvojedi <ivojedi@swgemu.com>
Sun, 3 Nov 2013 13:42:30 +0000 (05:42 -0800)
committerIvojedi <ivojedi@swgemu.com>
Sun, 3 Nov 2013 13:42:30 +0000 (05:42 -0800)
recipient's datapad

Change-Id: I4508740a2968ab2e17ac449d18e47705cb24f10d

MMOCoreORB/src/server/zone/objects/intangible/PetControlDeviceImplementation.cpp

index 687fb0b..234b0bf 100644 (file)
@@ -364,16 +364,39 @@ int PetControlDeviceImplementation::canBeDestroyed(CreatureObject* player) {
 }
 
 bool PetControlDeviceImplementation::canBeTradedTo(CreatureObject* player, CreatureObject* receiver, int numberInTrade) {
+       ManagedReference<SceneObject*> datapad = receiver->getSlottedObject("datapad");
+
+       if (datapad == NULL)
+               return false;
+
        if (petType == FACTIONPET) {
                player->sendSystemMessage("@pet/pet_menu:bad_type"); // You cannot trade a pet of that type. Transfer failed.
                return false;
        } else if (petType == DROIDPET) {
+               int droidsInDatapad = numberInTrade;
+
+               for (int i = 0; i < datapad->getContainerObjectsSize(); i++) {
+                       Reference<SceneObject*> obj =  datapad->getContainerObject(i).castTo<SceneObject*>();
+
+                       if (obj != NULL && obj->isPetControlDevice() ){
+                               Reference<PetControlDevice*> petDevice = cast<PetControlDevice*>(obj.get());
+                               if( petDevice != NULL && petDevice->getPetType() == PetControlDevice::DROIDPET){
+                                       droidsInDatapad++;
+                               }
+                       }
+               }
+
+               if( droidsInDatapad >= 5){
+                       player->sendSystemMessage("That person has too many droids in their datapad");
+                       return false;
+               }
+
                return true;
+
        } else if (petType == CREATUREPET) {
-               ManagedReference<SceneObject*> datapad = receiver->getSlottedObject("datapad");
                ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
 
-               if (datapad == NULL || controlledObject == NULL || !controlledObject->isAiAgent())
+               if (controlledObject == NULL || !controlledObject->isAiAgent())
                        return false;
 
                ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get());