Valhalla Legends Forums Archive | Battle.net Bot Development References | Battle.net /time Command Discussion

AuthorMessageTime
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.
August 30, 2003, 12:30 AM
Soul Taker
Check 0x50 format, and send the correct timezone bias.
August 30, 2003, 12:50 AM
UserLoser
[quote author=Soul Taker link=board=17;threadid=2504;start=0#msg19477 date=1062204601]
Check 0x50 format, and send the correct timezone bias.
[/quote]
Isn't it the value of Timezone bias + daylight bias?
August 30, 2003, 4:19 AM
FuZe
This is what I use and it *seems to work
[code]

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
[/code]
August 30, 2003, 5:13 AM
DarkMinion
[code]
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);
}
[/code]
August 30, 2003, 5:52 AM
kamakazie
[quote author=FuZe- link=board=17;threadid=2504;start=0#msg19508 date=1062220408]
This is what I use and it *seems to work
[code]

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

...
[/code]
[/quote]

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.

[code]
' 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
[/code]
August 30, 2003, 7:09 AM
Adron
[quote author=kamakazie link=board=17;threadid=2504;start=0#msg19511 date=1062227355]
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.
[/quote]

That's a stupid thing! Is that noted anywhere in the documentation or do you have to notice it yourself?
August 30, 2003, 11:06 AM
kamakazie
[quote author=Adron link=board=17;threadid=2504;start=0#msg19516 date=1062241565]
That's a stupid thing! Is that noted anywhere in the documentation or do you have to notice it yourself?
[/quote]

I noticed that myself. I don't believe it says anything about that in the documentation.
August 30, 2003, 6:32 PM

Search