• Welcome to Valhalla Legends Archive.
 

Battle.net /time Command Discussion

Started by Pr0pHeT, August 29, 2003, 07:30 PM

Previous topic - Next topic

Pr0pHeT

When I connect my binary bot to Battle.net and send /time, it usually returns a time 5 hours behind my actual current time. How does the /time work and how do I fix this?

On actual Blizzard clients, I get the correct time when I send /time.

Soul Taker

Check 0x50 format, and send the correct timezone bias.

UserLoser

Quote from: Soul Taker on August 29, 2003, 07:50 PM
Check 0x50 format, and send the correct timezone bias.
Isn't it the value of Timezone bias + daylight bias?

FuZe

This is what I use and it *seems to work


Public Declare Function GetTimeZoneInformation Lib "kernel32.dll" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Public Const TIME_ZONE_ID_UNKNOWN = 0
Public Const TIME_ZONE_ID_STANDARD = 1
Public Const TIME_ZONE_ID_DAYLIGHT = 2





Public Function GetTZInfo() As Long
Dim TZinfo As TIME_ZONE_INFORMATION
Dim lngL As Long
lngL = GetTimeZoneInformation(TZinfo)

Select Case lngL
   Case TIME_ZONE_ID_STANDARD
       GetTZInfo = (TZinfo.Bias + TZinfo.StandardBias) * -1
   Case TIME_ZONE_ID_DAYLIGHT
       GetTZInfo = (TZinfo.Bias + TZinfo.DaylightBias) * -1
   Case TIME_ZONE_ID_UNKNOWN
       Debug.Print "Bias unknown. Setting to standard."
       GetTZInfo = TZinfo.Bias * -1
   Case Else
       MsgBox "Error with GetTimeZoneInformation. Setting Time Zone to 0."
       GetTZInfo = 0
End Select

End Function


DarkMinion


void SendAuthInfo(unsigned long dwGame, unsigned char uVersion)
{
   dBuf.add((int)0); //protocol
   dBuf.add((int)'IX86'); //platform
   dBuf.add(dwGame); //game
   dBuf.add((int)uVersion); //game version byte
   dBuf.add((int)0);
   struct sockaddr_in sLocalAddr;
   int iLocalLen = sizeof(sLocalAddr);
   getsockname(sBNET, (struct sockaddr *)&sLocalAddr, &iLocalLen);
   dBuf.add((int)sLocalAddr.sin_addr.s_addr); //dword ip
   TIME_ZONE_INFORMATION Tzi;
   unsigned long dwResult = GetTimeZoneInformation(&Tzi);
   dBuf.add(Tzi.Bias + (dwResult == TIME_ZONE_ID_DAYLIGHT ? Tzi.DaylightBias : 0)); //time zone
   dBuf.add((int)GetUserDefaultLCID()); //language
   dBuf.add((int)GetUserDefaultLangID());
   char szBuffer[0x41];
   GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, szBuffer, 0x40);
   dBuf.add(szBuffer);
   GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGCOUNTRY, szBuffer, 0x40);
   dBuf.add(szBuffer);
   SendPacket(SID_AUTH_INFO);
}

dxoigmn

Quote from: FuZe- on August 30, 2003, 12:13 AM
This is what I use and it *seems to work


Public Declare Function GetTimeZoneInformation Lib "kernel32.dll" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Public Const TIME_ZONE_ID_UNKNOWN = 0
Public Const TIME_ZONE_ID_STANDARD = 1
Public Const TIME_ZONE_ID_DAYLIGHT = 2

...


How do you declare TIME_ZONE_INFORMATION and do you set Option Base 1?

There is a problem in the API Text Viewer.  It seems that Microsoft just simply converted arrays without paying attention to the dimensions.  And since VB array declarations are different than C declarations, one will run into problems.


'  This is how it's declared in API Text Viewer
Type TIME_ZONE_INFORMATION
       Bias As Long
       StandardName(32) As Integer
       StandardDate As SYSTEMTIME
       StandardBias As Long
       DaylightName(32) As Integer
       DaylightDate As SYSTEMTIME
       DaylightBias As Long
End Type

' This is the fixed version if you DON'T use Option Base 1
' All I did was subtract 1 from the array dimensions
Type TIME_ZONE_INFORMATION
       Bias As Long
       StandardName(31) As Integer
       StandardDate As SYSTEMTIME
       StandardBias As Long
       DaylightName(31) As Integer
       DaylightDate As SYSTEMTIME
       DaylightBias As Long
End Type

Adron

Quote from: kamakazie on August 30, 2003, 02:09 AM
There is a problem in the API Text Viewer.  It seems that Microsoft just simply converted arrays without paying attention to the dimensions.  And since VB array declarations are different than C declarations, one will run into problems.

That's a stupid thing! Is that noted anywhere in the documentation or do you have to notice it yourself?

dxoigmn

Quote from: Adron on August 30, 2003, 06:06 AM
That's a stupid thing! Is that noted anywhere in the documentation or do you have to notice it yourself?

I noticed that myself.  I don't believe it says anything about that in the documentation.