{"action":"created","issue":{"url":"https://api.github.com/repos/mapcrafter/mapcrafter/issues/179","labels_url":"https://api.github.com/repos/mapcrafter/mapcrafter/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/mapcrafter/mapcrafter/issues/179/comments","events_url":"https://api.github.com/repos/mapcrafter/mapcrafter/issues/179/events","html_url":"https://github.com/mapcrafter/mapcrafter/issues/179","id":108716964,"number":179,"title":"Integer overflow causes circular crop to fail on large maps.","user":{"login":"hujackus","id":4826547,"avatar_url":"https://avatars.githubusercontent.com/u/4826547?v=3","gravatar_id":"","url":"https://api.github.com/users/hujackus","html_url":"https://github.com/hujackus","followers_url":"https://api.github.com/users/hujackus/followers","following_url":"https://api.github.com/users/hujackus/following{/other_user}","gists_url":"https://api.github.com/users/hujackus/gists{/gist_id}","starred_url":"https://api.github.com/users/hujackus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hujackus/subscriptions","organizations_url":"https://api.github.com/users/hujackus/orgs","repos_url":"https://api.github.com/users/hujackus/repos","events_url":"https://api.github.com/users/hujackus/events{/privacy}","received_events_url":"https://api.github.com/users/hujackus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapcrafter/mapcrafter/labels/Bug","name":"Bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-28T18:16:47Z","updated_at":"2015-09-29T00:33:28Z","closed_at":null,"body":"Circular cropping fails on maps with blocks further than 46340 from the origin. No matter what radius is specified, extra blocks will be rendered well outside of the circular bounds. This is caused by an integer overflow found in a few methods of mapcraftercore/mc/worldcrop.cpp.\r\n\r\nExample:\r\n\tbool WorldCrop::isBlockContainedXZ(const mc::BlockPos& block) const {\r\n\t\tif (type == RECTANGULAR) {\r\n\t\t\t// rectangular crop:\r\n\t\t\t// just check if the chunk is contained in the bounds\r\n\t\t\treturn bounds_x.contains(block.x) && bounds_z.contains(block.z);\r\n\t\t} else if (type == CIRCULAR) {\r\n\t\t\t// circular crop:\r\n\t\t\t// also check distance to the center (like with regions and chunks)\r\n\t\t\tint dx = block.x - center.x;\r\n\t\t\tint dz = block.z - center.z;\r\n\t\t\treturn radius*radius >= dx*dx + dz*dz;\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\r\nThe integer overflow occurs in the dx*dx + dz*dz part. A simple fix would be to use long for the temporary calculations...\r\n\r\n\t\tlong dx = block.x - center.x;\r\n\t\tlong dz = block.z - center.z;\r\n\t\treturn radius*radius >= dx*dx + dz*dz;\r\n\r\nMethods that include this bug are:\r\nWorldCrop::isRegionContained\r\nWorldCrop::isChunkContained\r\nWorldCrop::isBlockContainedXZ\r\n"},"comment":{"url":"https://api.github.com/repos/mapcrafter/mapcrafter/issues/comments/143910700","html_url":"https://github.com/mapcrafter/mapcrafter/issues/179#issuecomment-143910700","issue_url":"https://api.github.com/repos/mapcrafter/mapcrafter/issues/179","id":143910700,"user":{"login":"lalligood","id":3593503,"avatar_url":"https://avatars.githubusercontent.com/u/3593503?v=3","gravatar_id":"","url":"https://api.github.com/users/lalligood","html_url":"https://github.com/lalligood","followers_url":"https://api.github.com/users/lalligood/followers","following_url":"https://api.github.com/users/lalligood/following{/other_user}","gists_url":"https://api.github.com/users/lalligood/gists{/gist_id}","starred_url":"https://api.github.com/users/lalligood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lalligood/subscriptions","organizations_url":"https://api.github.com/users/lalligood/orgs","repos_url":"https://api.github.com/users/lalligood/repos","events_url":"https://api.github.com/users/lalligood/events{/privacy}","received_events_url":"https://api.github.com/users/lalligood/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T00:33:28Z","updated_at":"2015-09-29T00:33:28Z","body":"I've *got* to ask: Is there any way we could see your map? I thought mine was a decent size at +/-10,000 X & Z, but 45,000+...! O_O"}}