1. Click here to join our community discord server.

IEngineSound->EmitSound() buffer?

Discussion in 'General Discussion' started by lukemurawski, Apr 14, 2012.

  1. lukemurawski

    lukemurawski Senior Member

    Hey guys,

    I know I'm the only c++ programmer here, but idk where else to go (I'm banned everywhere else lol).

    I could use some help for an extension I am developing. As you know, the Valve Source SDK EmitSound() is virtualized by IEngineSound.
    Code:
    virtual void EmitSound( IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, float flAttenuation, int iFlags = 0, int iPitch = PITCH_NORM, const Vector *pOrigin = NULL, const Vector *pDirection = NULL, CUtlVector< Vector >* pUtlVecOrigins = NULL, bool bUpdatePositions = true, float soundtime = 0.0f, int speakerentity = -1 ) = 0;
    
    I know I could pass a filename through an SM command like so:
    Code:
    char* pSample = NULL; pCtx->LocalToString(pParams[1], &pSample);
    
    However, let's say I have a bit buffer like so, and I fill it with my streaming system:
    Code:
    extern byte* pBufferSnd;
    Luke::getSingleton()->LuKeAudio->FillBuffer(pBufferSnd, &g_paStream, pStreamURL);
    
    Now I create a networkable entity and fill it with my bit buffer data and send it to the clients. So far, so good. Now, how will I playback the networked data?

    Code:
    byte* pSound;
    soundengine->EmitSound( ... ); // does not support buffers
    
    I'm at a bind. Any ideas?
     
  2. lukemurawski

    lukemurawski Senior Member

    Nevermind, I found out that byte buffers can't be networked easily in Source Engine, since Valve server->client data transfer sucks.

    New problem I would like some help with. You know what would be awesome? A PR skill that shields you from boomer vomit once. Basically, you'll still get vomited and turn purple, but your screen won't be blurred green. We have not managed to get this one working because a) PR is written in Pawn and can't detour an external function w/o c++, and b) what function can we detour anyway?

    So I decided to get my lazy ass up and start searching for a detourable function and found several nice ones we can try--

    AbilityVomitIgnored():
    Code:
    002b555d <_Z15ServerClassInitIN15DT_AbilityVomit7ignoredEEiPT_>:
      2b555d:    55                       push   %ebp
      2b555e:    89 e5                    mov    %esp,%ebp
      2b5560:    57                       push   %edi
      2b5561:    56                       push   %esi
      2b5562:    53                       push   %ebx
      2b5563:    83 ec 3c                 sub    $0x3c,%esp
      2b5566:    e8 75 9e ec ff           call   17f3e0 <__i686.get_pc_thunk.bx>
      2b556b:    81 c3 45 a0 b1 00        add    $0xb1a045,%ebx
      2b5571:    8d b3 c4 cb 08 00        lea    0x8cbc4(%ebx),%esi
      2b5577:    80 bb 50 cb 08 00 00     cmpb   $0x0,0x8cb50(%ebx)
      2b557e:    75 18                    jne    2b5598 <_Z15ServerClassInitIN15DT_AbilityVomit7ignoredEEiPT_+0x3b>
      2b5580:    8d bb 50 cb 08 00        lea    0x8cb50(%ebx),%edi
      2b5586:    89 3c 24                 mov    %edi,(%esp)
      2b5589:    e8 be 99 ec ff           call   17ef4c <__cxa_guard_acquire@plt>
      2b558e:    8d b3 c4 cb 08 00        lea    0x8cbc4(%ebx),%esi
      2b5594:    85 c0                    test   %eax,%eax
      2b5596:    75 31                    jne    2b55c9 <_Z15ServerClassInitIN15DT_AbilityVomit7ignoredEEiPT_+0x6c>
    
      ...
    
    StopVomitEffect Ev:
    Code:
    002b6122 <_ZN6CVomit15StopVomitEffectEv>:
      2b6122:    55                       push   %ebp
      2b6123:    89 e5                    mov    %esp,%ebp
      2b6125:    57                       push   %edi
      2b6126:    56                       push   %esi
      2b6127:    53                       push   %ebx
      2b6128:    81 ec 8c 00 00 00        sub    $0x8c,%esp
      2b612e:    e8 ad 92 ec ff           call   17f3e0 <__i686.get_pc_thunk.bx>
      2b6133:    81 c3 7d 94 b1 00        add    $0xb1947d,%ebx
      2b6139:    8b 4d 08                 mov    0x8(%ebp),%ecx
      2b613c:    8b 83 18 f4 ff ff        mov    -0xbe8(%ebx),%eax
      2b6142:    8b 10                    mov    (%eax),%edx
      2b6144:    8b 81 40 04 00 00        mov    0x440(%ecx),%eax
      2b614a:    83 f8 ff                 cmp    $0xffffffff,%eax
      2b614d:    74 18                    je     2b6167 <_ZN6CVomit15StopVomitEffectEv+0x45>
      2b614f:    89 c7                    mov    %eax,%edi
      2b6151:    81 e7 ff 0f 00 00        and    $0xfff,%edi
      2b6157:    c1 e7 04                 shl    $0x4,%edi
      2b615a:    8d 34 3a                 lea    (%edx,%edi,1),%esi
    
      ...
    
    If anyone is good at assembly language, can someone tell me what parameters this function has :P
     
  3. marvel

    marvel Head Administrator Staff Member

    Luke, I know HC tried this before. L4D1 has it in survivor upgrades, where you can get goggles so you can see through boomer vomit. It also has raincoat which blocks the vomit one time. It wasn't portable to l4d2 though.
     
  4. lukemurawski

    lukemurawski Senior Member

    This can't be done with Pawn. HC tried to use SDKTools/Hooks to attach to a signature and then modify it, but that does not work. The function must be completely detoured and blocked with c++. I'll try it out when I get a chance.