Time packet

07/23/2018 08:29 teroareboss1#1
Does anyone know what's the problem with time packet on 5017?

[Only registered and activated users can see links. Click Here To Register...]


Code:
public static Packet CreateServerTime(this Packet stream, DateTime Time)
       {
           stream.InitWriter();
           stream.Write(0);//type //int
           stream.Write(Time.Year - 1900);//int
           stream.Write(Time.Month - 1);//int
           stream.Write(Time.DayOfYear);//int
           stream.Write(Time.Day);//int
           stream.Write(Time.Hour);//int
           stream.Write(Time.Minute);//int
           stream.Write(Time.Second);//int
           stream.Finalize((ushort)NetPacketTypes._MSG_ServerTime);
           return stream;
       }
5017 don't accept time packet?
07/23/2018 19:42 Spirited#2
Can you provide a hex dump of the finalized packet? Also, what happens when you explicitly cast those time values to 32-bit integers?
07/28/2018 09:14 Xio.#3
Never got time working on 5017 either. Just posting here to get notified
07/28/2018 19:52 teroareboss1#4
Quote:
Originally Posted by Xio. View Post
Never got time working on 5017 either. Just posting here to get notified
I managed to fix time with a hook. I only posted here maybe someone knew a solution to save some time.
#Closed
07/28/2018 20:08 Spirited#5
Quote:
Originally Posted by teroareboss1 View Post
I managed to fix time with a hook. I only posted here maybe someone knew a solution to save some time.
#Closed
A hook? So you're saying that patch 5017 doesn't support the time packet? Also, that could be a helpful bit of code to post here rather than it dying off with the community. We've lost a lot of collected knowledge from developers just leaving and not documenting anything they've discovered. I could make a client hook snippets section of my wiki if you'd like to contribute.
07/28/2018 20:38 teroareboss1#6
Quote:
Originally Posted by Spirited View Post
A hook? So you're saying that patch 5017 doesn't support the time packet? Also, that could be a helpful bit of code to post here rather than it dying off with the community. We've lost a lot of collected knowledge from developers just leaving and not documenting anything they've discovered. I could make a client hook snippets section of my wiki if you'd like to contribute.
I dont know if is working or not but i remembered that they use sprintf for this string.
07/28/2018 20:44 Spirited#7
Quote:
Originally Posted by teroareboss1 View Post
I dont know if is working or not but i remembered that they use sprintf for this string.
Oh, I see how you did that now. No worries then. If you'd like to share the code, then great, but that one seems simple enough with a hint. Are you sure it doesn't support the time packet though? Do any other 5017 sources implement it maybe?
07/28/2018 21:39 teroareboss1#8
Quote:
Originally Posted by Spirited View Post
Oh, I see how you did that now. No worries then. If you'd like to share the code, then great, but that one seems simple enough with a hint. Are you sure it doesn't support the time packet though? Do any other 5017 sources implement it maybe?
I dont know if "Time packet" is working or not

Code:
char StrFormat[] = { "[%s] (%03d,%03d) Ping: %04d; Fps: %02d; Time: %02d:%02d, %s" };
Code:
int  my_sprintf(char *buffer, char *format, ...)
{
    va_list args;
    va_start(args, format);

    if(!strcmp(StrFormat,format))
    {

        /*char* ServerName = va_arg(args, PCHAR);
        int x = va_arg(args, int);
        int y = va_arg(args, int);

       //TO DO
       */
    }
    return vsprintf(buffer, format, args);
}
hook msvcrt.dll , function-> sprintf

well.... you can compare just first 10 bytes...
07/28/2018 22:22 Spirited#9
Hm. That seems to be a bit of a naive approach, looking for a value rather than a key, but if it works then it works. I looked into other 5017 sources just to be sure that time packet (packet 1033) really isn't implemented anywhere, but I found one that does implement it:

Code:
DateTime Now = DateTime.Now.ToLocalTime();
byte[] buffer = new byte[36];
fixed (byte* Packet = buffer)
{
	*((ushort*)(Packet)) = (ushort)(36);
	*((ushort*)(Packet + 2)) = 1033;
	*((uint*)(Packet + 8)) = (uint)(Now.Year - 1900);
	*((uint*)(Packet + 12)) = (uint)(Now.Month - 1);
	*((uint*)(Packet + 16)) = (uint)Now.DayOfYear;
	*((uint*)(Packet + 20)) = (uint)Now.Day;
	*((uint*)(Packet + 24)) = (uint)Now.Hour;
	*((uint*)(Packet + 28)) = (uint)Now.Minute;
	*((uint*)(Packet + 32)) = (uint)Now.Second;
}
return buffer;
Could be that the source incorrectly assumes the time packet exists on this patch.
07/28/2018 22:48 CptSky#10
As far as I know, the client 5017 doesn't support the time packet.