sourcehook/sourcehook.cpp
changeset 128 63f95eed16b6
parent 123 53e819ac032a
child 151 1667580b0c91
     1.1 --- a/sourcehook/sourcehook.cpp	Sat Oct 08 01:15:02 2005 +0000
     1.2 +++ b/sourcehook/sourcehook.cpp	Wed Oct 12 20:25:15 2005 +0000
     1.3 @@ -365,8 +365,12 @@
     1.4  			if (iface_iter->m_PostHooks.m_List.empty() && iface_iter->m_PreHooks.m_List.empty())
     1.5  			{
     1.6  				// There are no hooks on this iface anymore...
     1.7 -				if (m_CurIface == static_cast<IIface*>(&(*iface_iter)))
     1.8 -					m_HLS = HLS_Stop;
     1.9 +				for (HookLoopInfoStack::iterator hli_iter = m_HLIStack.begin();
    1.10 +					hli_iter != m_HLIStack.end(); ++hli_iter)
    1.11 +				{
    1.12 +					if (hli_iter->pCurIface == static_cast<IIface*>(&(*iface_iter)))
    1.13 +						hli_iter->shouldContinue = false;
    1.14 +				}
    1.15  
    1.16  				iface_iter = vfnptr_iter->m_Ifaces.erase(iface_iter);
    1.17  				if (vfnptr_iter->m_Ifaces.empty())
    1.18 @@ -519,74 +523,80 @@
    1.19  		SetPluginPaused(plug, false);
    1.20  	}
    1.21  
    1.22 +	void CSourceHookImpl::HookLoopBegin(IIface *pIface)
    1.23 +	{
    1.24 +		HookLoopInfo hli;
    1.25 +		hli.pCurIface = pIface;
    1.26 +		hli.shouldContinue = true;
    1.27 +		m_HLIStack.push(hli);
    1.28 +	}
    1.29 +
    1.30 +	void CSourceHookImpl::HookLoopEnd()
    1.31 +	{
    1.32 +		m_HLIStack.pop();
    1.33 +	}
    1.34 +
    1.35  	void CSourceHookImpl::SetRes(META_RES res)
    1.36  	{
    1.37 -		m_CurRes = res;
    1.38 +		*m_HLIStack.front().pCurRes = res;
    1.39  	}
    1.40  
    1.41  	META_RES CSourceHookImpl::GetPrevRes()
    1.42  	{
    1.43 -		return m_PrevRes;
    1.44 +		return *m_HLIStack.front().pPrevRes;
    1.45  	}
    1.46  
    1.47  	META_RES CSourceHookImpl::GetStatus()
    1.48  	{
    1.49 -		return m_Status;
    1.50 +		return *m_HLIStack.front().pStatus;
    1.51  	}
    1.52  
    1.53  	const void *CSourceHookImpl::GetOrigRet()
    1.54  	{
    1.55 -		return m_OrigRet;
    1.56 +		return m_HLIStack.front().pOrigRet;
    1.57  	}
    1.58  
    1.59  	const void *CSourceHookImpl::GetOverrideRet()
    1.60  	{
    1.61 -		return m_OverrideRet;
    1.62 -	}
    1.63 -
    1.64 -	META_RES &CSourceHookImpl::GetCurResRef()
    1.65 -	{
    1.66 -		return m_CurRes;
    1.67 -	}
    1.68 -
    1.69 -	META_RES &CSourceHookImpl::GetPrevResRef()
    1.70 -	{
    1.71 -		return m_PrevRes;
    1.72 -	}
    1.73 -
    1.74 -	META_RES &CSourceHookImpl::GetStatusRef()
    1.75 -	{
    1.76 -		return m_Status;
    1.77 -	}
    1.78 -
    1.79 -	void * &CSourceHookImpl::GetIfacePtrRef()
    1.80 -	{
    1.81 -		return m_IfacePtr;
    1.82 -	}
    1.83 -
    1.84 -	void CSourceHookImpl::SetOrigRet(const void *ptr)
    1.85 -	{
    1.86 -		m_OrigRet = ptr;
    1.87 -	}
    1.88 -
    1.89 -	void CSourceHookImpl::SetOverrideRet(const void *ptr)
    1.90 -	{
    1.91 -		m_OverrideRet = ptr;
    1.92 +		return m_HLIStack.front().pOverrideRet;
    1.93  	}
    1.94  
    1.95  	void *CSourceHookImpl::GetIfacePtr()
    1.96  	{
    1.97 -		return m_IfacePtr;
    1.98 +		return *m_HLIStack.front().pIfacePtrPtr;
    1.99 +	}
   1.100 +
   1.101 +	void CSourceHookImpl::SetCurResPtr(META_RES *mres)
   1.102 +	{
   1.103 +		m_HLIStack.front().pCurRes = mres;
   1.104 +	}
   1.105 +
   1.106 +	void CSourceHookImpl::SetPrevResPtr(META_RES *mres)
   1.107 +	{
   1.108 +		m_HLIStack.front().pPrevRes = mres;
   1.109  	}
   1.110  
   1.111 -	HookLoopStatus &CSourceHookImpl::GetStatusVarRef(IIface *pIface)
   1.112 +	void CSourceHookImpl::SetStatusPtr(META_RES *mres)
   1.113 +	{
   1.114 +		m_HLIStack.front().pStatus = mres;
   1.115 +	}
   1.116 +
   1.117 +	void CSourceHookImpl::SetIfacePtrPtr(void **pp)
   1.118  	{
   1.119 -		m_CurIface = pIface;
   1.120 -		return m_HLS;
   1.121 +		m_HLIStack.front().pIfacePtrPtr = pp;
   1.122 +	}
   1.123 +
   1.124 +	void CSourceHookImpl::SetOrigRetPtr(const void *ptr)
   1.125 +	{
   1.126 +		m_HLIStack.front().pOrigRet = ptr;
   1.127  	}
   1.128 -	void CSourceHookImpl::HookLoopDone()
   1.129 +	void CSourceHookImpl::SetOverrideRetPtr(const void *ptr)
   1.130  	{
   1.131 -		m_CurIface = NULL;
   1.132 +		m_HLIStack.front().pOverrideRet = ptr;
   1.133 +	}
   1.134 +	bool CSourceHookImpl::ShouldContinue()
   1.135 +	{
   1.136 +		return m_HLIStack.front().shouldContinue;
   1.137  	}
   1.138  
   1.139  	////////////////////////////