Some serverlist fixes.
This commit is contained in:
parent
4bc3ec10b1
commit
4ebf3849ab
@ -45,25 +45,16 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
char* Colors::CL_GetClientName(int a1, int a2, char* buffer, size_t _length)
|
||||
char* Colors::GetClientName(int localClientNum, int index, char *buf, size_t size)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push _length
|
||||
push buffer
|
||||
push a2
|
||||
push a1
|
||||
mov eax, 4563D0h
|
||||
call eax
|
||||
add esp, 10h
|
||||
}
|
||||
Game::CL_GetClientName(localClientNum, index, buf, size);
|
||||
|
||||
// Remove the colors
|
||||
char tempBuffer[100] = { 0 };
|
||||
Colors::Strip(buffer, tempBuffer, _length);
|
||||
strncpy(buffer, tempBuffer, _length);
|
||||
Colors::Strip(buf, tempBuffer, size);
|
||||
strncpy(buf, tempBuffer, size);
|
||||
|
||||
return buffer;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void Colors::UpdateColorTable()
|
||||
@ -103,7 +94,7 @@ namespace Components
|
||||
Utils::Hook(0x5D8B40, Colors::ClientUserinfoChanged, HOOK_JUMP).Install()->Quick();
|
||||
|
||||
// Though, don't apply that to overhead names.
|
||||
Utils::Hook(0x581932, Colors::CL_GetClientName, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x581932, Colors::GetClientName, HOOK_CALL).Install()->Quick();
|
||||
|
||||
// Set frame handler
|
||||
Renderer::OnFrame(Colors::UpdateColorTable);
|
||||
|
@ -8,10 +8,11 @@ namespace Components
|
||||
Colors();
|
||||
const char* GetName() { return "Colors"; };
|
||||
|
||||
private:
|
||||
static Dvar::Var NewColors;
|
||||
|
||||
static void ClientUserinfoChanged(int length);
|
||||
static char* CL_GetClientName(int a1, int a2, char* buffer, size_t _length);
|
||||
static char* GetClientName(int localClientNum, int index, char *buf, size_t size);
|
||||
|
||||
static void UpdateColorTable();
|
||||
|
||||
|
@ -157,14 +157,21 @@ namespace Components
|
||||
info.Set("challenge", data.substr(0, data.find_first_of("\n")).data());
|
||||
info.Set("gamename", "IW4");
|
||||
info.Set("hostname", Dvar::Var("sv_hostname").Get<const char*>());
|
||||
info.Set("mapname", Dvar::Var("mapname").Get<const char*>());
|
||||
info.Set("gametype", Dvar::Var("g_gametype").Get<const char*>());
|
||||
info.Set("fs_game", Dvar::Var("fs_game").Get<const char*>());
|
||||
info.Set("xuid", Utils::VA("%llX", Steam::SteamUser()->GetSteamID().Bits));
|
||||
info.Set("clients", Utils::VA("%i", clientCount));
|
||||
info.Set("sv_maxclients", Utils::VA("%i", maxclientCount));
|
||||
info.Set("protocol", Utils::VA("%i", PROTOCOL));
|
||||
info.Set("shortversion", VERSION_STR);
|
||||
info.Set("checksum", Utils::VA("%d", Game::Com_Milliseconds()));
|
||||
info.Set("mapname", Dvar::Var("mapname").Get<const char*>());
|
||||
|
||||
// Ensure mapname is set
|
||||
if (!info.Get("mapname").size())
|
||||
{
|
||||
info.Set("mapname", Dvar::Var("ui_mapname").Get<const char*>());
|
||||
}
|
||||
|
||||
// Set matchtype
|
||||
// 0 - No match, connecting not possible
|
||||
|
@ -106,11 +106,14 @@ namespace Components
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Implement deeper check like version and game
|
||||
// Remove server from queue
|
||||
ServerList::RefreshContainer.Servers.erase(i);
|
||||
|
||||
ServerInfo server;
|
||||
server.Hostname = info.Get("hostname");
|
||||
server.Mapname = info.Get("mapname");
|
||||
server.Gametype = info.Get("gametype");
|
||||
server.Shortversion = info.Get("shortversion");
|
||||
server.Mod = info.Get("fs_game");
|
||||
server.MatchType = atoi(info.Get("matchtype").data());
|
||||
server.Clients = atoi(info.Get("clients").data());
|
||||
@ -129,13 +132,11 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
if (server.MatchType)
|
||||
if (info.Get("gamename") == "IW4" && server.MatchType && server.Shortversion == VERSION_STR)
|
||||
{
|
||||
ServerList::OnlineList.push_back(server);
|
||||
}
|
||||
|
||||
ServerList::RefreshContainer.Servers.erase(i);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace Components
|
||||
std::string Mapname;
|
||||
std::string Gametype;
|
||||
std::string Mod;
|
||||
std::string Shortversion;
|
||||
int Clients;
|
||||
int MaxClients;
|
||||
bool Password;
|
||||
|
@ -4,6 +4,7 @@ namespace Game
|
||||
{
|
||||
Cbuf_AddText_t Cbuf_AddText = (Cbuf_AddText_t)0x404B20;
|
||||
|
||||
CL_GetClientName_t CL_GetClientName = (CL_GetClientName_t)0x4563D0;
|
||||
CL_IsCgameInitialized_t CL_IsCgameInitialized = (CL_IsCgameInitialized_t)0x43EB20;
|
||||
CL_ConnectFromParty_t CL_ConnectFromParty = (CL_ConnectFromParty_t)0x433D30;
|
||||
|
||||
|
@ -3,6 +3,9 @@ namespace Game
|
||||
typedef void(__cdecl * Cbuf_AddText_t)(int a1, const char* cmd);
|
||||
extern Cbuf_AddText_t Cbuf_AddText;
|
||||
|
||||
typedef char*(__cdecl * CL_GetClientName_t)(int localClientNum, int index, char *buf, size_t size);
|
||||
extern CL_GetClientName_t CL_GetClientName;
|
||||
|
||||
typedef int(__cdecl * CL_IsCgameInitialized_t)();
|
||||
extern CL_IsCgameInitialized_t CL_IsCgameInitialized;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user