diff --git a/README.md b/README.md index f332508..529e971 100644 --- a/README.md +++ b/README.md @@ -145,8 +145,10 @@ faction auction house. how full the market is, so it keeps a background of listings even when many players are online (without it, player auctions count toward the total and the SQL max values must be raised a lot). -- `MinItems` / `MaxItems` bound the total number of auctions; `DuplicatesCount` caps - duplicate stacks of a single item (per-item overrides can raise or lower this). +- `MaxItems` bounds the total number of auctions the bots keep listed; `DuplicatesCount` + caps duplicate stacks of a single item (per-item overrides can raise or lower this). + Both come from the conf file - the `minitems` / `maxitems` columns that used to live in + `mod_auctionhousebot` were never read and have been dropped. ### Item filtering diff --git a/conf/mod_ahbot.conf.dist b/conf/mod_ahbot.conf.dist index f79faca..8b90c29 100644 --- a/conf/mod_ahbot.conf.dist +++ b/conf/mod_ahbot.conf.dist @@ -123,7 +123,6 @@ AuctionHouseBot.ConsiderOnlyBotAuctions = 0 AuctionHouseBot.DuplicatesCount = 0 AuctionHouseBot.DivisibleStacks = 0 AuctionHouseBot.ElapsingTimeClass = 1 -AuctionHouseBot.MinItems = 10000 AuctionHouseBot.MaxItems = 15000 AuctionHouseBot.MaxStackSize = 20 diff --git a/data/sql/db-world/z_2026_08_24_00_drop_minitems_maxitems.sql b/data/sql/db-world/z_2026_08_24_00_drop_minitems_maxitems.sql new file mode 100644 index 0000000..25afb9a --- /dev/null +++ b/data/sql/db-world/z_2026_08_24_00_drop_minitems_maxitems.sql @@ -0,0 +1,41 @@ +-- +-- Drop the unused minitems / maxitems columns from mod_auctionhousebot. +-- +-- The module stopped reading them a long time ago: InitializeFromSql() had both +-- SELECTs commented out, so the seller took its ceiling from AuctionHouseBot.MaxItems +-- in the conf file only, while the columns kept being written by ".ahbotoptions +-- minitems/maxitems" and never read back. Editing them looked like it worked and did +-- nothing. +-- +-- Guarded so the file is safe to run twice and works on both MySQL and MariaDB +-- (MySQL has no DROP COLUMN IF EXISTS). The z_ prefix keeps it sorted after +-- mod_auctionhousebot.sql, which still creates the columns on a fresh install. +-- + +SET @columnExists := ( + SELECT COUNT(*) FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'mod_auctionhousebot' + AND COLUMN_NAME = 'minitems'); + +SET @statement := IF(@columnExists > 0, + 'ALTER TABLE `mod_auctionhousebot` DROP COLUMN `minitems`', + 'DO 0'); + +PREPARE dropMinItems FROM @statement; +EXECUTE dropMinItems; +DEALLOCATE PREPARE dropMinItems; + +SET @columnExists := ( + SELECT COUNT(*) FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() + AND TABLE_NAME = 'mod_auctionhousebot' + AND COLUMN_NAME = 'maxitems'); + +SET @statement := IF(@columnExists > 0, + 'ALTER TABLE `mod_auctionhousebot` DROP COLUMN `maxitems`', + 'DO 0'); + +PREPARE dropMaxItems FROM @statement; +EXECUTE dropMaxItems; +DEALLOCATE PREPARE dropMaxItems; diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 4f729ca..ed7ef79 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -1670,24 +1670,13 @@ void AuctionHouseBot::Commands(AHBotCommand command, uint32 ahMapID, uint32 col, break; } - case AHBotCommand::minitems: - { - char * param1 = strtok(args, " "); - uint32 minItems = (uint32) strtoul(param1, NULL, 0); - - WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minitems = '{}' WHERE auctionhouse = '{}'", minItems, ahMapID); - - config->SetMinItems(minItems); - - break; - } case AHBotCommand::maxitems: { char * param1 = strtok(args, " "); uint32 maxItems = (uint32) strtoul(param1, NULL, 0); - WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxitems = '{}' WHERE auctionhouse = '{}'", maxItems, ahMapID); - + // Runtime only: the seller reads its ceiling from AuctionHouseBot.MaxItems, + // so this lasts until the next restart and is not persisted anywhere. config->SetMaxItems(maxItems); config->CalculatePercents(); break; diff --git a/src/AuctionHouseBotCommon.h b/src/AuctionHouseBotCommon.h index 73532ad..a8cfb16 100644 --- a/src/AuctionHouseBotCommon.h +++ b/src/AuctionHouseBotCommon.h @@ -85,7 +85,6 @@ enum class AHBotCommand : uint32 useMarketPrice, ahexpire, - minitems, maxitems, percentages, minprice, diff --git a/src/AuctionHouseBotConfig.cpp b/src/AuctionHouseBotConfig.cpp index 480f8cc..f04ecc9 100644 --- a/src/AuctionHouseBotConfig.cpp +++ b/src/AuctionHouseBotConfig.cpp @@ -101,7 +101,6 @@ AHBConfig::AHBConfig(uint32 ahid, AHBConfig* conf) // Copy the private values // - minItems = conf->minItems; maxItems = conf->maxItems; percentGreyTradeGoods = conf->percentGreyTradeGoods; percentWhiteTradeGoods = conf->percentWhiteTradeGoods; @@ -392,7 +391,6 @@ void AHBConfig::Reset() AHID = 0; AHFID = 0; - minItems = 0; maxItems = 0; percentGreyTradeGoods = 0; @@ -620,27 +618,6 @@ uint32 AHBConfig::GetMaxStackSize() return maxStackSize; } -void AHBConfig::SetMinItems(uint32 value) -{ - minItems = value; -} - -uint32 AHBConfig::GetMinItems() -{ - if ((minItems == 0) && (maxItems)) - { - return maxItems; - } - else if ((maxItems) && (minItems > maxItems)) - { - return maxItems; - } - else - { - return minItems; - } -} - void AHBConfig::SetMaxItems(uint32 value) { maxItems = value; @@ -2073,7 +2050,6 @@ void AHBConfig::InitializeFromFile() ElapsingTimeClass = sConfigMgr->GetOption("AuctionHouseBot.ElapsingTimeClass" , 1); ConsiderOnlyBotAuctions = sConfigMgr->GetOption ("AuctionHouseBot.ConsiderOnlyBotAuctions", false); ItemsPerCycle = sConfigMgr->GetOption("AuctionHouseBot.ItemsPerCycle" , 200); - minItems = sConfigMgr->GetOption("AuctionHouseBot.MinItems" , 1000); maxItems = sConfigMgr->GetOption("AuctionHouseBot.MaxItems" , 5000); maxStackSize = sConfigMgr->GetOption("AuctionHouseBot.MaxStackSize", 20); @@ -2211,10 +2187,6 @@ void AHBConfig::InitializeFromFile() void AHBConfig::InitializeFromSql(std::set botsIds) { - // Load min and max items - //SetMinItems(WorldDatabase.Query("SELECT minitems FROM mod_auctionhousebot WHERE auctionhouse = {}", GetAHID())->Fetch()->Get()); - //SetMaxItems(WorldDatabase.Query("SELECT maxitems FROM mod_auctionhousebot WHERE auctionhouse = {}", GetAHID())->Fetch()->Get()); - // Load percentages, min/max prices, min/max bid prices, and max stacks in a single query QueryResult databaseValuesResult = WorldDatabase.Query( "SELECT " @@ -2306,7 +2278,6 @@ void AHBConfig::InitializeFromSql(std::set botsIds) { LOG_INFO("module", "Settings for Auctionhouse {}", GetAHID()); - //LOG_INFO("module", "minItems = {}", GetMinItems()); //LOG_INFO("module", "maxItems = {}", GetMaxItems()); LOG_INFO("module", "percentGreyTradeGoods = {}", greytg); diff --git a/src/AuctionHouseBotConfig.h b/src/AuctionHouseBotConfig.h index de55433..5c0e70d 100644 --- a/src/AuctionHouseBotConfig.h +++ b/src/AuctionHouseBotConfig.h @@ -34,7 +34,6 @@ class AHBConfig uint32 AHID; // Id uint32 AHFID; // Faction id - uint32 minItems; uint32 maxItems; uint32 maxStackSize; @@ -350,9 +349,6 @@ class AHBConfig uint32 GetAHID(); uint32 GetAHFID(); - uint32 GetMinItems(); - void SetMinItems(uint32 value); - uint32 GetMaxItems(); void SetMaxItems(uint32 value); diff --git a/src/cs_ah_bot.cpp b/src/cs_ah_bot.cpp index 5826d6c..d87266d 100644 --- a/src/cs_ah_bot.cpp +++ b/src/cs_ah_bot.cpp @@ -210,8 +210,7 @@ class ah_bot_commandscript : public CommandScript handler->PSendSysMessage("seller - enable/disabler seller"); handler->PSendSysMessage("usemarketprice - enable/disabler selling at market price"); handler->PSendSysMessage("ahexpire - remove all bot auctions"); - handler->PSendSysMessage("minitems - set min auctions"); - handler->PSendSysMessage("maxitems - set max auctions"); + handler->PSendSysMessage("maxitems - set max auctions (until restart)"); handler->PSendSysMessage("percentages - set selling percentages"); handler->PSendSysMessage("minprice - set min price"); handler->PSendSysMessage("maxprice - set max price"); @@ -237,21 +236,6 @@ class ah_bot_commandscript : public CommandScript bot->Commands(AHBotCommand::ahexpire, ahMapID, 0, NULL); } } - else if (strncmp(opt, "minitems", l) == 0) - { - char* param1 = strtok(NULL, " "); - - if (!ahMapIdStr || !param1) - { - handler->PSendSysMessage("Syntax is: ahbotoptions minitems $ahMapID (2, 6 or 7) $minItems"); - return false; - } - - for (AuctionHouseBot* bot : gBots) - { - bot->Commands(AHBotCommand::minitems, ahMapID, 0, param1); - } - } else if (strncmp(opt, "maxitems", l) == 0) { char* param1 = strtok(NULL, " ");