Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] [CR] Nested Item Containers #11182
Conversation
DavidKeaton
changed the title
Nested Item Containers Update 1
[CR] Nested Item Containers Update 1
Feb 9, 2015
DavidKeaton
reviewed
Feb 9, 2015
View changes
| it->contents.push_back(item(target_id, calendar::turn)); | ||
| target = &it->contents.back(); | ||
| it->contents.add(item(target_id, calendar::turn)); | ||
| target = &it->contents[it->contents.size()]; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KA101
Feb 9, 2015
Contributor
Side note: that comment up there looks Precarious if one stores perishables. Careful with this one.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KA101
Feb 9, 2015
Contributor
Possibly, but a quick search for "container" didn't turn up anything that looked relevant.
This comment has been minimized.
This comment has been minimized.
BevapDin
reviewed
Feb 9, 2015
View changes
|
|
||
| storage::storage(item *self, item_iterator start, item_iterator stop) | ||
| { | ||
| me = self; |
This comment has been minimized.
This comment has been minimized.
BevapDin
Feb 9, 2015
Contributor
Linking back to the parent object is usually not a good approach. This implementation will give you crashes as the pointer is not updated by the copy constructor nor by the assignment operator.
item a = ... ; // a.content.me == &a
item b = ... ; // b.content.me == &b
a = b; // a.content.me == &b
This comment has been minimized.
This comment has been minimized.
BevapDin
reviewed
Feb 9, 2015
View changes
| // removes the item (from iterator) | ||
| item_iterator rem(item_iterator iter); | ||
| // removes a range of items | ||
| std::vector<item> rem(item_iterator start, item_iterator stop); |
This comment has been minimized.
This comment has been minimized.
BevapDin
Feb 9, 2015
Contributor
Why not use the std::vector function names push_back and erase, you don't have to update all the code that uses it.
This comment has been minimized.
This comment has been minimized.
DavidKeaton
Feb 9, 2015
Author
Contributor
I had done just that, but wanted to make the names more sane for their purpose.
BevapDin
reviewed
Feb 9, 2015
View changes
| // items stored in this bag | ||
| std::vector<item> items; | ||
| // holds any extra information we need about storage | ||
| std::map<std::string, void *> var; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
DavidKeaton
Feb 9, 2015
Author
Contributor
it's a generic type, not solely a void pointer, used for type casted data. prob gonna remove.
DavidKeaton
changed the title
[CR] Nested Item Containers Update 1
[CR] Nested Item Containers
Feb 12, 2015
DavidKeaton
force-pushed the
DavidKeaton:item_nested_containers
branch
Feb 15, 2015
DavidKeaton
force-pushed the
DavidKeaton:item_nested_containers
branch
Mar 8, 2015
DavidKeaton
force-pushed the
DavidKeaton:item_nested_containers
branch
Mar 15, 2015
DavidKeaton
added some commits
Feb 9, 2015
DavidKeaton
force-pushed the
DavidKeaton:item_nested_containers
branch
to
69a5d56
Mar 17, 2015
DavidKeaton
changed the title
[CR] Nested Item Containers
[WIP] [CR] Nested Item Containers
Mar 20, 2015
This comment has been minimized.
This comment has been minimized.
|
@DavidKeaton: Any news on this? |
This comment has been minimized.
This comment has been minimized.
|
tbh the aim bit took most of my time, but I want to finish this before the next release. :-) |
This comment has been minimized.
This comment has been minimized.
|
I also have been considering other avenues for doing it, so it's not on the backburner completely! :-) |
This comment has been minimized.
This comment has been minimized.
|
Please read the description as to why this is closed. (new branch) |
DavidKeaton commentedFeb 9, 2015
SUPER NOTE
I have begun working from scratch due to a fresh approach and merge conflicts that have accrued over time. I will be setting up a new PR for this. If you want to take a peek at the new branch, please refer to https://github.com/DavidKeaton/Cataclysm-DDA/tree/item_bags in the meantime. This branch aims to more or less refactor and rework the item class to make all the fun item stuff less of a hack approach and more of a correct one.
Thanks all!
-Davek
END OF SUPER NOTE
_Note!_
This PR is in desperate need of some peer review, but I know ya'll been busy. Whenever someone gets a chance, I'd love to make sure I haven't borked anything bad! :-)
Items all up in Items!
I have placed the storage class in item.h, to reduce clutter for fs and headers.
contentsis now classstorageinstead of a simple std::vector, but is accessible most of the same way as before (see above)._TODO_
AIMinventory_uiUpdate 1:
selfpointer to itemUpdate 2:
Update 3:
push_backanderaseas per @BevapDinUpdate: Also as an aside, I am doing some smaller PRs to take a minor break from this so I don't burn out on it. Still in the works!