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
[3.3.5] Core/AuctionHouse: Auction Bidder Table #18328
Conversation
is this how it works on retail? |
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTION_BIDDERS); | ||
stmt->setUInt32(0, Id); | ||
|
||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going to be terribly slow if you launch a separate query for every single auction during startup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be a better idea to load all of the table at once and keep it around in memory until all auctions are loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All auctions are loaded on startup with one query in AuctionHouseMgr::LoadAuctions
, just run another query (for the entire table) there and parse it before the loop calling AuctionEntry::LoadFromDB
To be fair, I can't say with 100% certainty this is retail. But it seems, to me at least, like an oversight. |
@@ -85,6 +85,7 @@ struct TC_GAME_API AuctionEntry | |||
ObjectGuid::LowType bidder; | |||
uint32 deposit; //deposit can be calculated only when creating auction | |||
uint32 etime; | |||
std::unordered_set<uint32> bidderlist; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is meant to be a guid, use ObjectGuid::LowType, never the underlying type (master branch portability issue, its a different type there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks
It seems like the Travis build breaks on the SQL patch. I can't quite make sense of the error, what's going on there? |
It's not your issue, the guy who merges the patch must rename the file and add it to updates. |
@@ -373,13 +396,17 @@ void AuctionHouseMgr::LoadAuctions() | |||
continue; | |||
} | |||
|
|||
auto it = bidderlists.find(aItem->Id); | |||
if (it != bidderlists.end()) | |||
aItem->bidderlist = std::unordered_set<ObjectGuid::LowType>(it->second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for extra performance&fun, std::move it->second
|
||
auto it = bidderlists.find(auctionId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed, operator[] creates entries in map if not present.
just bidderlists[fields[0].GetUInt32()].insert(fields[1].GetUInt32());
@Shauren Done, thanks for your comments! |
Any comments? |
@joschiwald could you please check? |
@@ -845,6 +865,10 @@ void AuctionEntry::DeleteFromDB(SQLTransaction& trans) const | |||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_AUCTION); | |||
stmt->setUInt32(0, Id); | |||
trans->Append(stmt); | |||
|
|||
PreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_DEL_AUCTION_BIDDERS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can reuse stmt
The branch |
PreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_AUCTION_BIDDERS); | ||
stmt2->setUInt32(0, auction->Id); | ||
stmt2->setUInt32(1, auction->bidder); | ||
trans->Append(stmt2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you only need to fire this query if bidder was not present in bidderlist before
sql/base/characters_database.sql
Outdated
DROP TABLE IF EXISTS `auctionbidders`; | ||
CREATE TABLE `auctionbidders` ( | ||
`id` INT(10) UNSIGNED NOT NULL DEFAULT '0', | ||
`bidder` INT(10) UNSIGNED NOT NULL DEFAULT '0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't like tabs and better name will be BidderGuid
Well I can't say I was expecting this PR to be dug up again. Thanks for the comments, I'll reinstall the tools and see what I can do. Is there an easy way to rebase this PR on HEAD of 3.3.5 without screwing up the version history? Am a bit of a git noob |
To update your branch I only use Git Extensions, so I use the GUI approach. There is of course a git command for doing this, but I would prefer if someone doing it regularly could advise you on what it looks like in your case, if you use git on the command line. |
BTW, you may want to include an update in the Example, insert the following at the end of line 2571 of your ,('9999_99_99_18328_characters.sql','B978AC2CF95DDFC71E640362578295FA2D63AF76','RELEASED','2017-11-12 16:56:23',0) before the ending semicolon ( That content will have to be changed again when merging due to different file name and date/time info. |
The way I do it is, something like this: Do this once for the local repository. If you clone a new one you must do it again.
Then every time you want to update
Of course, if it cannot auto merge your changes on top of the current latest version it will list conflicts, which you need to fix. Once you're sure all are fixed (after fixing each file you need to add with git add) you can then enter (only if there were conflicts)
If you did a good job of fixing conflicts it will complete and you'll have a repo in the state that your commits appear after the latest commits from the TrinityCore 3.3.5 branch. Now you should ensure that it compiles and works as before. If so, then you must force push to your own github repo with git push -f. The reason to force it is because you're rewriting the history of your repo by rebasing. Now, the way to do it without rewriting history is git merge. But, for the purposes of updating a PR I think it's better to rebase. This will cause a spam of text in our IRC channel for each commit.. :) |
@r00ty-tc "This will cause a spam of text in our IRC channel for each commit.. :)" |
Well I personally think the bot should mute/summarize these multiple commits that happen in a short period. But, that's not your problem :) |
because that seems less expensive than dereferencing and parsing the value three times
ed61003
to
6601805
Compare
Actually looks like I was wrong. Just a single line sent. I think it's because I was working on a branch on TrinityCore itself and that logs each commit. So, all good. |
Neat-o. I'll look into the requested changes! |
@tkrokli What hash algorithm is used for the characters.updates table? Doesn't seem like throwing SHA1 at the file gets me the same value as in your comment. |
md5 |
It is sha1sum, but if you're on windows it will give the wrong result. Try using dos2unix (if you have git bash it will be there I think) or similar to convert to unix text file and then do sha1sum and the value should then be correct. |
Sorry, I generated a SHA1 hash because that was what came up when I checked the DB table info for the |
To look up your local hash, run this query in SELECT * FROM `characters`.`updates` WHERE `name`= '9999_99_99_18328_characters.sql'; If you use a different name for your |
Tested in-game
Come on, gents, don't leave me hanging again. If you think this is a shitty patch, just tell me, then at least I know which way is up. |
….sql - hoping to trigger a successful build in AppVeyor this time
No, this is actually pretty good |
Looks good this time around, travis-ci has accepted the updated |
Changes proposed:
Target branch(es):
(it might also apply to master, I have not tested this)
Todo:
WorldSession::HandleAuctionListBidderItems
and if it matters if we just ignore that entirely? I mean, using this bid table system, it's completely irrelevant if the client happens to remember a handful of auction IDs.Tests performed:
Built and tested in game.