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
[WIP] Core/Misc Support for Account Wide Mounts #14849
Conversation
- it's still work in progress, I'm just tired from this weird weather so I'd like some feedback before I mess something up... - the packet size is based on https://gist.github.com/Boomper/4434a33ac3c0f10dd1ee packet length was 476 and if you fill it with numbers (1 + 4 + 4 + 452 + 14 + 1) it equals 476 aswell... so it propably makes sense... - TODO: - Evil SQL Query to transfer old mounts from character_spell into account_mounts (I'll propably have to export the Mount.db2 for spellIds (just thinking out loud) - add support for PlayerCondition.db2 - add support for db table disables - add support for mounts that change when you change your faction (propably table in world db player_factionchange_spells)
void InitializeMounts(std::unordered_map<uint32, bool> mounts, bool fullUpdate); | ||
WorldPacket const* Write() override; | ||
|
||
bool IsFullUpdate; |
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.
bool IsFullUpdate = false;
gj |
You are executing database queries directly in packet handlers (MountSetFavorite) - this is unacceptable as it opens a DoS attack possibility. I suggest you take a look at how everything else is saved for players and add it there (Player::SaveToDB) Another thing is that mounts are battle.net account wide what adds another layer of complexity since you can be logged on the account multiple times (many game accounts) - data needs to be synchronized between them (possibly across multiple realms) |
- actual "save system" - account_mounts table is now moved into LoginDatabase (auth)
- forgot to move the sql file...
@@ -3420,6 +3420,9 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent | |||
return false; | |||
} | |||
|
|||
if (MountEntry const* mountEntry = sDB2Manager.GetMount(spellId)) |
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.
mountEntry variable looks unused
MountEntry is there for "Todo: add support for PlayerCondition.db2" because it contains value "PlayerConditionId" which is for mounts that you can use only after you complete quest/achievement/something... There is no check if spells referenced in Mount.db2 exist, or I'm being blind. Currently the loading part isn't working, must've messed something up when I've moved the table into LoginDatabase... |
Just finished writing the "Evil SQL Query to transfer old mounts from character_spell into account_mounts"... I'll be updating the pull request in few hours, just need to polish some stuff (the loading should be fixed by then)... |
The query must be on the final destination database. |
- now also merges all spells from character_spell into account_mounts - not going to commit other things tonight, my computer is being mean by refusing to compile core under 30 minutes so rest will be tomorrow (today 10.6.2015) night-ish
JOIN `characters`.`characters` `chars` ON `chars`.`guid` = `characters`.`character_spell`.`guid` | ||
WHERE `characters`.`character_spell`.`spell` IN (SELECT `spell` FROM `temp_mounts`); | ||
|
||
DELETE FROM `characters`.`character_spell` WHERE `spell` IN (SELECT `spell` FROM `temp_mounts`); |
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.
@Aokromes I was writing about this. The reason why I don't want it in a seperate sql file is that it deletes the now useless mounts from character_spell and uses temp_mounts
table which is dropped afterwards... -> it wouldn't do anything because the table temp_mounts wouldn't exist.
Yes I could just do "WHERE spell
IN (1, 2,...)" but that would open up the possiblity that someone somewhere could execute the "DELETE FROM..." query before this one which would make him loose all playermounts.
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.
Maybe the way to do is a secondary commit after few days on that way no one fucks the database xd
- loading from auth DB now works - but I need to look into the asynch loading for smoother experience (can't quite figure out how that works for login db, any pointers would be appreciated (I don't mean pointers like 0x2E314A81)) - added basic handling for faction mounts (through world db table playerfactionchange_spells), players now learn both version (alliance and horde) but only the version for their faction will appear in their mount collection (there are exceptions because some faction based mounts aren't included in that table - also added m_mountCount variable into Player class for future handling of mount count achievements (+ for size of vectors with sweet packet data (this text doesn't have to make sense, I'm tired))
Wrongly merged something, I'll fix it during sunlight... |
if (!sSpellMgr->GetSpellInfo(spellId)) | ||
return false; | ||
|
||
if (!sDB2Manager.GetMount(spellId)) |
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.
check again?
lines like DROP TABLE IF EXISTS `auth`.`account_mounts`; don't assure in ANY way that the statement is executed on the correct database and should NEVER be written in that way (speaking of personal experience, in my case "auth" is 335 auth database and "auth6x" is 6.x auth database, so your sql will execute statements on the 335 database instead of the 6.x one) This is just the issue and it doesn't include the solution. 919ab91 is what I did last time I encountered this issue, up to you (and other devs) about what to do. Take a look how the solution plays with TC Database Auto Update too. |
JOIN `characters`.`characters` `chars` ON `chars`.`guid` = `characters`.`character_spell`.`guid` | ||
WHERE `characters`.`character_spell`.`spell` IN (SELECT `spell` FROM `temp_mounts`); | ||
|
||
DELETE FROM `characters`.`character_spell` WHERE `spell` IN (SELECT `spell` FROM `temp_mounts`); |
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.
the problem with this sql file is that you directly reference world, chars, characters (dafuq?) databases in this file, while there is no guarantee for anyone that all databases use those names
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.
Or even that these databases are on the same server
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.
From now on I shall reference them through time-space rift..., removing this from the pull request in next update, thanks for those heartwarming lines with so much potential to help me with this.
- wrongly merged files from yesterday (did some cleanup in my local branches, from now on there shouldn't be issues like this)
- it's going to be replaced with space-time rift which will convert all the old mounts in character_spell into those new ones (long story short: I'm not going to do anything with this until someone suggests better way)
Fixed the compilation errors from yesterday (problems with my local branches), removed the conversion part from SQL file and updated the description. |
- added new sqlqueryholder for other account wide things like achievements, battle pets, quets,... - accepting suggestions for better name for "collectionsHolder"
… (account_mounts) - old mounts are now added into new ones when player enters the world - no idea how that async query converted itself into sync query... it should be async... weird
The merging of old mounts is now handled by core (when player enters the world), I think that's all I was planning on doing so can someone test this if they find something wrong with it so we can finish this? |
Nice work, keep it :) |
So I did some more research into the account wide mounts system and it seems like that @Exodius was right. I'm currenlty trying to write a list for sql table for mounts that should be account-wide/account-wide in spellbook/and only character specific... |
@Boomper don't you dare do that. The client is able to know this by itself (see ingame mount tooltips) - fd786c8 Also a list of mount flags I conveniently researched earlier https://github.com/TrinityCore/TrinityCore/blob/6.x/src/server/game/DataStores/DBCEnums.h#L578 |
@Shauren Completely missed that one, thanks 👍 |
Just a heads up - I am working on implementing something nice for loading account wide data so you will need to adjust your patch in a near future |
https://gist.github.com/Boomper/e6a2c9abc45512ab5364
P.S.: Too tired, going to cry... so much gold/time wasted on testing. |
Can you give an example of this? Also please don't add class/race/faction conditions if they can be pulled from PlayerCondition.db2 (even if it's not implemented) |
http://www.wowhead.com/spell=60424 Mekgineer's Chopper / http://www.wowhead.com/spell=55531 Mechano-Hog Edit: Currently I'm stuck with 6.2 client unable to downgrade it/use previous versions (#134 error) so waiting till the core get's updated. |
- just adding this so I can update my repo for 6.2 so I can finally test this out
All checks have failed |
I've been busy with exams and studying for them, no idea when I'll have time to finish this. |
To fix the conflicts, you will usually only need to update/rebase your branch so it is even with 6.x |
I am closing this PR:
|
Go for it, feel free to reuse whatever you want from it, if there's something worth a while. |
Everything from TODO list seems to be finished (except playercondition.db2, no idea how that works, I'll leave it to someone else) so feel free to test it out and leave feedback.
Edit: Currently I'm stuck with 6.2 client unable to downgrade it/use previous versions (#134 error) so waiting till the core get's updated.