Jump to content

Sane Spell Class/Family Masks


Guest Loki_PhoenixWOW
 Share

Recommended Posts

Hi, I'm a dev at a private server that's using a MaNGOS-based core now, and we've decided to submit some of our changes back to the community here, in the hope that they will be helpful. Not everything will be drop-in compatible, but most of it should be usable with only minimal editing.

The first thing we'd like to give you guys is a sane way to deal with spell class/family masks. These are 96-bit sets of binary flags that help class spells decide which other spells to affect or be affected by. Currently they're stored alternately as an array of 3 uint32's or a uint64 and a uint32. Also, when they're used in code the flags are hard-coded, making the code hard to read and harder yet to update for new versions and debug.

SpellClassMask.h contains the masks and flags enum'd out for every class, up to date for 3.1.x. These change very little from version to version FYI. It also contains a data type (SpellCM) that can be used as both a std::bitset<96> and an array of 3 uint32's. It uses std::bitset<96> as it's parent class, so all binary ops & << >> ~ etc should work on it as if it were a 96-bit number. See the class definition at the bottom for full details.

SpellCM.diff is the patch that implemented it on our server. You should only need to change a few lines to make it useable. If you look through the file you should be easily able to tell how to use the SpellCM class.

I don't seem to have permission to post attachments, so I guess I'll just paste them in here as replies xD ~Loki

Link to comment
Share on other sites

No, advertising in signatures is not ok. I would edit your username too if I had the right.

We definitely will not accept any patch with server advertising anywhere in the files. Author names, maybe but it's generally accepted that we don't change the copyright notice just set the user as the author of the commit. If multiple users need to be thanked they are listed additionally in the commit message.

Link to comment
Share on other sites

No, advertising in signatures is not ok. I would edit your username too if I had the right.

We definitely will not accept any patch with server advertising anywhere in the files. Author names, maybe but it's generally accepted that we don't change the copyright notice just set the user as the author of the commit. If multiple users need to be thanked they are listed additionally in the commit message.

I would be happy to be just plain Loki, but it was taken =P

I assumed a site link in the sig was ok because the guy who originally complained about it had one in his =P

I'm not a dev for this site, I'm a dev for a server. We're just trying to be good open-sourcey people and give stuff back because we use your code. I fail to understand the logic of the problem. ~Loki

Link to comment
Share on other sites

Anyhow... here's everything updated with a fix for gcc x86_64. And by "fix" I mean I changed the bitset class to store in multiples of sizeof(char) instead of sizeof(long) xD

src/game/SpellClassMask.h:

http://github.com/Loki-PhoenixWOW/For-MaNGOS/blob/32bd762d7d4dec68df5d28f8a168a6796dac37eb/SpellClassMask.h

src/shared/astd/bitset.h:

http://github.com/Loki-PhoenixWOW/For-MaNGOS/blob/32bd762d7d4dec68df5d28f8a168a6796dac37eb/bitset.h

diff for implementation (may need minor editting for drop-in compatibility):

http://github.com/Loki-PhoenixWOW/For-MaNGOS/blob/32bd762d7d4dec68df5d28f8a168a6796dac37eb/SpellCM.diff

Enjoy. ~Loki

Link to comment
Share on other sites

Forgot to return *this; from an assignment operator xD Should be good now.

src/shared/astd/bitset.h:

http://github.com/Loki-PhoenixWOW/For-MaNGOS/blob/642f7bdf9abfd2315f3d0e2cf7c2be00d4dd534c/bitset.h

src/game/SpellClassMask.h

http://github.com/Loki-PhoenixWOW/For-MaNGOS/blob/642f7bdf9abfd2315f3d0e2cf7c2be00d4dd534c/SpellClassMask.h

diff for implementation:

http://github.com/Loki-PhoenixWOW/For-MaNGOS/blob/642f7bdf9abfd2315f3d0e2cf7c2be00d4dd534c/SpellCM.diff

Someone want to tweak the diff so it can drop into your core?

~Loki

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use