Skip to content

Commit

Permalink
fix offset bug + remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ampreeT authored and ampreeT committed Jun 19, 2024
1 parent 57d1b2d commit 3473d37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 5 additions & 6 deletions scripting/include/srccoop/classdef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2462,14 +2462,13 @@ Address GetSoundPoolPropAddress(CSoundEnt pSoundEnt, const int iSoundIndex, cons
ThrowError("Unable to retrieve offset %s", "m_SoundPool");

// obtain the offset within `CSound`
int iOffset = FindDataMapInfo(pSoundEnt.GetEntIndex(), szProperty);
if (iOffset == -1)
int iOffsetFromStartProperty = FindDataMapInfo(pSoundEnt.GetEntIndex(), szProperty);
if (iOffsetFromStartProperty == -1)
ThrowError("Unable to retrieve offset %s", szProperty);
else
iOffset -= iOffsetPoolStart;

if (iOffset <= 0)
ThrowError("Internal Error: Unable to retrive offset %s", szProperty);
int iOffset = iOffsetFromStartProperty - iOffsetPoolStart;
if (iOffset < 0)
ThrowError("Internal Error: Computed offset %s is negative (%i); %s offset: %i, SoundPool offset: %i", szProperty, iOffset, szProperty, iOffsetFromStartProperty, iOffsetPoolStart);

// this + offsetof(m_SoundPool[iSoundIndex]) + offsetof(property)
return pSoundEnt.GetAddress() + iOffsetPoolStart + iSoundIndex * g_iCSoundSize + iOffset;
Expand Down
2 changes: 0 additions & 2 deletions scripting/include/srccoop/entitypatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,6 @@ public MRESReturn Hook_BaseNpcUpdateSleepState(int _this, Handle hParams)
{
for (int i = 1; i <= MaxClients; ++i)
{
// TODO:
// Should this check for if the player is alive?
CBasePlayer pPlayer = CBasePlayer(i);
if (pPlayer.IsValid() && pPlayer.IsAlive() && !(pPlayer.GetFlags() & FL_NOTARGET) && pPlayer.FVisibleEntity(pBaseNPC))
{
Expand Down

0 comments on commit 3473d37

Please sign in to comment.