Update sqlite module project files and use AMTL.

This commit is contained in:
Arkshine 2014-08-10 17:24:38 +02:00
parent ab16be08f5
commit 3f6ad29f55
18 changed files with 57 additions and 7079 deletions

View File

@ -9,7 +9,7 @@ binary.compiler.cxxincludes += [
]
binary.compiler.defines += [
'SM_DEFAULT_THREADER',
'stricmp=strcasecmp',
'HAVE_STDINT_H',
]
if builder.target_platform == 'linux':
@ -20,7 +20,7 @@ binary.sources += [
'handles.cpp',
'module.cpp',
'threading.cpp',
'sdk/amxxmodule.cpp',
'../../public/sdk/amxxmodule.cpp',
'oldcompat_sql.cpp',
'thread/BaseWorker.cpp',
'thread/ThreadWorker.cpp',

View File

@ -7,6 +7,7 @@
HLSDK = ../../../hlsdk
MM_ROOT = ../../../metamod/metamod
PUBLIC_ROOT = ../../public
SQL = sqlite-source
#####################################
@ -15,7 +16,7 @@ SQL = sqlite-source
PROJECT = sqlite
OBJECTS = basic_sql.cpp handles.cpp module.cpp threading.cpp sdk/amxxmodule.cpp oldcompat_sql.cpp \
OBJECTS = basic_sql.cpp handles.cpp module.cpp threading.cpp amxxmodule.cpp oldcompat_sql.cpp \
thread/BaseWorker.cpp thread/ThreadWorker.cpp thread/PosixThreads.cpp \
sqlitepp/SqliteQuery.cpp sqlitepp/SqliteResultSet.cpp sqlitepp/SqliteDatabase.cpp \
sqlitepp/SqliteDriver.cpp
@ -41,8 +42,10 @@ CPP_OSX = clang
LINK =
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared \
-I$(HLSDK)/public -I$(MM_ROOT) -I$(SQL) -Isqlitepp -Ithread -Isdk
INCLUDE = -I. -I$(PUBLIC_ROOT) -I$(PUBLIC_ROOT)/sdk -I$(PUBLIC_ROOT)/amtl \
-I$(HLSDK) -I$(HLSDK)/public -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/pm_shared\
-I$(SQL) -Isqlitepp -Ithread \
-I$(MM_ROOT)
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
@ -127,10 +130,10 @@ $(BIN_DIR)/%.o: %.c
all:
mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)/sdk
mkdir -p $(BIN_DIR)/thread
mkdir -p $(BIN_DIR)/sqlitepp
mkdir -p $(BIN_DIR)/$(SQL)
ln -sf $(PUBLIC_ROOT)/sdk/amxxmodule.cpp
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
$(PROJECT): $(OBJ_BIN)
@ -143,7 +146,6 @@ default: all
clean:
rm -rf $(BIN_DIR)/*.o
rm -rf $(BIN_DIR)/sdk/*.o
rm -rf $(BIN_DIR)/thread/*.o
rm -rf $(BIN_DIR)/sqlitepp/*.o
rm -rf $(BIN_DIR)/$(SQL)/*.o

View File

@ -16,9 +16,6 @@
#include "sqlite_header.h"
#include "sqlheaders.h"
using namespace SourceMod;
using namespace SourceHook;
SqliteDriver g_Sqlite;
void FreeConnection(void *p, unsigned int num)

View File

@ -12,8 +12,8 @@
//
#include <string.h>
#include "sh_stack.h"
#include "CVector.h"
#include <sh_stack.h>
#include <am-vector.h>
#include "sqlite_header.h"
struct QHandle
@ -24,7 +24,7 @@ struct QHandle
bool isfree;
};
CVector<QHandle *> g_Handles;
ke::Vector<QHandle *> g_Handles;
CStack<unsigned int> g_FreeHandles;
unsigned int MakeHandle(void *ptr, HandleType type, FREEHANDLE f)
@ -39,8 +39,8 @@ unsigned int MakeHandle(void *ptr, HandleType type, FREEHANDLE f)
h = g_Handles[num];
} else {
h = new QHandle;
g_Handles.push_back(h);
num = static_cast<unsigned int>(g_Handles.size()) - 1;
g_Handles.append(h);
num = static_cast<unsigned int>(g_Handles.length()) - 1;
}
h->_ptr = ptr;
@ -57,7 +57,7 @@ void *GetHandle(unsigned int num, HandleType type)
return NULL;
num--;
if (num >= g_Handles.size())
if (num >= g_Handles.length())
return NULL;
QHandle *h = g_Handles[num];
@ -75,7 +75,7 @@ bool FreeHandle(unsigned int num)
unsigned int _num = num;
num--;
if (num >= g_Handles.size())
if (num >= g_Handles.length())
return false;
QHandle *h = g_Handles[num];
@ -95,7 +95,7 @@ bool FreeHandle(unsigned int num)
void FreeAllHandles(HandleType type)
{
QHandle *q;
for (size_t i = 0; i < g_Handles.size(); i++)
for (size_t i = 0; i < g_Handles.length(); i++)
{
q = g_Handles[i];
if (q && !q->isfree && q->type == type)
@ -108,7 +108,7 @@ void FreeAllHandles(HandleType type)
void FreeHandleTable()
{
QHandle *q;
for (size_t i = 0; i < g_Handles.size(); i++)
for (size_t i = 0; i < g_Handles.length(); i++)
{
q = g_Handles[i];
if (q && !q->isfree)

View File

View File

@ -53,8 +53,8 @@
<ClCompile>
<AdditionalOptions>/D "NO_TCL" %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\;..\sdk;..\sqlite-source;..\sqlitepp;..\thread;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;sqlite_EXPORTS;SM_DEFAULT_THREADER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk; ..\..\..\public\amtl;..\sqlite-source;..\sqlitepp;..\thread;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;sqlite_EXPORTS;SM_DEFAULT_THREADER;HAVE_STDINT_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -82,8 +82,8 @@
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\;..\sdk;..\sqlite-source;..\sqlitepp;..\thread;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;sqlite_EXPORTS;SM_DEFAULT_THREADER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk; ..\..\..\public\amtl;..\sqlite-source;..\sqlitepp;..\thread;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;sqlite_EXPORTS;SM_DEFAULT_THREADER;HAVE_STDINT_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StructMemberAlignment>4Bytes</StructMemberAlignment>
@ -157,12 +157,11 @@
<ClCompile Include="..\sqlite-source\vdbemem.c" />
<ClCompile Include="..\sqlite-source\vtab.c" />
<ClCompile Include="..\sqlite-source\where.c" />
<ClCompile Include="..\sdk\amxxmodule.cpp" />
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\sqlheaders.h" />
<ClInclude Include="..\sqlite_header.h" />
<ClInclude Include="..\svn_version.h" />
<ClInclude Include="..\threading.h" />
<ClInclude Include="..\sqlitepp\ISQLDriver.h" />
<ClInclude Include="..\sqlitepp\SqliteDatabase.h" />
@ -189,9 +188,8 @@
<ClInclude Include="..\sqlite-source\sqliteInt.h" />
<ClInclude Include="..\sqlite-source\vdbe.h" />
<ClInclude Include="..\sqlite-source\vdbeInt.h" />
<ClInclude Include="..\sdk\moduleconfig.h" />
<ClInclude Include="..\sdk\sh_list.h" />
<ClInclude Include="..\sdk\amxxmodule.h" />
<ClInclude Include="..\moduleconfig.h" />
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\plugins\include\sqlx.inc" />

View File

@ -33,9 +33,6 @@
<Filter Include="Module SDK">
<UniqueIdentifier>{b24e595e-f6a9-4358-bbe3-094ef6383e53}</UniqueIdentifier>
</Filter>
<Filter Include="Module SDK\AMXX STL">
<UniqueIdentifier>{a5586883-461e-4f33-a5df-d7a9226a4cb2}</UniqueIdentifier>
</Filter>
<Filter Include="Module SDK\SDK Base">
<UniqueIdentifier>{c60d3c45-e23b-4c5a-aae2-2c3c5441bac6}</UniqueIdentifier>
</Filter>
@ -203,7 +200,7 @@
<ClCompile Include="..\sqlite-source\where.c">
<Filter>SQLite Source</Filter>
</ClCompile>
<ClCompile Include="..\sdk\amxxmodule.cpp">
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp">
<Filter>Module SDK\SDK Base</Filter>
</ClCompile>
</ItemGroup>
@ -214,9 +211,6 @@
<ClInclude Include="..\sqlite_header.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\svn_version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\threading.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -295,15 +289,12 @@
<ClInclude Include="..\sqlite-source\vdbeInt.h">
<Filter>SQLite Source</Filter>
</ClInclude>
<ClInclude Include="..\sdk\moduleconfig.h">
<Filter>Module SDK</Filter>
</ClInclude>
<ClInclude Include="..\sdk\sh_list.h">
<Filter>Module SDK\AMXX STL</Filter>
</ClInclude>
<ClInclude Include="..\sdk\amxxmodule.h">
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h">
<Filter>Module SDK\SDK Base</Filter>
</ClInclude>
<ClInclude Include="..\moduleconfig.h">
<Filter>Module SDK</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\plugins\include\sqlx.inc">

View File

@ -1,480 +0,0 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#ifndef __CVECTOR_H__
#define __CVECTOR_H__
#include <assert.h>
// Vector
template <class T> class CVector
{
bool Grow(size_t amount)
{
// automatic grow
size_t newSize = m_Size * 2;
if (newSize == 0)
{
newSize = 8;
}
while (m_CurrentUsedSize + amount > newSize)
{
newSize *= 2;
}
T *newData = new T[newSize];
if (!newData)
return false;
if (m_Data)
{
for (size_t i=0; i<m_CurrentUsedSize; i++)
newData[i] = m_Data[i];
delete [] m_Data;
}
m_Data = newData;
m_Size = newSize;
return true;
}
bool GrowIfNeeded(size_t amount)
{
if (m_CurrentUsedSize + amount >= m_Size)
{
return Grow(amount);
}
else
{
return true;
}
}
bool ChangeSize(size_t size)
{
// change size
if (size == m_Size)
return true;
if (!size)
{
if (m_Data)
{
delete [] m_Data;
m_Data = NULL;
m_Size = 0;
}
return true;
}
T *newData = new T[size];
if (!newData)
return false;
if (m_Data)
{
size_t end = (m_CurrentUsedSize < size) ? (m_CurrentUsedSize) : size;
for (size_t i=0; i<end; i++)
newData[i] = m_Data[i];
delete [] m_Data;
}
m_Data = newData;
m_Size = size;
if (m_CurrentUsedSize > m_Size)
m_CurrentUsedSize = m_Size;
return true;
}
void FreeMemIfPossible()
{
if (!m_Data)
return;
if (!m_CurrentUsedSize)
{
ChangeSize(0);
return;
}
size_t newSize = m_Size;
while (m_CurrentUsedSize <= newSize / 2)
newSize /= 2;
if (newSize != m_Size)
ChangeSize(newSize);
}
protected:
T *m_Data;
size_t m_Size;
size_t m_CurrentUsedSize;
public:
class iterator
{
protected:
T *m_Ptr;
public:
// constructors / destructors
iterator()
{
m_Ptr = NULL;
}
iterator(T * ptr)
{
m_Ptr = ptr;
}
// member functions
T * base()
{
return m_Ptr;
}
const T * base() const
{
return m_Ptr;
}
// operators
T & operator*()
{
return *m_Ptr;
}
T * operator->()
{
return m_Ptr;
}
iterator & operator++() // preincrement
{
++m_Ptr;
return (*this);
}
iterator operator++(int) // postincrement
{
iterator tmp = *this;
++m_Ptr;
return tmp;
}
iterator & operator--() // predecrement
{
--m_Ptr;
return (*this);
}
iterator operator--(int) // postdecrememnt
{
iterator tmp = *this;
--m_Ptr;
return tmp;
}
bool operator==(T * right) const
{
return (m_Ptr == right);
}
bool operator==(const iterator & right) const
{
return (m_Ptr == right.m_Ptr);
}
bool operator!=(T * right) const
{
return (m_Ptr != right);
}
bool operator!=(const iterator & right) const
{
return (m_Ptr != right.m_Ptr);
}
iterator & operator+=(size_t offset)
{
m_Ptr += offset;
return (*this);
}
iterator & operator-=(size_t offset)
{
m_Ptr -= offset;
return (*this);
}
iterator operator+(size_t offset) const
{
iterator tmp(*this);
tmp.m_Ptr += offset;
return tmp;
}
iterator operator-(size_t offset) const
{
iterator tmp(*this);
tmp.m_Ptr -= offset;
return tmp;
}
T & operator[](size_t offset)
{
return (*(*this + offset));
}
const T & operator[](size_t offset) const
{
return (*(*this + offset));
}
bool operator<(const iterator & right) const
{
return m_Ptr < right.m_Ptr;
}
bool operator>(const iterator & right) const
{
return m_Ptr > right.m_Ptr;
}
bool operator<=(const iterator & right) const
{
return m_Ptr <= right.m_Ptr;
}
bool operator>=(const iterator & right) const
{
return m_Ptr >= right.m_Ptr;
}
size_t operator-(const iterator & right) const
{
return m_Ptr - right.m_Ptr;
}
};
// constructors / destructors
CVector<T>()
{
m_Size = 0;
m_CurrentUsedSize = 0;
m_Data = NULL;
}
CVector<T>(const CVector<T> & other)
{
// copy data
m_Data = new T [other.m_CurrentUsedSize];
m_Size = other.m_CurrentUsedSize;
m_CurrentUsedSize = other.m_CurrentUsedSize;
for (size_t i=0; i<other.m_CurrentUsedSize; i++)
m_Data[i] = other.m_Data[i];
}
~CVector<T>()
{
clear();
}
// interface
size_t size() const
{
return m_CurrentUsedSize;
}
size_t capacity() const
{
return m_Size;
}
iterator begin() const
{
return iterator(m_Data);
}
iterator end() const
{
return iterator(m_Data + m_CurrentUsedSize);
}
iterator iterAt(size_t pos)
{
if (pos > m_CurrentUsedSize)
assert(0);
return iterator(m_Data + pos);
}
bool reserve(size_t newSize)
{
if (newSize > m_Size)
return ChangeSize(newSize);
return true;
}
bool push_back(const T & elem)
{
if (!GrowIfNeeded(1))
{
return false;
}
m_Data[m_CurrentUsedSize++] = elem;
return true;
}
void pop_back()
{
--m_CurrentUsedSize;
if (m_CurrentUsedSize < 0)
m_CurrentUsedSize = 0;
FreeMemIfPossible();
}
bool resize(size_t newSize)
{
if (!ChangeSize(newSize))
return false;
m_CurrentUsedSize = newSize;
return true;
}
bool empty() const
{
return (m_CurrentUsedSize == 0);
}
T & at(size_t pos)
{
if (pos > m_CurrentUsedSize)
{
assert(0);
}
return m_Data[pos];
}
const T & at(size_t pos) const
{
if (pos > m_CurrentUsedSize)
{
assert(0);
}
return m_Data[pos];
}
T & operator[](size_t pos)
{
return at(pos);
}
const T & operator[](size_t pos) const
{
return at(pos);
}
T & front()
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[0];
}
const T & front() const
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[0];
}
T & back()
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
const T & back() const
{
if (m_CurrentUsedSize < 1)
{
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
iterator insert(iterator where, const T & value)
{
// validate iter
if (where < m_Data || where > (m_Data + m_CurrentUsedSize))
return iterator(0);
size_t ofs = where - begin();
if (!GrowIfNeeded(1))
{
return false;
}
++m_CurrentUsedSize;
where = begin() + ofs;
// Move subsequent entries
for (T *ptr = m_Data + m_CurrentUsedSize - 2; ptr >= where.base(); --ptr)
*(ptr + 1) = *ptr;
*where.base() = value;
return where;
}
iterator erase(iterator where)
{
// validate iter
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
return iterator(0);
size_t ofs = where - begin();
if (m_CurrentUsedSize > 1)
{
// move
T *theend = m_Data + m_CurrentUsedSize;
for (T *ptr = where.base() + 1; ptr < theend; ++ptr)
*(ptr - 1) = *ptr;
}
--m_CurrentUsedSize;
FreeMemIfPossible();
return begin() + ofs;
}
void clear()
{
m_Size = 0;
m_CurrentUsedSize = 0;
if (m_Data)
{
delete [] m_Data;
m_Data = NULL;
}
}
};
#endif // __CVECTOR_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,298 +0,0 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2005 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
*
* Author(s): David "BAILOPAN" Anderson
* ============================
*/
#ifndef _INCLUDE_SMM_LIST_H
#define _INCLUDE_SMM_LIST_H
// MSVC8 fix for offsetof macro redefition warnings
#ifdef _MSC_VER
#if _MSC_VER >= 1400
#undef offsetof
#endif
#endif
#include <new>
#include <stdlib.h>
namespace SourceHook
{
//This class is from CSDM for AMX Mod X
/*
A circular, doubly-linked list with one sentinel node
Empty:
m_Head = sentinel
m_Head->next = m_Head;
m_Head->prev = m_Head;
One element:
m_Head = sentinel
m_Head->next = node1
m_Head->prev = node1
node1->next = m_Head
node1->prev = m_Head
Two elements:
m_Head = sentinel
m_Head->next = node1
m_Head->prev = node2
node1->next = node2
node1->prev = m_Head
node2->next = m_Head
node2->prev = node1
*/
template <class T>
class List
{
public:
class iterator;
friend class iterator;
class ListNode
{
public:
ListNode(const T & o) : obj(o) { };
ListNode() { };
T obj;
ListNode *next;
ListNode *prev;
};
private:
// Initializes the sentinel node.
// BAIL used malloc instead of new in order to bypass the need for a constructor.
ListNode *_Initialize()
{
ListNode *n = (ListNode *)malloc(sizeof(ListNode));
n->next = n;
n->prev = n;
return n;
}
public:
List() : m_Head(_Initialize()), m_Size(0)
{
}
List(const List &src) : m_Head(_Initialize()), m_Size(0)
{
iterator iter;
for (iter=src.begin(); iter!=src.end(); iter++)
push_back( (*iter) );
}
~List()
{
clear();
// Don't forget to free the sentinel
if (m_Head)
{
free(m_Head);
m_Head = NULL;
}
}
void push_back(const T &obj)
{
ListNode *node = new ListNode(obj);
node->prev = m_Head->prev;
node->next = m_Head;
m_Head->prev->next = node;
m_Head->prev = node;
m_Size++;
}
size_t size()
{
return m_Size;
}
void clear()
{
ListNode *node = m_Head->next;
ListNode *temp;
m_Head->next = m_Head;
m_Head->prev = m_Head;
// Iterate through the nodes until we find g_Head (the sentinel) again
while (node != m_Head)
{
temp = node->next;
delete node;
node = temp;
}
m_Size = 0;
}
bool empty()
{
return (m_Size == 0);
}
T & back()
{
return m_Head->prev->obj;
}
private:
ListNode *m_Head;
size_t m_Size;
public:
class iterator
{
friend class List;
public:
iterator()
{
m_This = NULL;
}
iterator(const List &src)
{
m_This = src.m_Head;
}
iterator(ListNode *n) : m_This(n)
{
}
iterator(const iterator &where)
{
m_This = where.m_This;
}
//pre decrement
iterator & operator--()
{
if (m_This)
m_This = m_This->prev;
return *this;
}
//post decrement
iterator operator--(int)
{
iterator old(*this);
if (m_This)
m_This = m_This->prev;
return old;
}
//pre increment
iterator & operator++()
{
if (m_This)
m_This = m_This->next;
return *this;
}
//post increment
iterator operator++(int)
{
iterator old(*this);
if (m_This)
m_This = m_This->next;
return old;
}
const T & operator * () const
{
return m_This->obj;
}
T & operator * ()
{
return m_This->obj;
}
T * operator -> ()
{
return &(m_This->obj);
}
const T * operator -> () const
{
return &(m_This->obj);
}
bool operator != (const iterator &where) const
{
return (m_This != where.m_This);
}
bool operator ==(const iterator &where) const
{
return (m_This == where.m_This);
}
private:
ListNode *m_This;
};
public:
iterator begin() const
{
return iterator(m_Head->next);
}
iterator end() const
{
return iterator(m_Head);
}
iterator erase(iterator &where)
{
ListNode *pNode = where.m_This;
iterator iter(where);
iter++;
// Works for all cases: empty list, erasing first element, erasing tail, erasing in the middle...
pNode->prev->next = pNode->next;
pNode->next->prev = pNode->prev;
delete pNode;
m_Size--;
return iter;
}
iterator insert(iterator where, const T &obj)
{
// Insert obj right before where
ListNode *node = new ListNode(obj);
ListNode *pWhereNode = where.m_This;
pWhereNode->prev->next = node;
node->prev = pWhereNode->prev;
pWhereNode->prev = node;
node->next = pWhereNode;
m_Size++;
return iterator(node);
}
public:
void remove(const T & obj)
{
iterator b;
for (b=begin(); b!=end(); b++)
{
if ( (*b) == obj )
{
erase( b );
break;
}
}
}
template <typename U>
iterator find(const U & equ)
{
iterator iter;
for (iter=begin(); iter!=end(); iter++)
{
if ( (*iter) == equ )
return iter;
}
return end();
}
List & operator =(const List &src)
{
clear();
iterator iter;
for (iter=src.begin(); iter!=src.end(); iter++)
push_back( (*iter) );
return *this;
}
};
}; //NAMESPACE
#endif //_INCLUDE_CSDM_LIST_H

View File

@ -1,219 +0,0 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2005 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
*
* Author(s): Pavol "PM OnoTo" Marko
* ============================
*/
#ifndef __SH_STACK_H__
#define __SH_STACK_H__
#define SH_STACK_DEFAULT_SIZE 4
//namespace SourceHook
//{/
// Vector
template <class T> class CStack
{
T *m_Elements;
size_t m_AllocatedSize;
size_t m_UsedSize;
public:
friend class iterator;
class iterator
{
CStack<T> *m_pParent;
size_t m_Index;
public:
iterator(CStack<T> *pParent, size_t id) : m_pParent(pParent), m_Index(id)
{
}
iterator(CStack<T> *pParent) : m_pParent(pParent), m_Index(0)
{
}
iterator() : m_pParent(NULL), m_Index(0)
{
}
T &operator *()
{
return m_pParent->m_Elements[m_Index];
}
const T &operator *() const
{
return m_pParent->m_Elements[m_Index];
}
T * operator->()
{
return m_pParent->m_Elements + m_Index;
}
const T * operator->() const
{
return m_pParent->m_Elements + m_Index;
}
iterator & operator++() // preincrement
{
++m_Index;
return (*this);
}
iterator operator++(int) // postincrement
{
iterator tmp = *this;
++m_Index;
return tmp;
}
iterator & operator--() // predecrement
{
--m_Index;
return (*this);
}
iterator operator--(int) // postdecrememnt
{
iterator tmp = *this;
--m_Index;
return tmp;
}
bool operator==(const iterator & right) const
{
return (m_pParent == right.m_pParent && m_Index == right.m_Index);
}
bool operator!=(const iterator & right) const
{
return !(*this == right);
}
};
CStack() : m_Elements(new T[SH_STACK_DEFAULT_SIZE]),
m_AllocatedSize(SH_STACK_DEFAULT_SIZE),
m_UsedSize(0)
{
}
CStack(size_t size) : m_Elements(new T[size]),
m_AllocatedSize(size),
m_UsedSize(0)
{
}
CStack(const CStack &other) : m_Elements(NULL),
m_AllocatedSize(0),
m_UsedSize(0)
{
reserve(other.m_AllocatedSize);
m_UsedSize = other.m_UsedSize;
for (size_t i = 0; i < m_UsedSize; ++i)
m_Elements[i] = other.m_Elements[i];
}
~CStack()
{
if (m_Elements)
delete [] m_Elements;
}
void operator=(const CStack &other)
{
if (m_AllocatedSize < other.m_AllocatedSize)
{
if (m_Elements)
delete [] m_Elements;
m_Elements = new T[other.m_AllocatedSize];
m_AllocatedSize = other.m_AllocatedSize;
}
m_UsedSize = other.m_UsedSize;
for (size_t i = 0; i < m_UsedSize; ++i)
m_Elements[i] = other.m_Elements[i];
}
bool push(const T &val)
{
if (m_UsedSize + 1 == m_AllocatedSize)
{
// zOHNOES! REALLOCATE!
m_AllocatedSize *= 2;
T *newElements = new T[m_AllocatedSize];
if (!newElements)
{
m_AllocatedSize /= 2;
return false;
}
if (m_Elements)
{
for (size_t i = 0; i < m_UsedSize; ++i)
newElements[i] = m_Elements[i];
delete [] m_Elements;
}
m_Elements = newElements;
}
m_Elements[m_UsedSize++] = val;
return true;
}
void pop()
{
--m_UsedSize;
}
T &front()
{
return m_Elements[m_UsedSize - 1];
}
const T &front() const
{
return m_Elements[m_UsedSize - 1];
}
iterator begin()
{
return iterator(this, 0);
}
iterator end()
{
return iterator(this, m_UsedSize);
}
size_t size()
{
return m_UsedSize;
}
size_t capacity()
{
return m_AllocatedSize;
}
bool empty()
{
return m_UsedSize == 0 ? true : false;
}
bool reserve(size_t size)
{
if (size > m_AllocatedSize)
{
T *newElements = new T[size];
if (!newElements)
return false;
if (m_Elements)
{
for (size_t i = 0; i < m_UsedSize; ++i)
newElements[i] = m_Elements[i];
delete [] m_Elements;
}
m_Elements = newElements;
m_AllocatedSize = size;
}
return true;
}
};
//}; //namespace SourceHook
#endif

View File

@ -1,367 +0,0 @@
/* ======== SourceMM ========
* Copyright (C) 2004-2005 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
*
* Author(s): David "BAILOPAN" Anderson
* ============================
*/
/* AMX Mod X
*
* by the AMX Mod X Development Team
*/
#ifndef _INCLUDE_CSTRING_H
#define _INCLUDE_CSTRING_H
#include <string.h>
#include <stdio.h>
namespace SourceHook
{
class String
{
public:
String()
{
v = NULL;
a_size = 0;
//assign("");
}
~String()
{
if (v)
delete [] v;
}
String(const char *src)
{
v = NULL;
a_size = 0;
assign(src);
}
String(const String &src)
{
v = NULL;
a_size = 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)
{
Grow(size() + strlen(t) + 1);
strcat(v, t);
}
void append(const char c)
{
size_t len = size();
Grow(len + 2);
v[len] = c;
v[len + 1] = '\0';
}
void append(String &d)
{
append(d.c_str());
}
void assign(const String &src)
{
assign(src.c_str());
}
void assign(const char *d)
{
if (!d)
{
clear();
} else {
Grow(strlen(d) + 1, false);
strcpy(v, d);
}
}
void clear()
{
if (v)
v[0] = '\0';
}
int compare (const char *d)
{
if (!v)
return strcmp("", d);
else
return strcmp(v, d);
}
//Added this for amxx inclusion
bool empty()
{
if (!v)
return true;
if (v[0] == '\0')
return true;
return false;
}
size_t size()
{
if (v)
return strlen(v);
else
return 0;
}
int find(const char c, int index = 0)
{
int len = static_cast<int>(size());
if (len < 1)
return npos;
if (index >= len || index < 0)
return npos;
int i = 0;
for (i=index; i<len; i++)
{
if (v[i] == c)
{
return i;
}
}
return npos;
}
bool is_space(int c)
{
if (c == '\f' || c == '\n' ||
c == '\t' || c == '\r' ||
c == '\v' || c == ' ')
{
return true;
}
return false;
}
void trim()
{
if (!v)
return;
unsigned int i = 0;
unsigned int j = 0;
size_t len = strlen(v);
if (len == 1)
{
if (is_space(v[i]))
{
clear();
return;
}
}
unsigned char c0 = v[0];
if (is_space(c0))
{
for (i=0; i<len; i++)
{
if (!is_space(v[i]) || (is_space(v[i]) && ((unsigned char)i==len-1)))
{
erase(0, i);
break;
}
}
}
len = strlen(v);
if (len < 1)
{
return;
}
if (is_space(v[len-1]))
{
for (i=len-1; i<len; i--)
{
if (!is_space(v[i])
|| (is_space(v[i]) && i==0))
{
erase(i+1, j);
break;
}
j++;
}
}
if (len == 1)
{
if (is_space(v[0]))
{
clear();
return;
}
}
}
void erase(unsigned int start, int num = npos)
{
if (!v)
return;
unsigned int i = 0;
size_t len = size();
//check for bounds
if (num == npos || start+num > len-start)
num = len - start;
//do the erasing
bool copyflag = false;
for (i=0; i<len; i++)
{
if (i>=start && i<start+num)
{
if (i+num < len)
{
v[i] = v[i+num];
} else {
v[i] = 0;
}
copyflag = true;
} else if (copyflag) {
if (i+num < len)
{
v[i] = v[i+num];
} else {
v[i] = 0;
}
}
}
len -= num;
v[len] = 0;
}
String substr(unsigned int index, int num = npos)
{
if (!v)
{
String b("");
return b;
}
String ns;
size_t len = size();
if (index >= len || !v)
return ns;
if (num == npos)
{
num = len - index;
} else if (index+num >= len) {
num = len - index;
}
unsigned int i = 0;
unsigned int nslen = num + 2;
ns.Grow(nslen);
for (i=index; i<index+num; i++)
ns.append(v[i]);
return ns;
}
void toLower()
{
if (!v)
return;
unsigned int i = 0;
size_t len = strlen(v);
for (i=0; i<len; i++)
{
if (v[i] >= 65 && v[i] <= 90)
v[i] &= ~(1<<5);
}
}
String & operator = (const String &src)
{
assign(src);
return *this;
}
String & operator = (const char *src)
{
assign(src);
return *this;
}
char operator [] (unsigned int index)
{
if (index > size() || !v)
{
return -1;
} else {
return v[index];
}
}
int at(int a)
{
if (a < 0 || a >= (int)size() || !v)
return -1;
return v[a];
}
bool at(int at, char c)
{
if (at < 0 || at >= (int)size() || !v)
return false;
v[at] = c;
return true;
}
private:
void Grow(unsigned int d, bool copy=true)
{
if (d <= a_size)
return;
char *n = new char[d + 1];
if (copy && v)
strcpy(n, v);
if (v)
delete [] v;
else
strcpy(n, "");
v = n;
a_size = d + 1;
}
char *v;
unsigned int a_size;
public:
static const int npos = -1;
};
}; //NAMESPACE
#endif //_INCLUDE_CSTRING_H

View File

@ -16,7 +16,7 @@
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
#if defined _MSC_VER && _MSC_VER >= 1400
#if defined _MSC_VER && _MSC_VER >= 1400 && !defined _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif

View File

@ -86,7 +86,7 @@ SWThreadHandle *BaseWorker::PopThreadFromQueue()
if (!m_ThreadQueue.size())
return NULL;
SourceHook::List<SWThreadHandle *>::iterator begin;
List<SWThreadHandle *>::iterator begin;
SWThreadHandle *swt;
begin = m_ThreadQueue.begin();

View File

@ -10,7 +10,7 @@
#ifndef _INCLUDE_SOURCEMOD_BASEWORKER_H
#define _INCLUDE_SOURCEMOD_BASEWORKER_H
#include "sh_list.h"
#include <sh_list.h>
#include "ThreadSupport.h"
#define SM_DEFAULT_THREADS_PER_FRAME 1
@ -73,7 +73,7 @@ public: //BaseWorker
virtual void SetMaxThreadsPerFrame(unsigned int threads);
virtual unsigned int GetMaxThreadsPerFrame();
protected:
SourceHook::List<SWThreadHandle *> m_ThreadQueue;
List<SWThreadHandle *> m_ThreadQueue;
unsigned int m_perFrame;
volatile WorkerState m_state;
};

View File

@ -14,9 +14,7 @@
#include "amxxmodule.h"
#include "sqlite_header.h"
#include "threading.h"
using namespace SourceMod;
using namespace SourceHook;
#include <am-string.h>
MainThreader g_Threader;
ThreadWorker *g_pWorker = NULL;
@ -141,20 +139,20 @@ void MysqlThread::SetForward(int forward)
void MysqlThread::SetInfo(const char *db)
{
m_db.assign(db);
m_db = db;
m_qrInfo.queue_time = gpGlobals->time;
}
void MysqlThread::SetQuery(const char *query)
{
m_query.assign(query);
m_query = query;
}
void MysqlThread::RunThread(IThreadHandle *pHandle)
{
DatabaseInfo info;
info.database = m_db.c_str();
info.database = m_db.chars();
info.pass = "";
info.user = "";
info.host = "";
@ -174,7 +172,7 @@ void MysqlThread::RunThread(IThreadHandle *pHandle)
m_qrInfo.query_success = false;
} else {
m_qrInfo.connect_success = true;
pQuery = pDatabase->PrepareQuery(m_query.c_str());
pQuery = pDatabase->PrepareQuery(m_query.chars());
if (!pQuery->Execute2(&m_qrInfo.amxinfo.info, m_qrInfo.amxinfo.error, 254))
{
m_qrInfo.query_success = false;
@ -193,8 +191,8 @@ void MysqlThread::RunThread(IThreadHandle *pHandle)
{
m_qrInfo.amxinfo.pQuery = pQuery;
} else {
m_qrInfo.amxinfo.opt_ptr = new char[m_query.size() + 1];
strcpy(m_qrInfo.amxinfo.opt_ptr, m_query.c_str());
m_qrInfo.amxinfo.opt_ptr = new char[m_query.length() + 1];
strcpy(m_qrInfo.amxinfo.opt_ptr, m_query.chars());
}
if (pDatabase)
@ -418,7 +416,7 @@ bool AtomicResult::FieldNameToNum(const char *name, unsigned int *columnId)
for (unsigned int i=0; i<m_FieldCount; i++)
{
assert(m_Table[i] != NULL);
if (strcmp(m_Table[i]->c_str(), name) == 0)
if (strcmp(m_Table[i]->chars(), name) == 0)
{
if (columnId)
{
@ -438,7 +436,7 @@ const char *AtomicResult::FieldNumToName(unsigned int num)
assert(m_Table[num] != NULL);
return m_Table[num]->c_str();
return m_Table[num]->chars();
}
double AtomicResult::GetDouble(unsigned int columnId)
@ -479,7 +477,7 @@ const char *AtomicResult::GetString(unsigned int columnId)
assert(m_Table[idx] != NULL);
return m_Table[idx]->c_str();
return m_Table[idx]->chars();
}
IResultRow *AtomicResult::GetRow()
@ -529,11 +527,11 @@ void AtomicResult::CopyFrom(IResultSet *rs)
size_t newTotal = (m_RowCount * m_FieldCount) + m_FieldCount;
if (newTotal > m_AllocSize)
{
SourceHook::String **table = new SourceHook::String *[newTotal];
memset(table, 0, newTotal * sizeof(SourceHook::String *));
ke::AString **table = new ke::AString *[newTotal];
memset(table, 0, newTotal * sizeof(ke::AString *));
if (m_Table)
{
memcpy(table, m_Table, m_AllocSize * sizeof(SourceHook::String *));
memcpy(table, m_Table, m_AllocSize * sizeof(ke::AString *));
delete [] m_Table;
}
m_Table = table;
@ -544,9 +542,9 @@ void AtomicResult::CopyFrom(IResultSet *rs)
{
if (m_Table[i])
{
m_Table[i]->assign(rs->FieldNumToName(i));
*m_Table[i] = rs->FieldNumToName(i);
} else {
m_Table[i] = new SourceHook::String(rs->FieldNumToName(i));
m_Table[i] = new ke::AString(rs->FieldNumToName(i));
}
}
@ -559,9 +557,9 @@ void AtomicResult::CopyFrom(IResultSet *rs)
{
if (m_Table[idx])
{
m_Table[idx]->assign(row->GetString(i));
*m_Table[idx] = row->GetString(i);
} else {
m_Table[idx] = new SourceHook::String(row->GetString(i));
m_Table[idx] = new ke::AString(row->GetString(i));
}
}
rs->NextRow();

View File

@ -16,9 +16,9 @@
#include "IThreader.h"
#include "ISQLDriver.h"
#include "sh_string.h"
#include "CVector.h"
#include "sh_stack.h"
#include <am-string.h>
#include <am-vector.h>
#include <sh_stack.h>
struct QueuedResultInfo
{
@ -64,7 +64,7 @@ private:
unsigned int m_RowCount;
unsigned int m_FieldCount;
size_t m_AllocSize;
SourceHook::String **m_Table;
ke::AString **m_Table;
unsigned int m_CurRow;
bool m_IsFree;
};
@ -85,8 +85,8 @@ public:
void RunThread(IThreadHandle *pHandle);
void OnTerminate(IThreadHandle *pHandle, bool cancel);
private:
SourceHook::String m_query;
SourceHook::String m_db;
ke::AString m_query;
ke::AString m_db;
cell *m_data;
ucell m_datalen;
size_t m_maxdatalen;