mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
misc changes
This commit is contained in:
@@ -94,7 +94,7 @@ void CCore::Load()
|
||||
if (m_bUnload = m_bFailed2 = !U::Hooks.Initialize() || !U::BytePatches.Initialize() || !H::Events.Initialize())
|
||||
return;
|
||||
F::Materials.LoadMaterials();
|
||||
U::ConVars.Initialize();
|
||||
U::ConVars.Unlock();
|
||||
|
||||
F::Configs.LoadConfig(F::Configs.m_sCurrentConfig, false);
|
||||
|
||||
@@ -142,7 +142,7 @@ void CCore::Unload()
|
||||
|
||||
Sleep(250);
|
||||
F::EnginePrediction.Unload();
|
||||
U::ConVars.Unload();
|
||||
U::ConVars.Restore();
|
||||
F::Materials.UnloadMaterials();
|
||||
|
||||
if (m_bFailed2)
|
||||
|
||||
@@ -120,17 +120,9 @@ public:
|
||||
class IMatchGroupDescription
|
||||
{
|
||||
public:
|
||||
inline int GetLevelForIndex(int iIndex)
|
||||
inline int GetLevelForSteamID(CSteamID* pSteamID)
|
||||
{
|
||||
player_info_t tInfo;
|
||||
if (!I::EngineClient->GetPlayerInfo(iIndex, &tInfo) || tInfo.fakeplayer)
|
||||
return -1;
|
||||
|
||||
CSteamID cSteamID = { tInfo.friendsID, 1, k_EUniversePublic, k_EAccountTypeIndividual };
|
||||
if (!cSteamID.IsValid())
|
||||
return -1;
|
||||
|
||||
auto pRating = S::CTFRatingData_YieldingGetPlayerRatingDataBySteamID.Call<CTFRatingData*>(&cSteamID, m_eMatchType == MATCH_TYPE_CASUAL ? m_eCurrentDisplayRating : m_eCurrentDisplayRank);
|
||||
auto pRating = S::CTFRatingData_YieldingGetPlayerRatingDataBySteamID.Call<CTFRatingData*>(pSteamID, m_eMatchType == MATCH_TYPE_CASUAL ? m_eCurrentDisplayRating : m_eCurrentDisplayRank);
|
||||
if (!pRating)
|
||||
return -1;
|
||||
|
||||
@@ -141,6 +133,24 @@ public:
|
||||
return m_pProgressionDesc->GetLevelByNumber(nLevel).m_nLevelNum;
|
||||
}
|
||||
|
||||
inline int GetLevelForAccountID(uint32 uAccountID)
|
||||
{
|
||||
CSteamID tSteamID = { uAccountID, 1, k_EUniversePublic, k_EAccountTypeIndividual };
|
||||
if (!tSteamID.IsValid())
|
||||
return -1;
|
||||
|
||||
return GetLevelForSteamID(&tSteamID);
|
||||
}
|
||||
|
||||
inline int GetLevelForIndex(int iIndex)
|
||||
{
|
||||
player_info_t tInfo;
|
||||
if (!I::EngineClient->GetPlayerInfo(iIndex, &tInfo) || tInfo.fakeplayer)
|
||||
return -1;
|
||||
|
||||
return GetLevelForAccountID(tInfo.friendsID);
|
||||
}
|
||||
|
||||
public:
|
||||
byte pad0[8];
|
||||
const ETFMatchGroup m_eMatchGroup;
|
||||
|
||||
@@ -170,19 +170,25 @@ void CEntities::Store()
|
||||
|
||||
if (auto pLobby = I::TFGCClientSystem->GetLobby())
|
||||
{
|
||||
auto pGameRules = I::TFGameRules();
|
||||
auto pMatchDesc = pGameRules ? pGameRules->GetMatchGroupDescription() : nullptr;
|
||||
|
||||
int iMembers = pLobby->GetNumMembers();
|
||||
for (int i = 0; i < iMembers; i++)
|
||||
{
|
||||
auto cSteamID = CSteamID(); pLobby->GetMember(&cSteamID, i);
|
||||
auto uAccountID = cSteamID.GetAccountID();
|
||||
auto tSteamID = CSteamID(); pLobby->GetMember(&tSteamID, i);
|
||||
auto uAccountID = tSteamID.GetAccountID();
|
||||
|
||||
ConstTFLobbyPlayer pDetails;
|
||||
pLobby->GetMemberDetails(&pDetails, i);
|
||||
|
||||
auto pProto = pDetails.Proto();
|
||||
mF2P[uAccountID] = pProto->chat_suspension;
|
||||
mLevels[uAccountID] = pProto->rank;
|
||||
mParties[uAccountID] = pProto->original_party_id;
|
||||
if (pMatchDesc && pMatchDesc->m_pProgressionDesc)
|
||||
mLevels[uAccountID] = std::max(int(pProto->rank), pMatchDesc->GetLevelForSteamID(&tSteamID));
|
||||
else
|
||||
mLevels[uAccountID] = pProto->rank;
|
||||
}
|
||||
}
|
||||
if (auto pParty = I::TFGCClientSystem->GetParty())
|
||||
|
||||
@@ -2,30 +2,42 @@
|
||||
|
||||
#include "../../SDK/Definitions/Interfaces/ICVar.h"
|
||||
|
||||
void CConVars::Initialize()
|
||||
bool CConVars::Unlock()
|
||||
{
|
||||
ConCommandBase* pCmdBase = I::CVar->GetCommands();
|
||||
while (pCmdBase != nullptr)
|
||||
if (!m_bUnlocked)
|
||||
{
|
||||
mFlagMap[pCmdBase] = pCmdBase->m_nFlags;
|
||||
pCmdBase->m_nFlags &= ~(FCVAR_HIDDEN | FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT | FCVAR_NOT_CONNECTED);
|
||||
pCmdBase = pCmdBase->m_pNext;
|
||||
ConCommandBase* pCmdBase = I::CVar->GetCommands();
|
||||
while (pCmdBase != nullptr)
|
||||
{
|
||||
m_mFlagMap[pCmdBase] = pCmdBase->m_nFlags;
|
||||
pCmdBase->m_nFlags &= ~(FCVAR_HIDDEN | FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT | FCVAR_NOT_CONNECTED);
|
||||
pCmdBase = pCmdBase->m_pNext;
|
||||
}
|
||||
m_bUnlocked = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CConVars::Unload()
|
||||
bool CConVars::Restore()
|
||||
{
|
||||
for (auto& [pCmdBase, nFlags] : mFlagMap)
|
||||
if (m_bUnlocked)
|
||||
{
|
||||
if (pCmdBase)
|
||||
for (auto& [pCmdBase, nFlags] : m_mFlagMap)
|
||||
pCmdBase->m_nFlags = nFlags;
|
||||
m_mFlagMap.clear();
|
||||
m_bUnlocked = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ConVar* CConVars::FindVar(const char* sCVar)
|
||||
{
|
||||
auto uHash = FNV1A::Hash32(sCVar);
|
||||
if (!mCVarMap.contains(uHash))
|
||||
mCVarMap[uHash] = I::CVar->FindVar(sCVar);
|
||||
return mCVarMap[uHash];
|
||||
if (!m_mCVarMap.contains(uHash))
|
||||
m_mCVarMap[uHash] = I::CVar->FindVar(sCVar);
|
||||
return m_mCVarMap[uHash];
|
||||
}
|
||||
@@ -7,14 +7,15 @@
|
||||
class CConVars
|
||||
{
|
||||
private:
|
||||
std::unordered_map<uint32_t, ConVar*> mCVarMap = {};
|
||||
std::unordered_map<ConCommandBase*, int> mFlagMap = {};
|
||||
std::unordered_map<uint32_t, ConVar*> m_mCVarMap = {};
|
||||
std::unordered_map<ConCommandBase*, int> m_mFlagMap = {};
|
||||
|
||||
bool m_bUnlocked = false;
|
||||
|
||||
public:
|
||||
bool Unlock();
|
||||
bool Restore();
|
||||
ConVar* FindVar(const char* sCVar);
|
||||
|
||||
void Initialize();
|
||||
void Unload();
|
||||
};
|
||||
|
||||
ADD_FEATURE_CUSTOM(CConVars, ConVars, U);
|
||||
Reference in New Issue
Block a user