Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: steamid cond #199

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Features/ConfigPlus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ struct Condition {
SVAR,
CVAR,
STRING,
LINUX
LINUX,
STEAMID
} type;

union {
Expand Down Expand Up @@ -377,6 +378,7 @@ static void FreeCondition(Condition *c) {
FreeCondition(c->binop_l);
FreeCondition(c->binop_r);
break;
case Condition::STEAMID:
NeKzor marked this conversation as resolved.
Show resolved Hide resolved
default:
break;
}
Expand Down Expand Up @@ -418,6 +420,7 @@ static bool EvalCondition(Condition *c) {
#else
return true;
#endif
case Condition::STEAMID: return engine->IsCoop() ? !strcmp(c->val, engine->GetPartnerSteamID32().c_str()) : false;
}
return false;
}
Expand Down Expand Up @@ -568,6 +571,7 @@ static Condition *ParseCondition(std::queue<Token> toks) {
c->type = Condition::LINUX;
} else if (
t.len == 3 && !strncmp(t.str, "map", t.len) ||
t.len == 7 && !strncmp(t.str, "steamid", t.len) ||
t.len == 8 && !strncmp(t.str, "prev_map", t.len) ||
t.len == 4 && !strncmp(t.str, "game", t.len) ||
t.len > 4 && !strncmp(t.str, "var:", 4) ||
Expand Down Expand Up @@ -611,7 +615,7 @@ static Condition *ParseCondition(std::queue<Token> toks) {
strncpy(c->var, t.str + 1, t.len - 1);
c->var[t.len - 1] = 0; // Null terminator
} else {
c->type = t.len == 8 ? Condition::PREV_MAP : t.len == 4 ? Condition::GAME : Condition::MAP;
c->type = t.len == 8 ? Condition::PREV_MAP : t.len == 4 ? Condition::GAME : t.len == 7 ? Condition::STEAMID : Condition::MAP;
}

if (val_tok.len > 4 && !strncmp(val_tok.str, "var:", 4) || val_tok.len > 1 && val_tok.str[0] == '?') {
Expand Down
17 changes: 17 additions & 0 deletions src/Modules/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,22 @@ Color Engine::GetLightAtPoint(Vector point) {
return Color{(uint8_t)(light.x * 255), (uint8_t)(light.y * 255), (uint8_t)(light.z * 255), 255};
}

bool Engine::GetPlayerInfo(int ent_num, player_info_t* pInfo)
{
return this->GetInfo(this->engineClient->ThisPtr(), ent_num, pInfo);
}

std::string Engine::GetPartnerSteamID32() {
player_info_t pInfo;

if (IsOrange()) {
GetPlayerInfo(1, &pInfo);
} else {
GetPlayerInfo(2, &pInfo);
}
return std::to_string(pInfo.friendsID);
}

static _CommandCompletionCallback playdemo_orig_completion;
DECL_COMMAND_FILE_COMPLETION(playdemo, ".dem", engine->GetGameDirectory(), 1)

Expand All @@ -830,6 +846,7 @@ bool Engine::Init() {
this->Con_IsVisible = this->engineClient->Original<_Con_IsVisible>(Offsets::Con_IsVisible);
this->GetLevelNameShort = this->engineClient->Original<_GetLevelNameShort>(Offsets::GetLevelNameShort);
this->GetLightForPoint = this->engineClient->Original<_GetLightForPoint>(Offsets::GetLightForPoint);
this->GetInfo = this->engineClient->Original<_GetPlayerInfo>(Offsets::GetPlayerInfo);

#ifndef _WIN32
this->engineClient->Hook(Engine::GetMouseDelta_Hook, Engine::GetMouseDelta, Offsets::GetMouseDelta);
Expand Down
4 changes: 4 additions & 0 deletions src/Modules/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Engine : public Module {
using _ScreenPosition = int(__rescall *)(void *thisptr, const Vector &point, Vector &screen);
using _ConPrintEvent = int(__rescall *)(void *thisptr, IGameEvent *ev);
using _PrecacheModel = int(__rescall *)(void *thisptr, const char *, bool);
using _GetPlayerInfo = bool(__rescall *)(void* thisptr, int, player_info_t*);
#ifdef _WIN32
// See comment in OverlayRender::startShading
using _GetLightForPoint = void (__rescall *)(void *thisptr, Vector &out, const Vector &pos, bool clamp);
Expand Down Expand Up @@ -97,6 +98,7 @@ class Engine : public Module {
_GetLevelNameShort GetLevelNameShort = nullptr;
_CreateDebugMesh CreateDebugMesh = nullptr;
_DestroyDebugMesh DestroyDebugMesh = nullptr;
_GetPlayerInfo GetInfo = nullptr;

EngineDemoPlayer *demoplayer = nullptr;
EngineDemoRecorder *demorecorder = nullptr;
Expand Down Expand Up @@ -156,6 +158,8 @@ class Engine : public Module {
void SetSkipping(bool skipping);
bool IsSkipping();
Color GetLightAtPoint(Vector point);
bool GetPlayerInfo(int ent_num, player_info_t *pInfo);
std::string GetPartnerSteamID32();

// CClientState::Disconnect
DECL_DETOUR(Disconnect, bool bShowMainMenu);
Expand Down
3 changes: 2 additions & 1 deletion src/OffsetsData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ OFFSET_DEFAULT(GetSaveDirName, 124, 124)
OFFSET_DEFAULT(ExecuteClientCmd, 104, 104)
OFFSET_DEFAULT(GetActiveSplitScreenPlayerSlot, 127, 127)
OFFSET_DEFAULT(GetSteamAPIContext, 177, 178)
OFFSET_DEFAULT(GetMouseDelta, -1, 161) // This method only exists on Linux
OFFSET_DEFAULT(GetMouseDelta, -1, 161) // This method only exists on Linux
NeKzor marked this conversation as resolved.
Show resolved Hide resolved
OFFSET_DEFAULT(IsPaused, 86, 86)
OFFSET_DEFAULT(DebugDrawPhysCollide, 75, 75)
OFFSET_DEFAULT(Con_IsVisible, 11, 11)
OFFSET_DEFAULT(GetLevelNameShort, 53, 53)
OFFSET_DEFAULT(GetLightForPoint, 1, 1)
OFFSET_DEFAULT(GetPlayerInfo, 8, 8);

// CHLClient
OFFSET_DEFAULT(GetAllClasses, 8, 8)
Expand Down
4 changes: 2 additions & 2 deletions src/SourceAutoRecord.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ProjectGuid>{3F6459A9-566E-4CAC-A412-C03FF51D67E9}</ProjectGuid>
<RootNamespace>SourceAutoRecord</RootNamespace>
<ProjectName>SourceAutoRecord</ProjectName>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
NeKzor marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -495,4 +495,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
24 changes: 24 additions & 0 deletions src/Utils/SDK/Other.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,27 @@ class CPlayerState {
void *m_hTonemapController;
QAngle v_angle;
};

typedef struct player_info_s
{
// network xuid
uint64_t xuid;
// scoreboard information
char name[32];
// local server user ID, unique while server is running
int userID;
// global unique player identifer
char guid[32 + 1];
// friends identification number
uint32_t friendsID;
// friends name
char friendsName[32];
// true, if player is a bot controlled by game.dll
bool fakeplayer;
// true if player is the HLTV proxy
bool ishltv;
// custom files CRC for this player
CRC32_t customFiles[4];
// this counter increases each time the server downloaded a new file
unsigned char filesDownloaded;
} player_info_t;