• Welcome to Valhalla Legends Archive.
 

[VB6] D2GS Waypoint Flags

Started by Ringo, December 23, 2005, 07:37 AM

Previous topic - Next topic

Ringo

Iv not been awake long, so try to bear with me :P
Over the last few days iv been tinkering with Open bnet, and iv been slowly working my way through my list of things to add/finished, one of which was the avalible waypoint flags.
Cos blizzard did them on a basic * 2 flagging system, and the number of possible avalible waypoints, they are sent in a TWORD (6 bytes) or maybe a QWORD?.
So far iv worked out all the flags and have been testing them, and they hold true all the way.
Heres what i have at the moment:

    ~~~ Act 1 Waypoints ~~~
Rogue Encampment           = &H1
Cold Plains                = &H2
Stony Fields               = &H4
Dark Wood                  = &H8
Black Marsh                = &H10
Outer Cloister             = &H20
Jail Level 1               = &H40
Inner Cloister             = &H80
CataCombs Level 2          = &H100
    ~~~ Act 2 Waypoints ~~~
Lut Gholein                = &H200
Sewers Level 2             = &H400
Dry Hills                  = &H800
Halls Of The Dead Level 2  = &H1000
Far Oasis                  = &H2000
Lost City                  = &H4000
Palace Cellar Level 1      = &H8000
Arcain Sanctuary           = &H10000
Canyon Of The Magi         = &H20000
    ~~~ Act 3 Waypoints ~~~
Kurast Docks               = &H40000
Spider Forest              = &H80000
Great Marsh                = &H100000
Flayer Jungle              = &H200000
Lower Kurast               = &H400000
Kurast Bazaar              = &H800000
Upper Kurast               = &H1000000
Travincal                  = &H2000000
Durance Of Hate Level 2    = &H4000000
    ~~~ Act 4 Waypoints ~~~
The Pandeminoum Fortress   = &H8000000
City Of The Damned         = &H10000000
River Of Flame             = &H20000000
    ~~~ Act 5 Waypoints ~~~
Harrogath                  = &H40000000
Frigid Highlands           = &H80000000
Arreat Plateau             = &H100000000
Crystalline Passage        = &H200000000
Glacial Trail              = &H400000000
Halls Of Pain              = &H800000000
Frozen Tundra              = &H1000000000
The Ancient's Way          = &H2000000000
Worldstone Keep Level 2    = &H4000000000


It looks somthing like this:
(All towns incuded)

Harrogath:           0x48040201   (&H40000000)    01 02 04 48 00 00
Frigid Highlands:    0xC8040201   (&H80000000)    01 02 04 C8 00 00
Arreat Plateau:      0x148040201  (&H100000000)    01 02 04 48 01 00
Crystalline Passage: 0x248040201  (&H200000000)    01 02 04 48 02 00
Glacial Trail:       0x448040201  (&H400000000)    01 02 04 48 04 00
Halls Of Pain:       0x848040201  (&H800000000)    01 02 04 48 08 00
Frozen Tundra:       0x1048040201 (&H1000000000)    01 02 04 48 10 00
The Ancient's Way:   0x2048040201 (&H2000000000)    01 02 04 48 20 00
WS Keep Level 2:     0x4048040201 (&H4000000000)    01 02 04 48 40 00

And for a player with all the waypoints avalible, the flag is: 0x007FFFFFFFFF
Can anyone think of a good data type to handle this?
Im corrently thinking CCur("&H" & StrToHex(Strreverse(Data))) cos copy memory doesnt seem to be liking it.

Ideas?

[EDIT]: OK, im stupid, iv woke up now, CDbl("&H" & "7FFFFFFFFF") works like a charm.

[REEDIT]: The moto this this topic is, dont start programing untill you have had your weetabix :P

Joe[x86]

According to LoRd[nK], the closest data type to a QWORD, in Visual Basic, is Currency.

If I know how CopyMemory works, which I daresay not, you can do something like this.

Public Type udtQWORD
  dwLO as Long
  dwHI as Long
End Type

Public Function MakeQWORD(QWORD as udtQWORD) As String
    Dim Ret as String * 8
    CopyMemory udtQWORD, Ret, 8 '// udtQWORD should be displayed in memory as DWORD|DWORD
End Function
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Ringo

Hm i didnt think to try that.
I knocked these up for a quick solution and they worked great :)
Cos i dont hardly ever need to use them, it kinda makes up for the ewwyness :)
Merry xmas btw

Public Function GetTWORD(ByVal Data6 As String) As Double
    If Data6 = "" Then Exit Function
    GetTWORD = CDbl("&H" & StrToHex(StrReverse(Left(Data6, 6)), ""))
End Function

Public Function GetQWORD(ByVal Data8 As String) As Currency
    If Data8 = "" Then Exit Function
    GetQWORD = CCur("&H" & StrToHex(StrReverse(Left(Data8, 8)), ""))
End Function

Joe[x86]

Public Type udtTWORD
  w1 as Integer
  w2 as Integer
  w3 as Integer
End Type

Public Type udtQWORD
  dw1 as Long
  dw2 as Long
End Type

Public Function QWORD_TOSTRING(QWORD as udtQWORD) As String
  QWORD_TOSTRING = MakeDWORD(QWORD.dw1) & MakeDWORD(QWORD.dw2)
End Sub

Public Function QWORD_FROMSTRING(sData as String) As udtQWORD
  Dim Ret as udtQWORD
  Ret.dw1 = GetDWORD(Mid(sData, 1, 4))
  Ret.dw2 = GetDWORD(Mid(sData, 5, 4))
  QWORD_FROMSTRING = Ret
End Function


I'd write the TWORD functions too, but I'm passing out at the keyboard. Good night, morning, heck, afternoon. I'm going to bed!
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Trejo

The GetMem8 function of MSVBVM60.dll is a much more cleaner version of what Ringo's GetQWORD and Joe's QWORD_FROMSTRING do.  Just for your convenience, I have included the prototype for the function call below.


Declare Sub GetQWord Lib "MSVBVM60.dll" Alias "GetMem8" (ByRef inSrc As Any, ByRef inDst As Currency)


The second parameter can be changed to Any incase you would like to copy the data into a user-defined type.  This can be changed without any issues assuming you call the function correctly, hope this helps.

Ringo

#5
Awsome, thanks!

[EDIT]: I dont think that function is ment for this kinda thing :(

    Dim D As Currency
    Dim E As String
    E = Chr(&HFF) & Chr(&HFF) & _
        Chr(&HFF) & Chr(&HFF) & _
        Chr(&H7F) & Chr(0) & _
        Chr(0) & Chr(0)
    Call GetQWORD(E, D)

D returns a differnt number every time.
Any ideas?

Trejo

#6
No, this function is perfectally fine for this.  Remember that the first value needs to be passed by value.  With a Currency data type, it'll return 54975581.3887 into the variable.  Although, 0x7fffffffff is 549755813887, that's the only way you can copy it unless you're using a user-defined type with two long members.

MyndFyre

I don't think Currency is the right type for this.  You'd be better off just reading two 32-bit integers.  Currency is floating-point, which is not appropriate for bitfields.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.