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

[WIP] Core/Misc Support for Account Wide Mounts #14849

Closed
wants to merge 12 commits into from

Conversation

Boomper
Copy link
Contributor

@Boomper Boomper commented Jun 7, 2015

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.

 - 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

bool IsFullUpdate = false;

@ElleEntertainment
Copy link

gj

@Shauren
Copy link
Member

Shauren commented Jun 7, 2015

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))
Copy link
Member

Choose a reason for hiding this comment

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

mountEntry variable looks unused

@Boomper
Copy link
Contributor Author

Boomper commented Jun 8, 2015

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...

@Boomper
Copy link
Contributor Author

Boomper commented Jun 9, 2015

Just finished writing the "Evil SQL Query to transfer old mounts from character_spell into account_mounts"...
https://gist.github.com/Boomper/ea3f851f66ddf0f8f1eb
Since it's "touching" auth, characters and world database (multidb queries) should it still be in sql/updates/auth or is there a special place for it?

I'll be updating the pull request in few hours, just need to polish some stuff (the loading should be fixed by then)...

@Aokromes
Copy link
Member

Aokromes commented Jun 9, 2015

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`);
Copy link
Contributor Author

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.

Copy link
Member

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))
 - whooooops... hopefuly no one notices...
@Boomper
Copy link
Contributor Author

Boomper commented Jun 10, 2015

Wrongly merged something, I'll fix it during sunlight...

if (!sSpellMgr->GetSpellInfo(spellId))
return false;

if (!sDB2Manager.GetMount(spellId))
Copy link

Choose a reason for hiding this comment

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

check again?

@jackpoz
Copy link
Member

jackpoz commented Jun 10, 2015

Just finished writing the "Evil SQL Query to transfer old mounts from character_spell into account_mounts"...
https://gist.github.com/Boomper/ea3f851f66ddf0f8f1eb

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`);
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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)
@Boomper
Copy link
Contributor Author

Boomper commented Jun 10, 2015

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
@Boomper
Copy link
Contributor Author

Boomper commented Jun 12, 2015

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?

@ghost
Copy link

ghost commented Jun 13, 2015

Nice work, keep it :)

@Boomper
Copy link
Contributor Author

Boomper commented Jun 15, 2015

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...

@Shauren
Copy link
Member

Shauren commented Jun 15, 2015

@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

@Boomper
Copy link
Contributor Author

Boomper commented Jun 16, 2015

@Shauren Completely missed that one, thanks 👍
I did found that there are few mount "pairs" like:
http://www.wowhead.com/item=44226 / http://www.wowhead.com/item=44225 (not sure why) http://www.wowhead.com/item=67101 / http://www.wowhead.com/item=62298 (unlocked by completing achievement)
That work in a way that If you learn one of them you also learn the second one and you're only able to see one of them in your mounts (depending on your faction).
So what I'm currently thinking is that I should still make a table to list these mounts, and maybe in same table I should keep track of faction for which the mount works (doesn't seem to be stored in DBC) and temporarily raceMask/classMask till playercondition.db2 is implemented.

@Shauren
Copy link
Member

Shauren commented Jun 18, 2015

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

@Boomper
Copy link
Contributor Author

Boomper commented Jun 22, 2015

https://gist.github.com/Boomper/e6a2c9abc45512ab5364
That's the table that I'm proposing (accepting suggestions for better table/variable names), how it should work:

  • spell (spell id of the mount)
  • faction (0 - factionism free; 1 - alliance only; 2 - horde only) - if the mount is horde only on alliance character, he/she will see it in his collections but it will be red (unusable)
  • other_spell (oposite version) - those are special cases when the player gets both from earning one of them but can only see one of them (his faction version) in his collection
  • raceMask (1 Human | 2 Orc |...) - these mounts will only appear in collection if player fits into raceMask
  • classMask (same as raceMask)
    I should have the table implemented mid-week if I get enough free time.

P.S.: Too tired, going to cry... so much gold/time wasted on testing.

@Shauren
Copy link
Member

Shauren commented Jun 22, 2015

  • other_spell (oposite version) - those are special cases when the player gets both from earning one of them but can only see one of them (his faction version) in his collection

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)

@Boomper
Copy link
Contributor Author

Boomper commented Jun 22, 2015

http://www.wowhead.com/spell=60424 Mekgineer's Chopper / http://www.wowhead.com/spell=55531 Mechano-Hog
It's mostly mounts that are rewarded from completing faction specific reputations/achievements/quests or mounts that are faction specific and award achievement for getting them (mekgineer's chopper/mechano-hog - achievement http://www.wowhead.com/achievement=2097)

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
 - TODO: Research how to squish commits... for reasons... it looks cooler
@Aokromes
Copy link
Member

All checks have failed
1 failing check
Details continuous-integration/travis-ci/pr — The Travis CI build failed
This branch has conflicts that must be resolved
Use the command line to resolve conflicts before continuing.

@Boomper
Copy link
Contributor Author

Boomper commented Sep 13, 2015

I've been busy with exams and studying for them, no idea when I'll have time to finish this.

@ghost
Copy link

ghost commented Sep 13, 2015

To fix the conflicts, you will usually only need to update/rebase your branch so it is even with 6.x
(just make sure that you got a backup copy of your files, in case anything goes wrong during rebase).

@MitchesD
Copy link
Contributor

I am closing this PR:

  1. It's outdated
  2. I am working on it ;)
  3. Author looks like gone

@MitchesD MitchesD closed this Nov 13, 2015
@Boomper
Copy link
Contributor Author

Boomper commented Nov 14, 2015

Go for it, feel free to reuse whatever you want from it, if there's something worth a while.
I don't have time to work on this anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants