-
Notifications
You must be signed in to change notification settings - Fork 29
Reworked Items #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reworked Items #111
Conversation
All the items of the player are now in Items. The Location attribute of Item is not just BodyLocation anymore, it contains the position in the inventory along with it's width and height. The Container indicates where the Item is stored (Equipment, Belt, Cube, Inventory, Stash) Changed GetItemDescription to take a D2Unit (item) instead of Item and made it public Added Location for hireling items
|
It works on my end, but still needs to be tested with Plugy and PD2 etc. Also maybe the Hireling needs to be done differently. Also nothing done for the PipeServer thingy :D |
Zutatensuppe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see comments =)
I would ask to undo the 'formatting only' change in GameMemoryTableFactory for now. (Probably the whole project code should be reformatted as a whole, if something like this is done, so that it is consistent. I think it is not 100% consistent atm anyway, but doing partly reformat will make it more inconsistent ^^)
All the other comments are just questions and comments that don't require a change now in my opinion.
| Loading = BaseAddress + 0x30F2C0, | ||
| Saving = BaseAddress + 0x3792F8, | ||
| Saving2 = BaseAddress + 0x3786D0, | ||
| InGame = BaseAddress + 0x30EE8C, | ||
| InMenu = BaseAddress + 0x379970, | ||
|
|
||
| GlobalData = BaseAddress + 0x00344304, // game.744304 | ||
| World = BaseAddress + 0x00483D38, | ||
| PlayersX = BaseAddress + 0x483D70, | ||
| GameId = BaseAddress + 0x00482D0C, | ||
| LowQualityItems = BaseAddress + 0x56CC58, | ||
| ItemDescriptions = BaseAddress + 0x56CA58, | ||
| MagicModifierTable = BaseAddress + 0x56CA7C, | ||
| RareModifierTable = BaseAddress + 0x56CAA0, | ||
| Units113 = null, | ||
| Units114 = BaseAddress + 0x003A5E70, | ||
| PlayerUnit = BaseAddress + 0x003A5E74, | ||
| Area = BaseAddress + 0x003A3140, | ||
| Pets = BaseAddress + 0x003BB5BC, | ||
| InventoryTab = BaseAddress + 0x3BCC4C, | ||
| StringIndexerTable = BaseAddress + 0x4829B4, | ||
| StringAddressTable = BaseAddress + 0x4829B8, | ||
| PatchStringIndexerTable = BaseAddress + 0x4829D0, | ||
| PatchStringAddressTable = BaseAddress + 0x4829BC, | ||
| GlobalData = BaseAddress + 0x344304, // game.744304 | ||
| World = BaseAddress + 0x483D38, | ||
| PlayersX = BaseAddress + 0x483D70, | ||
| GameId = BaseAddress + 0x482D0C, | ||
| LowQualityItems = BaseAddress + 0x56CC58, | ||
| ItemDescriptions = BaseAddress + 0x56CA58, | ||
| MagicModifierTable = BaseAddress + 0x56CA7C, | ||
| RareModifierTable = BaseAddress + 0x56CAA0, | ||
| Units113 = null, | ||
| Units114 = BaseAddress + 0x3A5E70, | ||
| PlayerUnit = BaseAddress + 0x3A5E74, | ||
| Area = BaseAddress + 0x3A3140, | ||
| Pets = BaseAddress + 0x3BB5BC, | ||
| InventoryTab = BaseAddress + 0x3BCC4C, | ||
| StringIndexerTable = BaseAddress + 0x4829B4, | ||
| StringAddressTable = BaseAddress + 0x4829B8, | ||
| PatchStringIndexerTable = BaseAddress + 0x4829D0, | ||
| PatchStringAddressTable = BaseAddress + 0x4829BC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no change here apart from the formatting
the file should not be part of the PR
maybe we can implement some kind of coding standard and then reformat all the code accordingly, but for now i'd like to keep this as it is, if there is no real code change
src/D2Reader/Models/Item.cs
Outdated
| internal bool IsInCube() => !IsEquipped() && ItemData.InvPage == InventoryPage.HoradricCube; | ||
| internal bool IsInStash() => !IsEquipped() && ItemData.InvPage == InventoryPage.Stash; | ||
| internal bool IsInInventory() => !IsEquipped() && ItemData.InvPage == InventoryPage.Inventory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why IsEquipped check is needed in all those cases?
| @@ -0,0 +1,31 @@ | |||
| using System.Runtime.InteropServices; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job finding the new structures =D
| } | ||
|
|
||
| private D2ItemDescription GetItemDescription(Item item) | ||
| public D2ItemDescription GetItemDescription(D2Unit item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for now =)
But I d prefer if this could stay Item (more clear that 100% item comes in, and never another unit), but the change in InventoryReader makes this necessary atm.
| return this.X == other.X && | ||
| this.Y == other.Y && | ||
| this.Width == other.Width && | ||
| this.Height == other.Height && | ||
| this.BodyLocation == other.BodyLocation && | ||
| this.Container == other.Container; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change, but just a note because i saw it in multiple places:
So far we didn't use this kind of alignment of parameters or operators, and at least the reason for me is that a change in one line may increase PR unecessary, because all lines need to be adjusted if longest line changes. But as said, no need to change, it may be better readable this way, and we read this more often than change it :D
And as this is new code and not purely formatting, this is fine for me!
src/D2Reader/Models/Item.cs
Outdated
|
|
||
| public override int GetHashCode() | ||
| { | ||
| return X.GetHashCode() ^ Y.GetHashCode() ^ Width.GetHashCode() ^ Height.GetHashCode() ^ BodyLocation.GetHashCode() ^ Container.GetHashCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty long line ^^
|
Imma reply to all in this comment. I would prefer it if the GameMemoryTableFactory.cs would be all formated like that because it very quickly highlights the memory region the data is in. I formatted that because I initially added my own pointers to get to the item containers and frankly it was horrible to read that code with only some addresses normalized to 8 digits and everything "jagged". I am not sure why I added the IsEquipped() check, probably just didn't understand the way it was done at the time. It doesn't really make any sense if I am looking at it now so I guess I just remove that part. GetItemDescription() Item Comparison |
|
alrighty, I reverted the formatting in GameMemoryTableFactory and removed the unnecessary checks in the Item class I also added the check in GetItemDescription so there will be a sane Exception if the wrong D2Unit type is passed ot the function. |
Zutatensuppe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 nice work! =)
All the items of the player are now in Items.
The Location attribute of Item is not just BodyLocation anymore,
it contains the position in the inventory along with it's width and height.
The Container indicates where the Item is stored (Equipment, Belt, Cube, Inventory, Stash)
Changed GetItemDescription to take a D2Unit (item) instead of Item and made it public
Added Location for hireling items