Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AddTemplateHotbar(): loading action spells #194

Merged
merged 6 commits into from
Oct 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/ptr_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class createTemplate : public PlayerScript {
{
itemRoutine = METHOD_DELETE;
}

scheduler.Schedule(Milliseconds(delayMultiplier * APPLY_DELAY), [player, index, itemRoutine](TaskContext context)
{
switch (context.GetRepeatCounter())
Expand Down Expand Up @@ -467,7 +467,7 @@ class createTemplate : public PlayerScript {
{
return;
}

int STARTER_QUESTS[33] = { 12593, 12619, 12842, 12848, 12636, 12641, 12657, 12678, 12679, 12680, 12687, 12698, 12701, 12706, 12716, 12719, 12720, 12722, 12724, 12725, 12727, 12733, -1, 12751, 12754, 12755, 12756, 12757, 12779, 12801, 13165, 13166 };
// Blizz just dumped all of the special surprise quests on every DK template. Don't know yet if I want to do the same.
int specialSurpriseQuestId = -1;
Expand Down Expand Up @@ -560,25 +560,28 @@ class createTemplate : public PlayerScript {
}
}

static void AddTemplateHotbar(Player* player, uint32 index) // Someone smarter than me needs to fix this.
static void AddTemplateHotbar(Player* player, uint32 index)
{ // 0 1 2
QueryResult barInfo = WorldDatabase.Query("SELECT Button, Action, Type FROM mod_ptrtemplate_action WHERE (ID = {} AND RaceMask & {} AND ClassMask & {})", index, player->getRaceMask(), player->getClassMask());
for (uint8 j = ACTION_BUTTON_BEGIN; j <= MAX_ACTION_BUTTONS; j++) // This is supposed to go through every available action slot and remove what's there.
{ // This doesn't work for spells added by AddTemplateSpells.
player->removeActionButton(j); // I don't know why and I've tried everything I can think of, but nothing's worked.
} // And yes, I do want the hotbar cleared for characters that don't have any hotbar data in the template.
if (barInfo)
{
for (uint8 j = ACTION_BUTTON_BEGIN; j <= MAX_ACTION_BUTTONS; j++)
{
player->removeActionButton(j);
}
sogladev marked this conversation as resolved.
Show resolved Hide resolved
do
{
uint8 buttonEntry = (*barInfo)[0].Get<uint8>();
uint32 actionEntry = (*barInfo)[1].Get<uint32>();
uint8 typeEntry = (*barInfo)[2].Get<uint8>();
player->addActionButton(buttonEntry, actionEntry, typeEntry);
LOG_DEBUG("module", "Added hotbar spell {} on button {} with type {} for template character {}.", actionEntry, buttonEntry, typeEntry, player->GetGUID().ToString());
if (player->addActionButton(buttonEntry, actionEntry, typeEntry))
LOG_DEBUG("module", "Added hotbar spell {} on button {} with type {} for template character {}.", actionEntry, buttonEntry, typeEntry, player->GetGUID().ToString());
else
LOG_ERROR("module", "Failed to add hotbar spell {} on button {} with type {} for template character {}.", actionEntry, buttonEntry, typeEntry, player->GetGUID().ToString());
} while (barInfo->NextRow());
player->SendActionButtons(1);
player->SaveToDB(false, false); // commit action buttons
Copy link
Owner

@heyitsbench heyitsbench Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
player->SaveToDB(false, false); // commit action buttons
player->SaveToDB(false, false); // Commit action buttons

Do you happen to know of any reasons this (L577) would have to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
player->SendActionButtons(2);
}

static void AddTemplateLevel(Player* player, uint32 index)
Expand Down Expand Up @@ -868,7 +871,7 @@ class createTemplate : public PlayerScript {
item->DeleteFromInventoryDB(trans);
vestigialEquipItems.push_back(item);
}

while (!vestigialEquipItems.empty())
{
std::string subject = player->GetSession()->GetModuleString(module_string, MAIL_BOOST_SUBJECT)[0];
Expand Down