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

feat(Misc): base rework module #57

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

feat(Misc): base rework module #57

wants to merge 4 commits into from

Conversation

Winfidonarleyan
Copy link
Member

@Winfidonarleyan Winfidonarleyan commented Mar 19, 2022

Changes:

  • ...

Comment on lines +1421 to +1459
config->SetMinPrice(ITEM_QUALITY_POOR, minpricegrey);
config->SetMaxPrice(ITEM_QUALITY_POOR, maxpricegrey);
config->SetMinPrice(ITEM_QUALITY_NORMAL, minpricewhite);
config->SetMaxPrice(ITEM_QUALITY_NORMAL, maxpricewhite);
config->SetMinPrice(ITEM_QUALITY_UNCOMMON, minpricegreen);
config->SetMaxPrice(ITEM_QUALITY_UNCOMMON, maxpricegreen);
config->SetMinPrice(ITEM_QUALITY_RARE, minpriceblue);
config->SetMaxPrice(ITEM_QUALITY_RARE, maxpriceblue);
config->SetMinPrice(ITEM_QUALITY_EPIC, minpricepurple);
config->SetMaxPrice(ITEM_QUALITY_EPIC, maxpricepurple);
config->SetMinPrice(ITEM_QUALITY_LEGENDARY, minpriceorange);
config->SetMaxPrice(ITEM_QUALITY_LEGENDARY, maxpriceorange);
config->SetMinPrice(ITEM_QUALITY_ARTIFACT, minpriceyellow);
config->SetMaxPrice(ITEM_QUALITY_ARTIFACT, maxpriceyellow);

// Load min and max bid prices
config->SetMinBidPrice(ITEM_QUALITY_POOR, minbidpricegrey);
config->SetMaxBidPrice(ITEM_QUALITY_POOR, maxbidpricegrey);
config->SetMinBidPrice(ITEM_QUALITY_NORMAL, minbidpricewhite);
config->SetMaxBidPrice(ITEM_QUALITY_NORMAL, maxbidpricewhite);
config->SetMinBidPrice(ITEM_QUALITY_UNCOMMON, minbidpricegreen);
config->SetMaxBidPrice(ITEM_QUALITY_UNCOMMON, maxbidpricegreen);
config->SetMinBidPrice(ITEM_QUALITY_RARE, minbidpriceblue);
config->SetMaxBidPrice(ITEM_QUALITY_RARE, maxbidpriceblue);
config->SetMinBidPrice(ITEM_QUALITY_EPIC, minbidpricepurple);
config->SetMaxBidPrice(ITEM_QUALITY_EPIC, maxbidpricepurple);
config->SetMinBidPrice(ITEM_QUALITY_LEGENDARY, minbidpriceorange);
config->SetMaxBidPrice(ITEM_QUALITY_LEGENDARY, maxbidpriceorange);
config->SetMinBidPrice(ITEM_QUALITY_ARTIFACT, minbidpriceyellow);
config->SetMaxBidPrice(ITEM_QUALITY_ARTIFACT, maxbidpriceyellow);

// Load max stacks
config->SetMaxStack(ITEM_QUALITY_POOR, maxstackgrey);
config->SetMaxStack(ITEM_QUALITY_NORMAL, maxstackwhite);
config->SetMaxStack(ITEM_QUALITY_UNCOMMON, maxstackgreen);
config->SetMaxStack(ITEM_QUALITY_RARE, maxstackblue);
config->SetMaxStack(ITEM_QUALITY_EPIC, maxstackpurple);
config->SetMaxStack(ITEM_QUALITY_LEGENDARY, maxstackorange);
config->SetMaxStack(ITEM_QUALITY_ARTIFACT, maxstackyellow);
Copy link

Choose a reason for hiding this comment

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

Bad indent

Suggested change
config->SetMinPrice(ITEM_QUALITY_POOR, minpricegrey);
config->SetMaxPrice(ITEM_QUALITY_POOR, maxpricegrey);
config->SetMinPrice(ITEM_QUALITY_NORMAL, minpricewhite);
config->SetMaxPrice(ITEM_QUALITY_NORMAL, maxpricewhite);
config->SetMinPrice(ITEM_QUALITY_UNCOMMON, minpricegreen);
config->SetMaxPrice(ITEM_QUALITY_UNCOMMON, maxpricegreen);
config->SetMinPrice(ITEM_QUALITY_RARE, minpriceblue);
config->SetMaxPrice(ITEM_QUALITY_RARE, maxpriceblue);
config->SetMinPrice(ITEM_QUALITY_EPIC, minpricepurple);
config->SetMaxPrice(ITEM_QUALITY_EPIC, maxpricepurple);
config->SetMinPrice(ITEM_QUALITY_LEGENDARY, minpriceorange);
config->SetMaxPrice(ITEM_QUALITY_LEGENDARY, maxpriceorange);
config->SetMinPrice(ITEM_QUALITY_ARTIFACT, minpriceyellow);
config->SetMaxPrice(ITEM_QUALITY_ARTIFACT, maxpriceyellow);
// Load min and max bid prices
config->SetMinBidPrice(ITEM_QUALITY_POOR, minbidpricegrey);
config->SetMaxBidPrice(ITEM_QUALITY_POOR, maxbidpricegrey);
config->SetMinBidPrice(ITEM_QUALITY_NORMAL, minbidpricewhite);
config->SetMaxBidPrice(ITEM_QUALITY_NORMAL, maxbidpricewhite);
config->SetMinBidPrice(ITEM_QUALITY_UNCOMMON, minbidpricegreen);
config->SetMaxBidPrice(ITEM_QUALITY_UNCOMMON, maxbidpricegreen);
config->SetMinBidPrice(ITEM_QUALITY_RARE, minbidpriceblue);
config->SetMaxBidPrice(ITEM_QUALITY_RARE, maxbidpriceblue);
config->SetMinBidPrice(ITEM_QUALITY_EPIC, minbidpricepurple);
config->SetMaxBidPrice(ITEM_QUALITY_EPIC, maxbidpricepurple);
config->SetMinBidPrice(ITEM_QUALITY_LEGENDARY, minbidpriceorange);
config->SetMaxBidPrice(ITEM_QUALITY_LEGENDARY, maxbidpriceorange);
config->SetMinBidPrice(ITEM_QUALITY_ARTIFACT, minbidpriceyellow);
config->SetMaxBidPrice(ITEM_QUALITY_ARTIFACT, maxbidpriceyellow);
// Load max stacks
config->SetMaxStack(ITEM_QUALITY_POOR, maxstackgrey);
config->SetMaxStack(ITEM_QUALITY_NORMAL, maxstackwhite);
config->SetMaxStack(ITEM_QUALITY_UNCOMMON, maxstackgreen);
config->SetMaxStack(ITEM_QUALITY_RARE, maxstackblue);
config->SetMaxStack(ITEM_QUALITY_EPIC, maxstackpurple);
config->SetMaxStack(ITEM_QUALITY_LEGENDARY, maxstackorange);
config->SetMaxStack(ITEM_QUALITY_ARTIFACT, maxstackyellow);
config->SetMinPrice(ITEM_QUALITY_POOR, minpricegrey);
config->SetMaxPrice(ITEM_QUALITY_POOR, maxpricegrey);
config->SetMinPrice(ITEM_QUALITY_NORMAL, minpricewhite);
config->SetMaxPrice(ITEM_QUALITY_NORMAL, maxpricewhite);
config->SetMinPrice(ITEM_QUALITY_UNCOMMON, minpricegreen);
config->SetMaxPrice(ITEM_QUALITY_UNCOMMON, maxpricegreen);
config->SetMinPrice(ITEM_QUALITY_RARE, minpriceblue);
config->SetMaxPrice(ITEM_QUALITY_RARE, maxpriceblue);
config->SetMinPrice(ITEM_QUALITY_EPIC, minpricepurple);
config->SetMaxPrice(ITEM_QUALITY_EPIC, maxpricepurple);
config->SetMinPrice(ITEM_QUALITY_LEGENDARY, minpriceorange);
config->SetMaxPrice(ITEM_QUALITY_LEGENDARY, maxpriceorange);
config->SetMinPrice(ITEM_QUALITY_ARTIFACT, minpriceyellow);
config->SetMaxPrice(ITEM_QUALITY_ARTIFACT, maxpriceyellow);
// Load min and max bid prices
config->SetMinBidPrice(ITEM_QUALITY_POOR, minbidpricegrey);
config->SetMaxBidPrice(ITEM_QUALITY_POOR, maxbidpricegrey);
config->SetMinBidPrice(ITEM_QUALITY_NORMAL, minbidpricewhite);
config->SetMaxBidPrice(ITEM_QUALITY_NORMAL, maxbidpricewhite);
config->SetMinBidPrice(ITEM_QUALITY_UNCOMMON, minbidpricegreen);
config->SetMaxBidPrice(ITEM_QUALITY_UNCOMMON, maxbidpricegreen);
config->SetMinBidPrice(ITEM_QUALITY_RARE, minbidpriceblue);
config->SetMaxBidPrice(ITEM_QUALITY_RARE, maxbidpriceblue);
config->SetMinBidPrice(ITEM_QUALITY_EPIC, minbidpricepurple);
config->SetMaxBidPrice(ITEM_QUALITY_EPIC, maxbidpricepurple);
config->SetMinBidPrice(ITEM_QUALITY_LEGENDARY, minbidpriceorange);
config->SetMaxBidPrice(ITEM_QUALITY_LEGENDARY, maxbidpriceorange);
config->SetMinBidPrice(ITEM_QUALITY_ARTIFACT, minbidpriceyellow);
config->SetMaxBidPrice(ITEM_QUALITY_ARTIFACT, maxbidpriceyellow);
// Load max stacks
config->SetMaxStack(ITEM_QUALITY_POOR, maxstackgrey);
config->SetMaxStack(ITEM_QUALITY_NORMAL, maxstackwhite);
config->SetMaxStack(ITEM_QUALITY_UNCOMMON, maxstackgreen);
config->SetMaxStack(ITEM_QUALITY_RARE, maxstackblue);
config->SetMaxStack(ITEM_QUALITY_EPIC, maxstackpurple);
config->SetMaxStack(ITEM_QUALITY_LEGENDARY, maxstackorange);
config->SetMaxStack(ITEM_QUALITY_ARTIFACT, maxstackyellow);

AuctionEntry *Aentry = itr->second;
Item *item = sAuctionMgr->GetAItem(Aentry->item_guid);
if (item)
Item* item = sAuctionMgr->GetAItem(auction->item_guid);
Copy link

Choose a reason for hiding this comment

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

Suggested change
Item* item = sAuctionMgr->GetAItem(auction->item_guid);
Item* item = sAuctionMgr->GetAItem(auction->item_guid);

Comment on lines +1603 to +1617
// Load buyer bid prices
config->SetBuyerPrice(ITEM_QUALITY_POOR, buyerpricegrey);
config->SetBuyerPrice(ITEM_QUALITY_NORMAL, buyerpricewhite);
config->SetBuyerPrice(ITEM_QUALITY_UNCOMMON, buyerpricegreen);
config->SetBuyerPrice(ITEM_QUALITY_RARE, buyerpriceblue);
config->SetBuyerPrice(ITEM_QUALITY_EPIC, buyerpricepurple);
config->SetBuyerPrice(ITEM_QUALITY_LEGENDARY, buyerpriceorange);
config->SetBuyerPrice(ITEM_QUALITY_ARTIFACT, buyerpriceyellow);

// Load bidding interval
config->SetBiddingInterval(Minutes(buyerbiddinginterval));

// Load bids per interval
config->SetBidsPerInterval(buyerbidsperinterval);

Copy link

Choose a reason for hiding this comment

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

Suggested change
// Load buyer bid prices
config->SetBuyerPrice(ITEM_QUALITY_POOR, buyerpricegrey);
config->SetBuyerPrice(ITEM_QUALITY_NORMAL, buyerpricewhite);
config->SetBuyerPrice(ITEM_QUALITY_UNCOMMON, buyerpricegreen);
config->SetBuyerPrice(ITEM_QUALITY_RARE, buyerpriceblue);
config->SetBuyerPrice(ITEM_QUALITY_EPIC, buyerpricepurple);
config->SetBuyerPrice(ITEM_QUALITY_LEGENDARY, buyerpriceorange);
config->SetBuyerPrice(ITEM_QUALITY_ARTIFACT, buyerpriceyellow);
// Load bidding interval
config->SetBiddingInterval(Minutes(buyerbiddinginterval));
// Load bids per interval
config->SetBidsPerInterval(buyerbidsperinterval);
// Load buyer bid prices
config->SetBuyerPrice(ITEM_QUALITY_POOR, buyerpricegrey);
config->SetBuyerPrice(ITEM_QUALITY_NORMAL, buyerpricewhite);
config->SetBuyerPrice(ITEM_QUALITY_UNCOMMON, buyerpricegreen);
config->SetBuyerPrice(ITEM_QUALITY_RARE, buyerpriceblue);
config->SetBuyerPrice(ITEM_QUALITY_EPIC, buyerpricepurple);
config->SetBuyerPrice(ITEM_QUALITY_LEGENDARY, buyerpriceorange);
config->SetBuyerPrice(ITEM_QUALITY_ARTIFACT, buyerpriceyellow);
// Load bidding interval
config->SetBiddingInterval(Minutes(buyerbiddinginterval));
// Load bids per interval
config->SetBidsPerInterval(buyerbidsperinterval);

}
else if (totalPercent != 100)
{
_itemsPercent[ITEM_QUALITY_POOR] = 0;
Copy link

Choose a reason for hiding this comment

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

Should print a warning log message here?

Or re-normalize the values

80+80 = 160
value*(100/160)
so it becomes 50+50

@dedmen
Copy link

dedmen commented Oct 31, 2023

What is holding this back? looks good to me

@Winfidonarleyan
Copy link
Member Author

I don't remember if I finished everything here or forgot something

@dedmen
Copy link

dedmen commented Nov 1, 2023

If I find time I'll deploy this on my server on the weekend.
I want to make some additions (real price data from a real server with median/stddev) for which I'll need that cleanup first.
I'll probably find more things to clean up with that

return _buyerBiddingInterval;
}

void CalculatePercents();
Copy link

Choose a reason for hiding this comment

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

That is a bad name
This doesn't calculate "Percents", it calculates the maximum number of items per quality level.
I will probably rename to "CalculateMaxCounts" later

Copy link

Choose a reason for hiding this comment

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

In general naming is bad all over the place.
"SetMinPrice" doesn't set the min price. It sets the minimum price multiplier in percent with 0-100 value.

return;
}

QueryResult result = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE itemowner<>{} AND buyguid<>{}", AHBplayerGUID, AHBplayerGUID);
auto sharedConfig = std::make_shared<AHBConfig>(*config);
Copy link

@dedmen dedmen Nov 3, 2023

Choose a reason for hiding this comment

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

Every time we add new auctions, we copy the whole config.
The config should've been a shared_ptr to begin with..

I'll rework that later

Co-authored-by: Dedmen Miller <dedmen@users.noreply.github.com>
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

Copy link

Choose a reason for hiding this comment

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

Missing include guard, including this file twice will break stuff

isVendorItem = true;
}

if (isVendorItem)
continue;
}

if ((Vendor_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS))
Copy link

Choose a reason for hiding this comment

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

BUG!
Class check went from == to !=

There are more of these here

isLootTG = true;
}

if (isLootTG)
continue;
}

if ((Other_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS))
Copy link

Choose a reason for hiding this comment

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

more bug.
Other_Items == 0 turned into OtherItems

@dedmen
Copy link

dedmen commented Nov 3, 2023

Please merge my indent fixes.
I will make a PR to fix the filtering issues

@dedmen
Copy link

dedmen commented Nov 3, 2023

I'm now running this plus my PR on my server, no issues so far 🤞

* chore: switch to reusable module workflow (#58)

* chore(Module/Structure): update structure (#72)

* chore(Bot): add db env include

* Split item indexing into separate files

* Fixed copyright headers

* Remove unused variable

---------

Co-authored-by: Patrick Lewis <pat@lo5t.com>
Co-authored-by: Walter Pagani <paganiwalter@gmail.com>
Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants