Add ICellArray and create/free in ISourceMod
Add an ICellArray interface to expose the adt_array CellArray class from logic to core. Add methods to ISourceMod to create and delete ICellArray instances in logic.
This commit is contained in:
+15
-2
@@ -34,10 +34,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ICellArray.h>
|
||||
|
||||
extern HandleType_t htCellArray;
|
||||
|
||||
class CellArray
|
||||
class CellArray : public ICellArray
|
||||
{
|
||||
public:
|
||||
CellArray(size_t blocksize) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_Size(0)
|
||||
@@ -49,6 +50,18 @@ public:
|
||||
free(m_Data);
|
||||
}
|
||||
|
||||
static ICellArray *New(size_t blocksize)
|
||||
{
|
||||
return new CellArray(blocksize);
|
||||
}
|
||||
|
||||
static void Free(ICellArray *arr)
|
||||
{
|
||||
delete arr;
|
||||
}
|
||||
|
||||
// ICellArray
|
||||
public:
|
||||
size_t size() const
|
||||
{
|
||||
return m_Size;
|
||||
@@ -154,7 +167,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
CellArray *clone()
|
||||
ICellArray *clone()
|
||||
{
|
||||
CellArray *array = new CellArray(m_BlockSize);
|
||||
array->m_AllocSize = m_AllocSize;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "LibrarySys.h"
|
||||
#include "RootConsoleMenu.h"
|
||||
#include "CDataPack.h"
|
||||
#include "CellArray.h"
|
||||
#include <bridge/include/BridgeAPI.h>
|
||||
#include <bridge/include/IProviderCallbacks.h>
|
||||
|
||||
@@ -147,6 +148,8 @@ static sm_logic_t logic =
|
||||
RegisterProfiler,
|
||||
CDataPack::New,
|
||||
CDataPack::Free,
|
||||
CellArray::New,
|
||||
CellArray::Free,
|
||||
&g_PluginSys,
|
||||
&g_ShareSys,
|
||||
&g_Extensions,
|
||||
|
||||
@@ -502,7 +502,7 @@ static cell_t CloneArray(IPluginContext *pContext, const cell_t *params)
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
CellArray *array = oldArray->clone();
|
||||
ICellArray *array = oldArray->clone();
|
||||
|
||||
Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||
if (!hndl)
|
||||
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
{
|
||||
return strcmp((char *)str1, (char *)str2);
|
||||
}
|
||||
CellArray *UpdateMapList(CellArray *pUseArray, const char *name, int *pSerial, unsigned int flags)
|
||||
ICellArray *UpdateMapList(ICellArray *pUseArray, const char *name, int *pSerial, unsigned int flags)
|
||||
{
|
||||
int change_serial;
|
||||
CellArray *pNewArray = NULL;
|
||||
@@ -594,7 +594,7 @@ static cell_t LoadMapList(IPluginContext *pContext, const cell_t *params)
|
||||
char *str;
|
||||
Handle_t hndl;
|
||||
cell_t *addr, flags;
|
||||
CellArray *pArray, *pNewArray;
|
||||
ICellArray *pArray, *pNewArray;
|
||||
|
||||
hndl = params[1];
|
||||
pContext->LocalToPhysAddr(params[2], &addr);
|
||||
|
||||
Reference in New Issue
Block a user