void Hook_R_DrawEntitiesOnList()
{
	if( !g_Old_R_DrawEntitiesOnList && 0 != HL_ADDR_GET(R_DrawEntitiesOnList) ) 
	{
		g_Old_R_DrawEntitiesOnList = (R_DrawEntitiesOnList_t) DetourApply((BYTE *)HL_ADDR_GET(R_DrawEntitiesOnList), (BYTE *)New_R_DrawEntitiesOnList, (int)HL_ADDR_GET(DTOURSZ_R_DrawEntitiesOnList));
	}
}
Exemplo n.º 2
0
void Hook_Host_Frame()
{
	if( !g_Old_HostFrame && 0 != HL_ADDR_GET(Host_Frame) )
	{
		g_phost_frametime = (double *)HL_ADDR_GET(host_frametime);
		g_Old_HostFrame = (Host_Frame_t) DetourApply((BYTE *)HL_ADDR_GET(Host_Frame), (BYTE *)New_Host_Frame, (int)HL_ADDR_GET(Host_Frame_DSZ));
	}
}
Exemplo n.º 3
0
void touring_S_TransferPaintBuffer(int endtime)
{
	static volatile dma_HL_t *shm;

	if (g_FilmSound_Capturing)
	{
		// filming

		shm=*(dma_HL_t **)HL_ADDR_GET(shm);
		
		int paintedtime = *(int *)HL_ADDR_GET(paintedtime);

		portable_samplepair_t * paintbuffer = (portable_samplepair_t *)HL_ADDR_GET(paintbuffer);

		int iMyVolume = (int)(g_Volume*256.0f);

		int * snd_p = (int *) paintbuffer;
		int lpaintedtime = paintedtime;

		while (lpaintedtime < endtime)
		{
			for (int i=0;i<2;i++)
			{
				int ilchan;
				int irchan;
				WORD wlchan,wrchan;

				// limiter from Snd_WriteLinearBlastStereo16:
				
				ilchan = (snd_p[0]*iMyVolume)>>8;
				if (ilchan > 0x7fff) wlchan = 0x7fff;
				else if (ilchan < (short)0x8000) wlchan = (short)0x8000;
				else wlchan = ilchan;

				irchan = (snd_p[1]*iMyVolume)>>8;
				if (irchan > 0x7fff) wrchan = 0x7fff;
				else if (irchan < (short)0x8000) wrchan = (short)0x8000;
				else wrchan = irchan;

				g_FilmSound->Snd_Supply(wlchan, wrchan);
				snd_p+=2;
			}

			lpaintedtime++;
		}
	}

	// pass through to sound buffer:
	detoured_S_TransferPaintBuffer(endtime);

}
Exemplo n.º 4
0
bool Hook_R_DrawViewModel()
{
	static bool firstRun = true;
	static bool firstResult = true;
	if (!firstRun) return firstResult;
	firstRun = false;

	if (HL_ADDR_GET(R_DrawViewModel))
	{
		LONG error = NO_ERROR;

		g_Old_R_DrawViewModel = (R_DrawViewModel_t)AFXADDR_GET(R_DrawViewModel);

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)g_Old_R_DrawViewModel, New_R_DrawViewModel);
		error = DetourTransactionCommit();

		if (NO_ERROR != error)
		{
			firstResult = false;
			ErrorBox("Interception failed:\nHook_R_DrawViewModel");
		}
	}
	else
		firstResult = false;

	return firstResult;
}
Exemplo n.º 5
0
bool Hook_Mod_LeafPvs()
{
	static bool firstRun = true;
	static bool firstResult = true;
	if (!firstRun) return firstResult;
	firstRun = false;

	if (HL_ADDR_GET(Mod_LeafPVS) != NULL)
	{
		LONG error = NO_ERROR;

		g_Old_Mod_LeafPVS = (Mod_LeafPVS_t)AFXADDR_GET(Mod_LeafPVS);

		DetourTransactionBegin();
		DetourUpdateThread(GetCurrentThread());
		DetourAttach(&(PVOID&)g_Old_Mod_LeafPVS, New_Mod_LeafPVS);
		error = DetourTransactionCommit();

		if (NO_ERROR != error)
		{
			firstResult = false;
			ErrorBox("Interception failed:\nHook_Mod_LeafPvs");
		}
	}
	else
		firstResult = false;

	return firstResult;
}
Exemplo n.º 6
0
void touring_S_PaintChannels(int endtime)
{
	static volatile dma_HL_t *shm;

	if (g_FilmSound_Capturing)
	{
		double dDeltaTime;
		int deltaTime;

		shm = *(dma_HL_t **)HL_ADDR_GET(shm);

		dDeltaTime = (
			g_TargetTime - g_CurrentTime
		) * (double)shm->Quake_speed;

		// and override
		switch(g_FilmSound_TimeRounding)
		{
		case FS_TR_CEIL:
			deltaTime = (int)ceil(dDeltaTime); // we preffer having too much samples when stopping
			break;
		case FS_TR_FLOOR:
		default:
			deltaTime = (int)floor(dDeltaTime); // we preffer having faster updates and therefore less samples during filming
			break;
		}

		// we cannot go back in time, so stfu:
		if(deltaTime < 0) deltaTime = 0;

		dDeltaTime = (double)deltaTime / (double)shm->Quake_speed;

		// >> Sound painting
		detoured_S_PaintChannels(*(int *)HL_ADDR_GET(paintedtime) +deltaTime);
		// << Sound painting

		// update Our class's _CurrentTime:
		g_CurrentTime = g_CurrentTime +dDeltaTime;
	}
	else
	{
		// don't do anything abnormal
		detoured_S_PaintChannels(endtime);
	}
}
Exemplo n.º 7
0
void CFilmSound::Stop()
{
	if(!g_FilmSound_Capturing)
		return;

	// for sound finishing and extra sound make it ceil:
	g_FilmSound_TimeRounding = FS_TR_CEIL;

	//
	// finish the painting:

	touring_S_PaintChannels(*(int *)HL_ADDR_GET(paintedtime));
	_fEndWave(_pWaveFile); // finish the wave file
	_pWaveFile = 0;

	//
	// do any extra painting:

	if(m_pWaveFileExtra)
	{
		_pWaveFile = m_pWaveFileExtra;
		m_pWaveFileExtra = 0;
		g_TargetTime += m_ExtraTime;

		touring_S_PaintChannels(*(int *)HL_ADDR_GET(paintedtime));
		_fEndWave(_pWaveFile); // finish the wave file

		_pWaveFile = 0;
	}

	// done capturing, stop and restore:

	g_FilmSound_Capturing = false;
	
	pEngfuncs->Con_Printf("Sound system finished stopping (almost :).\n");

	//
	// make soundsystem catch up:

	touring_GetSoundtime();
	*(int *)HL_ADDR_GET(paintedtime) = (*(int *)HL_ADDR_GET(soundtime)) >> 1;
	pEngfuncs->pfnClientCmd("stopsound");
}
Exemplo n.º 8
0
void Hook_Cstrike_CrossHair_Fix()
{
	static bool firstRun = true;
	if(!firstRun) return;
	firstRun = false;

	double * addrMul = (double *)HL_ADDR_GET(cstrike_UnkCrosshairFn_mul_fac);
	double * addrAdd = (double *)HL_ADDR_GET(cstrike_UnkCrosshairFn_add_fac);
	BYTE * addrFn = (BYTE *)HL_ADDR_GET(cstrike_UnkCrosshairFn);
	int addrFnDsz = (int)HL_ADDR_GET(cstrike_UnkCrosshairFn_DSZ);

	if(!(
		addrMul && addrAdd && addrFn && addrFnDsz
	)) return;

	g_pfnCrosshairFix_Hooked_Func = (UnkCstrikeCrosshairFn_t)DetourClassFunc(addrFn, (BYTE *)CrosshairFix_Hooking_Func, addrFnDsz);
	g_f_ch_mul_fac = addrMul;
	g_f_ch_add_fac = addrAdd;
}
Exemplo n.º 9
0
bool CFilmSound::Start(wchar_t const * fileName, double dTargetTime, float fUseVolume, wchar_t const * extraFileName, double extraTime)
{
	InstallHooks(); // make sure hooks are installed

	if (!g_FilmSound_Capturing)
	{
		// only start when idle

		g_FilmSound_TimeRounding = FS_TR_FLOOR;
		
		// init time:
		g_TargetTime = dTargetTime;
		g_CurrentTime = 0.0;

		// set volume:
		g_Volume = fUseVolume;

		// retrive sound info structure (since we need the samples per second value == shm->Valve_speed):
		volatile dma_HL_t *shm=*(dma_HL_t **)HL_ADDR_GET(shm);

		if(!(_pWaveFile=_fBeginWave(fileName, shm->Valve_speed))) // we use Quake speed since we capture the internal mixer
			return false; // on fail return false

		m_pWaveFileExtra = 0;
		if(0 < extraTime)
		{
			m_ExtraTime = extraTime;

			if(!(m_pWaveFileExtra = _fBeginWave(extraFileName, shm->Valve_speed)))
			{
				_fEndWave(_pWaveFile);
				return false;
			}
		}

		g_FilmSound_Capturing = true; // switch to filming mode

		return true;
	}

	return false;
}
Exemplo n.º 10
0
void InstallHooks()
{
	// notice the memory allocted here gets never freed o_O
	if(!detoured_GetSoundtime) detoured_GetSoundtime = (GetSoundtime_t) DetourApply((BYTE *)HL_ADDR_GET(GetSoundtime), (BYTE *)touring_GetSoundtime, (int)HL_ADDR_GET(DTOURSZ_GetSoundtime));
	if(!detoured_S_PaintChannels) detoured_S_PaintChannels = (S_PaintChannels_t) DetourApply((BYTE *)HL_ADDR_GET(S_PaintChannels), (BYTE *)touring_S_PaintChannels, (int)HL_ADDR_GET(DTOURSZ_S_PaintChannels));
	if(!detoured_S_TransferPaintBuffer) detoured_S_TransferPaintBuffer = (S_TransferPaintBuffer_t) DetourApply((BYTE *)HL_ADDR_GET(S_TransferPaintBuffer), (BYTE *)touring_S_TransferPaintBuffer, (int)HL_ADDR_GET(DTOURSZ_S_TransferPaintBuffer));
	if(!detoured_SND_PickChannel) detoured_SND_PickChannel = (SND_PickChannel_t)DetourApply((BYTE *)HL_ADDR_GET(SND_PickChannel), (BYTE *)touring_SND_PickChannel, (int)HL_ADDR_GET(DTOURSZ_SND_PickChannel));
}
Exemplo n.º 11
0
void Hook_R_PolyBlend()
{
	if (!g_Old_R_PolyBlend && (HL_ADDR_GET(R_PolyBlend)!=NULL))
			g_Old_R_PolyBlend = (R_PolyBlend_t) DetourApply((BYTE *)HL_ADDR_GET(R_PolyBlend), (BYTE *)New_R_PolyBlend, (int)HL_ADDR_GET(DTOURSZ_R_PolyBlend));
}
Exemplo n.º 12
0
void Hook_Mod_LeafPvs()
{
	if (!g_Old_Mod_LeafPVS && (HL_ADDR_GET(Mod_LeafPVS)!=NULL))
		g_Old_Mod_LeafPVS = (Mod_LeafPVS_t) DetourApply((BYTE *)HL_ADDR_GET(Mod_LeafPVS), (BYTE *)New_Mod_LeafPVS, (int)HL_ADDR_GET(DTOURSZ_Mod_LeafPVS));
}