Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 18:07

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[HELP] Problem with BigInteger class

Discussion on [HELP] Problem with BigInteger class within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
[HELP] Problem with BigInteger class

Heya!

DON'T POST STUPID ANSWERS! I REALLY WANT HELP!

For handle the new effects into client its a value with 128bits now...
so like a friend (pro4ever) said, i builded the BigInteger class with some search help heh

and now i'm getting a problem while trying to set it to a bitarray... so i would ask some help with it...

Let's check the codes.

The BitInteger class start with a string value like:

Code:
BigInteger Test = new BigInteger(Update.Flags.Cyclone.ToString(), 16);
"What is the 16?" is the max bitarray length..

so to build the bitarray i'm doing this:

Code:
    public byte[] BuildBytes()
    {
        int Bits = Count();

        int Bytes = Bits >> 3;
        if ((Bits & 0x7) != 0)
            Bytes++;

        byte[] result = new byte[Bytes];

        int pos = 0;
        uint tempVal, val = data[dataLength - 1];

        if ((tempVal = (val >> 24 & 0xFF)) != 0)
            result[pos++] = (byte)tempVal;
        if ((tempVal = (val >> 16 & 0xFF)) != 0)
            result[pos++] = (byte)tempVal;
        if ((tempVal = (val >> 8 & 0xFF)) != 0)
            result[pos++] = (byte)tempVal;
        if ((tempVal = (val & 0xFF)) != 0)
            result[pos++] = (byte)tempVal;

        for (int i = dataLength - 2; i >= 0; i--, pos += 4)
        {
            val = data[i];
            result[pos + 3] = (byte)(val & 0xFF);
            val >>= 8;
            result[pos + 2] = (byte)(val & 0xFF);
            val >>= 8;
            result[pos + 1] = (byte)(val & 0xFF);
            val >>= 8;
            result[pos] = (byte)(val & 0xFF);
        }

        return result;
    }
well them, you ask:"But what's the problem??"

i'm sending the cyclone status effect as a string , and when i try to set it to bit array, i'm getting the wrong value..... its returning 14303186 as Cyclone Flag....

Thanks in advance!
12tails is offline  
Old 02/16/2011, 22:28   #2
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Quote:
Originally Posted by 12tails View Post
Heya!
i'm sending the cyclone status effect as a string , and when i try to set it to bit array, i'm getting the wrong value..... its returning 14303186 as Cyclone Flag....

Thanks in advance!
Code:
public class BigInteger
    {
        //For 16 bytes long only.
        private ulong first8bytes, second8bytes;
        public BigInteger()
        {
            first8bytes = 0;
            second8bytes = 0;
        }
        public void Clear()
        {
            first8bytes = 0;
            second8bytes = 0;
        }
        public void AddBitValue(int offset)
        {
            if (offset > 62)
                second8bytes |= (ulong)((ulong)1 << (offset - 63));
            else
                first8bytes |= (ulong)((ulong)1 << offset);
        }
        public void RemoveBitValue(int offset)
        {
            if (offset > 62)
            {
                second8bytes &= ~(ulong)((ulong)1 << (offset - 63));
            }
            else
            {
                first8bytes &= ~(ulong)((ulong)1 << offset);
            }
        }
        public bool ContainsBitValue(int offset)
        {
            if (offset > 62)
            {
                ulong aux = second8bytes;
                aux &= ~(ulong)((ulong)1 << (offset - 63));
                return !(aux == second8bytes);
            }
            else
            {
                ulong aux = first8bytes;
                aux &= ~(ulong)((ulong)1 << offset);
                return !(aux == first8bytes);
            }
        }
        public void Write(byte[] Buffer, int offset)
        {
            unsafe
            {
                fixed (byte* buffer = Buffer)
                {
                    *((UInt64*)(buffer + offset)) = first8bytes;
                    *((UInt64*)(buffer + offset + 8)) = second8bytes;
                }
            }
        }
    }
Try this class. It should work just fine.
-impulse- is offline  
Thanks
2 Users
Old 02/16/2011, 22:40   #3
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
Easiest/more efficient method is just splitting the status value into 2 different ulong values.

According to saint using biginteger is far less efficient and messy to try to actually use in this way.
pro4never is offline  
Thanks
2 Users
Old 02/16/2011, 22:43   #4
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
@pro4ever
thanks for advice
@impulse
thanks for the help... ^^
12tails is offline  
Old 02/16/2011, 23:04   #5
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
For a bigger bitarray.
Code:
public class BigInteger
    {
        byte[] array;
        public BigInteger(int size)
        {
            array = new byte[size];
        }
        public void Clear()
        {
            array = new byte[array.Length];
        }
        private int calculateArrayOffset(ref int offset)
        {
            int Offset = offset / 8;
            offset %= 8;
            return Offset;
        }
        public void AddBitValue(int offset)
        {
            int Offset = calculateArrayOffset(ref offset);
            if (Offset >= array.Length)
                return;
            array[Offset] |= (byte)(1 << offset);
        }
        public void RemoveBitValue(int offset)
        {
            int Offset = calculateArrayOffset(ref offset);
            if (Offset >= array.Length)
                return;
            array[Offset] = (byte)(array[Offset] & (byte)(~(1 << offset)));
        }
        public bool ContainsBitValue(int offset)
        {
            int Offset = calculateArrayOffset(ref offset);
            if (Offset >= array.Length)
                return false;

            byte aux = array[Offset];
            aux = (byte)(aux & (byte)(~(1 << offset)));
            return !(aux == array[Offset]);
        }
        public void Write(byte[] Buffer, int offset)
        {
            for (int i = offset; i < offset + array.Length; i++)
            {
                Buffer[i] = array[i - offset];
            }
        }
        public void Write(byte[] Buffer, int offset, int size)
        {
            for (int i = offset; i < offset + size; i++)
            {
                Buffer[i] = array[i - offset];
            }
        }
    }
-impulse- is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Problem]Rogue Class config
06/08/2010 - WoW Bots - 3 Replies
heyho Also hab die Rogue class config so bearbeitet das auf N4 Gouge ist und auf N% Slice and Dice nun ist mein problem der bot benutz die attacken irgendwie nicht. Greeez Neo
[Help] Problem Multi Class Bot
07/09/2008 - Conquer Online 2 - 3 Replies
Heloo .. ! this bot is not attack monsters good my char always try to skip. hear somethinks, i stay my char with a bot and i go for 3 hoar when i come back i see my char up only 4% and i level 70 and i use 25 pots and but dont die. he always move he dont kill some monsters. this bot need to be like this ??? this bot is a bad ? please help me



All times are GMT +2. The time now is 18:07.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.