Fix typo, documention and others issues.
This commit is contained in:
@@ -147,8 +147,8 @@ void UTIL_ShowMenu(edict_t* pEntity, int slots, int time, char *menu, int mlen);
|
||||
void UTIL_ClientSayText(edict_t *pEntity, int sender, char *msg);
|
||||
void UTIL_TeamInfo(edict_t *pEntity, int playerIndex, const char *pszTeamName);
|
||||
|
||||
template <typename D> int UTIL_CheckValidChar(D *c);
|
||||
template <typename D> unsigned int strncopy(D *dest, const char *src, size_t count);
|
||||
template <typename D> int UTIL_CheckValidChar(D *c);
|
||||
template <typename D, typename S> unsigned int strncopy(D *dest, const S *src, size_t count);
|
||||
unsigned int UTIL_GetUTF8CharBytes(const char *stream);
|
||||
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive);
|
||||
char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t searchLen, const char *replace, size_t replaceLen, bool caseSensitive);
|
||||
|
@@ -48,7 +48,6 @@ static cell AMX_NATIVE_CALL ArrayCreate(AMX* amx, cell* params)
|
||||
|
||||
// params[2] (reserved) is how many elements to allocate
|
||||
// immediately when the list is created.
|
||||
// this MUST be greater than 0!
|
||||
int reserved = params[2];
|
||||
|
||||
if (cellsize <= 0)
|
||||
@@ -56,11 +55,6 @@ static cell AMX_NATIVE_CALL ArrayCreate(AMX* amx, cell* params)
|
||||
LogError(amx, AMX_ERR_NATIVE, "Invalid array size (%d)", cellsize);
|
||||
return -1;
|
||||
}
|
||||
if (reserved <= 0)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NATIVE, "Invalid reserved size (%d)", reserved);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Scan through the vector list to see if any are NULL.
|
||||
// NULL means the vector was previously destroyed.
|
||||
@@ -69,14 +63,23 @@ static cell AMX_NATIVE_CALL ArrayCreate(AMX* amx, cell* params)
|
||||
if (VectorHolder[i]==NULL)
|
||||
{
|
||||
VectorHolder[i] = new CellArray(cellsize);
|
||||
//VectorHolder[i]->resize(reserved);
|
||||
|
||||
if (reserved > 0)
|
||||
{
|
||||
VectorHolder[i]->resize(reserved);
|
||||
}
|
||||
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// None are NULL, create a new vector
|
||||
CellArray* NewVector = new CellArray(cellsize);
|
||||
//NewVector->resize(reserved);
|
||||
|
||||
if (reserved > 0)
|
||||
{
|
||||
NewVector->resize(reserved);
|
||||
}
|
||||
|
||||
VectorHolder.append(NewVector);
|
||||
|
||||
@@ -188,7 +191,7 @@ static cell AMX_NATIVE_CALL ArrayGetArray(AMX* amx, cell* params)
|
||||
|
||||
memcpy(addr, blk, sizeof(cell) * indexes);
|
||||
|
||||
return 1;
|
||||
return indexes;
|
||||
}
|
||||
|
||||
// native any:ArrayGetCell(Array:which, item, block = 0, bool:asChar = false);
|
||||
@@ -288,7 +291,7 @@ static cell AMX_NATIVE_CALL ArraySetArray(AMX* amx, cell* params)
|
||||
|
||||
memcpy(blk, addr, sizeof(cell) * indexes);
|
||||
|
||||
return 1;
|
||||
return indexes;
|
||||
}
|
||||
|
||||
// native ArraySetCell(Array:which, item, any:input, block = 0, bool:asChar = false);
|
||||
@@ -425,15 +428,13 @@ static cell AMX_NATIVE_CALL ArrayPushString(AMX* amx, cell* params)
|
||||
}
|
||||
|
||||
cell *blk = vec->push();
|
||||
cell *start = blk;
|
||||
if (!blk)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NATIVE, "Failed to grow array");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(blk, get_amxaddr(amx, params[2]), sizeof(cell) * vec->blocksize());
|
||||
blk[vec->blocksize() - 1]= '\0';
|
||||
strncopy(blk, get_amxaddr(amx, params[2]), vec->blocksize());
|
||||
|
||||
return static_cast<cell>((vec->size() - 1));
|
||||
}
|
||||
@@ -634,7 +635,7 @@ static cell AMX_NATIVE_CALL ArraySwap(AMX* amx, cell* params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
vec->swap(params[2], params[3]);
|
||||
vec->swap(idx1, idx2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -514,11 +514,12 @@ unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search
|
||||
return total;
|
||||
}
|
||||
|
||||
template unsigned int strncopy<char>(char *, const char *src, size_t count);
|
||||
template unsigned int strncopy<cell>(cell *, const char *src, size_t count);
|
||||
template unsigned int strncopy<char, char>(char *, const char *src, size_t count);
|
||||
template unsigned int strncopy<cell, char>(cell *, const char *src, size_t count);
|
||||
template unsigned int strncopy<cell, cell>(cell *, const cell *src, size_t count);
|
||||
|
||||
template <typename D>
|
||||
unsigned int strncopy(D *dest, const char *src, size_t count)
|
||||
template <typename D, typename S>
|
||||
unsigned int strncopy(D *dest, const S *src, size_t count)
|
||||
{
|
||||
if (!count)
|
||||
{
|
||||
|
Reference in New Issue
Block a user