{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/44990389","id":44990389,"diff_hunk":"@@ -834,110 +834,103 @@ int game::inv_for_salvage(const std::string &title, const salvage_actor& actor )\n     return display_slice(reduced_inv, title);\n }\n \n-constexpr char first_invlet = '0';\n-constexpr char last_invlet = '9';\n-typedef std::vector< std::list<item> > pseudo_inventory;\n-\n-template<typename Collection, typename Filter>\n-void pseudo_inv_to_slice( Collection here, Filter filter,\n-                          pseudo_inventory &item_stacks, indexed_invslice &result_slice,\n-                          std::vector<item *> &selectables, char &cur_invlet )\n+item_location game::inv_map_splice( item_filter filter, const std::string &title, int radius )\n {\n-\n-    for( auto candidate = here.begin(); candidate != here.end(); ++candidate ) {\n-        if( filter( *candidate ) ) {\n-            // Check if we can stack the item with an existing one\n-            bool stacks = false;\n-            for( auto &elem : item_stacks ) {\n-                if( candidate->stacks_with( elem.back() ) ) {\n-                    stacks = true;\n-                    elem.push_back( *candidate );\n-                    break;\n-                }\n-            }\n-\n-            if( !stacks ) {\n-                item_stacks.push_back( std::list<item>( 1, *candidate ) );\n-\n-                if( cur_invlet <= last_invlet ) {\n-                    item_stacks.back().front().invlet = cur_invlet;\n-                    cur_invlet++;\n-                } else {\n-                    item_stacks.back().front().invlet = ' ';\n-                }\n-\n-                selectables.push_back( &*candidate );\n-            }\n-        }\n-    }\n-\n-    for( size_t a = 0; a < item_stacks.size(); a++ ) {\n-        // avoid INT_MIN, as it can be confused with \"no item at all\"\n-        result_slice.push_back( indexed_invslice::value_type( &item_stacks[a], INT_MIN + a + 1 ) );\n-    }\n-}\n-\n-item_location game::inv_map_splice( item_filter filter, const std::string &title )\n-{\n-    return inv_map_splice( filter, filter, filter, title );\n+    return inv_map_splice( filter, filter, filter, title, radius );\n }\n \n item_location game::inv_map_splice(\n-    item_filter inv_filter, item_filter ground_filter, item_filter vehicle_filter, const std::string &title )\n+    item_filter inv_filter, item_filter ground_filter, item_filter vehicle_filter, const std::string &title, int radius )\n {\n-    char cur_invlet = '0';\n-\n-    pseudo_inventory ground_items;\n-    pseudo_inventory vehicle_items;\n-\n-    std::vector<item *> ground_selectables;\n-    std::vector<item *> vehicle_selectables;\n-\n-    indexed_invslice ground_items_slice;\n-    indexed_invslice veh_items_slice;\n+    inventory_selector inv_s(false, false, title);\n \n-    if( !m.has_flag( \"SEALED\", g->u.pos() ) ) {\n-        pseudo_inv_to_slice( m.i_at( g->u.pos() ), ground_filter,\n-                             ground_items, ground_items_slice,\n-                             ground_selectables, cur_invlet );\n-    }\n+    // first get matching items from the inventory\n+    u.inv.restack(&u);\n+    u.inv.sort();\n+    inv_s.make_item_list(u.inv.slice_filter_by(inv_filter));\n+\n+    static const item_category ground_cat (\"GROUND:\",  _(\"GROUND:\"),  -1000);\n+    static const item_category nearby_cat (\"NEARBY:\",  _(\"NEARBY:\"),  -2000);\n+    static const item_category vehicle_cat(\"VEHICLE:\", _(\"VEHICLE:\"), -3000);\n+\n+    std::vector<std::vector<std::list<item>>> stacks;\n+    std::vector<indexed_invslice> slices;\n+    std::unordered_map<item *, item_location> opts;\n+\n+    const char min_invlet = '0';\n+    const char max_invlet = '9';\n+    char cur_invlet = min_invlet;\n+    std::vector<item_location> invlets;\n+\n+    for (const auto& pos : closest_tripoints_first(radius, g->u.pos())) {\n+        // second get all matching items on the map within radius\n+        if (m.accessible_items(g->u.pos(), pos, radius)) {\n+            auto items = m.i_at(pos);\n+\n+            // create a new slice and stack for the current map tile\n+            stacks.emplace_back(items.size());","path":"src/inventory_ui.cpp","position":99,"original_position":99,"commit_id":"7a1452519bd4616a3ed4eff12dece4a2f8110e37","original_commit_id":"7a1452519bd4616a3ed4eff12dece4a2f8110e37","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},"body":"> Did you want a vector with items.size() capacity?\r\n\r\nYes, I swapped a call to `std::vector::reserve` for that constructor call but as you've noted it's not equivalent given that for an empty list the call to `std::list::back` is undefined behavior","created_at":"2015-11-16T22:00:23Z","updated_at":"2015-11-16T22:00:23Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13986#discussion_r44990389","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/44990389"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13986#discussion_r44990389"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986","id":50415873,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13986","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13986.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13986.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13986","number":13986,"state":"open","locked":false,"title":"Extend inv_map_splice to include items within radius","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},"body":"Successor to #13970 which started out as a refactor but has ended up as a nuking of the original function\r\n\r\nSummary:\r\n* Adds `radius` parameter to `inv_map_splice`\r\n* Items are stacked per tile with separate stacking for map and vehicle items\r\n* Map items not on the current tile are shown as `NEARBY` and in order of proximity\r\n* Items not in inventory are allocated invlets `0` to `9` (inclusive)\r\n* Unlike the original function does not segfault when selecting items by invlet\r\n\r\nProbably has many possible uses (eg. #13907 and especially #13153) but for now merely lets you consume items from adjacent tiles and therefore resolves #13955 ","created_at":"2015-11-11T18:08:52Z","updated_at":"2015-11-16T22:00:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7564acd7e7ea49d94a7fff33b01effa7e973b542","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986/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/13986/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/7a1452519bd4616a3ed4eff12dece4a2f8110e37","head":{"label":"mugling:adjacent","ref":"adjacent","sha":"7a1452519bd4616a3ed4eff12dece4a2f8110e37","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},"repo":{"id":35048130,"name":"Cataclysm-DDA","full_name":"mugling/Cataclysm-DDA","owner":{"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},"private":false,"html_url":"https://github.com/mugling/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":true,"url":"https://api.github.com/repos/mugling/Cataclysm-DDA","forks_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/mugling/Cataclysm-DDA/releases{/id}","created_at":"2015-05-04T17:12:42Z","updated_at":"2015-05-05T15:58:32Z","pushed_at":"2015-11-15T23:54:45Z","git_url":"git://github.com/mugling/Cataclysm-DDA.git","ssh_url":"git@github.com:mugling/Cataclysm-DDA.git","clone_url":"https://github.com/mugling/Cataclysm-DDA.git","svn_url":"https://github.com/mugling/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":561304,"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":"dc57de4c7d05812e517677dffc609d7fc5cdf8aa","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-15T20:33:58Z","pushed_at":"2015-11-16T21:40:14Z","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":867594,"stargazers_count":784,"watchers_count":784,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":798,"mirror_url":null,"open_issues_count":1134,"forks":798,"open_issues":1134,"watchers":784,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/13986"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13986"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/13986/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/13986/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/13986/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/7a1452519bd4616a3ed4eff12dece4a2f8110e37"}}}}