bool	ManiSMMHooks::SetClientListening(int iReceiver, int iSender, bool bListen)
{
	bool new_listen = false;

	if ( iSender == iReceiver )
		RETURN_META_VALUE ( MRES_IGNORED, bListen );

	if (ProcessMuteTalk(iReceiver, iSender, &new_listen))
		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, new_listen));

	if (ProcessDeadAllTalk(iReceiver, iSender, &new_listen))
		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, new_listen));

	RETURN_META_VALUE(MRES_IGNORED, bListen );
}
bool ManiSMMHooks::LevelInit(const char *pMapName, const char *pMapEntities, const char *pOldLevel, const char *pLandmarkName, bool loadGame, bool background)
{
	if (!gpManiGameType->IsSpawnPointHookAllowed())
	{
		RETURN_META_VALUE(MRES_IGNORED, true);
	}

	// Do the spawnpoints hook control if on SourceMM
	// Copy the map entities
	if (!gpManiSpawnPoints->AddSpawnPoints(&pReplaceEnts, pMapEntities))
	{
		RETURN_META_VALUE(MRES_IGNORED, true);
	}

	RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, true, &IServerGameDLL::LevelInit, (pMapName, pReplaceEnts, pOldLevel, pLandmarkName, loadGame, background));
}
bool CSourceMMMAP::LevelInit(const char *pMapName, const char *pMapEntities, const char *pOldLevel, const char *pLandmarkName, bool loadGame, bool background)
{
//	META_LOG(g_PLAPI, "LevelInit() called: pMapName=%s", pMapName); 
	gpManiAdminPlugin->LevelInit(pMapName);

	if (!gpManiGameType->IsSpawnPointHookAllowed())
	{
		RETURN_META_VALUE(MRES_IGNORED, true);
	}

	// Do the spawnpoints hook control if on SourceMM
	// Copy the map entities
	if (!gpManiSpawnPoints->AddSpawnPoints(&pReplaceEnts, pMapEntities))
	{
		RETURN_META_VALUE(MRES_IGNORED, true);
	}

	RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, true, &IServerGameDLL::LevelInit, (pMapName, pReplaceEnts, pOldLevel, pLandmarkName, loadGame, background));
}
Ejemplo n.º 4
0
void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample, 
							 float flVolume, float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin, 
							 const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions, 
							 float soundtime, int speakerentity)
#endif
{
	SoundHookIter iter;
	IPluginFunction *pFunc;
	cell_t res = static_cast<ResultType>(Pl_Continue);
	cell_t sndlevel = static_cast<cell_t>(ATTN_TO_SNDLVL(flAttenuation));
	char buffer[PLATFORM_MAX_PATH];
	strcpy(buffer, pSample);

	char soundEntry[PLATFORM_MAX_PATH] = "";
#if SOURCE_ENGINE >= SE_PORTAL2
	Q_strncpy(soundEntry, pSoundEntry, sizeof(soundEntry));
#endif

#if SOURCE_ENGINE < SE_PORTAL2
	int nSeed = 0;
#endif

	for (iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++)
	{
		int players[SM_MAXPLAYERS], size;
		size = _FillInPlayers(players, &filter);
		pFunc = (*iter);

		pFunc->PushArray(players, SM_ARRAYSIZE(players), SM_PARAM_COPYBACK);
		pFunc->PushCellByRef(&size);
		pFunc->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
		pFunc->PushCellByRef(&iEntIndex);
		pFunc->PushCellByRef(&iChannel);
		pFunc->PushFloatByRef(&flVolume);
		pFunc->PushCellByRef(&sndlevel);
		pFunc->PushCellByRef(&iPitch);
		pFunc->PushCellByRef(&iFlags);
		pFunc->PushStringEx(soundEntry, sizeof(soundEntry), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
		pFunc->PushCellByRef(&nSeed);
		g_InSoundHook = true;
		pFunc->Execute(&res);
		g_InSoundHook = false;

		switch (res)
		{
		case Pl_Handled:
		case Pl_Stop:
			{
#if SOURCE_ENGINE >= SE_PORTAL2
				RETURN_META_VALUE(MRES_SUPERCEDE, -1);
#else
				RETURN_META(MRES_SUPERCEDE);
#endif
			}
		case Pl_Changed:
			{
				/* Client validation */
				for (int i = 0; i < size; i++)
				{
					int client = players[i];
					IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);

					if (!pPlayer)
					{
						pFunc->GetParentContext()->BlamePluginError(pFunc, "Client index %d is invalid", client);
					} else if (!pPlayer->IsInGame()) {
						pFunc->GetParentContext()->BlamePluginError(pFunc, "Client %d is not connected", client);
					} else {
						continue;
					}

#if SOURCE_ENGINE >= SE_PORTAL2
					RETURN_META_VALUE(MRES_IGNORED, -1 );
#else
					return;
#endif
				}

#if SOURCE_ENGINE >= SE_PORTAL2
				if (strcmp(pSoundEntry, soundEntry) != 0 || strcmp(pSample, buffer) != 0)
				{
					if (strcmp(soundEntry, buffer) == 0)
						nSoundEntryHash = -1;
					else if (strcmp(soundEntry, "") != 0)
						nSoundEntryHash = GenerateSoundEntryHash(soundEntry);
				}
#endif

				CellRecipientFilter crf;
				crf.Initialize(players, size);
#if SOURCE_ENGINE >= SE_PORTAL2
				RETURN_META_VALUE_NEWPARAMS(
					MRES_IGNORED,
					-1,
					static_cast<int (IEngineSound::*)(IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float, 
					int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>(&IEngineSound::EmitSound), 
					(crf, iEntIndex, iChannel, soundEntry, nSoundEntryHash, buffer, flVolume, SNDLVL_TO_ATTN(static_cast<soundlevel_t>(sndlevel)),
					nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
					);
#elif SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
	|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2
RETURN_META_NEWPARAMS(
					MRES_IGNORED,
					static_cast<void (IEngineSound::*)(IRecipientFilter &, int, int, const char *, float, float, 
					int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>(&IEngineSound::EmitSound), 
					(crf, iEntIndex, iChannel, buffer, flVolume, SNDLVL_TO_ATTN(static_cast<soundlevel_t>(sndlevel)), 
					iFlags, iPitch, iSpecialDSP, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
					);
#else
				RETURN_META_NEWPARAMS(
					MRES_IGNORED,
					static_cast<void (IEngineSound::*)(IRecipientFilter &, int, int, const char *, float, float, 
					int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>(&IEngineSound::EmitSound), 
					(crf, iEntIndex, iChannel, buffer, flVolume, SNDLVL_TO_ATTN(static_cast<soundlevel_t>(sndlevel)), 
					iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
					);
#endif
			}
		}
	}

#if SOURCE_ENGINE >= SE_PORTAL2
	RETURN_META_VALUE(MRES_IGNORED, -1 );
#endif
}
Ejemplo n.º 5
0
/* IGameEventManager2::FireEvent hook */
bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
{
	EventHook *pHook;
	IChangeableForward *pForward;
	const char *name;
	cell_t res = Pl_Continue;
	bool broadcast = bDontBroadcast;

	/* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
	if (!pEvent)
	{
		RETURN_META_VALUE(MRES_IGNORED, false);
	}

	name = pEvent->GetName();
	
	if (m_EventHooks.retrieve(name, &pHook))
	{
		/* Push the event onto the event stack.  The reference count is increased to make sure 
		 * the structure is not garbage collected in between now and the post hook.
		 */
		pHook->refCount++;
		m_EventStack.push(pHook);

		pForward = pHook->pPreHook;

		if (pForward)
		{
			EventInfo info(pEvent, NULL);
			HandleSecurity sec(NULL, g_pCoreIdent);
			Handle_t hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);

			info.bDontBroadcast = bDontBroadcast;

			EventForwardFilter filter(&info);

			pForward->PushCell(hndl);
			pForward->PushString(name);
			pForward->PushCell(bDontBroadcast);
			pForward->Execute(&res, &filter);

			broadcast = info.bDontBroadcast;

			handlesys->FreeHandle(hndl, &sec);
		}

		if (pHook->postCopy)
		{
			m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
		}

		if (res)
		{
			gameevents->FreeEvent(pEvent);
			RETURN_META_VALUE(MRES_SUPERCEDE, false);
		}
	}
	else
	{
		m_EventStack.push(NULL);
	}

	if (broadcast != bDontBroadcast)
		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, true, &IGameEventManager2::FireEvent, (pEvent, broadcast));

	RETURN_META_VALUE(MRES_IGNORED, true);
}