{"action":"created","comment":{"url":"https://api.github.com/repos/minetest/minetest/pulls/comments/33226315","id":33226315,"diff_hunk":"@@ -0,0 +1,475 @@\n+/*\n+Minetest\n+Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>\n+\n+This program is free software; you can redistribute it and/or modify\n+it under the terms of the GNU Lesser General Public License as published by\n+the Free Software Foundation; either version 2.1 of the License, or\n+(at your option) any later version.\n+\n+This program is distributed in the hope that it will be useful,\n+but WITHOUT ANY WARRANTY; without even the implied warranty of\n+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+GNU Lesser General Public License for more details.\n+\n+You should have received a copy of the GNU Lesser General Public License along\n+with this program; if not, write to the Free Software Foundation, Inc.,\n+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+*/\n+\n+#include \"minimap.h\"\n+#include \"logoutputbuffer.h\"\n+#include \"jthread/jmutexautolock.h\"\n+#include \"clientmap.h\"\n+#include \"settings.h\"\n+#include \"nodedef.h\"\n+#include \"porting.h\"\n+#include \"util/numeric.h\"\n+#include \"util/string.h\"\n+#include <math.h>\n+\n+\n+\n+QueuedMinimapUpdate::QueuedMinimapUpdate():\n+\tp(-1337,-1337,-1337),\n+\tdata(NULL)\n+{\n+}\n+\n+QueuedMinimapUpdate::~QueuedMinimapUpdate()\n+{\n+\tdelete data;\n+}\n+\n+MinimapUpdateQueue::MinimapUpdateQueue()\n+{\n+}\n+\n+MinimapUpdateQueue::~MinimapUpdateQueue()\n+{\n+\tJMutexAutoLock lock(m_mutex);\n+\n+\tfor(std::vector<QueuedMinimapUpdate*>::iterator\n+\t\t\ti = m_queue.begin();\n+\t\t\ti != m_queue.end(); i++)\n+\t{\n+\t\tQueuedMinimapUpdate *q = *i;\n+\t\tdelete q;\n+\t}\n+}\n+\n+void MinimapUpdateQueue::addBlock(v3s16 p, MinimapMapblock *data)\n+{\n+\tDSTACK(__FUNCTION_NAME);\n+\n+\tJMutexAutoLock lock(m_mutex);\n+\n+\t/*\n+\t\tFind if block is already in queue.\n+\t\tIf it is, update the data and quit.\n+\t*/\n+\tfor(std::vector<QueuedMinimapUpdate*>::iterator\n+\t\t\ti = m_queue.begin();\n+\t\t\ti != m_queue.end(); i++)\n+\t{\n+\t\tQueuedMinimapUpdate *q = *i;\n+\t\tif(q->p == p) {\n+\t\t\tdelete q->data;\n+\t\t\tq->data = data;\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\t/*\n+\t\tAdd the block\n+\t*/\n+\tQueuedMinimapUpdate *q = new QueuedMinimapUpdate;\n+\tq->p = p;\n+\tq->data = data;\n+\tm_queue.push_back(q);\n+}\n+\n+QueuedMinimapUpdate * MinimapUpdateQueue::pop()\n+{\n+\tJMutexAutoLock lock(m_mutex);\n+\n+\tfor(std::vector<QueuedMinimapUpdate*>::iterator\n+\t\t\ti = m_queue.begin();\n+\t\t\ti != m_queue.end(); i++)\n+\t{\n+\t\tQueuedMinimapUpdate *q = *i;\n+\t\tm_queue.erase(i);\n+\t\treturn q;\n+\t}\n+\treturn NULL;\n+}\n+\n+/*\n+\tMinimap update thread\n+*/\n+\n+void * MinimapUpdateThread::Thread()\n+{\n+\tThreadStarted();\n+\n+\tlog_register_thread(\"MinimapUpdateThread\");\n+\n+\tDSTACK(__FUNCTION_NAME);\n+\n+\tBEGIN_DEBUG_EXCEPTION_HANDLER\n+\n+\tporting::setThreadName(\"MinimapUpdateThread\");\n+\n+\twhile(!StopRequested()) {\n+\n+\t\twhile(m_queue.size()) {\n+\t\t\tQueuedMinimapUpdate *q = m_queue.pop();\n+\t\t\tstd::map<v3s16, MinimapMapblock *>::iterator it;\n+\t\t\tit = m_blocks_cache.find(q->p);\n+\t\t\tif (q->data)\n+\t\t\t\tm_blocks_cache[q->p] = q->data;\n+\t\t\telse if (it != m_blocks_cache.end())\n+\t\t\t\tm_blocks_cache.erase(it);\n+\t\t}\t\n+\n+\t\tif (data->map_invalidated) {\n+\t\t\tif (data->mode != 0) {","path":"src/minimap.cpp","position":136,"original_position":136,"commit_id":"cfc0aa214285493f868bbd9efd08531a74c3e716","original_commit_id":"cfc0aa214285493f868bbd9efd08531a74c3e716","user":{"login":"kwolekr","id":630595,"avatar_url":"https://avatars.githubusercontent.com/u/630595?v=3","gravatar_id":"","url":"https://api.github.com/users/kwolekr","html_url":"https://github.com/kwolekr","followers_url":"https://api.github.com/users/kwolekr/followers","following_url":"https://api.github.com/users/kwolekr/following{/other_user}","gists_url":"https://api.github.com/users/kwolekr/gists{/gist_id}","starred_url":"https://api.github.com/users/kwolekr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwolekr/subscriptions","organizations_url":"https://api.github.com/users/kwolekr/orgs","repos_url":"https://api.github.com/users/kwolekr/repos","events_url":"https://api.github.com/users/kwolekr/events{/privacy}","received_events_url":"https://api.github.com/users/kwolekr/received_events","type":"User","site_admin":false},"body":"Compare your enumeration against an enumeration value.","created_at":"2015-06-25T06:43:56Z","updated_at":"2015-06-25T06:43:56Z","html_url":"https://github.com/minetest/minetest/pull/2814#discussion_r33226315","pull_request_url":"https://api.github.com/repos/minetest/minetest/pulls/2814","_links":{"self":{"href":"https://api.github.com/repos/minetest/minetest/pulls/comments/33226315"},"html":{"href":"https://github.com/minetest/minetest/pull/2814#discussion_r33226315"},"pull_request":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2814"}}},"pull_request":{"url":"https://api.github.com/repos/minetest/minetest/pulls/2814","id":38196514,"html_url":"https://github.com/minetest/minetest/pull/2814","diff_url":"https://github.com/minetest/minetest/pull/2814.diff","patch_url":"https://github.com/minetest/minetest/pull/2814.patch","issue_url":"https://api.github.com/repos/minetest/minetest/issues/2814","number":2814,"state":"open","locked":false,"title":"Add minimap feature.","user":{"login":"RealBadAngel","id":2177790,"avatar_url":"https://avatars.githubusercontent.com/u/2177790?v=3","gravatar_id":"","url":"https://api.github.com/users/RealBadAngel","html_url":"https://github.com/RealBadAngel","followers_url":"https://api.github.com/users/RealBadAngel/followers","following_url":"https://api.github.com/users/RealBadAngel/following{/other_user}","gists_url":"https://api.github.com/users/RealBadAngel/gists{/gist_id}","starred_url":"https://api.github.com/users/RealBadAngel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RealBadAngel/subscriptions","organizations_url":"https://api.github.com/users/RealBadAngel/orgs","repos_url":"https://api.github.com/users/RealBadAngel/repos","events_url":"https://api.github.com/users/RealBadAngel/events{/privacy}","received_events_url":"https://api.github.com/users/RealBadAngel/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-22T02:38:10Z","updated_at":"2015-06-25T06:43:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"633ce6930a0a30327657f66e5f4c2085c5c1ebad","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/minetest/minetest/pulls/2814/commits","review_comments_url":"https://api.github.com/repos/minetest/minetest/pulls/2814/comments","review_comment_url":"https://api.github.com/repos/minetest/minetest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minetest/minetest/issues/2814/comments","statuses_url":"https://api.github.com/repos/minetest/minetest/statuses/cfc0aa214285493f868bbd9efd08531a74c3e716","head":{"label":"RealBadAngel:minimap_pr","ref":"minimap_pr","sha":"cfc0aa214285493f868bbd9efd08531a74c3e716","user":{"login":"RealBadAngel","id":2177790,"avatar_url":"https://avatars.githubusercontent.com/u/2177790?v=3","gravatar_id":"","url":"https://api.github.com/users/RealBadAngel","html_url":"https://github.com/RealBadAngel","followers_url":"https://api.github.com/users/RealBadAngel/followers","following_url":"https://api.github.com/users/RealBadAngel/following{/other_user}","gists_url":"https://api.github.com/users/RealBadAngel/gists{/gist_id}","starred_url":"https://api.github.com/users/RealBadAngel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RealBadAngel/subscriptions","organizations_url":"https://api.github.com/users/RealBadAngel/orgs","repos_url":"https://api.github.com/users/RealBadAngel/repos","events_url":"https://api.github.com/users/RealBadAngel/events{/privacy}","received_events_url":"https://api.github.com/users/RealBadAngel/received_events","type":"User","site_admin":false},"repo":{"id":18859749,"name":"minetest","full_name":"RealBadAngel/minetest","owner":{"login":"RealBadAngel","id":2177790,"avatar_url":"https://avatars.githubusercontent.com/u/2177790?v=3","gravatar_id":"","url":"https://api.github.com/users/RealBadAngel","html_url":"https://github.com/RealBadAngel","followers_url":"https://api.github.com/users/RealBadAngel/followers","following_url":"https://api.github.com/users/RealBadAngel/following{/other_user}","gists_url":"https://api.github.com/users/RealBadAngel/gists{/gist_id}","starred_url":"https://api.github.com/users/RealBadAngel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RealBadAngel/subscriptions","organizations_url":"https://api.github.com/users/RealBadAngel/orgs","repos_url":"https://api.github.com/users/RealBadAngel/repos","events_url":"https://api.github.com/users/RealBadAngel/events{/privacy}","received_events_url":"https://api.github.com/users/RealBadAngel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RealBadAngel/minetest","description":"Minetest, an open source infinite-world block sandbox game with survival and crafting. [also https://github.com/minetest/minetest_game]","fork":true,"url":"https://api.github.com/repos/RealBadAngel/minetest","forks_url":"https://api.github.com/repos/RealBadAngel/minetest/forks","keys_url":"https://api.github.com/repos/RealBadAngel/minetest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RealBadAngel/minetest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RealBadAngel/minetest/teams","hooks_url":"https://api.github.com/repos/RealBadAngel/minetest/hooks","issue_events_url":"https://api.github.com/repos/RealBadAngel/minetest/issues/events{/number}","events_url":"https://api.github.com/repos/RealBadAngel/minetest/events","assignees_url":"https://api.github.com/repos/RealBadAngel/minetest/assignees{/user}","branches_url":"https://api.github.com/repos/RealBadAngel/minetest/branches{/branch}","tags_url":"https://api.github.com/repos/RealBadAngel/minetest/tags","blobs_url":"https://api.github.com/repos/RealBadAngel/minetest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RealBadAngel/minetest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RealBadAngel/minetest/git/refs{/sha}","trees_url":"https://api.github.com/repos/RealBadAngel/minetest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RealBadAngel/minetest/statuses/{sha}","languages_url":"https://api.github.com/repos/RealBadAngel/minetest/languages","stargazers_url":"https://api.github.com/repos/RealBadAngel/minetest/stargazers","contributors_url":"https://api.github.com/repos/RealBadAngel/minetest/contributors","subscribers_url":"https://api.github.com/repos/RealBadAngel/minetest/subscribers","subscription_url":"https://api.github.com/repos/RealBadAngel/minetest/subscription","commits_url":"https://api.github.com/repos/RealBadAngel/minetest/commits{/sha}","git_commits_url":"https://api.github.com/repos/RealBadAngel/minetest/git/commits{/sha}","comments_url":"https://api.github.com/repos/RealBadAngel/minetest/comments{/number}","issue_comment_url":"https://api.github.com/repos/RealBadAngel/minetest/issues/comments{/number}","contents_url":"https://api.github.com/repos/RealBadAngel/minetest/contents/{+path}","compare_url":"https://api.github.com/repos/RealBadAngel/minetest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RealBadAngel/minetest/merges","archive_url":"https://api.github.com/repos/RealBadAngel/minetest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RealBadAngel/minetest/downloads","issues_url":"https://api.github.com/repos/RealBadAngel/minetest/issues{/number}","pulls_url":"https://api.github.com/repos/RealBadAngel/minetest/pulls{/number}","milestones_url":"https://api.github.com/repos/RealBadAngel/minetest/milestones{/number}","notifications_url":"https://api.github.com/repos/RealBadAngel/minetest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RealBadAngel/minetest/labels{/name}","releases_url":"https://api.github.com/repos/RealBadAngel/minetest/releases{/id}","created_at":"2014-04-16T23:10:17Z","updated_at":"2015-05-12T10:09:29Z","pushed_at":"2015-06-23T23:06:40Z","git_url":"git://github.com/RealBadAngel/minetest.git","ssh_url":"git@github.com:RealBadAngel/minetest.git","clone_url":"https://github.com/RealBadAngel/minetest.git","svn_url":"https://github.com/RealBadAngel/minetest","homepage":"http://minetest.net/","size":42059,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"minetest:master","ref":"master","sha":"c6766b275f25368e78eeffc68719b0ca1979c819","user":{"login":"minetest","id":2624745,"avatar_url":"https://avatars.githubusercontent.com/u/2624745?v=3","gravatar_id":"","url":"https://api.github.com/users/minetest","html_url":"https://github.com/minetest","followers_url":"https://api.github.com/users/minetest/followers","following_url":"https://api.github.com/users/minetest/following{/other_user}","gists_url":"https://api.github.com/users/minetest/gists{/gist_id}","starred_url":"https://api.github.com/users/minetest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minetest/subscriptions","organizations_url":"https://api.github.com/users/minetest/orgs","repos_url":"https://api.github.com/users/minetest/repos","events_url":"https://api.github.com/users/minetest/events{/privacy}","received_events_url":"https://api.github.com/users/minetest/received_events","type":"Organization","site_admin":false},"repo":{"id":2168780,"name":"minetest","full_name":"minetest/minetest","owner":{"login":"minetest","id":2624745,"avatar_url":"https://avatars.githubusercontent.com/u/2624745?v=3","gravatar_id":"","url":"https://api.github.com/users/minetest","html_url":"https://github.com/minetest","followers_url":"https://api.github.com/users/minetest/followers","following_url":"https://api.github.com/users/minetest/following{/other_user}","gists_url":"https://api.github.com/users/minetest/gists{/gist_id}","starred_url":"https://api.github.com/users/minetest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minetest/subscriptions","organizations_url":"https://api.github.com/users/minetest/orgs","repos_url":"https://api.github.com/users/minetest/repos","events_url":"https://api.github.com/users/minetest/events{/privacy}","received_events_url":"https://api.github.com/users/minetest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minetest/minetest","description":"Minetest, an open source infinite-world block sandbox game with survival and crafting. [also https://github.com/minetest/minetest_game]","fork":false,"url":"https://api.github.com/repos/minetest/minetest","forks_url":"https://api.github.com/repos/minetest/minetest/forks","keys_url":"https://api.github.com/repos/minetest/minetest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minetest/minetest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minetest/minetest/teams","hooks_url":"https://api.github.com/repos/minetest/minetest/hooks","issue_events_url":"https://api.github.com/repos/minetest/minetest/issues/events{/number}","events_url":"https://api.github.com/repos/minetest/minetest/events","assignees_url":"https://api.github.com/repos/minetest/minetest/assignees{/user}","branches_url":"https://api.github.com/repos/minetest/minetest/branches{/branch}","tags_url":"https://api.github.com/repos/minetest/minetest/tags","blobs_url":"https://api.github.com/repos/minetest/minetest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minetest/minetest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minetest/minetest/git/refs{/sha}","trees_url":"https://api.github.com/repos/minetest/minetest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minetest/minetest/statuses/{sha}","languages_url":"https://api.github.com/repos/minetest/minetest/languages","stargazers_url":"https://api.github.com/repos/minetest/minetest/stargazers","contributors_url":"https://api.github.com/repos/minetest/minetest/contributors","subscribers_url":"https://api.github.com/repos/minetest/minetest/subscribers","subscription_url":"https://api.github.com/repos/minetest/minetest/subscription","commits_url":"https://api.github.com/repos/minetest/minetest/commits{/sha}","git_commits_url":"https://api.github.com/repos/minetest/minetest/git/commits{/sha}","comments_url":"https://api.github.com/repos/minetest/minetest/comments{/number}","issue_comment_url":"https://api.github.com/repos/minetest/minetest/issues/comments{/number}","contents_url":"https://api.github.com/repos/minetest/minetest/contents/{+path}","compare_url":"https://api.github.com/repos/minetest/minetest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minetest/minetest/merges","archive_url":"https://api.github.com/repos/minetest/minetest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minetest/minetest/downloads","issues_url":"https://api.github.com/repos/minetest/minetest/issues{/number}","pulls_url":"https://api.github.com/repos/minetest/minetest/pulls{/number}","milestones_url":"https://api.github.com/repos/minetest/minetest/milestones{/number}","notifications_url":"https://api.github.com/repos/minetest/minetest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minetest/minetest/labels{/name}","releases_url":"https://api.github.com/repos/minetest/minetest/releases{/id}","created_at":"2011-08-07T13:48:36Z","updated_at":"2015-06-24T18:57:39Z","pushed_at":"2015-06-24T20:56:15Z","git_url":"git://github.com/minetest/minetest.git","ssh_url":"git@github.com:minetest/minetest.git","clone_url":"https://github.com/minetest/minetest.git","svn_url":"https://github.com/minetest/minetest","homepage":"http://minetest.net/","size":99181,"stargazers_count":1532,"watchers_count":1532,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":493,"mirror_url":null,"open_issues_count":540,"forks":493,"open_issues":540,"watchers":1532,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2814"},"html":{"href":"https://github.com/minetest/minetest/pull/2814"},"issue":{"href":"https://api.github.com/repos/minetest/minetest/issues/2814"},"comments":{"href":"https://api.github.com/repos/minetest/minetest/issues/2814/comments"},"review_comments":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2814/comments"},"review_comment":{"href":"https://api.github.com/repos/minetest/minetest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2814/commits"},"statuses":{"href":"https://api.github.com/repos/minetest/minetest/statuses/cfc0aa214285493f868bbd9efd08531a74c3e716"}}}}