Normalize all the line endings

This commit is contained in:
Arkshine
2015-03-10 16:51:45 +01:00
parent afc3cac54d
commit 48d6a3354a
64 changed files with 16240 additions and 16240 deletions

View File

@ -90,9 +90,9 @@ void CTaskMngr::CTask::changeBase(float fNewBase)
}
void CTaskMngr::CTask::resetNextExecTime(float fCurrentTime)
{
// If we're here while we're executing we would add m_fBase twice
if (!m_bInExecute)
{
// If we're here while we're executing we would add m_fBase twice
if (!m_bInExecute)
m_fNextExecTime = fCurrentTime + m_fBase;
}

View File

@ -6,208 +6,208 @@
// 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 DATASTRUCTS_H
#define DATASTRUCTS_H
#include <am-vector.h>
class CellArray
{
public:
CellArray(size_t blocksize, size_t basesize = 0) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_BaseSize(basesize > 0 ? basesize : 8), m_Size(0)
{
}
~CellArray()
{
free(m_Data);
}
size_t size() const
{
return m_Size;
}
cell *push()
{
if (!GrowIfNeeded(1))
{
return NULL;
}
cell *arr = &m_Data[m_Size * m_BlockSize];
m_Size++;
return arr;
}
cell *at(size_t b) const
{
return &m_Data[b * m_BlockSize];
}
size_t blocksize() const
{
return m_BlockSize;
}
void clear()
{
m_Size = 0;
}
bool swap(size_t item1, size_t item2)
{
/* Make sure there is extra space available */
if (!GrowIfNeeded(1))
{
return false;
}
cell *pri = at(item1);
cell *alt = at(item2);
/* Get our temporary array 1 after the limit */
cell *temp = &m_Data[m_Size * m_BlockSize];
memcpy(temp, pri, sizeof(cell)* m_BlockSize);
memcpy(pri, alt, sizeof(cell)* m_BlockSize);
memcpy(alt, temp, sizeof(cell)* m_BlockSize);
return true;
}
void remove(size_t index)
{
/* If we're at the end, take the easy way out */
if (index == m_Size - 1)
{
m_Size--;
return;
}
/* Otherwise, it's time to move stuff! */
size_t remaining_indexes = (m_Size - 1) - index;
cell *src = at(index + 1);
cell *dest = at(index);
memmove(dest, src, sizeof(cell)* m_BlockSize * remaining_indexes);
m_Size--;
}
cell *insert_at(size_t index)
{
/* Make sure it'll fit */
if (!GrowIfNeeded(1))
{
return NULL;
}
/* move everything up */
cell *src = at(index);
cell *dst = at(index + 1);
memmove(dst, src, sizeof(cell)* m_BlockSize * (m_Size - index));
m_Size++;
return src;
}
bool resize(size_t count)
{
if (count <= m_Size)
{
m_Size = count;
return true;
}
if (!GrowIfNeeded(count - m_Size))
{
return false;
}
m_Size = count;
return true;
}
CellArray *clone()
{
CellArray *array = new CellArray(m_BlockSize);
array->m_AllocSize = m_AllocSize;
array->m_Size = m_Size;
array->m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
memcpy(array->m_Data, m_Data, sizeof(cell)* m_BlockSize * m_Size);
return array;
}
cell *base()
{
return m_Data;
}
size_t mem_usage()
{
return m_AllocSize * m_BlockSize * sizeof(cell);
}
private:
bool GrowIfNeeded(size_t count)
{
/* Shortcut out if we can store this */
if (m_Size + count <= m_AllocSize)
{
return true;
}
/* Set a base allocation size of 8 items */
if (!m_AllocSize)
{
m_AllocSize = m_BaseSize;
}
/* If it's not enough, keep doubling */
while (m_Size + count > m_AllocSize)
{
m_AllocSize *= 2;
}
/* finally, allocate the new block */
if (m_Data)
{
m_Data = (cell *)realloc(m_Data, sizeof(cell)* m_BlockSize * m_AllocSize);
}
else {
m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
}
return (m_Data != NULL);
}
private:
cell *m_Data;
size_t m_BlockSize;
size_t m_AllocSize;
size_t m_BaseSize;
size_t m_Size;
};
extern ke::Vector<CellArray*> VectorHolder;
inline CellArray* HandleToVector(AMX* amx, int handle)
{
if (handle <= 0 || handle > (int)VectorHolder.length())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
CellArray* ret = VectorHolder[handle - 1];
if (ret == NULL)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
return ret;
}
#endif
#ifndef DATASTRUCTS_H
#define DATASTRUCTS_H
#include <am-vector.h>
class CellArray
{
public:
CellArray(size_t blocksize, size_t basesize = 0) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_BaseSize(basesize > 0 ? basesize : 8), m_Size(0)
{
}
~CellArray()
{
free(m_Data);
}
size_t size() const
{
return m_Size;
}
cell *push()
{
if (!GrowIfNeeded(1))
{
return NULL;
}
cell *arr = &m_Data[m_Size * m_BlockSize];
m_Size++;
return arr;
}
cell *at(size_t b) const
{
return &m_Data[b * m_BlockSize];
}
size_t blocksize() const
{
return m_BlockSize;
}
void clear()
{
m_Size = 0;
}
bool swap(size_t item1, size_t item2)
{
/* Make sure there is extra space available */
if (!GrowIfNeeded(1))
{
return false;
}
cell *pri = at(item1);
cell *alt = at(item2);
/* Get our temporary array 1 after the limit */
cell *temp = &m_Data[m_Size * m_BlockSize];
memcpy(temp, pri, sizeof(cell)* m_BlockSize);
memcpy(pri, alt, sizeof(cell)* m_BlockSize);
memcpy(alt, temp, sizeof(cell)* m_BlockSize);
return true;
}
void remove(size_t index)
{
/* If we're at the end, take the easy way out */
if (index == m_Size - 1)
{
m_Size--;
return;
}
/* Otherwise, it's time to move stuff! */
size_t remaining_indexes = (m_Size - 1) - index;
cell *src = at(index + 1);
cell *dest = at(index);
memmove(dest, src, sizeof(cell)* m_BlockSize * remaining_indexes);
m_Size--;
}
cell *insert_at(size_t index)
{
/* Make sure it'll fit */
if (!GrowIfNeeded(1))
{
return NULL;
}
/* move everything up */
cell *src = at(index);
cell *dst = at(index + 1);
memmove(dst, src, sizeof(cell)* m_BlockSize * (m_Size - index));
m_Size++;
return src;
}
bool resize(size_t count)
{
if (count <= m_Size)
{
m_Size = count;
return true;
}
if (!GrowIfNeeded(count - m_Size))
{
return false;
}
m_Size = count;
return true;
}
CellArray *clone()
{
CellArray *array = new CellArray(m_BlockSize);
array->m_AllocSize = m_AllocSize;
array->m_Size = m_Size;
array->m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
memcpy(array->m_Data, m_Data, sizeof(cell)* m_BlockSize * m_Size);
return array;
}
cell *base()
{
return m_Data;
}
size_t mem_usage()
{
return m_AllocSize * m_BlockSize * sizeof(cell);
}
private:
bool GrowIfNeeded(size_t count)
{
/* Shortcut out if we can store this */
if (m_Size + count <= m_AllocSize)
{
return true;
}
/* Set a base allocation size of 8 items */
if (!m_AllocSize)
{
m_AllocSize = m_BaseSize;
}
/* If it's not enough, keep doubling */
while (m_Size + count > m_AllocSize)
{
m_AllocSize *= 2;
}
/* finally, allocate the new block */
if (m_Data)
{
m_Data = (cell *)realloc(m_Data, sizeof(cell)* m_BlockSize * m_AllocSize);
}
else {
m_Data = (cell *)malloc(sizeof(cell)* m_BlockSize * m_AllocSize);
}
return (m_Data != NULL);
}
private:
cell *m_Data;
size_t m_BlockSize;
size_t m_AllocSize;
size_t m_BaseSize;
size_t m_Size;
};
extern ke::Vector<CellArray*> VectorHolder;
inline CellArray* HandleToVector(AMX* amx, int handle)
{
if (handle <= 0 || handle > (int)VectorHolder.length())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
CellArray* ret = VectorHolder[handle - 1];
if (ret == NULL)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", handle);
return NULL;
}
return ret;
}
#endif

View File

@ -52,11 +52,11 @@ public:
}
};
enum FileTimeType
{
FileTime_LastAccess = 0, /* Last access (not available on FAT) */
FileTime_Created = 1, /* Creation (not available on FAT) */
FileTime_LastChange = 2, /* Last modification */
enum FileTimeType
{
FileTime_LastAccess = 0, /* Last access (not available on FAT) */
FileTime_Created = 1, /* Creation (not available on FAT) */
FileTime_LastChange = 2, /* Last modification */
};
static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
@ -855,26 +855,26 @@ static cell AMX_NATIVE_CALL GetFileTime(AMX *amx, cell *params)
char path[256];
build_pathname_r(path, sizeof(path), "%s", file);
#if defined(WIN32)
struct _stat s;
if (_stat(path, &s) != 0)
#elif defined(__linux__) || defined(__APPLE__)
struct stat s;
if (stat(path, &s) != 0)
#endif
{
return -1;
}
time_t time_val = -1;
switch( params[2] )
{
case FileTime_LastAccess : time_val = s.st_atime; break;
case FileTime_Created : time_val = s.st_ctime; break;
case FileTime_LastChange : time_val = s.st_mtime; break;
}
#if defined(WIN32)
struct _stat s;
if (_stat(path, &s) != 0)
#elif defined(__linux__) || defined(__APPLE__)
struct stat s;
if (stat(path, &s) != 0)
#endif
{
return -1;
}
time_t time_val = -1;
switch( params[2] )
{
case FileTime_LastAccess : time_val = s.st_atime; break;
case FileTime_Created : time_val = s.st_ctime; break;
case FileTime_LastChange : time_val = s.st_mtime; break;
}
return (cell)time_val;
}

View File

@ -58,14 +58,14 @@ void validate_menu_text(char *str)
*(str-offs) = '\0';
}
}
}
Menu *get_menu_by_id(int id)
{
if (id < 0 || size_t(id) >= g_NewMenus.size() || !g_NewMenus[id])
return NULL;
return g_NewMenus[id];
}
Menu *get_menu_by_id(int id)
{
if (id < 0 || size_t(id) >= g_NewMenus.size() || !g_NewMenus[id])
return NULL;
return g_NewMenus[id];
}
Menu::Menu(const char *title, AMX *amx, int fid) : m_Title(title), m_ItemColor("\\r"),
@ -311,11 +311,11 @@ bool Menu::Display(int player, page_t page)
void Menu::Close(int player)
{
CPlayer *pPlayer = GET_PLAYER_POINTER_I(player);
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
pPlayer->keys = 0;
@ -700,40 +700,40 @@ static cell AMX_NATIVE_CALL menu_addtext(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL menu_addblank2(AMX *amx, cell *params)
{
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
menuitem *pItem = pMenu->AddItem("", "", 0);
pItem->isBlank = true;
return 1;
}
static cell AMX_NATIVE_CALL menu_addtext2(AMX *amx, cell *params)
{
int len;
char *name;
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
name = get_amxstring(amx, params[2], 0, len);
validate_menu_text(name);
menuitem *pItem = pMenu->AddItem(name, "", 0);
pItem->isBlank = true;
static cell AMX_NATIVE_CALL menu_addblank2(AMX *amx, cell *params)
{
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
menuitem *pItem = pMenu->AddItem("", "", 0);
pItem->isBlank = true;
return 1;
}
static cell AMX_NATIVE_CALL menu_addtext2(AMX *amx, cell *params)
{
int len;
char *name;
GETMENU(params[1]);
if (!pMenu->items_per_page && pMenu->GetItemCount() >= 10)
{
LogError(amx, AMX_ERR_NATIVE, "Non-paginated menus are limited to 10 items.");
return 0;
}
name = get_amxstring(amx, params[2], 0, len);
validate_menu_text(name);
menuitem *pItem = pMenu->AddItem(name, "", 0);
pItem->isBlank = true;
return 1;
}
@ -805,7 +805,7 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
break;
}
Menu *pOther = g_NewMenus[menu];
Menu *pOther = g_NewMenus[menu];
pOther->Close(pPlayer->index);
/* Infinite loop counter */
@ -822,7 +822,7 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
if (time < 0)
pPlayer->menuexpire = INFINITE;
else
else
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
return pMenu->Display(player, page);
@ -1082,7 +1082,7 @@ static cell AMX_NATIVE_CALL menu_destroy(AMX *amx, cell *params)
{
player = GET_PLAYER_POINTER_I(i);
if (player->newmenu == pMenu->thisId)
{
{
pMenu->Close(player->index);
}
}

View File

@ -7,42 +7,42 @@
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
#include <string.h>
#include "nongpl_matches.h"
NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[] =
{
{"Live", "CZ Gun Game", "czgungame.amxx"},
{"Live", "AMXX Gun Game", "czgungame.amxx"},
{NULL, NULL, NULL},
};
NONGPL_CVAR_T NONGPL_CVAR_LIST[] =
{
{"gg_mode", 0},
{"gg_warmuptimer", 0},
{"gg_ff", 0},
{"gg_fflevel", 0},
{"gg_stats", 0},
{"gg_dm", 0},
{"gg_turbo", 0},
{"amx_ggreset", 1},
{"amx_gg", 1},
{NULL, 0},
};
bool CheckBadConList(const char *cvar, int type)
{
int i = 0;
while (NONGPL_CVAR_LIST[i].cvar != NULL)
{
if (NONGPL_CVAR_LIST[i].type == type
&& strcmp(NONGPL_CVAR_LIST[i].cvar, cvar) == 0)
{
return true;
}
i++;
}
return false;
}
#include <string.h>
#include "nongpl_matches.h"
NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[] =
{
{"Live", "CZ Gun Game", "czgungame.amxx"},
{"Live", "AMXX Gun Game", "czgungame.amxx"},
{NULL, NULL, NULL},
};
NONGPL_CVAR_T NONGPL_CVAR_LIST[] =
{
{"gg_mode", 0},
{"gg_warmuptimer", 0},
{"gg_ff", 0},
{"gg_fflevel", 0},
{"gg_stats", 0},
{"gg_dm", 0},
{"gg_turbo", 0},
{"amx_ggreset", 1},
{"amx_gg", 1},
{NULL, 0},
};
bool CheckBadConList(const char *cvar, int type)
{
int i = 0;
while (NONGPL_CVAR_LIST[i].cvar != NULL)
{
if (NONGPL_CVAR_LIST[i].type == type
&& strcmp(NONGPL_CVAR_LIST[i].cvar, cvar) == 0)
{
return true;
}
i++;
}
return false;
}

View File

@ -6,25 +6,25 @@
// 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_AMXMODX_NONGPL_MATCHES_H_
#define _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
struct NONGPL_PLUGIN_T
{
const char *author;
const char *title;
const char *filename;
};
struct NONGPL_CVAR_T
{
const char *cvar;
int type;
};
extern NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[];
extern NONGPL_CVAR_T NONGPL_CVAR_LIST[];
extern bool CheckBadConList(const char *cvar, int type);
#endif //_INCLUDE_AMXMODX_NONGPL_MATCHES_H_
#ifndef _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
#define _INCLUDE_AMXMODX_NONGPL_MATCHES_H_
struct NONGPL_PLUGIN_T
{
const char *author;
const char *title;
const char *filename;
};
struct NONGPL_CVAR_T
{
const char *cvar;
int type;
};
extern NONGPL_PLUGIN_T NONGPL_PLUGIN_LIST[];
extern NONGPL_CVAR_T NONGPL_CVAR_LIST[];
extern bool CheckBadConList(const char *cvar, int type);
#endif //_INCLUDE_AMXMODX_NONGPL_MATCHES_H_

View File

@ -75,21 +75,21 @@ int sort_ints_desc(const void *int1, const void *int2)
return (*(int *)int2) - (*(int *)int1);
}
void sort_random(cell *array, cell size)
{
srand((unsigned int)time(NULL));
for (int i = size-1; i > 0; i--)
{
int n = rand() % (i + 1);
if (array[i] != array[n])
{
array[i] ^= array[n];
array[n] ^= array[i];
array[i] ^= array[n];
}
}
void sort_random(cell *array, cell size)
{
srand((unsigned int)time(NULL));
for (int i = size-1; i > 0; i--)
{
int n = rand() % (i + 1);
if (array[i] != array[n])
{
array[i] ^= array[n];
array[n] ^= array[i];
array[i] ^= array[n];
}
}
}
static cell AMX_NATIVE_CALL SortIntegers(AMX *amx, cell *params)
@ -395,92 +395,92 @@ static cell AMX_NATIVE_CALL SortCustom2D(AMX *amx, cell *params)
return 1;
}
enum SortType
{
Sort_Integer = 0,
Sort_Float,
Sort_String,
};
int sort_adtarray_strings_asc(const void *str1, const void *str2)
{
return strcmp((char *) str1, (char *) str2);
}
int sort_adtarray_strings_desc(const void *str1, const void *str2)
{
return strcmp((char *) str2, (char *) str1);
enum SortType
{
Sort_Integer = 0,
Sort_Float,
Sort_String,
};
int sort_adtarray_strings_asc(const void *str1, const void *str2)
{
return strcmp((char *) str1, (char *) str2);
}
void sort_adt_random(CellArray *cArray)
{
size_t arraysize = cArray->size();
srand((unsigned int)time(NULL));
for (int i = arraysize-1; i > 0; i--)
{
int n = rand() % (i + 1);
cArray->swap(i, n);
}
int sort_adtarray_strings_desc(const void *str1, const void *str2)
{
return strcmp((char *) str2, (char *) str1);
}
void sort_adt_random(CellArray *cArray)
{
size_t arraysize = cArray->size();
srand((unsigned int)time(NULL));
for (int i = arraysize-1; i > 0; i--)
{
int n = rand() % (i + 1);
cArray->swap(i, n);
}
}
static cell AMX_NATIVE_CALL SortADTArray(AMX *amx, cell *params)
{
CellArray* vec = HandleToVector(amx, params[1]);
if (vec == NULL)
{
return 0;
CellArray* vec = HandleToVector(amx, params[1]);
if (vec == NULL)
{
return 0;
}
cell order = params[2];
if (order == Sort_Random)
{
sort_adt_random(vec);
return 1;
cell order = params[2];
if (order == Sort_Random)
{
sort_adt_random(vec);
return 1;
}
cell type = params[3];
size_t arraysize = vec->size();
size_t blocksize = vec->blocksize();
size_t arraysize = vec->size();
size_t blocksize = vec->blocksize();
cell *array = vec->base();
if (type == Sort_Integer)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_desc);
}
}
else if (type == Sort_Float)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_desc);
}
}
else if (type == Sort_String)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_desc);
}
if (type == Sort_Integer)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_ints_desc);
}
}
else if (type == Sort_Float)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_floats_desc);
}
}
else if (type == Sort_String)
{
if (order == Sort_Ascending)
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_asc);
}
else
{
qsort(array, arraysize, blocksize * sizeof(cell), sort_adtarray_strings_desc);
}
}
return 1;