Intersect-Engine
Intersect-Engine copied to clipboard
bug: api throws error when using ["bankoverflow"] => bool(true) to "Give Item"
Description
If you try to give an item to a player with a full inventory, and pass the ["bankoverflow"] => bool(true) to the api, the api responds with an error. Cheshire mentioned the error points to issues finding bank slots.
sent to api: array(3) { ["itemid"]=> string(36) "41f04cd7-9d87-450d-ab41-80a918833f36" ["quantity"]=> string(1) "1" ["bankoverflow"]=> string(4) "true" }
Of course, the character had open bank slots and the item was able to be banked.
Steps to Reproduce
- Log into the game.
- Log into any character.
- Fill the character's inventory with items until there are no inventory spaces left.
- Send the following data to the api using the player's id where "$pID" is below:
$url = 'path/to/api/v1/players/'.$pID.'/items/give';
$data = array(
"itemid" => $itemID,
"quantity" => $itemQ,
"bankoverflow" => true
);
Actual result: the api throws an error Expected result: the api should respond with "item given successfully" or "failed to give item"
Version with bug
v0.7.1.079
Last version that worked well
unknown
Affected platforms
Windows, I was not able test on other platforms
Did you find any workaround?
No, I cannot give an item and have it overflow into the player's bank.
Relevant log output
API Response:
{
"Message": "An error has occurred.",
"ExceptionMessage": "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index",
"ExceptionType": "System.ArgumentOutOfRangeException",
"StackTrace": " <below> "
}
Stack trace
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <5dfd69ae4e3b402db546d8ded6fc755e>:0
at Intersect.Server.Entities.BankInterface.FindOpenSlots () [0x0000c] in <549f78e9699443dc8f3df1cd4ff9a29b>:0
at Intersect.Server.Entities.BankInterface.CanStoreItem (Intersect.Server.Database.Item item) [0x000fd] in <549f78e9699443dc8f3df1cd4ff9a29b>:0
at Intersect.Server.Entities.BankInterface.TryDepositItem (Intersect.Server.Database.Item item, System.Boolean sendUpdate) [0x00164] in <549f78e9699443dc8f3df1cd4ff9a29b>:0
at Intersect.Server.Entities.Player.TryGiveItem (Intersect.Server.Database.Item item, Intersect.Enums.ItemHandling handler, System.Boolean bankOverflow, System.Int32 slot, System.Boolean sendUpdate, System.Int32 overflowTileX, System.Int32 overflowTileY) [0x0022a] in <549f78e9699443dc8f3df1cd4ff9a29b>:0
at Intersect.Server.Entities.Player.TryGiveItem (System.Guid itemId, System.Int32 quantity, Intersect.Enums.ItemHandling handler, System.Boolean bankOverflow, System.Int32 slot, System.Boolean sendUpdate) [0x00009] in <549f78e9699443dc8f3df1cd4ff9a29b>:0
at Intersect.Server.Web.RestApi.Routes.V1.PlayerController.ItemsGive (Intersect.Server.Web.RestApi.Payloads.LookupKey lookupKey, Intersect.Server.Web.RestApi.Payloads.ItemInfo itemInfo) [0x00120] in <549f78e9699443dc8f3df1cd4ff9a29b>:0
at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,object,object[])
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor+ActionExecutor+<>c__DisplayClass6_2.b__2 (System.Object instance, System.Object[] methodParameters) [0x00000] in <469ece4c5e50469a945a25a6befb4ee5>:0
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor+ActionExecutor.Execute (System.Object instance, System.Object[] arguments) [0x00000] in <469ece4c5e50469a945a25a6befb4ee5>:0
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync (System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Collections.Generic.IDictionary`2[TKey,TValue] arguments, System.Threading.CancellationToken cancellationToken) [0x00046] in <469ece4c5e50469a945a25a6befb4ee5>:0 --- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsyncCore (System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken) [0x000ab] in <469ece4c5e50469a945a25a6befb4ee5>:0
at System.Web.Http.Controllers.ActionFilterResult.ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00109] in <469ece4c5e50469a945a25a6befb4ee5>:0
at System.Web.Http.Filters.AuthorizationFilterAttribute.ExecuteAuthorizationFilterAsyncCore (System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken, System.Func`1[TResult] continuation) [0x000f3] in <469ece4c5e50469a945a25a6befb4ee5>:0
at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00152] in <469ece4c5e50469a945a25a6befb4ee5>:0
Duplicate Bug Check
- [X] This bug report is not a duplicate to the best of my knowledge.
The mBank[i] is the responsible code. My guess is that it either wasn't loaded from the DB properly, or the BankInterface was not initialized correctly.
public List<int> FindOpenSlots()
{
var slots = new List<int>();
for (var i = 0; i < mMaxSlots; i++)
{
var bankSlot = mBank[i];
if (bankSlot != null && bankSlot.ItemId == Guid.Empty)
{
slots.Add(i);
}
}
return slots;
}
@izakt Is the player offline or online when this occurs?
In the opposite state (e.g. if this is when a player is offline please re-run the test when the player is online), what happens when this request is done?
@lodicolo I get the same result (api error) whether the player is offline or is online. I attached some gifs that try to show the whole process.
