{"action":"created","issue":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17154","repository_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17154/labels{/name}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17154/comments","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17154/events","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17154","id":159825161,"number":17154,"title":"Crafting snapshots [WIP] [CR]","user":{"login":"mugling","id":12238606,"avatar_url":"https://avatars.githubusercontent.com/u/12238606?v=3","gravatar_id":"","url":"https://api.github.com/users/mugling","html_url":"https://github.com/mugling","followers_url":"https://api.github.com/users/mugling/followers","following_url":"https://api.github.com/users/mugling/following{/other_user}","gists_url":"https://api.github.com/users/mugling/gists{/gist_id}","starred_url":"https://api.github.com/users/mugling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugling/subscriptions","organizations_url":"https://api.github.com/users/mugling/orgs","repos_url":"https://api.github.com/users/mugling/repos","events_url":"https://api.github.com/users/mugling/events{/privacy}","received_events_url":"https://api.github.com/users/mugling/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-06-12T12:38:12Z","updated_at":"2016-07-11T17:37:06Z","closed_at":"2016-07-11T17:37:06Z","pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/17154","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17154","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17154.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17154.patch"},"body":"`Character::crafting_inventory` has two major limitations:\r\n* It does not support an item `quality` consuming charges (eg. `WELD 2`)\r\n* Vehicle mounted tools are provided by an ugly and buggy hack (`pseudo` items)\r\n\r\nI'd like to propose a new `snapshot` class that uses the `visitable` interface to cache available items, charges and qualities. This PR outlines a potential design for review.\r\n\r\nThree maps, `items`, `charges` and `quals` are used to cache all available sources which are stored via `item_location`. Queries against these caches are very efficient. Only when methods external to `snapshot` manipulate items is it necessary to call `refresh`. \r\n\r\nFor crafting recipes with multiple requirements it is possible that an earlier selection removed an entry which also exists elsewhere in the caches. For example `screwdriver` will exist in both `items` and `quals` whereas `toolbox` provides multiple `quals`.\r\n\r\nRather than traversing each cache to remove all invalidated entries these are instead pushed to `snapshot::invalid`. Invalidated entries are then checked for on-demand. In theory two ordered sets can be handled in linear time but as `invalid` is likely to be at most a few entries `clean_invalid` takes the simpler approach.\r\n\r\nAre there any more efficient designs without excessive complexity?"},"comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments/231807219","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/17154#issuecomment-231807219","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/17154","id":231807219,"user":{"login":"mugling","id":12238606,"avatar_url":"https://avatars.githubusercontent.com/u/12238606?v=3","gravatar_id":"","url":"https://api.github.com/users/mugling","html_url":"https://github.com/mugling","followers_url":"https://api.github.com/users/mugling/followers","following_url":"https://api.github.com/users/mugling/following{/other_user}","gists_url":"https://api.github.com/users/mugling/gists{/gist_id}","starred_url":"https://api.github.com/users/mugling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mugling/subscriptions","organizations_url":"https://api.github.com/users/mugling/orgs","repos_url":"https://api.github.com/users/mugling/repos","events_url":"https://api.github.com/users/mugling/events{/privacy}","received_events_url":"https://api.github.com/users/mugling/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T17:37:06Z","updated_at":"2016-07-11T17:37:06Z","body":"Closed for now, may reopen when resuming work on this"}}
{"actor":{"display_login":"mugling"}}