Instructions Jenkins Doxygen

[Fixed] some target/message errors with /consent, /unconsent, and 93/5393/1
authorIvojedi <ivojedi@swgemu.com>
Fri, 17 Feb 2017 10:52:50 +0000 (02:52 -0800)
committerIvojedi <ivojedi@swgemu.com>
Fri, 17 Feb 2017 10:52:50 +0000 (02:52 -0800)
/haveconsent - mantis 7198

Change-Id: Id64995aa4086f0866dbaf89040cdf9a88ac13903

MMOCoreORB/src/server/zone/managers/sui/SuiManager.cpp
MMOCoreORB/src/server/zone/managers/sui/SuiManager.h
MMOCoreORB/src/server/zone/objects/creature/commands/ConsentCommand.h
MMOCoreORB/src/server/zone/objects/creature/commands/HaveconsentCommand.h
MMOCoreORB/src/server/zone/objects/creature/commands/UnconsentCommand.h
MMOCoreORB/src/server/zone/objects/player/sui/callbacks/RevokeConsentSuiCallback.h

index 1e6c33c..23520f5 100644 (file)
@@ -94,9 +94,6 @@ void SuiManager::handleSuiEventNotification(uint32 boxID, CreatureObject* player
        //info(msg, true);
 
        switch (windowType) {
-       case SuiWindowType::MEDIC_CONSENT:
-               handleConsentBox(player, suiBox, eventIndex, args);
-               break;
        case SuiWindowType::DANCING_START:
                handleStartDancing(player, suiBox, eventIndex, args);
                break;
@@ -609,24 +606,6 @@ void SuiManager::handleCharacterBuilderSelectItem(CreatureObject* player, SuiBox
        }
 }
 
-void SuiManager::handleConsentBox(CreatureObject* player, SuiBox* suiBox, uint32 cancel, Vector<UnicodeString>* args) {
-       if (!suiBox->isListBox() || cancel != 0)
-               return;
-
-       if (args->size() < 1)
-               return;
-
-       int index = Integer::valueOf(args->get(0).toString());
-
-       if (index == -1)
-               return;
-
-       SuiListBox* suiList = cast<SuiListBox*>(suiBox);
-
-       String name = suiList->getMenuItemName(index);
-       UnconsentCommand::unconscent(player, name);
-}
-
 void SuiManager::sendKeypadSui(SceneObject* keypad, SceneObject* creatureSceneObject, const String& play, const String& callback) {
 
        if (keypad == NULL)
index 2f647c7..aa820f2 100644 (file)
@@ -51,7 +51,6 @@ namespace server {
                void handleSetObjectName(CreatureObject* player, SuiBox* suiBox, uint32 cancel, Vector<UnicodeString>* args);
                void handleBankTransfer(CreatureObject* player, SuiBox* suiBox, uint32 cancel, Vector<UnicodeString>* args);
                void handleFishingAction(CreatureObject* player, SuiBox* suiBox, uint32 cancel, Vector<UnicodeString>* args);
-               void handleConsentBox(CreatureObject* player, SuiBox* suiBox, uint32 cancel, Vector<UnicodeString>* args);
                void handleCharacterBuilderSelectItem(CreatureObject* player, SuiBox* suiBox, uint32 cancel, Vector<UnicodeString>* args);
 
                void sendKeypadSui(SceneObject* keypad, SceneObject* creatureSceneObject, const String& play, const String& callback);
index e5bf0dd..bd34009 100755 (executable)
@@ -16,7 +16,9 @@ public:
 
        }
 
-       static void consent(CreatureObject* player, const String& name) {
+       static void consent(CreatureObject* player, CreatureObject* targetPlayer) {
+               String name = targetPlayer->getFirstName().toLowerCase();
+
                PlayerObject* ghost = player->getPlayerObject();
                ghost->addToConsentList(name);
 
@@ -24,11 +26,12 @@ public:
                stringId.setTO(name);
                player->sendSystemMessage(stringId);
 
+               StringIdChatParameter stringId2("base_player", "prose_got_consent"); // %TO consents you.
+               stringId2.setTO(player->getFirstName());
+               targetPlayer->sendSystemMessage(stringId2);
        }
 
        int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const {
-
-               //System::out << "entering ConsentCommand" << endl;
                if (!checkStateMask(creature))
                        return INVALIDSTATE;
 
@@ -38,8 +41,6 @@ public:
                if (!creature->isPlayerCreature())
                        return GENERALERROR;
 
-               //System::out << "past initial checks ConsentCommand" << endl;
-
                PlayerObject* ghost = creature->getPlayerObject();
 
                if (ghost == NULL)
@@ -50,10 +51,12 @@ public:
                        return GENERALERROR;
                }
 
-               if (arguments.isEmpty() && !creature->getTargetID()) {
+               uint64 targetID = creature->getTargetID();
+
+               if (arguments.isEmpty() && targetID == 0) {
                        creature->sendSystemMessage("To give consent, you must either specify the player name or target that player and use the command.");
                        return GENERALERROR;
-               } //TODO: How can we allow consent to be fired from toolbar with the command icon??
+               }
 
                if (!arguments.isEmpty()) {
                        StringTokenizer tokenizer(arguments.toString());
@@ -75,32 +78,27 @@ public:
                                if (!validName) {
                                        creature->sendSystemMessage("@ui_cmnty:friend_location_failed_noname"); //No player with that name exists.
                                        return GENERALERROR;
-                               }
-
-                               if (server->getZoneServer()->getPlayerManager()->existsName(name) && creature->getFirstName().toLowerCase() != name) {
-                                       consent(creature, name);
-                               } else {
+                               } else if (creature->getFirstName().toLowerCase() == name) {
                                        creature->sendSystemMessage("You cannot give consent to yourself!");
                                        return INVALIDTARGET;
+                               } else {
+                                       CreatureObject* targetPlayer = playerManager->getPlayer(name);
+
+                                       if (targetPlayer == NULL)
+                                               return INVALIDTARGET;
+
+                                       consent(creature, targetPlayer);
                                }
                        }
                } else {
-                       ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(target);
+                       ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(targetID);
                        CreatureObject* playerTarget = cast<CreatureObject*>( object.get());
 
-                       if (object == NULL || !object->isPlayerCreature() || object == creature) {
-                               //System::out << "invalid target" << endl;
+                       if (playerTarget == NULL || !playerTarget->isPlayerCreature() || playerTarget == creature) {
                                return INVALIDTARGET;
                        }
 
-                       if (playerTarget != NULL)
-                               consent(creature, playerTarget->getFirstName().toLowerCase());
-
-                               StringIdChatParameter stringId2("base_player", "prose_got_consent"); // %TO consents you.
-                               stringId2.setTO(creature->getObjectID());
-                               if (playerTarget->isPlayerCreature()) {
-                                       playerTarget->sendSystemMessage(stringId2);
-                               }
+                       consent(creature, playerTarget);
                }
 
                return SUCCESS;
index 80dfd86..18be07b 100644 (file)
@@ -27,19 +27,20 @@ public:
                if (!creature->isPlayerCreature())
                        return GENERALERROR;
 
-               CreatureObject* player = cast<CreatureObject*>(creature);
+               PlayerObject* ghost = creature->getPlayerObject();
 
-               PlayerObject* ghost = player->getPlayerObject();
+               if (ghost == NULL)
+                       return GENERALERROR;
 
-               ghost->closeSuiWindowType(SuiWindowType::CLONE_REQUEST);
+               ghost->closeSuiWindowType(SuiWindowType::MEDIC_CONSENT);
 
                if (ghost->getConsentListSize() <= 0) {
-                       player->sendSystemMessage("@error_message:consent_to_empty"); //You have not granted consent to anyone.
+                       creature->sendSystemMessage("@error_message:consent_to_empty"); //You have not granted consent to anyone.
                        return GENERALERROR;
                }
 
-               Reference<SuiListBox*> consentBox = new SuiListBox(player, SuiWindowType::MEDIC_CONSENT);
-               ZoneServer* server = player->getZoneServer();
+               Reference<SuiListBox*> consentBox = new SuiListBox(creature, SuiWindowType::MEDIC_CONSENT);
+               ZoneServer* server = creature->getZoneServer();
                consentBox->setCallback(new RevokeConsentSuiCallback(server));
                consentBox->setPromptTitle("@ui:consent_title");
                consentBox->setPromptText("All players whom you have given your consent to are listed below.\n\nHighlight a player's name and click OK to revoke consent.");
@@ -52,8 +53,8 @@ public:
                                consentBox->addMenuItem(entryName);
                }
 
-               player->getPlayerObject()->addSuiBox(consentBox);
-               player->sendMessage(consentBox->generateMessage());
+               ghost->addSuiBox(consentBox);
+               creature->sendMessage(consentBox->generateMessage());
 
                return SUCCESS;
        }
index d2c195c..91c3767 100755 (executable)
@@ -11,7 +11,6 @@
 #include "server/zone/managers/player/PlayerManager.h"
 #include "QueueCommand.h"
 
-
 class UnconsentCommand : public QueueCommand {
 public:
 
@@ -20,13 +19,19 @@ public:
 
        }
 
-       static void unconscent(CreatureObject* player, const String& name) {
+       static void unconscent(CreatureObject* player, CreatureObject* targetPlayer) {
+               String name = targetPlayer->getFirstName().toLowerCase();
+
                PlayerObject* ghost = player->getPlayerObject();
                ghost->removeFromConsentList(name);
 
                StringIdChatParameter stringId("base_player", "prose_unconsent"); //You revoke your consent from %TO.
                stringId.setTO(name);
                player->sendSystemMessage(stringId);
+
+               StringIdChatParameter stringId2("base_player", "prose_lost_consent"); //%TO no longer consents you.
+               stringId2.setTO(player->getFirstName());
+               targetPlayer->sendSystemMessage(stringId2);
        }
 
        int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const {
@@ -42,10 +47,20 @@ public:
 
                PlayerObject* ghost = creature->getPlayerObject();
 
-               if (arguments.isEmpty() && !creature->getTargetID()) {
+               if (ghost == NULL)
+                       return GENERALERROR;
+
+               if (ghost->getConsentListSize() <= 0) {
+                       creature->sendSystemMessage("@error_message:consent_to_empty"); //You have not granted consent to anyone.
+                       return GENERALERROR;
+               }
+
+               uint64 targetID = creature->getTargetID();
+
+               if (arguments.isEmpty() && targetID == 0) {
                        creature->sendSystemMessage("@error_message:syntax_unconsent"); //syntax: /unconsent {optionally, use commas to seperate several player names}
                        return GENERALERROR;
-               } //TODO: How can we allow unconsent to be fired from toolbar with the command icon??
+               }
 
                if (!arguments.isEmpty()) {
                        StringTokenizer tokenizer(arguments.toString());
@@ -61,31 +76,27 @@ public:
 
                                if (!validName) {
                                        creature->sendSystemMessage("@ui_cmnty:friend_location_failed_noname"); //No player with that name exists.
-                                       return GENERALERROR;
-                               }
-
-                               if (ghost != NULL && !ghost->hasInConsentList(name)) {
+                                       continue;
+                               } else if (!ghost->hasInConsentList(name)) {
                                        creature->sendSystemMessage("That player isn't on your consent list.");
-                                       return GENERALERROR;
-                               }
+                                       continue;
+                               } else {
+                                       CreatureObject* targetPlayer = playerManager->getPlayer(name);
 
-                               if (server->getZoneServer()->getPlayerManager()->existsName(name))
-                                       unconscent(creature, name);
+                                       if (targetPlayer == NULL)
+                                               continue;
+
+                                       unconscent(creature, targetPlayer);
+                               }
                        }
                } else {
-
-                       ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(target);
+                       ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(targetID);
                        CreatureObject* playerTarget = cast<CreatureObject*>( object.get());
 
-                       if (object == NULL || !object->isPlayerCreature() || object == creature)
+                       if (playerTarget == NULL || !playerTarget->isPlayerCreature() || playerTarget == creature)
                                return INVALIDTARGET;
 
-                       if (playerTarget != NULL && playerTarget->isPlayerCreature())
-                               unconscent(creature, playerTarget->getFirstName().toLowerCase());
-                               StringIdChatParameter stringId2("base_player", "prose_lost_consent"); //%TO no longer consents you.
-                               stringId2.setTO(creature->getObjectID());
-                               playerTarget->sendSystemMessage(stringId2);
-
+                       unconscent(creature, playerTarget);
                }
 
                return SUCCESS;
index 62099a0..d4abb7c 100644 (file)
@@ -16,7 +16,6 @@ public:
                : SuiCallback(server) {
        }
 
-
        void run(CreatureObject* player, SuiBox* suiBox, uint32 eventIndex, Vector<UnicodeString>* args) {
                bool cancelPressed = (eventIndex == 1);
 
@@ -26,20 +25,28 @@ public:
                int index = Integer::valueOf(args->get(0).toString());
 
                PlayerObject* ghost = player->getPlayerObject();
-               for (int i = 0; i < ghost->getConsentListSize(); ++i) {
-                       String entryName = ghost->getConsentName(i);
-                       if (!entryName.isEmpty() && index == i){
-                               ghost->removeFromConsentList(entryName);
-                               StringIdChatParameter stringId("base_player", "prose_unconsent");
-                               stringId.setTO(entryName);
-                               player->sendSystemMessage(stringId);
-                       }
-               }
-       }
-};
 
+               if (ghost == NULL)
+                       return;
 
+               String entryName = ghost->getConsentName(index);
 
+               if (!entryName.isEmpty()) {
+                       ghost->removeFromConsentList(entryName);
+                       StringIdChatParameter stringId("base_player", "prose_unconsent"); //You revoke your consent from %TO.
+                       stringId.setTO(entryName);
+                       player->sendSystemMessage(stringId);
 
+                       PlayerManager* playerManager = server->getPlayerManager();
+                       CreatureObject* targetPlayer = playerManager->getPlayer(entryName);
+
+                       if (targetPlayer != NULL) {
+                               StringIdChatParameter stringId2("base_player", "prose_lost_consent"); //%TO no longer consents you.
+                               stringId2.setTO(player->getFirstName());
+                               targetPlayer->sendSystemMessage(stringId2);
+                       }
+               }
+       }
+};
 
 #endif /* REVOKECONSENTSUICALLBACK_H_ */