mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-11-29 11:24:19 +01:00
Build fixes.
This commit is contained in:
parent
a99e8b0f21
commit
48b345cb2c
@ -29,7 +29,7 @@
|
||||
// This is not a SH_IFACE_VERSION change so that old plugins continue working!
|
||||
// 5 - addition of direct vp hooks (new hook mode; from now on AddHookNew checks for
|
||||
// invalid hookmode -> impl version won't have to change because of things like this)
|
||||
#define SH_IMPL_VERSION 5
|
||||
#define SH_IMPL_VERSION 4
|
||||
|
||||
// Hookman version:
|
||||
// 1 - Support for recalls, performance optimisations
|
||||
|
147
core-legacy/sourcehook/sh_listcat.h
Executable file
147
core-legacy/sourcehook/sh_listcat.h
Executable file
@ -0,0 +1,147 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2007 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
*
|
||||
* Author(s): Pavol "PM OnoTo" Marko
|
||||
* ============================
|
||||
*/
|
||||
|
||||
// Used for VP-Hooks
|
||||
|
||||
#ifndef _INCLUDE_SMM_LISTCAT_H
|
||||
#define _INCLUDE_SMM_LISTCAT_H
|
||||
|
||||
#include "sh_list.h"
|
||||
|
||||
namespace SourceHook
|
||||
{
|
||||
|
||||
// Only a very special-case forward iterator!
|
||||
template <typename T>
|
||||
class ListCatIterator
|
||||
{
|
||||
List<T> *m_pListLeft;
|
||||
List<T> *m_pListRight;
|
||||
typename List<T>::iterator m_Iter;
|
||||
|
||||
void CheckLeftEmptyOnBegin()
|
||||
{
|
||||
// If the left list is empty and right is valid, GoToBegin sets m_Iter to m_Left
|
||||
// End() checks for equality to m_Right.end() so it returns false
|
||||
// then Next() corrupts by incrementing!
|
||||
|
||||
// To avoid this, we skip left if it's empty.
|
||||
if (m_pListLeft && m_pListLeft->empty() && m_pListRight)
|
||||
{
|
||||
m_Iter = m_pListRight->begin();
|
||||
}
|
||||
}
|
||||
public:
|
||||
// At least one list has to be non-null!
|
||||
ListCatIterator(List<T> *pListLeft, List<T> *pListRight) : m_pListLeft(pListLeft), m_pListRight(pListRight),
|
||||
m_Iter(pListLeft ? pListLeft->begin() : pListRight->begin())
|
||||
{
|
||||
CheckLeftEmptyOnBegin();
|
||||
}
|
||||
|
||||
void GoToBegin()
|
||||
{
|
||||
m_Iter = m_pListLeft ? m_pListLeft->begin() : m_pListRight->begin();
|
||||
CheckLeftEmptyOnBegin();
|
||||
}
|
||||
|
||||
bool End()
|
||||
{
|
||||
return m_pListRight ? (m_Iter == m_pListRight->end())
|
||||
: (m_Iter == m_pListLeft->end());
|
||||
}
|
||||
|
||||
//pre increment
|
||||
ListCatIterator & operator++()
|
||||
{
|
||||
++m_Iter;
|
||||
if (m_pListLeft && m_Iter == m_pListLeft->end())
|
||||
{
|
||||
if (m_pListRight)
|
||||
m_Iter = m_pListRight->begin();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
//post increment
|
||||
ListCatIterator operator++(int)
|
||||
{
|
||||
ListCatIterator old(*this);
|
||||
|
||||
++m_Iter;
|
||||
if (m_pListLeft && m_Iter == m_pListLeft->end())
|
||||
{
|
||||
if (m_pListRight)
|
||||
m_Iter = m_pListRight->begin();
|
||||
}
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
const T & operator * () const
|
||||
{
|
||||
return *m_Iter;
|
||||
}
|
||||
T & operator * ()
|
||||
{
|
||||
return *m_Iter;
|
||||
}
|
||||
|
||||
T * operator -> ()
|
||||
{
|
||||
return &(*m_Iter);
|
||||
}
|
||||
const T * operator -> () const
|
||||
{
|
||||
return &(*m_Iter);
|
||||
}
|
||||
|
||||
bool operator != (const typename List<T>::iterator &where) const
|
||||
{
|
||||
return (m_Iter != where);
|
||||
}
|
||||
bool operator ==(const typename List<T>::iterator &where) const
|
||||
{
|
||||
return (m_Iter == where);
|
||||
}
|
||||
|
||||
ListCatIterator & operator = (const typename List<T>::iterator &where)
|
||||
{
|
||||
m_Iter = where;
|
||||
|
||||
if (m_pListLeft && m_Iter == m_pListLeft->end())
|
||||
{
|
||||
if (m_pListRight)
|
||||
m_Iter = m_pListRight->begin();
|
||||
|
||||
// :HACK HACK: RemoveHookById is not aware of ListCatIterator (yet? :TODO: Change it!)
|
||||
// So we have to do this here... (look for the "Move all iterators pointing at this" section)
|
||||
--m_Iter;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ListCatIterator & operator = (const ListCatIterator<T> &other)
|
||||
{
|
||||
m_Iter = other.m_Iter;
|
||||
m_pListLeft = other.m_pListLeft;
|
||||
m_pListRight = other.m_pListRight;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SetListLeft(List<T> *pList)
|
||||
{
|
||||
m_pListLeft = pList;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define _INCLUDE_UTIL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sourcehook/sourcehook.h>
|
||||
#include "sourcehook/sourcehook.h"
|
||||
|
||||
/**
|
||||
* @brief Utility functions
|
||||
|
Loading…
Reference in New Issue
Block a user