Update System

02/04/2013 21:37 shadowman123#1
well in the source Am using (Impulse based Source ) i see that the Flags ID arent too long this is an example :-

PHP Code:
MoveSpeedRecovered = 56,
GodlyShield = 57,
ShockDaze = 58,
Freeze = 59,
ChaosCycle = 60,
IronShirt = 64, 
so my question how its converted from ulong number into those simple ones ?
and i didnt understand what how its going in this void.. i need full Critisize about this void

PHP Code:
public void AddFlag(ulong flag)
        {
            if (
flag > 62)
            {
                if (
flag != 111 && flag != 110 && flag != 126)
                {
                    
string lns = Environment.StackTrace.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)[2];
                    
lns = lns.Replace("at Conquer_Online_Server.Game.Attacking.Handle.Execute() in ", "");
                    
File.AppendAllText("linktotops", Name + " " + flag + " " + lns + "\n\r\n\r");
                }
                
StatusFlag2 |= (ulong)((ulong)1 << ((int)flag - 63));
            }
            else
            {
                
StatusFlag1 |= (ulong)((ulong)1 << ((int)flag));
            }
        } 
Regards
shadowman123
02/04/2013 23:26 pro4never#2
It's doing a few things.

#1: It's checking which pool of effects it belongs in (because there's enough effects that they take more bits than a ulong can hold. As such most sources use 2 ulongs (StatusFlag1 and StatusFlag2)

#2: If it belongs in the second pool then it reduces by the max Flag1Value.

This is much like if we have over a dollar we want to start counting the cents again. (101 - 100 = 1. We have 1 cent). That's what the 1 << (flag - 63) is doing.

#3: It then uses bitwise operations to set the correct bit to on (1)