{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/26893024","id":26893024,"diff_hunk":"@@ -198,28 +200,80 @@ const vehicle* map::veh_at_internal( const int x, const int y, int &part_num) co\n     return nullptr;\n }\n \n-point map::veh_part_coordinates(const int x, const int y)\n+vehicle* map::veh_at(const int x, const int y)\n {\n-    int part_num;\n-    vehicle* veh = veh_at(x, y, part_num);\n+    int part = 0;\n+    return veh_at(x, y, part);\n+}\n \n-    if(veh == nullptr) {\n-        return point(0,0);\n+const vehicle* map::veh_at(const int x, const int y) const\n+{\n+    int part = 0;\n+    return veh_at(x, y, part);\n+}\n+\n+// 3D veh_at functions\n+\n+vehicle* map::veh_at( const tripoint &p, int &part_num )\n+{\n+    if( !veh_in_active_range || !inbounds( p ) ) {\n+        return nullptr; // Out-of-bounds - null vehicle\n     }\n \n-    return veh->parts[part_num].mount;\n+    // Apparently this is a proper coding practice and not an ugly hack\n+    return const_cast<vehicle *>( veh_at_internal( p, part_num ) );\n }\n \n-vehicle* map::veh_at(const int x, const int y)\n+const vehicle* map::veh_at( const tripoint &p, int &part_num ) const\n+{\n+    if( !veh_in_active_range || !inbounds( p ) ) {\n+        return nullptr; // Out-of-bounds - null vehicle\n+    }\n+\n+    return veh_at_internal( p, part_num );\n+}\n+\n+const vehicle* map::veh_at_internal( const tripoint &p, int &part_num ) const\n+{\n+    // This function is called A LOT. Move as much out of here as possible.\n+    if( !veh_in_active_range || !veh_exists_at[p.x][p.y] ) {\n+        return nullptr; // Clear cache indicates no vehicle. This should optimize a great deal.\n+    }\n+\n+    const auto it = veh_cached_parts.find( point( p.x, p.y ) );\n+    if( it != veh_cached_parts.end() ) {\n+        part_num = it->second.second;\n+        return it->second.first;\n+    }\n+\n+    debugmsg( \"vehicle part cache cache indicated vehicle not found: %d %d %d\", p.x, p.y, p.z );","path":"src/map.cpp","position":66,"original_position":66,"commit_id":"cb2c441ac7857ffc3184a4298894159c601164b3","original_commit_id":"cb2c441ac7857ffc3184a4298894159c601164b3","user":{"login":"Coolthulhu","id":1878860,"avatar_url":"https://avatars.githubusercontent.com/u/1878860?v=3","gravatar_id":"","url":"https://api.github.com/users/Coolthulhu","html_url":"https://github.com/Coolthulhu","followers_url":"https://api.github.com/users/Coolthulhu/followers","following_url":"https://api.github.com/users/Coolthulhu/following{/other_user}","gists_url":"https://api.github.com/users/Coolthulhu/gists{/gist_id}","starred_url":"https://api.github.com/users/Coolthulhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coolthulhu/subscriptions","organizations_url":"https://api.github.com/users/Coolthulhu/orgs","repos_url":"https://api.github.com/users/Coolthulhu/repos","events_url":"https://api.github.com/users/Coolthulhu/events{/privacy}","received_events_url":"https://api.github.com/users/Coolthulhu/received_events","type":"User","site_admin":false},"body":"So you can lookup your lookups","created_at":"2015-03-21T15:53:36Z","updated_at":"2015-03-21T15:53:36Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/11705#discussion_r26893024","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/26893024"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/11705#discussion_r26893024"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705","id":31667279,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/11705","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/11705.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/11705.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/11705","number":11705,"state":"open","locked":false,"title":"Z-level update: lots of overloads","user":{"login":"Coolthulhu","id":1878860,"avatar_url":"https://avatars.githubusercontent.com/u/1878860?v=3","gravatar_id":"","url":"https://api.github.com/users/Coolthulhu","html_url":"https://github.com/Coolthulhu","followers_url":"https://api.github.com/users/Coolthulhu/followers","following_url":"https://api.github.com/users/Coolthulhu/following{/other_user}","gists_url":"https://api.github.com/users/Coolthulhu/gists{/gist_id}","starred_url":"https://api.github.com/users/Coolthulhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coolthulhu/subscriptions","organizations_url":"https://api.github.com/users/Coolthulhu/orgs","repos_url":"https://api.github.com/users/Coolthulhu/repos","events_url":"https://api.github.com/users/Coolthulhu/events{/privacy}","received_events_url":"https://api.github.com/users/Coolthulhu/received_events","type":"User","site_admin":false},"body":"Quite a bit of overloads. No in-game effect yet.\r\n\r\nIncludes #11472\r\n\r\nDoesn't yet implement everything in #6818 but is close.","created_at":"2015-03-21T06:51:15Z","updated_at":"2015-03-21T15:53:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0579a7e8b2f7e915075db7f614f85ccb2f3608b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705/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/11705/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/cb2c441ac7857ffc3184a4298894159c601164b3","head":{"label":"Coolthulhu:zlev-visibility-basic","ref":"zlev-visibility-basic","sha":"cb2c441ac7857ffc3184a4298894159c601164b3","user":{"login":"Coolthulhu","id":1878860,"avatar_url":"https://avatars.githubusercontent.com/u/1878860?v=3","gravatar_id":"","url":"https://api.github.com/users/Coolthulhu","html_url":"https://github.com/Coolthulhu","followers_url":"https://api.github.com/users/Coolthulhu/followers","following_url":"https://api.github.com/users/Coolthulhu/following{/other_user}","gists_url":"https://api.github.com/users/Coolthulhu/gists{/gist_id}","starred_url":"https://api.github.com/users/Coolthulhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coolthulhu/subscriptions","organizations_url":"https://api.github.com/users/Coolthulhu/orgs","repos_url":"https://api.github.com/users/Coolthulhu/repos","events_url":"https://api.github.com/users/Coolthulhu/events{/privacy}","received_events_url":"https://api.github.com/users/Coolthulhu/received_events","type":"User","site_admin":false},"repo":{"id":23649904,"name":"Cataclysm-DDA","full_name":"Coolthulhu/Cataclysm-DDA","owner":{"login":"Coolthulhu","id":1878860,"avatar_url":"https://avatars.githubusercontent.com/u/1878860?v=3","gravatar_id":"","url":"https://api.github.com/users/Coolthulhu","html_url":"https://github.com/Coolthulhu","followers_url":"https://api.github.com/users/Coolthulhu/followers","following_url":"https://api.github.com/users/Coolthulhu/following{/other_user}","gists_url":"https://api.github.com/users/Coolthulhu/gists{/gist_id}","starred_url":"https://api.github.com/users/Coolthulhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coolthulhu/subscriptions","organizations_url":"https://api.github.com/users/Coolthulhu/orgs","repos_url":"https://api.github.com/users/Coolthulhu/repos","events_url":"https://api.github.com/users/Coolthulhu/events{/privacy}","received_events_url":"https://api.github.com/users/Coolthulhu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Coolthulhu/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":true,"url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA","forks_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/Coolthulhu/Cataclysm-DDA/releases{/id}","created_at":"2014-09-04T05:39:34Z","updated_at":"2015-03-21T07:36:18Z","pushed_at":"2015-03-21T08:11:03Z","git_url":"git://github.com/Coolthulhu/Cataclysm-DDA.git","ssh_url":"git@github.com:Coolthulhu/Cataclysm-DDA.git","clone_url":"https://github.com/Coolthulhu/Cataclysm-DDA.git","svn_url":"https://github.com/Coolthulhu/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":383825,"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":"e592156858e3a2afb11c8e3da3521879f883ba00","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-03-21T14:16:42Z","pushed_at":"2015-03-21T09:58:08Z","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":463072,"stargazers_count":623,"watchers_count":623,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":680,"mirror_url":null,"open_issues_count":872,"forks":680,"open_issues":872,"watchers":623,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/11705"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/11705"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/11705/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/11705/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/11705/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/cb2c441ac7857ffc3184a4298894159c601164b3"}}}}