{"action":"created","comment":{"url":"https://api.github.com/repos/minetest/minetest/pulls/comments/35275169","id":35275169,"diff_hunk":"@@ -2590,6 +2591,37 @@ An `InvRef` is a reference to an inventory.\n * `get_location()`: returns a location compatible to `minetest.get_inventory(location)`\n     * returns `{type=\"undefined\"}` in case location is not known\n \n+### `AreaStore`\n+A fast access data structure to store areas, and find areas near a given position or area.\n+Every area has a `data` string attribute to store additional information.\n+You can create an empty `AreaStore` by calling `AreaStore()`, or `AreaStore(type_name)`.\n+If you chose the parameter-less constructor, a fast implementation will be automatically chosen for you.\n+#### Methods\n+* `get_area(id, borders, data)`: returns the area with the id `id`. (optional) Boolean values `borders` and `data` control what's copied.","path":"doc/lua_api.txt","position":18,"original_position":18,"commit_id":"7d1f5bfc47312c8fc7a53c81cde8954f8af7ea45","original_commit_id":"7d1f5bfc47312c8fc7a53c81cde8954f8af7ea45","user":{"login":"est31","id":8872119,"avatar_url":"https://avatars.githubusercontent.com/u/8872119?v=3","gravatar_id":"","url":"https://api.github.com/users/est31","html_url":"https://github.com/est31","followers_url":"https://api.github.com/users/est31/followers","following_url":"https://api.github.com/users/est31/following{/other_user}","gists_url":"https://api.github.com/users/est31/gists{/gist_id}","starred_url":"https://api.github.com/users/est31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/est31/subscriptions","organizations_url":"https://api.github.com/users/est31/orgs","repos_url":"https://api.github.com/users/est31/repos","events_url":"https://api.github.com/users/est31/events{/privacy}","received_events_url":"https://api.github.com/users/est31/received_events","type":"User","site_admin":false},"body":"yes, will do","created_at":"2015-07-22T23:08:52Z","updated_at":"2015-07-22T23:08:52Z","html_url":"https://github.com/minetest/minetest/pull/2898#discussion_r35275169","pull_request_url":"https://api.github.com/repos/minetest/minetest/pulls/2898","_links":{"self":{"href":"https://api.github.com/repos/minetest/minetest/pulls/comments/35275169"},"html":{"href":"https://github.com/minetest/minetest/pull/2898#discussion_r35275169"},"pull_request":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2898"}}},"pull_request":{"url":"https://api.github.com/repos/minetest/minetest/pulls/2898","id":39600006,"html_url":"https://github.com/minetest/minetest/pull/2898","diff_url":"https://github.com/minetest/minetest/pull/2898.diff","patch_url":"https://github.com/minetest/minetest/pull/2898.patch","issue_url":"https://api.github.com/repos/minetest/minetest/issues/2898","number":2898,"state":"open","locked":false,"title":"Add AreaStore data structure","user":{"login":"est31","id":8872119,"avatar_url":"https://avatars.githubusercontent.com/u/8872119?v=3","gravatar_id":"","url":"https://api.github.com/users/est31","html_url":"https://github.com/est31","followers_url":"https://api.github.com/users/est31/followers","following_url":"https://api.github.com/users/est31/following{/other_user}","gists_url":"https://api.github.com/users/est31/gists{/gist_id}","starred_url":"https://api.github.com/users/est31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/est31/subscriptions","organizations_url":"https://api.github.com/users/est31/orgs","repos_url":"https://api.github.com/users/est31/repos","events_url":"https://api.github.com/users/est31/events{/privacy}","received_events_url":"https://api.github.com/users/est31/received_events","type":"User","site_admin":false},"body":"AreaStore is a fast access data structure to retrieve areas close to a position, e.g. a player. You can see how it would be used in @ShadowNinja 's areas mod [here](https://github.com/est31/areas/tree/areastore-test). If my benchmarks are right (and do scale), a server with 40 players and 2600 areas takes up ~ 80% CPU just for the hud updates, conditions that @VanessaE 's vanilla server can be under, for example.\r\n\r\nThis PR adds an optional dependency on [libspatial](https://github.com/libspatialindex/libspatialindex) which has an [R* tree](https://en.wikipedia.org/wiki/R*_tree) implementation. If libspatial isn't available, a slower, vector based implementation is chosen. That one is still faster than a for loop over a lua array.\r\n\r\nThis PR is ready for review.\r\n\r\nAlso, there is an optional (default: on) cache that caches the lookup's result for a 64^3 area. This will spare many calls to underlying structure if the lookups are often at spots close to each other (most usecases have these properties).\r\n\r\nI've commented out serialisation so that we can change on it. Best we should store AreaStores with the map. Also, the serialisation format should perhaps be adopted to Libspatial, I dunno, have to research more. AreaStores are already useful without any serialisation, so the commit can be added without, we can add it later.\r\n\r\nTODO:\r\n* [x] document new dependency\r\n* [x] read through everything, verify that everything is OK\r\n* [x] use `getboolfield_default` (and so on) where we can","created_at":"2015-07-09T16:05:43Z","updated_at":"2015-07-22T23:08:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3afcd06b8a9b6d5d887397625eaf2535dff16161","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/minetest/minetest/pulls/2898/commits","review_comments_url":"https://api.github.com/repos/minetest/minetest/pulls/2898/comments","review_comment_url":"https://api.github.com/repos/minetest/minetest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minetest/minetest/issues/2898/comments","statuses_url":"https://api.github.com/repos/minetest/minetest/statuses/7d1f5bfc47312c8fc7a53c81cde8954f8af7ea45","head":{"label":"est31:areastore","ref":"areastore","sha":"7d1f5bfc47312c8fc7a53c81cde8954f8af7ea45","user":{"login":"est31","id":8872119,"avatar_url":"https://avatars.githubusercontent.com/u/8872119?v=3","gravatar_id":"","url":"https://api.github.com/users/est31","html_url":"https://github.com/est31","followers_url":"https://api.github.com/users/est31/followers","following_url":"https://api.github.com/users/est31/following{/other_user}","gists_url":"https://api.github.com/users/est31/gists{/gist_id}","starred_url":"https://api.github.com/users/est31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/est31/subscriptions","organizations_url":"https://api.github.com/users/est31/orgs","repos_url":"https://api.github.com/users/est31/repos","events_url":"https://api.github.com/users/est31/events{/privacy}","received_events_url":"https://api.github.com/users/est31/received_events","type":"User","site_admin":false},"repo":{"id":28881630,"name":"minetest","full_name":"est31/minetest","owner":{"login":"est31","id":8872119,"avatar_url":"https://avatars.githubusercontent.com/u/8872119?v=3","gravatar_id":"","url":"https://api.github.com/users/est31","html_url":"https://github.com/est31","followers_url":"https://api.github.com/users/est31/followers","following_url":"https://api.github.com/users/est31/following{/other_user}","gists_url":"https://api.github.com/users/est31/gists{/gist_id}","starred_url":"https://api.github.com/users/est31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/est31/subscriptions","organizations_url":"https://api.github.com/users/est31/orgs","repos_url":"https://api.github.com/users/est31/repos","events_url":"https://api.github.com/users/est31/events{/privacy}","received_events_url":"https://api.github.com/users/est31/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/est31/minetest","description":"Minetest, an open source infinite-world block sandbox game with survival and crafting. [also [minetest_game](https://github.com/minetest/minetest_game)]","fork":true,"url":"https://api.github.com/repos/est31/minetest","forks_url":"https://api.github.com/repos/est31/minetest/forks","keys_url":"https://api.github.com/repos/est31/minetest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/est31/minetest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/est31/minetest/teams","hooks_url":"https://api.github.com/repos/est31/minetest/hooks","issue_events_url":"https://api.github.com/repos/est31/minetest/issues/events{/number}","events_url":"https://api.github.com/repos/est31/minetest/events","assignees_url":"https://api.github.com/repos/est31/minetest/assignees{/user}","branches_url":"https://api.github.com/repos/est31/minetest/branches{/branch}","tags_url":"https://api.github.com/repos/est31/minetest/tags","blobs_url":"https://api.github.com/repos/est31/minetest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/est31/minetest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/est31/minetest/git/refs{/sha}","trees_url":"https://api.github.com/repos/est31/minetest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/est31/minetest/statuses/{sha}","languages_url":"https://api.github.com/repos/est31/minetest/languages","stargazers_url":"https://api.github.com/repos/est31/minetest/stargazers","contributors_url":"https://api.github.com/repos/est31/minetest/contributors","subscribers_url":"https://api.github.com/repos/est31/minetest/subscribers","subscription_url":"https://api.github.com/repos/est31/minetest/subscription","commits_url":"https://api.github.com/repos/est31/minetest/commits{/sha}","git_commits_url":"https://api.github.com/repos/est31/minetest/git/commits{/sha}","comments_url":"https://api.github.com/repos/est31/minetest/comments{/number}","issue_comment_url":"https://api.github.com/repos/est31/minetest/issues/comments{/number}","contents_url":"https://api.github.com/repos/est31/minetest/contents/{+path}","compare_url":"https://api.github.com/repos/est31/minetest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/est31/minetest/merges","archive_url":"https://api.github.com/repos/est31/minetest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/est31/minetest/downloads","issues_url":"https://api.github.com/repos/est31/minetest/issues{/number}","pulls_url":"https://api.github.com/repos/est31/minetest/pulls{/number}","milestones_url":"https://api.github.com/repos/est31/minetest/milestones{/number}","notifications_url":"https://api.github.com/repos/est31/minetest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/est31/minetest/labels{/name}","releases_url":"https://api.github.com/repos/est31/minetest/releases{/id}","created_at":"2015-01-06T20:18:47Z","updated_at":"2015-06-20T11:21:55Z","pushed_at":"2015-07-22T18:42:48Z","git_url":"git://github.com/est31/minetest.git","ssh_url":"git@github.com:est31/minetest.git","clone_url":"https://github.com/est31/minetest.git","svn_url":"https://github.com/est31/minetest","homepage":"http://minetest.net/","size":36578,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"minetest:master","ref":"master","sha":"1076bbd03ed1d6997d50101fad0fd6ad6c0cfb48","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-07-22T00:32:00Z","pushed_at":"2015-07-22T22:46:59Z","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":100691,"stargazers_count":1563,"watchers_count":1563,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":512,"mirror_url":null,"open_issues_count":556,"forks":512,"open_issues":556,"watchers":1563,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2898"},"html":{"href":"https://github.com/minetest/minetest/pull/2898"},"issue":{"href":"https://api.github.com/repos/minetest/minetest/issues/2898"},"comments":{"href":"https://api.github.com/repos/minetest/minetest/issues/2898/comments"},"review_comments":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2898/comments"},"review_comment":{"href":"https://api.github.com/repos/minetest/minetest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minetest/minetest/pulls/2898/commits"},"statuses":{"href":"https://api.github.com/repos/minetest/minetest/statuses/7d1f5bfc47312c8fc7a53c81cde8954f8af7ea45"}}}}