Skip to content

Commit

Permalink
Response challenge request with the correct server version
Browse files Browse the repository at this point in the history
  • Loading branch information
yourmnbbn committed Oct 31, 2022
1 parent 52b9fca commit c993230
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Server
m_ArgParser(parser)

{
m_VersionInt = GetIntVersionFromString(parser.GetOptionValueString("-version"));
}

public:
Expand Down Expand Up @@ -211,7 +212,7 @@ class Server
snprintf(temp, sizeof(temp), "connect0x%X", SERVER_CHALLENGE);
m_WriteBuf.WriteString(temp);

m_WriteBuf.WriteLong(13837);
m_WriteBuf.WriteLong(m_VersionInt);
m_WriteBuf.WriteString(SERVER_PASSWD_NEEDED ? "friends" : "public");
m_WriteBuf.WriteByte(SERVER_PASSWD_NEEDED);
m_WriteBuf.WriteLongLong((uint64)-1); //Lobby id
Expand Down Expand Up @@ -273,6 +274,29 @@ class Server
inline void ResetWriteBuffer() { m_WriteBuf.Reset(); }
inline void ResetReadBuffer() { m_ReadBuf.Seek(0); }

inline uint32_t GetIntVersionFromString(const char* version)
{
char temp[64];
int source_idx = 0;
int dest_idx = 0;

for (; ; ++source_idx)
{
if (version[source_idx] == '.')
continue;

temp[dest_idx++] = version[source_idx];

if (version[source_idx + 1] == 0)
{
temp[dest_idx] = 0;
break;
}
}

return atoi(temp);
}

private:
char m_Buf[10240];
bf_write m_WriteBuf;
Expand All @@ -281,6 +305,8 @@ class Server
ArgParser& m_ArgParser;

uint32_t m_LastReceivedPacketLength;

uint32_t m_VersionInt = 0;
};

#endif // !__TINY_CSGO_SERVER_HPP__

0 comments on commit c993230

Please sign in to comment.