Skip to content

Commit

Permalink
Hook TraceLine as PRE-FUNCTION
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileYzn committed Jun 29, 2023
1 parent 65641d4 commit 5e1f096
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions AccuracyFix/MetaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,24 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t* pengfuncsFromEngine, int* inte
memset(&gENGINE_FunctionTable_Pre, 0, sizeof(enginefuncs_t));

// Register Functions Here //
gENGINE_FunctionTable_Post.pfnTraceLine = ENGINE_PRE_TraceLine;

memcpy(pengfuncsFromEngine, &gENGINE_FunctionTable_Pre, sizeof(enginefuncs_t));

return 1;
}

void ENGINE_PRE_TraceLine(const float* start, const float* end, int fNoMonsters, edict_t* pentToSkip, TraceResult* ptr)
{
if (gAccuracyFix.TraceLine(start, end, fNoMonsters, pentToSkip, ptr))
{
RETURN_META(MRES_SUPERCEDE);
}
else
{
RETURN_META(MRES_IGNORED);
}
}
#pragma endregion

#pragma region ENGINE_POST
Expand All @@ -25,17 +38,9 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t* pengfuncsFromEngine, int*
memset(&gENGINE_FunctionTable_Post, 0, sizeof(enginefuncs_t));

// Register Functions Here //
gENGINE_FunctionTable_Post.pfnTraceLine = ENGINE_POST_TraceLine;

memcpy(pengfuncsFromEngine, &gENGINE_FunctionTable_Post, sizeof(enginefuncs_t));

return 1;
}

void ENGINE_POST_TraceLine(const float* start, const float* end, int fNoMonsters, edict_t* pentToSkip, TraceResult* ptr)
{
gAccuracyFix.TraceLine(start, end, fNoMonsters, pentToSkip, ptr);

RETURN_META(MRES_IGNORED);
}
#pragma endregion
2 changes: 1 addition & 1 deletion AccuracyFix/MetaEngine.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#pragma region ENGINE_PRE
void ENGINE_PRE_TraceLine(const float* start, const float* end, int fNoMonsters, edict_t* pentToSkip, TraceResult* ptr);
#pragma endregion

#pragma region ENGINE_POST
void ENGINE_POST_TraceLine(const float* start, const float* end, int fNoMonsters, edict_t* pentToSkip, TraceResult* ptr);
#pragma endregion

0 comments on commit 5e1f096

Please sign in to comment.