From 2166c320470f5a545c58c8114e961a473900b154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=BCnbacher?= Date: Sat, 28 Mar 2015 14:04:50 +0100 Subject: [PATCH] Make datapack natives error consistently, stop using IsPackReadable --- amxmodx/datapacks.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/amxmodx/datapacks.cpp b/amxmodx/datapacks.cpp index a61ec8d1..7da0c0ff 100644 --- a/amxmodx/datapacks.cpp +++ b/amxmodx/datapacks.cpp @@ -94,9 +94,9 @@ static cell AMX_NATIVE_CALL ReadPackCell(AMX* amx, cell* params) return 0; } - if (!d->IsReadable(sizeof(char) + sizeof(size_t) + sizeof(cell))) + if (!d->CanReadCell()) { - LogError(amx, AMX_ERR_NATIVE, "DataPack operation is out of bounds."); + LogError(amx, AMX_ERR_NATIVE, "Datapack operation is invalid."); return 0; } @@ -113,9 +113,9 @@ static cell AMX_NATIVE_CALL ReadPackFloat(AMX* amx, cell* params) return 0; } - if (!d->IsReadable(sizeof(char) + sizeof(size_t) + sizeof(float))) + if (!d->CanReadFloat()) { - LogError(amx, AMX_ERR_NATIVE, "DataPack operation is out of bounds."); + LogError(amx, AMX_ERR_NATIVE, "Datapack operation is invalid."); return 0; } @@ -134,14 +134,15 @@ static cell AMX_NATIVE_CALL ReadPackString(AMX* amx, cell* params) return 0; } - const char *str; - size_t len; - if (!(str = d->ReadString(&len))) + if (!d->CanReadString(NULL)) { - LogError(amx, AMX_ERR_NATIVE, "DataPack operation is out of bounds."); + LogError(amx, AMX_ERR_NATIVE, "Datapack operation is invalid."); return 0; } + size_t len; + const char *str = d->ReadString(&len); + return set_amxstring_utf8(amx, params[2], str, len, params[3] + 1); // + EOS }