mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
No more STL! Imported TinyHash
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40102
This commit is contained in:
parent
4f07756795
commit
3391d62146
@ -185,8 +185,8 @@ namespace SourceHook
|
||||
int thisptr_offs; //!< This pointer offset
|
||||
};
|
||||
void *ptr; //!< Pointer to the interface instance
|
||||
std::list<Hook> hooks_pre; //!< A list of pre-hooks
|
||||
std::list<Hook> hooks_post; //!< A list of post-hooks
|
||||
SourceHook::List<Hook> hooks_pre; //!< A list of pre-hooks
|
||||
SourceHook::List<Hook> hooks_post; //!< A list of post-hooks
|
||||
bool operator ==(void *other) const
|
||||
{
|
||||
return ptr == other;
|
||||
@ -196,7 +196,7 @@ namespace SourceHook
|
||||
void *vfnptr; //!< Pointer to the function
|
||||
void *orig_entry; //!< The original vtable entry
|
||||
|
||||
typedef std::list<Iface> IfaceList;
|
||||
typedef SourceHook::List<Iface> IfaceList;
|
||||
typedef IfaceList::iterator IfaceListIter;
|
||||
IfaceList ifaces; //!< List of interface pointers
|
||||
|
||||
@ -214,13 +214,13 @@ namespace SourceHook
|
||||
|
||||
void *hookfunc_vfnptr; //!< Pointer to the hookfunc impl
|
||||
|
||||
typedef std::list<VfnPtr> VfnPtrList;
|
||||
typedef SourceHook::List<VfnPtr> VfnPtrList;
|
||||
typedef VfnPtrList::iterator VfnPtrListIter;
|
||||
VfnPtrList vfnptrs; //!< List of hooked interfaces
|
||||
};
|
||||
|
||||
typedef std::vector<void*> OrigFuncs;
|
||||
typedef std::map<int, OrigFuncs> OrigVTables;
|
||||
typedef SourceHook::CVector<void*> OrigFuncs;
|
||||
typedef SourceHook::THash<int, OrigFuncs> OrigVTables;
|
||||
|
||||
template<class B> struct CallClass
|
||||
{
|
||||
@ -467,7 +467,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
void *ourvfnptr = reinterpret_cast<void*>( \
|
||||
*reinterpret_cast<void***>(reinterpret_cast<char*>(this) + ms_HI->vtbl_offs) + ms_HI->vtbl_idx); \
|
||||
\
|
||||
HookManagerInfo::VfnPtrListIter vfptriter = std::find(ms_HI->vfnptrs.begin(), \
|
||||
HookManagerInfo::VfnPtrListIter vfptriter = ms_HI->find(ms_HI->vfnptrs.begin(), \
|
||||
ms_HI->vfnptrs.end(), ourvfnptr); \
|
||||
if (vfptriter == ms_HI->vfnptrs.end()) \
|
||||
{ \
|
||||
@ -476,7 +476,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
} \
|
||||
HookManagerInfo::VfnPtr &vfnptr = *vfptriter; \
|
||||
/* 2) Find the iface */ \
|
||||
HookManagerInfo::VfnPtr::IfaceListIter ifiter = std::find(vfnptr.ifaces.begin(), vfnptr.ifaces.end(), this); \
|
||||
HookManagerInfo::VfnPtr::IfaceListIter ifiter = ms_HI->find(vfnptr.ifaces.begin(), vfnptr.ifaces.end(), this); \
|
||||
if (ifiter == vfnptr.ifaces.end()) \
|
||||
{ \
|
||||
/* The iface info was not found. Redirect the call to the original function. */ \
|
||||
@ -486,8 +486,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
} \
|
||||
HookManagerInfo::VfnPtr::Iface &ci = *ifiter; \
|
||||
/* 2) Declare some vars and set it up */ \
|
||||
std::list<HookManagerInfo::VfnPtr::Iface::Hook> &prelist = ci.hooks_pre; \
|
||||
std::list<HookManagerInfo::VfnPtr::Iface::Hook> &postlist = ci.hooks_post; \
|
||||
SourceHook::List<HookManagerInfo::VfnPtr::Iface::Hook> &prelist = ci.hooks_pre; \
|
||||
SourceHook::List<HookManagerInfo::VfnPtr::Iface::Hook> &postlist = ci.hooks_post; \
|
||||
rettype orig_ret; \
|
||||
rettype override_ret; \
|
||||
rettype plugin_ret; \
|
||||
@ -501,7 +501,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
|
||||
#define SH_CALL_HOOKS(post, params) \
|
||||
prev_res = MRES_IGNORED; \
|
||||
for (std::list<HookManagerInfo::VfnPtr::Iface::Hook>::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \
|
||||
for (SourceHook::List<HookManagerInfo::VfnPtr::Iface::Hook>::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \
|
||||
{ \
|
||||
if (hiter->paused) continue; \
|
||||
cur_res = MRES_IGNORED; \
|
||||
@ -544,7 +544,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
void *ourvfnptr = reinterpret_cast<void*>( \
|
||||
*reinterpret_cast<void***>(reinterpret_cast<char*>(this) + ms_HI->vtbl_offs) + ms_HI->vtbl_idx); \
|
||||
\
|
||||
HookManagerInfo::VfnPtrListIter vfptriter = std::find(ms_HI->vfnptrs.begin(), \
|
||||
HookManagerInfo::VfnPtrListIter vfptriter = ms_HI->find(ms_HI->vfnptrs.begin(), \
|
||||
ms_HI->vfnptrs.end(), ourvfnptr); \
|
||||
if (vfptriter == ms_HI->vfnptrs.end()) \
|
||||
{ \
|
||||
@ -553,7 +553,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
} \
|
||||
HookManagerInfo::VfnPtr &vfnptr = *vfptriter; \
|
||||
/* 2) Find the iface */ \
|
||||
HookManagerInfo::VfnPtr::IfaceListIter ifiter = std::find(vfnptr.ifaces.begin(), vfnptr.ifaces.end(), this); \
|
||||
HookManagerInfo::VfnPtr::IfaceListIter ifiter = ms_HI->find(vfnptr.ifaces.begin(), vfnptr.ifaces.end(), this); \
|
||||
if (ifiter == vfnptr.ifaces.end()) \
|
||||
{ \
|
||||
/* The iface info was not found. Redirect the call to the original function. */ \
|
||||
@ -564,8 +564,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
} \
|
||||
HookManagerInfo::VfnPtr::Iface &ci = *ifiter; \
|
||||
/* 2) Declare some vars and set it up */ \
|
||||
std::list<HookManagerInfo::VfnPtr::Iface::Hook> &prelist = ci.hooks_pre; \
|
||||
std::list<HookManagerInfo::VfnPtr::Iface::Hook> &postlist = ci.hooks_post; \
|
||||
SourceHook::List<HookManagerInfo::VfnPtr::Iface::Hook> &prelist = ci.hooks_pre; \
|
||||
SourceHook::List<HookManagerInfo::VfnPtr::Iface::Hook> &postlist = ci.hooks_post; \
|
||||
META_RES &cur_res = SH_GLOB_SHPTR->GetCurResRef(); \
|
||||
META_RES &prev_res = SH_GLOB_SHPTR->GetPrevResRef(); \
|
||||
META_RES &status = SH_GLOB_SHPTR->GetStatusRef(); \
|
||||
@ -575,7 +575,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
|
||||
#define SH_CALL_HOOKS_void(post, params) \
|
||||
prev_res = MRES_IGNORED; \
|
||||
for (std::list<HookManagerInfo::VfnPtr::Iface::Hook>::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \
|
||||
for (SourceHook::List<HookManagerInfo::VfnPtr::Iface::Hook>::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \
|
||||
{ \
|
||||
if (hiter->paused) continue; \
|
||||
cur_res = MRES_IGNORED; \
|
||||
@ -686,8 +686,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
using namespace ::SourceHook; \
|
||||
MemFuncInfo mfi; \
|
||||
GetFuncInfo(m_CC->ptr, m_MFP, mfi); \
|
||||
OrigVTables::const_iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->second.size() || iter->second[mfi.vtblindex] == NULL) \
|
||||
OrigVTables::iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->val.size() || iter->val[mfi.vtblindex] == NULL) \
|
||||
return (m_CC->ptr->*m_MFP)call; \
|
||||
\
|
||||
/* It's hooked. Call the original function. */ \
|
||||
@ -696,7 +696,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
RetType(EmptyClass::*mfpnew)prms; \
|
||||
void *addr; \
|
||||
} u; \
|
||||
u.addr = iter->second[mfi.vtblindex]; \
|
||||
u.addr = iter->val[mfi.vtblindex]; \
|
||||
\
|
||||
void *adjustedthisptr = reinterpret_cast<void*>(reinterpret_cast<char*>(m_CC->ptr) + mfi.thisptroffs); \
|
||||
return (reinterpret_cast<EmptyClass*>(adjustedthisptr)->*u.mfpnew)call; \
|
||||
@ -709,8 +709,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
using namespace ::SourceHook; \
|
||||
MemFuncInfo mfi; \
|
||||
GetFuncInfo(m_CC->ptr, m_MFP, mfi); \
|
||||
OrigVTables::const_iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->second.size() || iter->second[mfi.vtblindex] == NULL) \
|
||||
OrigVTables::iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->val.size() || iter->val[mfi.vtblindex] == NULL) \
|
||||
return (m_CC->ptr->*m_MFP)call; \
|
||||
\
|
||||
/* It's hooked. Call the original function. */ \
|
||||
@ -723,7 +723,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
intptr_t adjustor; \
|
||||
} s; \
|
||||
} u; \
|
||||
u.s.addr = iter->second[mfi.vtblindex]; \
|
||||
u.s.addr = iter->val[mfi.vtblindex]; \
|
||||
u.s.adjustor = mfi.thisptroffs; \
|
||||
\
|
||||
return (reinterpret_cast<EmptyClass*>(m_CC->ptr)->*u.mfpnew)call; \
|
||||
|
@ -137,6 +137,7 @@ public:
|
||||
m_This = m_This->next;
|
||||
return *this;
|
||||
}
|
||||
//post increment
|
||||
iterator operator++(int)
|
||||
{
|
||||
iterator old(*this);
|
||||
@ -164,6 +165,10 @@ public:
|
||||
{
|
||||
return (m_This == where.m_This);
|
||||
}
|
||||
bool operator ==(const iterator &where) const
|
||||
{
|
||||
return (m_This == where.m_This);
|
||||
}
|
||||
private:
|
||||
ListNode *m_This;
|
||||
};
|
||||
|
@ -454,9 +454,9 @@ namespace SourceHook
|
||||
OrigVTables::iterator iter = cc.cc.vt.find(vtbl_offs);
|
||||
if (iter != cc.cc.vt.end())
|
||||
{
|
||||
if (iter->second.size() > (size_t)vtbl_idx)
|
||||
if (iter->val.size() > (size_t)vtbl_idx)
|
||||
{
|
||||
iter->second[vtbl_idx] = 0;
|
||||
iter->val[vtbl_idx] = 0;
|
||||
// Free some memory if possible
|
||||
// :TODO: add this back in!
|
||||
/*
|
||||
|
@ -70,7 +70,7 @@
|
||||
#include "sh_memory.h"
|
||||
#include "sh_list.h"
|
||||
#include "sh_vector.h"
|
||||
#include <map>
|
||||
#include "sh_tinyhash.h"
|
||||
|
||||
// Good old metamod!
|
||||
|
||||
@ -219,7 +219,7 @@ namespace SourceHook
|
||||
};
|
||||
|
||||
typedef SourceHook::CVector<void*> OrigFuncs;
|
||||
typedef std::map<int, OrigFuncs> OrigVTables;
|
||||
typedef SourceHook::THash<int, OrigFuncs> OrigVTables;
|
||||
|
||||
template<class B> struct CallClass
|
||||
{
|
||||
@ -1497,8 +1497,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
using namespace ::SourceHook; \
|
||||
MemFuncInfo mfi; \
|
||||
GetFuncInfo(m_CC->ptr, m_MFP, mfi); \
|
||||
OrigVTables::const_iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->second.size() || iter->second[mfi.vtblindex] == NULL) \
|
||||
OrigVTables::iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->val.size() || iter->val[mfi.vtblindex] == NULL) \
|
||||
return (m_CC->ptr->*m_MFP)call; \
|
||||
\
|
||||
/* It's hooked. Call the original function. */ \
|
||||
@ -1507,7 +1507,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
RetType(EmptyClass::*mfpnew)prms; \
|
||||
void *addr; \
|
||||
} u; \
|
||||
u.addr = iter->second[mfi.vtblindex]; \
|
||||
u.addr = iter->val[mfi.vtblindex]; \
|
||||
\
|
||||
void *adjustedthisptr = reinterpret_cast<void*>(reinterpret_cast<char*>(m_CC->ptr) + mfi.thisptroffs); \
|
||||
return (reinterpret_cast<EmptyClass*>(adjustedthisptr)->*u.mfpnew)call; \
|
||||
@ -1520,8 +1520,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
using namespace ::SourceHook; \
|
||||
MemFuncInfo mfi; \
|
||||
GetFuncInfo(m_CC->ptr, m_MFP, mfi); \
|
||||
OrigVTables::const_iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->second.size() || iter->second[mfi.vtblindex] == NULL) \
|
||||
OrigVTables::iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
|
||||
if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->val.size() || iter->val[mfi.vtblindex] == NULL) \
|
||||
return (m_CC->ptr->*m_MFP)call; \
|
||||
\
|
||||
/* It's hooked. Call the original function. */ \
|
||||
@ -1534,7 +1534,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
|
||||
intptr_t adjustor; \
|
||||
} s; \
|
||||
} u; \
|
||||
u.s.addr = iter->second[mfi.vtblindex]; \
|
||||
u.s.addr = iter->val[mfi.vtblindex]; \
|
||||
u.s.adjustor = mfi.thisptroffs; \
|
||||
\
|
||||
return (reinterpret_cast<EmptyClass*>(m_CC->ptr)->*u.mfpnew)call; \
|
||||
|
Loading…
x
Reference in New Issue
Block a user