From 05aebfea465bd043dc5ab344b15968a50bebc8ca Mon Sep 17 00:00:00 2001 From: kadeshar Date: Sat, 16 May 2026 08:26:22 +0200 Subject: [PATCH] Outfit database persist (#2378) ## Pull Request Description Added storing outfit in database. Related with: #2239 ## How to Test the Changes 1. Invite altbot 2. Use command `outfit testcollection +[itemlink]` to add outfit collection and item 3. Check that is added `outfit ?` 4. Logout bot for example via multibot 5. Login bot 6. Check that is still added `outfit ?` ## Impact Assessment - Does this change increase per-bot/per-tick processing or risk scaling poorly with thousands of bots? - - [x] No, not at all - - [ ] Minimal impact (**explain below**) - - [ ] Moderate impact (**explain below**) - Does this change modify default bot behavior? - - [x] No - - [ ] Yes (**explain why**) - Does this change add new decision branches or increase maintenance complexity? - - [x] No - - [ ] Yes (**explain below**) ## AI Assistance Was AI assistance used while working on this change? - - [ ] No - - [x] Yes (**explain below**) To identify places to change. ## Final Checklist - - [x] Stability is not compromised. - - [x] Performance impact is understood, tested, and acceptable. - - [x] Added logic complexity is justified and explained. - - [x] Any new bot dialogue lines are translated. - - [x] Documentation updated if needed (Conf comments, WiKi commands). ## Notes for Reviewers Result after bot relogin: obraz --- src/Ai/Base/Actions/OutfitAction.cpp | 5 +++++ src/Db/PlayerbotRepository.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Ai/Base/Actions/OutfitAction.cpp b/src/Ai/Base/Actions/OutfitAction.cpp index 78f7f9bc4..cbb412194 100644 --- a/src/Ai/Base/Actions/OutfitAction.cpp +++ b/src/Ai/Base/Actions/OutfitAction.cpp @@ -7,6 +7,7 @@ #include "Event.h" #include "ItemVisitors.h" +#include "PlayerbotRepository.h" #include "Playerbots.h" #include "ItemPackets.h" @@ -28,6 +29,7 @@ bool OutfitAction::Execute(Event event) if (!name.empty()) { Save(name, items); + PlayerbotRepository::instance().Save(botAI); std::ostringstream out; out << "Setting outfit " << name << " as " << param; @@ -86,6 +88,7 @@ bool OutfitAction::Execute(Event event) botAI->TellMaster(out); Save(name, ItemIds()); + PlayerbotRepository::instance().Save(botAI); return true; } else if (command == "update") @@ -95,6 +98,7 @@ bool OutfitAction::Execute(Event event) botAI->TellMaster(out); Update(name); + PlayerbotRepository::instance().Save(botAI); return true; } @@ -124,6 +128,7 @@ bool OutfitAction::Execute(Event event) } Save(name, outfit); + PlayerbotRepository::instance().Save(botAI); } return true; diff --git a/src/Db/PlayerbotRepository.cpp b/src/Db/PlayerbotRepository.cpp index 115a4e95f..53bd188f8 100644 --- a/src/Db/PlayerbotRepository.cpp +++ b/src/Db/PlayerbotRepository.cpp @@ -39,6 +39,8 @@ void PlayerbotRepository::Load(PlayerbotAI* botAI) botAI->ChangeStrategy(value, BOT_STATE_DEAD); } while (result->NextRow()); + botAI->GetAiObjectContext()->GetUntypedValue("outfit list"); + botAI->GetAiObjectContext()->Load(values); } }