Skip to content

Commit

Permalink
Added some more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkHC committed Mar 18, 2016
1 parent 8359528 commit 196ed54
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CSGOSimple/EntityESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ void EntityESP::RenderESP(DrawManager& renderer) {

if(!pLocal) return;

//Checks if its an enemy
auto bIsEnemy = pLocal->GetTeamNum() != m_pEntity->GetTeamNum();

auto allyColor = Options::g_bESPAllyColor;
auto enemyColor = Options::g_bESPEnemyColor;

//Get the appropriate drawing color
auto d3dColor = bIsEnemy ?
D3DCOLOR_RGBA(int(enemyColor[0] * 255.0f), int(enemyColor[1] * 255.0f), int(enemyColor[2] * 255.0f), int(enemyColor[3] * 255.0f)) :
D3DCOLOR_RGBA(int(allyColor[0] * 255.0f), int(allyColor[1] * 255.0f), int(allyColor[2] * 255.0f), int(allyColor[3] * 255.0f));

auto vOrigin = m_pEntity->GetOrigin();
auto vHead = Utils::GetEntityBone(m_pEntity, ECSPlayerBones::head_0);

//Offset the head a bit, so the box looks nicer
vHead.z += 15.0f;

Vector vScreenOrigin, vScreenHead;
Expand All @@ -48,17 +51,20 @@ void EntityESP::RenderName(DrawManager& renderer) {

if(!pLocal) return;

//Checks if its an enemy
auto bIsEnemy = pLocal->GetTeamNum() != m_pEntity->GetTeamNum();

auto allyColor = Options::g_bESPAllyColor;
auto enemyColor = Options::g_bESPEnemyColor;

//Get the appropriate drawing color
auto d3dColor = bIsEnemy ?
D3DCOLOR_RGBA(int(enemyColor[0] * 255.0f), int(enemyColor[1] * 255.0f), int(enemyColor[2] * 255.0f), int(enemyColor[3] * 255.0f)) :
D3DCOLOR_RGBA(int(allyColor[0] * 255.0f), int(allyColor[1] * 255.0f), int(allyColor[2] * 255.0f), int(allyColor[3] * 255.0f));

auto vHead = Utils::GetEntityBone(m_pEntity, ECSPlayerBones::head_0);

//Offset the head a bit
vHead.z += 15.0f;

Vector vScreenHead;
Expand Down
25 changes: 20 additions & 5 deletions CSGOSimple/NetvarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ void NetvarManager::CreateDatabase() {
auto pClientDll = SourceEngine::Interfaces::Client();
if(pClientDll) {
m_TableList.clear();
//Iterate over the class list
for(auto pClientClass = pClientDll->GetAllClasses(); pClientClass; pClientClass = pClientClass->m_pNext) {
if(pClientClass->m_pRecvTable) {
//If the class has a RecvTable, load it
Load_Internal(pClientClass->m_pRecvTable);
m_tableCount++;
}
Expand All @@ -31,7 +33,9 @@ void NetvarManager::DestroyDatabase() {
void NetvarManager::LoadClass(const std::string& szClass) {
auto pClientDll = SourceEngine::Interfaces::Client();
if(pClientDll) {
//Iterate over the class list
for(auto pClientClass = pClientDll->GetAllClasses(); pClientClass; pClientClass = pClientClass->m_pNext) {
//If the class name matches and it hasnt been loaded, load it
if(pClientClass->m_pRecvTable && (szClass == pClientClass->m_pNetworkName || szClass == pClientClass->m_pRecvTable->m_pNetTableName)) {
if(!HasBeenLoaded(pClientClass->m_pRecvTable->m_pNetTableName)) {
Load_Internal(pClientClass->m_pRecvTable);
Expand Down Expand Up @@ -160,21 +164,32 @@ void NetvarManager::Load_Internal(SourceEngine::RecvTable* pTable) {
DataTable table;
table.m_iTableOffset = 0;

//Parse all the props on this table
for(int i = 0; i < pTable->m_nProps; i++) {
SourceEngine::RecvProp* pProp = &pTable->m_pProps[i];

//Skip trash array items
if(!pProp || isdigit(pProp->m_pVarName[0])) continue;
//We dont care about the base class
if(strcmp(pProp->m_pVarName, "baseclass") == 0) continue;

if(pProp->m_RecvType == SourceEngine::SendPropType::DPT_DataTable &&
pProp->m_pDataTable != NULL &&
pProp->m_pDataTable->m_pNetTableName[0] == 'D') {
table.m_ChildTables.insert(std::make_pair(pProp->m_pVarName, GetNestedTable(pProp->m_pDataTable, pProp->m_Offset)));
} else {

//If this prop is a table
if(pProp->m_RecvType == SourceEngine::SendPropType::DPT_DataTable && //If it is a table AND
pProp->m_pDataTable != NULL && //The DataTable isnt null AND
pProp->m_pDataTable->m_pNetTableName[0] == 'D') { //The Table name starts with D (this is because there are some shitty nested
//tables that we want to skip, and those dont start with D)

//Load it into the children list of this table
table.m_ChildTables.insert(std::make_pair(pProp->m_pVarName, GetNestedTable(pProp->m_pDataTable, pProp->m_Offset)));

} else { //Its not a table, its a regular prop
//Append it to the prop list of this table
table.m_ChildProps.insert(std::make_pair(pProp->m_pVarName, pProp));
}
m_netvarCount++;
}
//Append this table to the main table list
m_TableList.insert(std::make_pair(pTable->m_pNetTableName, table));
}

Expand Down

0 comments on commit 196ed54

Please sign in to comment.