Forum BigDB BigDB RemoveAt(0) deletes the last item, not the first.

Discussion and help relating to Player.IO's database solution, BigDB.

BigDB RemoveAt(0) deletes the last item, not the first.

Postby FuzzySlash » December 29th, 2011, 4:17 pm

Hey,
I'm afraid I have another problem here.
On the server code I have the following:
Code: Select all
int itemIDSell= message.GetInt(0); //The problem arises when this is 0;

player.RefreshPlayerObject(delegate()
{
player.PlayerObject.GetArray("Inventory").RemoveAt(itemIDSell); // Problem: When itemIDSell is 0, it removes the final item within the array.
player.PlayerObject.Save(false, false, delegate()
{
player.Send("SoldItem");
});
});


Any itemID other than 0 works perfectly fine. Any idea why RemoveAt(0) is deleting the last item within the array, instead of the first?

Thanks again,
Fuzzy
FuzzySlash
Paid Member
 
Posts: 11
Joined: April 15th, 2011, 3:59 am

Re: BigDB RemoveAt(0) deletes the last item, not the first.

Postby Oliver » January 2nd, 2012, 10:51 am

Hello Fuzzy,

We have unit tests for all the various bigdb methods, and since the code you've pasted is intermixed with your client/server logic, i wonder if the cause and effects are correct: that is, if it's really .RemoveAt() that's broken, or if your logic is somehow causing it to send over bad itemIDSell.

Obviously, if the error is on our end, we'd love to fix it. Can you perhaps boil down the code to a self contained example that reliably reproduces the error? Like, a single no-arguments C# method.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1136
Joined: January 12th, 2010, 8:29 am

Re: BigDB RemoveAt(0) deletes the last item, not the first.

Postby FuzzySlash » January 5th, 2012, 7:18 pm

Hey,
Thanks for the reply.
I have tested it without arguments using BigDB.Load instead of RefreshPlayerObject and it worked fine, but I have to test it using RefreshPlayerObject, as that is when the problem happened. I will do so as soon as I have the time.

Another thing though, I've been filtering a ListRooms function by Gametype("PVP" or "Mission") in the game.
It didn't work, there was an error that said "There was a PlayerIO error, please try again" something vague along those lines.

The searchable data was listed in Column 4 in the multiplayer section of the game's admin panel.
I moved it to Column 2 as I didn't need that column, and now it works. When I move it back to 4, again, there is an error. So something seems wrong with 4.

I'll test the initial thread's problem as soon as I can.
Thanks again,
Fuzzy.
FuzzySlash
Paid Member
 
Posts: 11
Joined: April 15th, 2011, 3:59 am

Re: BigDB RemoveAt(0) deletes the last item, not the first.

Postby MrBiscuits » January 25th, 2012, 12:11 am

I'm having a similar problem with RemoveAt always removing the final member of an array.

Here is my code:

DatabaseArray monsterCardArray = player.PlayerObject.GetArray("MonsterCards");

monsterCardArray.RemoveAt(index);

player.PlayerObject.Save(delegate()
{
//
});

When stepping through the code I can see that the correct element in the array is removed from monsterCardArray by the RemoveAt function, however when the playerObject is saved and I check it on BigDB via the admin panel it has removed the final element instead of the one it was supposed to.

It is the same story if I change the line to a particular value:

monsterCardArray.RemoveAt(1);
MrBiscuits
Paid Member
 
Posts: 26
Joined: May 15th, 2011, 8:09 pm

Re: BigDB RemoveAt(0) deletes the last item, not the first.

Postby Henrik » February 15th, 2012, 5:51 pm

FuzzySlash wrote:The searchable data was listed in Column 4 in the multiplayer section of the game's admin panel.
I moved it to Column 2 as I didn't need that column, and now it works. When I move it back to 4, again, there is an error. So something seems wrong with 4.

This bug is now finally fixed, and it'll go out in the next release.
User avatar
Henrik
.IO
 
Posts: 570
Joined: January 4th, 2010, 1:53 pm


Return to BigDB



cron