aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatan Shukry <matanshukry@gmail.com>2021-01-23 16:35:22 +0200
committerGitHub <noreply@github.com>2021-01-23 15:35:22 +0100
commit1d51013b71d46a2825519cdb85d7049109b226ae (patch)
tree1c26154e20a911706ccd9202298f95799362a698
parentf34c18fb5417353c3b3de51220c9dce71787f0fc (diff)
Scripts/Commands: Fixed .modify gender not setting correct customizations (#25920)
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index 2e04bbbae40..4931818f171 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -23,6 +23,7 @@ Category: commandscripts
EndScriptData */
#include "ScriptMgr.h"
+#include "CharacterCache.h"
#include "Chat.h"
#include "DB2Stores.h"
#include "Log.h"
@@ -34,6 +35,7 @@ EndScriptData */
#include "ReputationMgr.h"
#include "SpellMgr.h"
#include "SpellPackets.h"
+#include "UpdateFields.h"
#include "WorldSession.h"
class modify_commandscript : public CommandScript
@@ -891,6 +893,40 @@ public:
// Change display ID
target->InitDisplayIds();
+ target->RestoreDisplayId(false);
+ sCharacterCache->UpdateCharacterGender(target->GetGUID(), gender);
+
+ // Generate random customizations
+ std::vector<UF::ChrCustomizationChoice> customizations;
+
+ Classes playerClass = Classes(target->getClass());
+ std::vector<ChrCustomizationOptionEntry const*> const* options = sDB2Manager.GetCustomiztionOptions(target->getRace(), gender);
+ WorldSession const* worldSession = target->GetSession();
+ for (ChrCustomizationOptionEntry const* option : *options)
+ {
+ ChrCustomizationReqEntry const* optionReq = sChrCustomizationReqStore.LookupEntry(option->ChrCustomizationReqID);
+ if (optionReq && !worldSession->MeetsChrCustomizationReq(optionReq, playerClass, false, MakeChrCustomizationChoiceRange(customizations)))
+ continue;
+
+ // Loop over the options until the first one fits
+ std::vector<ChrCustomizationChoiceEntry const*> const* choicesForOption = sDB2Manager.GetCustomiztionChoices(option->ID);
+ for (ChrCustomizationChoiceEntry const* choiceForOption : *choicesForOption)
+ {
+ ChrCustomizationReqEntry const* choiceReq = sChrCustomizationReqStore.LookupEntry(choiceForOption->ChrCustomizationReqID);
+ if (choiceReq && !worldSession->MeetsChrCustomizationReq(choiceReq, playerClass, false, MakeChrCustomizationChoiceRange(customizations)))
+ continue;
+
+ ChrCustomizationChoiceEntry const* choiceEntry = choicesForOption->at(0);
+ UF::ChrCustomizationChoice choice;
+ choice.ChrCustomizationOptionID = option->ID;
+ choice.ChrCustomizationChoiceID = choiceEntry->ID;
+ customizations.push_back(choice);
+ break;
+ }
+ }
+
+ target->SetCustomizations(Trinity::Containers::MakeIteratorPair(customizations.begin(), customizations.end()));
+
char const* gender_full = gender ? "female" : "male";
handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target).c_str(), gender_full);