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

Refactor AHBot command passing #85

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 13 additions & 17 deletions src/AuctionHouseBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry)
config->DecItemCounts(prototype->Class, prototype->Quality);
}

void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
void AuctionHouseBot::Commands(AHBotCommand command, uint32 ahMapID, uint32 col, char* args)
{
AHBConfig *config = NULL;
switch (ahMapID)
Expand Down Expand Up @@ -1552,7 +1552,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
}
switch (command)
{
case 0: //ahexpire
case AHBotCommand::ahexpire:
{
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());

Expand All @@ -1572,15 +1572,15 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
}
}
break;
case 1: //min items
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 2: //max items
case AHBotCommand::maxitems:
{
char * param1 = strtok(args, " ");
uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
Expand All @@ -1589,11 +1589,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
config->CalculatePercents();
}
break;
case 3: //min time Deprecated (Place holder for future commands)
break;
case 4: //max time Deprecated (Place holder for future commands)
break;
case 5: //percentages
case AHBotCommand::percentages:
{
char * param1 = strtok(args, " ");
char * param2 = strtok(NULL, " ");
Expand Down Expand Up @@ -1643,63 +1639,63 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
}
break;
case 6: //min prices
case AHBotCommand::minprice:
{
char * param1 = strtok(args, " ");
uint32 minPrice = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minprice{} = '{}' WHERE auctionhouse = '{}'", color, minPrice, ahMapID);
config->SetMinPrice(col, minPrice);
}
break;
case 7: //max prices
case AHBotCommand::maxprice:
{
char * param1 = strtok(args, " ");
uint32 maxPrice = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxprice{} = '{}' WHERE auctionhouse = '{}'", color, maxPrice, ahMapID);
config->SetMaxPrice(col, maxPrice);
}
break;
case 8: //min bid price
case AHBotCommand::minbidprice:
{
char * param1 = strtok(args, " ");
uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minbidprice{} = '{}' WHERE auctionhouse = '{}'", color, minBidPrice, ahMapID);
config->SetMinBidPrice(col, minBidPrice);
}
break;
case 9: //max bid price
case AHBotCommand::maxbidprice:
{
char * param1 = strtok(args, " ");
uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxbidprice{} = '{}' WHERE auctionhouse = '{}'", color, maxBidPrice, ahMapID);
config->SetMaxBidPrice(col, maxBidPrice);
}
break;
case 10: //max stacks
case AHBotCommand::maxstack:
{
char * param1 = strtok(args, " ");
uint32 maxStack = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxstack{} = '{}' WHERE auctionhouse = '{}'", color, maxStack, ahMapID);
config->SetMaxStack(col, maxStack);
}
break;
case 11: //buyer bid prices
case AHBotCommand::buyerprice:
{
char * param1 = strtok(args, " ");
uint32 buyerPrice = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerprice{} = '{}' WHERE auctionhouse = '{}'", color, buyerPrice, ahMapID);
config->SetBuyerPrice(col, buyerPrice);
}
break;
case 12: //buyer bidding interval
case AHBotCommand::bidinterval:
{
char * param1 = strtok(args, " ");
uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerbiddinginterval = '{}' WHERE auctionhouse = '{}'", bidInterval, ahMapID);
config->SetBiddingInterval(bidInterval);
}
break;
case 13: //buyer bids per interval
case AHBotCommand::bidsperinterval:
{
char * param1 = strtok(args, " ");
uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0);
Expand Down
18 changes: 17 additions & 1 deletion src/AuctionHouseBot.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ struct AuctionEntry;
class Player;
class WorldSession;

enum class AHBotCommand : uint32
{
ahexpire,
minitems,
maxitems,
percentages,
minprice,
maxprice,
minbidprice,
maxbidprice,
maxstack,
buyerprice,
bidinterval,
bidsperinterval
};

#include "ItemTemplate.h"

#define AHB_GREY 0
Expand Down Expand Up @@ -1251,7 +1267,7 @@ class AuctionHouseBot
void LoadValues(AHBConfig*);
void DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry);
void IncrementItemCounts(AuctionEntry* ah);
void Commands(uint32, uint32, uint32, char*);
void Commands(AHBotCommand, uint32, uint32, char*);
ObjectGuid::LowType GetAHBplayerGUID() { return AHBplayerGUID; };
};

Expand Down
Loading
Loading