Raised This Month: $ Target: $400
 0% 

flags/math help [2, 4, 8, 16, 32, etc]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
sgtbane
Member
Join Date: Feb 2006
Old 01-02-2008 , 17:20   Re: flags/math help [2, 4, 8, 16, 32, etc]
Reply With Quote #4

thanks. i changed the title
also i discovered a method to get it done, but i was wondering if there is a simpler way, since with this you have to count down backwards through them till you find the one you want. Just wondering if there is a more direct way.

anyways this is what I am doing:
Code:
    Dim tmpcntInt As Integer, tmpInt As Integer, max As Long, i As Integer
    tmpInt = ReadInteger(ptrPlayer + 3088, pid)
    tmpcntInt = tmpInt
    max = 268435456
    For i = 0 To 28
        If tmpcntInt >= max And tmpcntInt <= (max * 2 - 1) Then
            tmpcntInt = tmpcntInt - max
            StorMove(28 - i) = True
        Else
            StorMove(28 - i) = False
        End If
        max = (max / 2)
    Next i
thats in VB 6.0 o.0... i know its old, please spare me the nagging
anyways I am getting the value from memory via pointer+offset, then making a copy of it to make it easyer to make changes to the value later.

as you can see I had to hard code the max value of what I wanted to find (in this case I went up to 28 flags, and at 28 it happens to equal what the hard coded max value is.
the boolean: StorMove(i) is where I store the flag values.

if there is a simpler method please let me know. or if this is how its supposed to be done then please also let me know.
__________________
[Add|Community]

~SgtBane
sgtbane is offline
Send a message via MSN to sgtbane
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode