Fix missing backward compatibility for some Array natives.

This commit is contained in:
Arkshine 2014-08-09 15:22:18 +02:00
parent 486fa99602
commit 2c146f564e

View File

@ -155,10 +155,13 @@ static cell AMX_NATIVE_CALL ArrayGetArray(AMX* amx, cell* params)
cell *blk = vec->at(idx);
size_t indexes = vec->blocksize();
if (*params / sizeof(cell) == 4)
{
if (params[4] != -1 && (size_t)params[4] <= vec->blocksize())
{
indexes = params[4];
}
}
cell *addr = get_amxaddr(amx, params[3]);
@ -186,6 +189,12 @@ static cell AMX_NATIVE_CALL ArrayGetCell(AMX* amx, cell* params)
}
cell *blk = vec->at(idx);
if (*params / sizeof(cell) <= 2)
{
return *blk;
}
idx = (size_t)params[3];
if (!params[4])
@ -255,10 +264,13 @@ static cell AMX_NATIVE_CALL ArraySetArray(AMX* amx, cell* params)
cell *blk = vec->at(idx);
size_t indexes = vec->blocksize();
if (*params / sizeof(cell) == 4)
{
if (params[4] != -1 && (size_t)params[4] <= vec->blocksize())
{
indexes = params[4];
}
}
cell *addr = get_amxaddr(amx, params[3]);
@ -288,6 +300,12 @@ static cell AMX_NATIVE_CALL ArraySetCell(AMX* amx, cell* params)
cell *blk = vec->at(idx);
idx = (size_t)params[4];
if (*params / sizeof(cell) <= 3)
{
*blk = params[3];
return 1;
}
if (params[5] == 0)
{
if (idx >= vec->blocksize())
@ -357,10 +375,13 @@ static cell AMX_NATIVE_CALL ArrayPushArray(AMX* amx, cell* params)
cell *addr = get_amxaddr(amx, params[2]);
size_t indexes = vec->blocksize();
if (*params / sizeof(cell) == 3)
{
if (params[3] != -1 && (size_t)params[3] <= vec->blocksize())
{
indexes = params[3];
}
}
memcpy(blk, addr, sizeof(cell) * indexes);