Rundimental ingame chat support
Technically, this implements #168. However, it's very ugly, so it needs cleanup.
This commit is contained in:
parent
a4437fb0db
commit
a3769a4489
@ -1,8 +1,10 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
#include "chat.hpp"
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#include "command.hpp"
|
||||
#include "client_command.hpp"
|
||||
@ -41,18 +43,55 @@ namespace chat
|
||||
|
||||
utils::hook::invoke<void>(0x140298E70_g, ent, p.data());
|
||||
}
|
||||
|
||||
void get_chat_client_name_stub(uint64_t xuid, char* buffer, const size_t max_length)
|
||||
{
|
||||
utils::string::copy(buffer, max_length, utils::string::va("%llX-something", xuid));
|
||||
OutputDebugStringA(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public server_component
|
||||
const char* GetClientName(const uint64_t xuid)
|
||||
{
|
||||
if (xuid < 19 && !game::is_server())
|
||||
{
|
||||
char buffer[256];
|
||||
game::CL_GetClientName(0, static_cast<int>(xuid - 1), buffer, sizeof(buffer), true);
|
||||
|
||||
return utils::string::va("%s\n", buffer);
|
||||
}
|
||||
|
||||
return "Unknown Soldier";
|
||||
}
|
||||
|
||||
uint64_t* divert_xuid_to_client_num_stub(int, int client_num, int)
|
||||
{
|
||||
static thread_local uint64_t value;
|
||||
// zero xuid is invalid, so increase the clientnum to prevent 0 values
|
||||
value = static_cast<uint64_t>(client_num) + 1;
|
||||
return &value;
|
||||
}
|
||||
|
||||
class component final : public generic_component
|
||||
{
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
utils::hook::call(game::select(0x141974B04, 0x14029908A), divert_xuid_to_client_num_stub);
|
||||
|
||||
if (game::is_server())
|
||||
{
|
||||
client_command::add("say", cmd_say_f);
|
||||
client_command::add("say_team", cmd_say_f);
|
||||
|
||||
client_command::add("chat", cmd_chat_f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore some check that suppresses the chat
|
||||
utils::hook::nop(0x141DEA9BD_g, 2);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
6
src/client/component/chat.hpp
Normal file
6
src/client/component/chat.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace chat
|
||||
{
|
||||
const char* GetClientName(const uint64_t xuid);
|
||||
}
|
@ -13,6 +13,9 @@ namespace game
|
||||
int numPrivateSlots, const char* mapname, const char* gametype,
|
||||
const char* somethingWithUserMaps)> CL_ConnectFromLobby
|
||||
{0x14134C570};
|
||||
WEAK symbol<bool(int localClientNum, int index, char* buf, int size, bool addClanName)> CL_GetClientName{
|
||||
0x1413E3140
|
||||
};
|
||||
|
||||
// Game
|
||||
WEAK symbol<void(gentity_s* ent, gentity_s* target, int mode, const char* chatText)> G_Say{0x0, 0x140299170};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <utils/nt.hpp>
|
||||
|
||||
#include "component/name.hpp"
|
||||
#include "component/chat.hpp"
|
||||
|
||||
namespace steam
|
||||
{
|
||||
@ -44,7 +45,7 @@ namespace steam
|
||||
|
||||
const char* friends::GetFriendPersonaName(steam_id steamIDFriend)
|
||||
{
|
||||
return "";
|
||||
return chat::GetClientName(steamIDFriend.bits);
|
||||
}
|
||||
|
||||
bool friends::GetFriendGamePlayed(steam_id steamIDFriend, void* pFriendGameInfo)
|
||||
|
Loading…
Reference in New Issue
Block a user