These are chat archives for ZaneDubya/UltimaXNA

24th
Jun 2015
Jeff Boulanger
@jeffboulanger
Jun 24 2015 00:42
I used it as reference but I wrote that code in notepad
Jeff Boulanger
@jeffboulanger
Jun 24 2015 16:19
i just noticed the right side under the "People" of the gitter page has all the check ins in realtime. So nice
Jeff Boulanger
@jeffboulanger
Jun 24 2015 17:27
@ZaneDubya Why not store the bit flag for spells as a ulong? Isnt it sent that way in the packet?
Jeff Boulanger
@jeffboulanger
Jun 24 2015 17:34
I ask because you can simplify a lot of the code
Jeff Boulanger
@jeffboulanger
Jun 24 2015 17:58

for instance. the spellbook can just contain a ulong, rather than a byte[]. and you wouldnt have to math.pow anywhere. Just a simple

for(int i = 0; i < 64; i++)
{
    ulong flag = 1U << i;

    if(spellbook.Flags & flag == flag && m_SpellData[i] == false) 
    {
        entityUpdated = true;
        m_SpellData[i] = true;
    }
    else if (m_SpellData[i] == true)
    {
        entityUpdated = true
        m_SpellData[i] = false;
    }
}

Also simplied the logic you had 2 less if/else branching

You could essientially just make this a ulong as well
        private bool[] m_SpellData;
Jeff Boulanger
@jeffboulanger
Jun 24 2015 18:03
The HasSpell becomes
    public bool HasSpell(int index)
    {
        ulong flag = 1U << index;
        return (m_SpellData & flag) == flag;
    }
Jeff Boulanger
@jeffboulanger
Jun 24 2015 18:10
All in all, this is faster than doing pow, and easier to read, at least to me ;) but i would hope to most as well
hehe
Actually doing this you could essentially make it so your for loop didnt do the bit flag check but instead called HasSpell
Jeff Boulanger
@jeffboulanger
Jun 24 2015 18:15
if(spellbook.HasSpell(i) && m_SpellData[i] == false)
Zane Wagner
@ZaneDubya
Jun 24 2015 23:32
I like that!
But don't other spellbooks have less than 64 spells? Does the server always send 64 bits regardless of the kind of spell book?
Jeff Boulanger
@jeffboulanger
Jun 24 2015 23:51
ya
i believe so
public class NecromancerSpellbook : Spellbook
they all inheret from Spellbook, so ya, should be fine.