Checkweight
-Fix bugreport:8503 (chkweight uint16 limitation on weight thx to AnnieRuru) -Add this testcase on npc_test_checkweight.txt and move it to npec/tests folder.
This commit is contained in:
parent
27cbc7ff24
commit
8115dc048a
@ -1 +1,7 @@
|
||||
// --------------------------------------------------------------
|
||||
// - Tests Scripts -
|
||||
// --------------------------------------------------------------
|
||||
// Thoses scripts are meant for regression test purposes
|
||||
|
||||
npc: npc/test/OnInterInit.txt
|
||||
npc: npc/test/npc_test_checkweight.txt
|
||||
|
@ -88,54 +88,72 @@ L_TEST3: //update using array tests
|
||||
.@succes = 0;
|
||||
|
||||
setarray .@item[0], 512,513,514,515;
|
||||
setarray .@count[0], 1,5,9,12;
|
||||
setarray .@count[0], 1,5,9,12;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be sucess
|
||||
|
||||
cleararray .@item[0], 0, 4;
|
||||
cleararray .@count[0], 0, 4;
|
||||
setarray .@item[0], 512,513,514,515;
|
||||
setarray .@count[0], 1,5,-1,12;
|
||||
setarray .@count[0], 1,5,-1,12;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, invalide amout
|
||||
|
||||
cleararray .@item[0], 0, 4;
|
||||
cleararray .@count[0], 0, 4;
|
||||
setarray .@item[0], 512,513,514,-1;
|
||||
setarray .@count[0], 1,5,15,12;
|
||||
setarray .@count[0], 1,5,15,12;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, invalide id
|
||||
|
||||
cleararray .@item[0], 0, 4;
|
||||
cleararray .@count[0], 0, 4;
|
||||
setarray .@item[0], 717,715,716,714;
|
||||
setarray .@count[0], 300,300,300,300;
|
||||
setarray .@count[0], 300,300,300,300;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, total by weight
|
||||
|
||||
cleararray .@item[0], 0, 4;
|
||||
cleararray .@count[0], 0, 4;
|
||||
setarray .@item[0], 6320,6320;
|
||||
setarray .@count[0], 31000,2000;
|
||||
setarray .@count[0], 31000,2000;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, total by weight
|
||||
|
||||
cleararray .@item[0], 0, 2;
|
||||
cleararray .@count[0], 0, 2;
|
||||
setarray .@item[0], 2794,2795;
|
||||
setarray .@count[0], 95,5;
|
||||
setarray .@count[0], 95,5;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success
|
||||
setarray .@count[0], 95,10;
|
||||
|
||||
setarray .@count[0], 95,10;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure overamount item
|
||||
|
||||
cleararray .@item[0], 0, 2;
|
||||
cleararray .@count[0], 0, 2;
|
||||
setarray .@item[0], 6320,6320,512;
|
||||
setarray .@count[0], 1,3;
|
||||
setarray .@count[0], 1,3;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch
|
||||
|
||||
cleararray .@item[0], 0, 3;
|
||||
cleararray .@count[0], 0, 2;
|
||||
setarray .@item[0], 6320,6320;
|
||||
setarray .@count[0], 1,3,5;
|
||||
setarray .@item[0], 6320,6321;
|
||||
setarray .@count[0], 1,3,5;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch
|
||||
set .@succes,.@succes+ChkResult(.@testid++,0,.@ret); //should be failure, size mistmatch
|
||||
|
||||
set .@weight_limit, MaxWeight;
|
||||
set MaxWeight, 4294967296 - 1; //currently maxweight is stored as uint32 (2^32-1)
|
||||
cleararray .@item[0], 0, 2;
|
||||
cleararray .@count[0], 0, 3;
|
||||
setarray .@item[0], 714;
|
||||
setarray .@count[0], 300;
|
||||
.@ret = checkweight2(.@item,.@count);
|
||||
set MaxWeight, .@weight_limit;
|
||||
set .@succes,.@succes+ChkResult(.@testid++,1,.@ret); //should be success, (test weight over 65k)
|
||||
|
||||
|
||||
debugmes "End update by array tests";
|
@ -6151,7 +6151,8 @@ int checkweight_sub(TBL_PC *sd,int nbargs,int32 *eitemid,int32 *eamount)
|
||||
{
|
||||
struct item_data* id = NULL;
|
||||
int nameid,amount;
|
||||
uint16 amount2=0,slots,weight=0,i;
|
||||
uint32 weight=0;
|
||||
uint16 amount2=0,slots,i;
|
||||
|
||||
slots = pc_inventoryblank(sd); //nb of empty slot
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user