Update ns module project files and use AMTL.

This commit is contained in:
Arkshine 2014-08-10 18:24:47 +02:00
parent 3f6ad29f55
commit 9d53d48552
33 changed files with 199 additions and 7054 deletions

View File

@ -3,8 +3,12 @@ import os.path
binary = AMXX.MetaModule(builder, 'ns')
binary.compiler.defines += [
'HAVE_STDINT_H',
]
binary.sources = [
'sdk/amxxmodule.cpp',
'../../public/sdk/amxxmodule.cpp',
'dllapi.cpp',
'utils.cpp',
'amxxapi.cpp',

View File

@ -23,13 +23,13 @@
#ifndef ALLOCSTRING_H
#define ALLOCSTRING_H
#include "CString.h"
#include "sh_list.h"
#include <am-string.h>
#include <am-linkedlist.h>
class StringManager
{
private:
List<String *> m_StringList;
ke::LinkedList<ke::AString *> m_StringList;
public:
/**
@ -38,8 +38,8 @@ public:
*/
inline void Clear(void)
{
List<String *>::iterator end;
List<String *>::iterator iter;
ke::LinkedList<ke::AString *>::iterator end;
ke::LinkedList<ke::AString *>::iterator iter;
iter=m_StringList.begin();
end=m_StringList.end();
@ -59,30 +59,28 @@ public:
*/
inline int Allocate(const char *str)
{
List<String *>::iterator end;
List<String *>::iterator iter;
ke::LinkedList<ke::AString *>::iterator end;
ke::LinkedList<ke::AString *>::iterator iter;
iter=m_StringList.begin();
end=m_StringList.end();
while (iter!=end)
{
if (strcmp(str, (*iter)->c_str()) == 0)
if (strcmp(str, (*iter)->chars()) == 0)
{
// String is already in the list, do not allocate it again
return MAKE_STRING((*iter)->c_str());
return MAKE_STRING((*iter)->chars());
}
++iter;
}
// Was not found in the linked list, allocate it and add it to the list
String *AllocStr = new String;
ke::AString *AllocStr = new ke::AString(str);
AllocStr->assign(str);
m_StringList.append(AllocStr);
m_StringList.push_back(AllocStr);
return MAKE_STRING(AllocStr->c_str());
return MAKE_STRING(AllocStr->chars());
};

View File

@ -1,406 +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 _INCLUDE_CSTRING_H
#define _INCLUDE_CSTRING_H
#include <string.h>
#include <stdio.h>
#include <ctype.h>
//by David "BAILOPAN" Anderson
class String
{
public:
String()
{
v = new char[33];
v[0]='\0';
a_size = 0;
//assign("");
}
~String()
{
delete [] v;
}
String(const char *src)
{
v = NULL;
a_size = 0;
assign(src);
}
const char * _fread(FILE *fp)
{
Grow(512, false);
char *ret = fgets(v, 511, fp);
return ret;
}
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 {
size_t len = strlen(d);
Grow(len + 1, false);
memcpy(v, d, len);
v[len] = '\0';
}
}
void clear()
{
if (v)
v[0] = '\0';
}
int compare (const char *d) const
{
if (!v)
return strcmp("", d);
else
return strcmp(v, d);
}
//Added this for amxx inclusion
bool empty() const
{
if (!v)
return true;
if (v[0] == '\0')
return true;
return false;
}
size_t size() const
{
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 reparse_newlines()
{
size_t len = size();
int offs = 0;
char c;
if (!len)
return;
for (size_t i=0; i<len; i++)
{
c = v[i];
if (c == '^' && (i != len-1))
{
c = v[++i];
if (c == 'n')
c = '\n';
else if (c == 't')
c = '\t';
offs++;
}
v[i-offs] = c;
}
v[len-offs] = '\0';
}
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(void)
{
if (v==NULL)
{
return;
}
char *iter=v+a_size;
while (iter--!=v)
{
*iter=tolower(*iter);
}
};
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;
};
#endif //_INCLUDE_CSTRING_H

View File

@ -1,479 +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()
{
if (m_CurrentUsedSize > 0)
--m_CurrentUsedSize;
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__

View File

@ -13,12 +13,9 @@
/* This holds the functions which determine which hooks I need forwareded */
#include "sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "CPlayer.h"

View File

@ -17,7 +17,7 @@
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
#include "CString.h"
#include <am-string.h>
class GameManager
{
@ -62,23 +62,21 @@ public:
};
inline void CheckMap(void)
{
String MapName;
ke::AString MapName;
MapName.assign(STRING(gpGlobals->mapname));
MapName.ToLower();
MapName = UTIL_ToLowerCase(STRING(gpGlobals->mapname));
m_iTitlesMap=0;
if (strcmp(MapName.c_str(),"ns_bast")==0 ||
strcmp(MapName.c_str(),"ns_bast_classic")==0 ||
strcmp(MapName.c_str(),"ns_hera")==0 ||
strcmp(MapName.c_str(),"ns_nothing")==0 ||
strcmp(MapName.c_str(),"ns_caged")==0 ||
strcmp(MapName.c_str(),"ns_tanith")==0 ||
strcmp(MapName.c_str(),"ns_eclipse")==0 ||
strcmp(MapName.c_str(),"ns_veil")==0 ||
strcmp(MapName.c_str(),"ns_nancy")==0)
if (MapName.compare("ns_bast")==0 ||
MapName.compare("ns_bast_classic") == 0 ||
MapName.compare("ns_hera") == 0 ||
MapName.compare("ns_nothing") == 0 ||
MapName.compare("ns_caged") == 0 ||
MapName.compare("ns_tanith") == 0 ||
MapName.compare("ns_eclipse") == 0 ||
MapName.compare("ns_veil") == 0 ||
MapName.compare("ns_nancy") == 0)
{
m_iTitlesMap=1;
}

View File

@ -14,13 +14,14 @@
#ifndef _HASH_H_
#define _HASH_H_
#include "CVector.h"
#include <am-vector.h>
#include <am-string.h>
// Just a very simple hash map, no iteration or anything of the like (not needed)
inline int HashFunction(const String& name)
inline int HashFunction(const ke::AString& name)
{
static const int kHashNumTable[128] =
{
@ -41,21 +42,21 @@ inline int HashFunction(const String& name)
0x245152A2, 0x49A38093, 0x36727833, 0x5E0FA501, 0x10E5FEC6, 0x52F42C4D, 0x1B54D3E3, 0x18C7F6AC,
0x45BC2D01, 0x064757EF, 0x2DA79EBC, 0x0309BED4, 0x5A56A608, 0x215AF6DE, 0x3B09613A, 0x35EDF071
};
size_t size = name.size();
size_t size = name.length();
if (size == 0)
{
return 0;
}
int hasha = kHashNumTable[(*(name.c_str() + (size - 1))) & 0x7F];
int hasha = kHashNumTable[(*(name.chars() + (size - 1))) & 0x7F];
int hashb = kHashNumTable[size % 128];
unsigned char c = 0;
for (size_t i = 0; i < size; i++)
{
c = (*(name.c_str() + (size - 1))) & 0x7F;
c = (*(name.chars() + (size - 1))) & 0x7F;
hasha = (hasha + hashb) ^ kHashNumTable[c];
hashb = hasha + hashb + c + (hasha << 8) + (hashb & 0xFF);
@ -74,13 +75,13 @@ inline int HashFunction(const String& name)
template <typename K = String, typename D = String, int (*F)(const K&) = HashFunction, int B = 1024>
template <typename K = ke::AString, typename D = ke::AString, int (*F)(const K&) = HashFunction, int B = 1024>
class Hash
{
protected:
CVector<int> m_HashBuckets[B];
CVector<K> m_KeyBuckets[B];
CVector<D> m_DataBuckets[B];
ke::Vector<int> m_HashBuckets[B];
ke::Vector<K> m_KeyBuckets[B];
ke::Vector<D> m_DataBuckets[B];
inline int GetBucket(int hash)
{
@ -116,9 +117,9 @@ public:
int bucketnum = GetBucket(hash);
m_HashBuckets[bucketnum].push_back(hash);
m_KeyBuckets[bucketnum].push_back(key);
m_DataBuckets[bucketnum].push_back(value);
m_HashBuckets[bucketnum].append(hash);
m_KeyBuckets[bucketnum].append(key);
m_DataBuckets[bucketnum].append(value);
return;
@ -135,9 +136,9 @@ public:
int bucketnum = GetBucket(hash);
m_HashBuckets[bucketnum].push_back(hash);
m_KeyBuckets[bucketnum].push_back(key);
m_DataBuckets[bucketnum].push_back(D());
m_HashBuckets[bucketnum].append(hash);
m_KeyBuckets[bucketnum].append(key);
m_DataBuckets[bucketnum].append(D());
return m_DataBuckets[bucketnum].at(m_DataBuckets[bucketnum].size() - 1);
@ -154,16 +155,16 @@ public:
// TODO: Possibly make this binary search?
// insertion would be annoying, don't think it is worth it
CVector<int>* hashbucket = &m_HashBuckets[bucketnum];
CVector<K>* keybucket = &m_KeyBuckets[bucketnum];
ke::Vector<int>* hashbucket = &m_HashBuckets[bucketnum];
ke::Vector<K>* keybucket = &m_KeyBuckets[bucketnum];
size_t bucketsize = hashbucket->size();
size_t bucketsize = hashbucket->length();
for (size_t i = 0; i < bucketsize; i++)
{
if (hashbucket->at(i) == hash)
{
if (key.compare(keybucket->at(i).c_str()) == 0)
if (key.compare(keybucket->at(i).chars()) == 0)
{
return &(m_DataBuckets[bucketnum].at(i));
}

View File

@ -14,11 +14,10 @@
#ifndef LOCATIONMANAGER_H
#define LOCATIONMANAGER_H
#include "CVector.h"
#include <am-vector.h>
#include "GameManager.h"
#include "TitleManager.h"
typedef struct location_data_s
{
char name[128];
@ -32,7 +31,7 @@ typedef struct location_data_s
class LocationManager
{
private:
CVector<location_data_t> m_LocationList;
ke::Vector<location_data_t> m_LocationList;
public:
LocationManager()
@ -43,7 +42,7 @@ public:
inline void Clear(void)
{
m_LocationList.clear();
m_LocationList.reserve(32);
m_LocationList.ensure(32);
};
inline void Add(const char *Name, edict_t *Entity)
@ -55,19 +54,17 @@ public:
strncpy(Temp.name,Name,sizeof(Temp.name)-1);
String NameString(Name);
NameString.toLower();
ke::AString NameString(UTIL_ToLowerCase(Name));
Temp.titlelookup=TitleMan.Lookup(NameString);
m_LocationList.push_back(Temp);
m_LocationList.append(Temp);
};
inline const char *Lookup(vec3_t origin, cell titlelookup)
{
unsigned int i=0;
location_data_t Temp;
while (i<m_LocationList.size())
while (i<m_LocationList.length())
{
Temp=m_LocationList[i++];

View File

@ -7,6 +7,7 @@
HLSDK = ../../../hlsdk
MM_ROOT = ../../../metamod/metamod
PUBLIC_ROOT = ../../public
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
@ -14,10 +15,10 @@ MM_ROOT = ../../../metamod/metamod
PROJECT = ns
OBJECTS = sdk/amxxmodule.cpp dllapi.cpp utils.cpp amxxapi.cpp engineapi.cpp TitleManager.cpp \
ParticleManager.cpp MessageHandler.cpp GameManager.cpp natives/general.cpp \
natives/player.cpp natives/player_memory.cpp natives/structure.cpp natives/weapons.cpp \
natives/particles.cpp natives/memberfuncs.cpp
OBJECTS = amxxmodule.cpp dllapi.cpp utils.cpp amxxapi.cpp engineapi.cpp TitleManager.cpp \
ParticleManager.cpp MessageHandler.cpp GameManager.cpp natives/general.cpp \
natives/player.cpp natives/player_memory.cpp natives/structure.cpp natives/weapons.cpp \
natives/particles.cpp natives/memberfuncs.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
@ -32,8 +33,10 @@ CPP_OSX = clang
LINK =
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared \
-I$(HLSDK)/pm_shared -I$(HLSDK)/public -I$(MM_ROOT) -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$(MYSQL_DIR)/include -Ithread -Imysql \
-I$(MM_ROOT)
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
@ -113,8 +116,8 @@ $(BIN_DIR)/%.o: %.cpp
all:
mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)/sdk
mkdir -p $(BIN_DIR)/natives
ln -sf $(PUBLIC_ROOT)/sdk/amxxmodule.cpp
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
$(PROJECT): $(OBJ_BIN)
@ -127,7 +130,6 @@ default: all
clean:
rm -rf $(BIN_DIR)/*.o
rm -rf $(BIN_DIR)/sdk/*.o
rm -rf $(BIN_DIR)/natives/*.o
rm -f $(BIN_DIR)/$(BINARY)

View File

@ -17,11 +17,9 @@
* is sending a message we care about.
*/
#include "sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "GameManager.h"
#include "MessageHandler.h"

View File

@ -11,15 +11,10 @@
// Natural Selection Module
//
#include "sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "ns.h"
#include "CVector.h"
#include "CString.h"
#include "ParticleManager.h"
void ParticleManager::ReadFile(void)
{
this->Prune();

View File

@ -14,9 +14,12 @@
#ifndef PARTICLEMANAGER_H
#define PARTICLEMANAGER_H
#include <am-vector.h>
#include <am-string.h>
typedef struct psystem_s
{
String Name;
ke::AString Name;
int id;
int IsStatic; // Set to 1 if the particle system is loaded from ns.ps
@ -25,43 +28,36 @@ typedef struct psystem_s
class ParticleManager
{
private:
CVector<ParticleSystem *> Systems;
int m_iFileLoaded;
unsigned short m_iEventID;
ke::Vector<ParticleSystem *> Systems;
int m_iFileLoaded;
unsigned short m_iEventID;
public:
ParticleManager()
{
m_iFileLoaded=0;
m_iEventID=0;
Systems.reserve(64);
Systems.ensure(64);
};
// Remove all non-static particle systems
inline void Prune()
{
if (Systems.size()==0)
for (size_t i = 0; i < Systems.length(); ++i)
{
return;
if (Systems[i]->IsStatic)
{
break;
}
Systems.remove(i);
delete Systems.at(i);
if (!Systems.length())
{
break;
}
}
CVector<ParticleSystem *>::iterator iter;
while (1)
{
if (Systems.size()==0)
{
break;
}
iter=Systems.end();
iter--;
if ((*iter)->IsStatic)
{
break;
}
delete (*iter);
Systems.pop_back();
};
};
void ReadFile(void);
@ -70,13 +66,13 @@ public:
{
ParticleSystem *ps=new ParticleSystem;
ps->id=Systems.size();
ps->id=Systems.length();
ps->IsStatic=Static;
ps->Name.assign(Start);
ps->Name = Start;
Systems.push_back(ps);
Systems.append(ps);
return Systems.size()-1;
return Systems.length()-1;
};
inline void FireSystem(int id, float *Origin, float *Angles, int flags)
{
@ -110,16 +106,12 @@ public:
};
inline int Find(const char *Needle)
{
CVector<ParticleSystem *>::iterator iter=Systems.begin();
CVector<ParticleSystem *>::iterator end=Systems.end();
while (iter!=end)
for (size_t i = 0; i < Systems.length(); ++i)
{
if (strcmp(Needle,(*iter)->Name.c_str())==0)
if (strcmp(Needle, Systems[i]->Name.chars()) == 0)
{
return (*iter)->id;
return Systems[i]->id;
}
++iter;
}
return -1;

View File

@ -14,7 +14,7 @@
#ifndef SPAWNMANAGER_H
#define SPAWNMANAGER_H
#include "CVector.h"
#include <am-vector.h>
typedef struct spawndata_s
{
@ -25,7 +25,7 @@ typedef struct spawndata_s
class SpawnManager
{
private:
CVector<SpawnData> TeamSpawns[5];
ke::Vector<SpawnData> TeamSpawns[5];
public:
SpawnManager()
@ -43,9 +43,9 @@ public:
// Reserve data for a "typical" map layout
// makes data entry faster on map load
TeamSpawns[0].reserve(32);
TeamSpawns[1].reserve(16);
TeamSpawns[2].reserve(48);
TeamSpawns[0].ensure(32);
TeamSpawns[1].ensure(16);
TeamSpawns[2].ensure(48);
};
inline void Insert(const edict_t *Entity)
@ -61,7 +61,7 @@ public:
Entity->v.origin.CopyToArray(TemporaryData.Location);
Entity->v.angles.CopyToArray(TemporaryData.Angle);
TeamSpawns[Entity->v.team].push_back(TemporaryData);
TeamSpawns[Entity->v.team].append(TemporaryData);
};
inline void InsertReadyRoom(const edict_t *Entity)
{
@ -70,7 +70,7 @@ public:
Entity->v.origin.CopyToArray(TemporaryData.Location);
Entity->v.angles.CopyToArray(TemporaryData.Angle);
TeamSpawns[0].push_back(TemporaryData);
TeamSpawns[0].append(TemporaryData);
};
// ns_get_spawn(team,number=0,Float:ret[3]);
@ -82,10 +82,10 @@ public:
}
if (params[2]==0)
{
return static_cast<int>(TeamSpawns[params[1]].size());
return static_cast<int>(TeamSpawns[params[1]].length());
}
if (params[2]>=(int)TeamSpawns[params[1]].size())
if (params[2]>=(int)TeamSpawns[params[1]].length())
{
return 0;
}

View File

@ -11,11 +11,10 @@
// Natural Selection Module
//
#include "sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "ns.h"
#include "TitleManager.h"
#include "utilfunctions.h"
void TitleManager::LoadTitles(void)
{
@ -136,10 +135,9 @@ scan_for_data:
if (*TempPointer=='}') // end of data
{
// insert KeyName & Data into the hash
String key(KeyName);
ke::AString key(UTIL_ToLowerCase(KeyName));
key.toLower();
this->m_Hash.insert(key, new String(Data));
this->m_Hash.insert(key, new ke::AString(Data));
goto scan_for_key;
}

View File

@ -18,7 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include "CString.h"
#include <am-string.h>
#include "Hash.h"
@ -29,7 +29,7 @@ private:
// Use a string pointer for the data type because the location manager
// stores a direct pointer to the c_str() of the title
Hash<String, String*> m_Hash;
Hash<ke::AString, ke::AString*> m_Hash;
public:
@ -38,9 +38,9 @@ public:
m_Loaded=0;
};
inline const char *Lookup(String &input)
inline const char *Lookup(ke::AString &input)
{
String** ret = m_Hash.find(input);
ke::AString** ret = m_Hash.find(input);
if (ret == NULL || *ret == NULL)
{
@ -48,8 +48,7 @@ public:
return NULL;
}
return (*ret)->c_str();
return (*ret)->chars();
};
void LoadTitles(void);
};

View File

@ -17,10 +17,6 @@
#include "ns.h"
#include "utilfunctions.h"
#include "CVector.h"
#include "CString.h"
#include "GameManager.h"
#include "TitleManager.h"
#include "MessageHandler.h"

View File

@ -13,14 +13,14 @@
/* Calls going from the engine to the game dll are handled here */
#include "sdk/amxxmodule.h"
#ifndef HAVE_STDINT_H
#define HAVE_STDINT_H
#endif
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "SpawnManager.h"
#include "GameManager.h"
#include "CPlayer.h"
#include "MessageHandler.h"

View File

@ -13,14 +13,9 @@
/* Calls going from the game dll to the engine are handled here */
#include "sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "CVector.h"
#include "CString.h"
#include "GameManager.h"
#include "ParticleManager.h"
#include "CPlayer.h"

0
dlls/ns/sdk/moduleconfig.h → dlls/ns/moduleconfig.h Executable file → Normal file
View File

View File

@ -63,8 +63,8 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\;..\sdk;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;ns_amxx_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk; ..\..\..\public\amtl;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_STDINT_H;WIN32;NDEBUG;_WINDOWS;_USRDLL;ns_amxx_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -102,8 +102,8 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\;..\sdk;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;ns_amxx_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk; ..\..\..\public\amtl;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_STDINT_H;WIN32;_DEBUG;_WINDOWS;_USRDLL;ns_amxx_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
@ -154,13 +154,11 @@
<ClCompile Include="..\natives\player_memory.cpp" />
<ClCompile Include="..\natives\structure.cpp" />
<ClCompile Include="..\natives\weapons.cpp" />
<ClCompile Include="..\sdk\amxxmodule.cpp" />
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\AllocString.h" />
<ClInclude Include="..\CPlayer.h" />
<ClInclude Include="..\CString.h" />
<ClInclude Include="..\CVector.h" />
<ClInclude Include="..\FastDelegate.h" />
<ClInclude Include="..\GameManager.h" />
<ClInclude Include="..\Hash.h" />
@ -170,12 +168,11 @@
<ClInclude Include="..\ns.h" />
<ClInclude Include="..\ns_const.h" />
<ClInclude Include="..\ParticleManager.h" />
<ClInclude Include="..\sh_list.h" />
<ClInclude Include="..\SpawnManager.h" />
<ClInclude Include="..\TitleManager.h" />
<ClInclude Include="..\utilfunctions.h" />
<ClInclude Include="..\sdk\amxxmodule.h" />
<ClInclude Include="..\sdk\moduleconfig.h" />
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h" />
<ClInclude Include="..\moduleconfig.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -12,9 +12,12 @@
<UniqueIdentifier>{e619584d-fe78-4fa8-9b61-715f075c990c}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="sdk">
<Filter Include="Module SDK">
<UniqueIdentifier>{d6f08195-ccd3-49f9-be66-8064cf182a41}</UniqueIdentifier>
</Filter>
<Filter Include="Module SDK\SDK Base">
<UniqueIdentifier>{28f804b5-b177-4048-b0c6-36ba103593b9}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\amxxapi.cpp">
@ -62,8 +65,8 @@
<ClCompile Include="..\natives\weapons.cpp">
<Filter>Source Files\Natives</Filter>
</ClCompile>
<ClCompile Include="..\sdk\amxxmodule.cpp">
<Filter>sdk</Filter>
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp">
<Filter>Module SDK\SDK Base</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -73,12 +76,6 @@
<ClInclude Include="..\CPlayer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\CString.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\CVector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\FastDelegate.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -106,9 +103,6 @@
<ClInclude Include="..\ParticleManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sh_list.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SpawnManager.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -118,11 +112,11 @@
<ClInclude Include="..\utilfunctions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sdk\amxxmodule.h">
<Filter>sdk</Filter>
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h">
<Filter>Module SDK\SDK Base</Filter>
</ClInclude>
<ClInclude Include="..\sdk\moduleconfig.h">
<Filter>sdk</Filter>
<ClInclude Include="..\moduleconfig.h">
<Filter>Module SDK</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -13,21 +13,21 @@
#include <string.h>
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "cbase.h" // TakeDamage
#include "../ns.h"
#include "ns.h"
#include "../utilfunctions.h"
#include "../NEW_Util.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "../GameManager.h"
#include "../SpawnManager.h"
#include "../LocationManager.h"
#include "../TitleManager.h"
#include "GameManager.h"
#include "SpawnManager.h"
#include "LocationManager.h"
#include "TitleManager.h"
#include "../CPlayer.h"
#include "CPlayer.h"
edict_t* avhgameplay=NULL;
@ -229,9 +229,7 @@ static cell AMX_NATIVE_CALL ns_get_locationname(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL ns_lookup_title(AMX *amx, cell *params)
{
// FIX: some keys have upper case characters; to fix i store all keys as lower case
String Input(MF_GetAmxString(amx,params[1],0,NULL));
Input.toLower();
ke::AString Input(UTIL_ToLowerCase(MF_GetAmxString(amx,params[1],0,NULL)));
const char *Output=TitleMan.Lookup(Input);

View File

@ -13,15 +13,15 @@
#include <string.h>
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "../ns.h"
#include "../ns_const.h"
#include "ns.h"
#include "ns_const.h"
#include "../utilfunctions.h"
#include "utilfunctions.h"
#include "../FastDelegate.h"
#include "../GameManager.h"
#include "FastDelegate.h"
#include "GameManager.h"
extern int IsValidBuilding[AVH_USER3_MAX + 1];

View File

@ -11,15 +11,14 @@
// Natural Selection Module
//
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "../ns.h"
#include "../utilfunctions.h"
#include "../NEW_Util.h"
#include "../CVector.h"
#include "../CString.h"
#include "../ParticleManager.h"
#include "ns.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "ParticleManager.h"
#include <am-vector.h>
#include <am-string.h>
#define KVI(__KEY) PSKeyValueI(__KEY,amx,params)
#define KVF(__KEY) PSKeyValueF(__KEY,amx,params)

View File

@ -11,17 +11,17 @@
// Natural Selection Module
//
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "../ns.h"
#include "ns.h"
#include "../utilfunctions.h"
#include "../NEW_Util.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "../GameManager.h"
#include "../CPlayer.h"
#include "GameManager.h"
#include "CPlayer.h"
#include "../AllocString.h"
#include "AllocString.h"
StringManager AllocStringList;

View File

@ -11,15 +11,15 @@
// Natural Selection Module
//
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "../ns.h"
#include "ns.h"
#include "../utilfunctions.h"
#include "../NEW_Util.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "../GameManager.h"
#include "../CPlayer.h"
#include "GameManager.h"
#include "CPlayer.h"
// Float:ns_get_res(Player)
static cell AMX_NATIVE_CALL ns_get_res(AMX *amx, cell *params)

View File

@ -11,12 +11,12 @@
// Natural Selection Module
//
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "../ns.h"
#include "ns.h"
#include "../utilfunctions.h"
#include "../NEW_Util.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
int IsValidBuilding[AVH_USER3_MAX + 1] = {
0, // AVH_USER3_NONE = 0,

View File

@ -11,15 +11,15 @@
// Natural Selection Module
//
#include "../sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "../ns.h"
#include "ns.h"
#include "../utilfunctions.h"
#include "../NEW_Util.h"
#include "utilfunctions.h"
#include "NEW_Util.h"
#include "../GameManager.h"
#include "../CPlayer.h"
#include "GameManager.h"
#include "CPlayer.h"
// ns_has_weapon(idPlayer,NsWeapon,set=0)
static cell AMX_NATIVE_CALL ns_has_weapon(AMX *amx,cell *params)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,297 +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

@ -99,6 +99,8 @@ int UTIL_FindBuildingHive(void);
BOOL UTIL_CheckForPublic(const char *publicname);
BOOL UTIL_CheckForNative(const char *NativeName);
char *UTIL_ToLowerCase(const char *str);
class CPlayer;
CPlayer *UTIL_PlayerByCID(int CID);

View File

@ -11,12 +11,9 @@
// Natural Selection Module
//
#include "sdk/amxxmodule.h"
#include "amxxmodule.h"
#include "ns.h"
#include "utilfunctions.h"
#include "CPlayer.h"
@ -170,3 +167,17 @@ int UTIL_LogToIndex(const char *LogLine)
return 0;
}
char *UTIL_ToLowerCase(const char *str)
{
size_t len = strlen(str);
char *buffer = new char[len + 1];
for (size_t i = 0; i < len; i++)
{
if (str[i] >= 'A' && str[i] <= 'Z')
buffer[i] = tolower(str[i]);
else
buffer[i] = str[i];
}
buffer[len] = '\0';
return buffer;
}