QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char *name, IPluginFunction *pCallback, Handle_t hndl) { QueryCvarCookie_t cookie = 0; #if SOURCE_ENGINE != SE_DARKMESSIAH /* Call StartQueryCvarValue() in either the IVEngineServer or IServerPluginHelpers depending on situation */ if (m_bIsDLLQueryHooked) { #if SOURCE_ENGINE == SE_DOTA cookie = engine->StartQueryCvarValue(CEntityIndex(IndexOfEdict(pPlayer)), name); #else cookie = engine->StartQueryCvarValue(pPlayer, name); #endif } #if SOURCE_ENGINE != SE_DOTA else if (m_bIsVSPQueryHooked) { cookie = serverpluginhelpers->StartQueryCvarValue(pPlayer, name); } #endif else { return InvalidQueryCvarCookie; } ConVarQuery query = {cookie, pCallback, (cell_t)hndl, IndexOfEdict(pPlayer)}; m_ConVarQueries.push_back(query); #endif return cookie; }
void SoundHooks::OnEmitAmbientSound(CEntityIndex index, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay) { int entindex = index.Get(); #else void SoundHooks::OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay) { #endif SoundHookIter iter; IPluginFunction *pFunc; cell_t vec[3] = {sp_ftoc(pos.x), sp_ftoc(pos.y), sp_ftoc(pos.z)}; cell_t res = static_cast<ResultType>(Pl_Continue); char buffer[PLATFORM_MAX_PATH]; strcpy(buffer, samp); for (iter=m_AmbientFuncs.begin(); iter!=m_AmbientFuncs.end(); iter++) { pFunc = (*iter); pFunc->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); pFunc->PushCellByRef(&entindex); pFunc->PushFloatByRef(&vol); pFunc->PushCellByRef(reinterpret_cast<cell_t *>(&soundlevel)); pFunc->PushCellByRef(&pitch); pFunc->PushArray(vec, 3, SM_PARAM_COPYBACK); pFunc->PushCellByRef(&fFlags); pFunc->PushFloatByRef(&delay); g_InSoundHook = true; pFunc->Execute(&res); g_InSoundHook = false; switch (res) { case Pl_Handled: case Pl_Stop: { RETURN_META(MRES_SUPERCEDE); } case Pl_Changed: { Vector vec2; vec2.x = sp_ctof(vec[0]); vec2.y = sp_ctof(vec[1]); vec2.z = sp_ctof(vec[2]); #if SOURCE_ENGINE == SE_DOTA RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::EmitAmbientSound, (CEntityIndex(entindex), vec2, buffer, vol, soundlevel, fFlags, pitch, delay)); #else RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::EmitAmbientSound, (entindex, vec2, buffer, vol, soundlevel, fFlags, pitch, delay)); #endif } } } }
int CoreProviderImpl::QueryClientConVar(int client, const char *cvar) { #if SOURCE_ENGINE != SE_DARKMESSIAH switch (hooks_.GetClientCvarQueryMode()) { case ClientCvarQueryMode::DLL: # if SOURCE_ENGINE == SE_DOTA return ::engine->StartQueryCvarValue(CEntityIndex(client), cvar); # else return ::engine->StartQueryCvarValue(PEntityOfEntIndex(client), cvar); # endif case ClientCvarQueryMode::VSP: # if SOURCE_ENGINE != SE_DOTA return serverpluginhelpers->StartQueryCvarValue(PEntityOfEntIndex(client), cvar); # endif default: return InvalidQueryCvarCookie; } #endif return -1; }