{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/44539993","id":44539993,"diff_hunk":"@@ -104,6 +104,55 @@ struct recipe {\n \n };\n \n+enum usage {\n+    use_from_map = 1,\n+    use_from_player = 2,\n+    use_from_both = 1 | 2,\n+    use_from_none = 4,\n+    cancel = 5\n+};\n+\n+template<typename CompType = component>\n+struct comp_selection {\n+    usage use_from = use_from_none;\n+    CompType comp;\n+\n+    std::string nname();\n+};\n+using item_selection = comp_selection<item_comp>;\n+using tool_selection = comp_selection<tool_comp>;\n+\n+class craft_command {\n+    public:\n+        const recipe* rec = nullptr;\n+        int batch_size = 0;\n+        bool is_long = false;\n+        player* crafter; // This is mainly here for maintainability reasons.\n+\n+        craft_command() {}\n+        craft_command( const recipe* to_make, int batch_size, bool is_long, player* crafter ) :\n+            rec( to_make ), batch_size( batch_size ), is_long( is_long ), crafter( crafter ) {}\n+\n+        void execute();\n+        std::list<item> consume_components();\n+\n+        bool has_cached_selections()\n+        {\n+            return !item_selections.empty() || !tool_selections.empty();\n+        }\n+\n+        bool empty()","path":"src/crafting.h","position":41,"original_position":41,"commit_id":"b798f13dcfa3f2d1e58632c9fc89584e8e8ef78c","original_commit_id":"b798f13dcfa3f2d1e58632c9fc89584e8e8ef78c","user":{"login":"BevapDin","id":5095435,"avatar_url":"https://avatars.githubusercontent.com/u/5095435?v=3","gravatar_id":"","url":"https://api.github.com/users/BevapDin","html_url":"https://github.com/BevapDin","followers_url":"https://api.github.com/users/BevapDin/followers","following_url":"https://api.github.com/users/BevapDin/following{/other_user}","gists_url":"https://api.github.com/users/BevapDin/gists{/gist_id}","starred_url":"https://api.github.com/users/BevapDin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BevapDin/subscriptions","organizations_url":"https://api.github.com/users/BevapDin/orgs","repos_url":"https://api.github.com/users/BevapDin/repos","events_url":"https://api.github.com/users/BevapDin/events{/privacy}","received_events_url":"https://api.github.com/users/BevapDin/received_events","type":"User","site_admin":false},"body":"It might not matter now, but this function (and `has_cached_selections` above and `comp_selection::nname`) should be const. The check functions below maybe as well, but I haven't looked into them.\r\n\r\nIt looks strange to see as `has` or `is` or `check` function being non-const, the verb implies only read-access to the data.","created_at":"2015-11-11T14:54:42Z","updated_at":"2015-11-11T14:54:42Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13957#discussion_r44539993","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/44539993"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13957#discussion_r44539993"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957","id":50155124,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13957","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13957.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13957.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13957","number":13957,"state":"open","locked":false,"title":"[Repost] Cancel crafting during component selection","user":{"login":"JornVernee","id":5962029,"avatar_url":"https://avatars.githubusercontent.com/u/5962029?v=3","gravatar_id":"","url":"https://api.github.com/users/JornVernee","html_url":"https://github.com/JornVernee","followers_url":"https://api.github.com/users/JornVernee/followers","following_url":"https://api.github.com/users/JornVernee/following{/other_user}","gists_url":"https://api.github.com/users/JornVernee/gists{/gist_id}","starred_url":"https://api.github.com/users/JornVernee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JornVernee/subscriptions","organizations_url":"https://api.github.com/users/JornVernee/orgs","repos_url":"https://api.github.com/users/JornVernee/repos","events_url":"https://api.github.com/users/JornVernee/events{/privacy}","received_events_url":"https://api.github.com/users/JornVernee/received_events","type":"User","site_admin":false},"body":"I decided to start this again with a fresh branch and without messing up my early commits so it's easier to see what I'm doing. This is a redo of: https://github.com/CleverRaven/Cataclysm-DDA/pull/13943\r\n\r\nHere is the idea again:\r\n'The idea is: when crafting (especially when repeating a craft), sometimes you expect a component to be there but it isn't (because it got used up). There are still other components that can be used, but you might not want to. So I added the ability to cancel crafting when this happens.\r\n\r\nExample:\r\nI'm crafting some item that can ether use a welder or some other components. When I repeat the craft (using '-'), I can not select my welder, because it ran out of batteries, and I don't want to waste the other components. Now I can cancel crafting at this point.'","created_at":"2015-11-09T17:56:47Z","updated_at":"2015-11-11T14:54:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"508f698104018cfceeea41a8a6d4b426ee7d0111","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957/comments","review_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13957/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/b798f13dcfa3f2d1e58632c9fc89584e8e8ef78c","head":{"label":"JornVernee:selection_Canceling","ref":"selection_Canceling","sha":"b798f13dcfa3f2d1e58632c9fc89584e8e8ef78c","user":{"login":"JornVernee","id":5962029,"avatar_url":"https://avatars.githubusercontent.com/u/5962029?v=3","gravatar_id":"","url":"https://api.github.com/users/JornVernee","html_url":"https://github.com/JornVernee","followers_url":"https://api.github.com/users/JornVernee/followers","following_url":"https://api.github.com/users/JornVernee/following{/other_user}","gists_url":"https://api.github.com/users/JornVernee/gists{/gist_id}","starred_url":"https://api.github.com/users/JornVernee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JornVernee/subscriptions","organizations_url":"https://api.github.com/users/JornVernee/orgs","repos_url":"https://api.github.com/users/JornVernee/repos","events_url":"https://api.github.com/users/JornVernee/events{/privacy}","received_events_url":"https://api.github.com/users/JornVernee/received_events","type":"User","site_admin":false},"repo":{"id":45788399,"name":"Cataclysm-DDA","full_name":"JornVernee/Cataclysm-DDA","owner":{"login":"JornVernee","id":5962029,"avatar_url":"https://avatars.githubusercontent.com/u/5962029?v=3","gravatar_id":"","url":"https://api.github.com/users/JornVernee","html_url":"https://github.com/JornVernee","followers_url":"https://api.github.com/users/JornVernee/followers","following_url":"https://api.github.com/users/JornVernee/following{/other_user}","gists_url":"https://api.github.com/users/JornVernee/gists{/gist_id}","starred_url":"https://api.github.com/users/JornVernee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JornVernee/subscriptions","organizations_url":"https://api.github.com/users/JornVernee/orgs","repos_url":"https://api.github.com/users/JornVernee/repos","events_url":"https://api.github.com/users/JornVernee/events{/privacy}","received_events_url":"https://api.github.com/users/JornVernee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JornVernee/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":true,"url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA","forks_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/JornVernee/Cataclysm-DDA/releases{/id}","created_at":"2015-11-08T16:25:39Z","updated_at":"2015-11-08T16:26:34Z","pushed_at":"2015-11-11T00:37:30Z","git_url":"git://github.com/JornVernee/Cataclysm-DDA.git","ssh_url":"git@github.com:JornVernee/Cataclysm-DDA.git","clone_url":"https://github.com/JornVernee/Cataclysm-DDA.git","svn_url":"https://github.com/JornVernee/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":563758,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CleverRaven:master","ref":"master","sha":"aa3d16118bc67ffcbbc953d9d64fd0031768b03b","user":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"repo":{"id":5973855,"name":"Cataclysm-DDA","full_name":"CleverRaven/Cataclysm-DDA","owner":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":false,"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","forks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/releases{/id}","created_at":"2012-09-26T22:57:43Z","updated_at":"2015-11-11T05:46:02Z","pushed_at":"2015-11-11T14:22:32Z","git_url":"git://github.com/CleverRaven/Cataclysm-DDA.git","ssh_url":"git@github.com:CleverRaven/Cataclysm-DDA.git","clone_url":"https://github.com/CleverRaven/Cataclysm-DDA.git","svn_url":"https://github.com/CleverRaven/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":864921,"stargazers_count":780,"watchers_count":780,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":796,"mirror_url":null,"open_issues_count":1140,"forks":796,"open_issues":1140,"watchers":780,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13957"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13957"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13957/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957/comments"},"review_comment":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13957/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/b798f13dcfa3f2d1e58632c9fc89584e8e8ef78c"}}}}