From 1efbb0f65e484e2641e2719dca70387b0729db85 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 13 Aug 2004 10:41:39 +0000 Subject: [PATCH] Updated AMXX Template Library --- dlls/engine/CString.h | 45 +++++++++++++++++++++++++++++++++++++++++++ dlls/engine/CVector.h | 10 ++++++---- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/dlls/engine/CString.h b/dlls/engine/CString.h index c5e315bc..b6e95f1e 100755 --- a/dlls/engine/CString.h +++ b/dlls/engine/CString.h @@ -1,3 +1,34 @@ +/* AMX Mod X +* +* by the AMX Mod X Development Team +* originally developed by OLO +* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +*/ + #ifndef _INCLUDE_CSTRING_H #define _INCLUDE_CSTRING_H @@ -8,7 +39,12 @@ public: CString() { v = NULL; mSize = 0; } ~CString() { if (v) delete [] v; } + //added these for amxx + CString(const char *src) { v = NULL; mSize = 0; assign(src); } + CString(CString &src) { v = NULL; mSize = 0; assign(src.c_str()); } + const char *c_str() { return v?v:""; } + const char *c_str() const { return v?v:""; } void append(const char *t) { @@ -61,6 +97,15 @@ public: } } + //Added this for amxx inclusion + bool empty() + { + if (!v || !mSize) + return true; + + return false; + } + int size() { if (!v) diff --git a/dlls/engine/CVector.h b/dlls/engine/CVector.h index cdb49355..ae05c66a 100755 --- a/dlls/engine/CVector.h +++ b/dlls/engine/CVector.h @@ -76,7 +76,7 @@ template class CVector delete [] m_Data; } if (m_Size < size) - m_CurrentUsedSize = size; + m_CurrentSize = size; m_Data = newData; m_Size = size; return true; @@ -90,6 +90,7 @@ protected: T *m_Data; size_t m_Size; size_t m_CurrentUsedSize; + size_t m_CurrentSize; public: class iterator { @@ -397,7 +398,7 @@ public: if (where != m_Data) --where; // validate iter - if (where < m_Data || where >= (m_Data + m_CurrentSize)) + if (where < m_Data || where >= (m_Data + m_CurrentUsedSize)) return false; ++m_CurrentUsedSize; @@ -415,7 +416,7 @@ public: void erase(iterator where) { // validate iter - if (where < m_Data || where >= (m_Data + m_CurrentSize)) + if (where < m_Data || where >= (m_Data + m_CurrentUsedSize)) return false; if (m_CurrentUsedSize > 1) @@ -437,4 +438,5 @@ public: } }; -#endif // __CVECTOR_H__ \ No newline at end of file +#endif // __CVECTOR_H__ +