Skip to content

Conversation

@tischepe
Copy link

@tischepe tischepe commented Jun 1, 2017

I've noticed that the backpack empty space count is not always correct,
The rotmg server returns this:
<Char id="***">
<ObjectType>782</ObjectType>
<Level>20</Level>
<Exp>154063</Exp>
<CurrentFame>261</CurrentFame>
<Equipment>2719,2774,2656,2755,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1</Equipment>
... snip ...
<HasBackpack>0</HasBackpack>
</Char>
The character has no backpack, yet equipment contains 19 items, these 7 nonexistent empty spaces get counted in totals.

So I slice the array if the char has no backpack before pushing it into items.

@Nightfirecat
Copy link
Contributor

What's the story about there being 19 slots of equipment? Why are 12 of 19 valid? (equips make 4, inventory is 8, backpack is 8 more, unless I'm missing something)

Just trying to figure out where all these numbers are coming from.

P.S. It might help to define magic numbers like these as constants. I know that's not done too well across the code as-is, but it would help for future maintenance.

@tischepe
Copy link
Author

tischepe commented Jun 1, 2017

Everything between <Char id="***"> and </Char> is generated by realmofthemadgodhrd.appspot.com/char/list so where those 7 extra -1 items come from, you would need to ask Deca games.
You mean, you want to define 0 as equipment_Begin, 3 as equipment_End, 4 as inventory_Begin etc.?

@Nightfirecat
Copy link
Contributor

No, I mean I'd like to define the 12 that marks the end of the slice. Why 12 exactly? What does that represent? (equip + inventory?)

@tischepe
Copy link
Author

tischepe commented Jun 1, 2017

Yes 12 is (equip + inventory)
I see two ways of doing this:
to complete the list I was making:
0 as equipment_Begin
3 as equipment_End
4 as inventory_Begin
11 as inventory_End
12 as backpack_Begin
19 as backpack_End
then you could write: this.items.chars.push(eq.slice(equipment_Begin, backpack_Begin));

Or you could also just define:
equipmentSize as 4
inventorySize as 8
backpackSize as 8
and write: this.items.chars.push(eq.slice(0, equipmentSize + inventorySize));

@Nightfirecat
Copy link
Contributor

I wouldn't overthink it. That said, I'm still a little worried about why 19 is the number we come up with for number of total inventory slots. Is that result different if you check a character which does have a backpack enabled?

@tischepe
Copy link
Author

tischepe commented Jun 1, 2017

Just to be clear, the 19 in "19 as backpack_End" comes from the fact that javascript start array indexes at 0.
The 19 items in "2719,2774,2656,2755,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1" is some weird thing Deca games its servers generate.
And yes, a char with backpack does have 20 itemslots. and example:
<Equipment>3151,3160,2703,2757,2815,2698,2698,2698,2698,2698,2698,
2698,2722,2722,2722,2722,2722,2722,2722,2722</Equipment>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants