{"action":"created","comment":{"url":"https://api.github.com/repos/otland/forgottenserver/pulls/comments/158828258","pull_request_review_id":85689402,"id":158828258,"diff_hunk":"@@ -0,0 +1,479 @@\n+#include <getopt.h>\n+\n+#include <fstream>\n+#include <iostream>\n+#include <memory>\n+#include <sstream>\n+#include <unordered_map>\n+#include <vector>\n+\n+#include <boost/filesystem.hpp>\n+#include <pugixml.hpp>\n+#include \"../src/pugicast.h\"\n+\n+namespace fs = boost::filesystem;\n+\n+void usage(const char* program)\n+{\n+\tstd::cout << \"usage: \" << program\n+\t\t<< \" [-r path/to/data/raids] [-g path/to/data/globalevents]\\n\";\n+}\n+\n+constexpr const char* INDENT = \"    \";\n+\n+struct RaidEvent\n+{\n+\texplicit RaidEvent(uint32_t delay) : delay{delay} {}\n+\tvirtual ~RaidEvent() = default;\n+\n+\tvirtual void to_script(std::ostringstream& ss) const { ss << '\\n'; };\n+\n+\tuint32_t delay;\n+};\n+\n+static const std::unordered_map<std::string, std::string> messageTypes{\n+\t{\"warning\", \"MESSAGE_STATUS_WARNING\"},\n+\t{\"event\", \"MESSAGE_EVENT_ADVANCE\"},\n+\t{\"default\", \"MESSAGE_EVENT_DEFAULT\"},\n+\t{\"description\", \"MESSAGE_INFO_DESCR\"},\n+\t{\"smallstatus\", \"MESSAGE_STATUS_SMALL\"},\n+\t{\"blueconsole\", \"MESSAGE_STATUS_CONSOLE_BLUE\"},\n+\t{\"redconsole\", \"MESSAGE_STATUS_CONSOLE_RED\"},\n+};\n+static const std::string defaultMessageType{\"MESSAGE_EVENT_ADVANCE\"};\n+\n+struct AnnounceEvent : public RaidEvent\n+{\n+\tAnnounceEvent(uint32_t delay, std::string msg, std::string type) :\n+\t\t\tRaidEvent{delay}, message{std::move(msg)}, type{std::move(type)} {}\n+\n+\tstatic AnnounceEvent* from(uint32_t delay, const pugi::xml_node& eventNode)\n+\t{\n+\t\tpugi::xml_attribute message = eventNode.attribute(\"message\");\n+\t\tif (not message) {\n+\t\t\tthrow std::runtime_error(\"message tag missing for announce event.\");\n+\t\t}\n+\n+\t\tstd::string messageType = [](const pugi::xml_attribute& type) {\n+\t\t\tif (not type) {\n+\t\t\t\tstd::cout << \"[Notice] Raid: type tag missing for announce\"\n+\t\t\t\t             \"event. Using default: \" << defaultMessageType <<\n+\t\t\t\t\t\t\t \"\\n\";\n+\t\t\t\treturn defaultMessageType;\n+\t\t\t}\n+\n+\t\t\ttry {\n+\t\t\t\treturn messageTypes.at(type.as_string());\n+\t\t\t} catch (const std::out_of_range&) {\n+\t\t\t\tstd::cout << \"[Notice] Raid: Unknown type tag for announce\"\n+\t\t\t\t\t\t\t \"event. Using default: MESSAGE_TYPE_ADVANCE\\n\";\n+\t\t\t\treturn defaultMessageType;\n+\t\t\t}\n+\t\t}(eventNode.attribute(\"type\"));\n+\n+\t\treturn new AnnounceEvent{delay, message.as_string(), messageType};","path":"tools/raid_xmltolua.cpp","position":74,"original_position":74,"commit_id":"a23cb24c19cd06b17be39a6d9cb95f947dfe8226","original_commit_id":"a23cb24c19cd06b17be39a6d9cb95f947dfe8226","user":{"login":"ranisalt","id":1993083,"avatar_url":"https://avatars0.githubusercontent.com/u/1993083?v=4","gravatar_id":"","url":"https://api.github.com/users/ranisalt","html_url":"https://github.com/ranisalt","followers_url":"https://api.github.com/users/ranisalt/followers","following_url":"https://api.github.com/users/ranisalt/following{/other_user}","gists_url":"https://api.github.com/users/ranisalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ranisalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranisalt/subscriptions","organizations_url":"https://api.github.com/users/ranisalt/orgs","repos_url":"https://api.github.com/users/ranisalt/repos","events_url":"https://api.github.com/users/ranisalt/events{/privacy}","received_events_url":"https://api.github.com/users/ranisalt/received_events","type":"User","site_admin":false},"body":"Just noticed I return those pointers and encapsulate in unique_ptrs. Might as well return unique_ptrs instead.","created_at":"2017-12-27T15:28:26Z","updated_at":"2017-12-27T15:28:26Z","html_url":"https://github.com/otland/forgottenserver/pull/1813#discussion_r158828258","pull_request_url":"https://api.github.com/repos/otland/forgottenserver/pulls/1813","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/otland/forgottenserver/pulls/comments/158828258"},"html":{"href":"https://github.com/otland/forgottenserver/pull/1813#discussion_r158828258"},"pull_request":{"href":"https://api.github.com/repos/otland/forgottenserver/pulls/1813"}},"in_reply_to_id":158806183},"pull_request":{"url":"https://api.github.com/repos/otland/forgottenserver/pulls/1813","id":72319929,"html_url":"https://github.com/otland/forgottenserver/pull/1813","diff_url":"https://github.com/otland/forgottenserver/pull/1813.diff","patch_url":"https://github.com/otland/forgottenserver/pull/1813.patch","issue_url":"https://api.github.com/repos/otland/forgottenserver/issues/1813","number":1813,"state":"open","locked":false,"title":"Move raid system to globalevents","user":{"login":"ranisalt","id":1993083,"avatar_url":"https://avatars0.githubusercontent.com/u/1993083?v=4","gravatar_id":"","url":"https://api.github.com/users/ranisalt","html_url":"https://github.com/ranisalt","followers_url":"https://api.github.com/users/ranisalt/followers","following_url":"https://api.github.com/users/ranisalt/following{/other_user}","gists_url":"https://api.github.com/users/ranisalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ranisalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranisalt/subscriptions","organizations_url":"https://api.github.com/users/ranisalt/orgs","repos_url":"https://api.github.com/users/ranisalt/repos","events_url":"https://api.github.com/users/ranisalt/events{/privacy}","received_events_url":"https://api.github.com/users/ranisalt/received_events","type":"User","site_admin":false},"body":"This effectively nukes the raid system in favor of global events, which permit better management for raids. It's easier to define raids on interval, on exact times, force execution, force scheduling, add monsters on different delays and randomized amounts and positions... and also gets rid of a command.\n\nI added a lib with helper functions to add monsters to a raid. The event is called `onRaid` and there is an example bundled pretty equivalent to the previous XML raid example.\n","created_at":"2016-06-02T10:06:09Z","updated_at":"2017-12-27T15:28:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa38c5dbcea3fb81f4267dbfb7cde1c318434f5c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/otland/forgottenserver/pulls/1813/commits","review_comments_url":"https://api.github.com/repos/otland/forgottenserver/pulls/1813/comments","review_comment_url":"https://api.github.com/repos/otland/forgottenserver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/otland/forgottenserver/issues/1813/comments","statuses_url":"https://api.github.com/repos/otland/forgottenserver/statuses/a23cb24c19cd06b17be39a6d9cb95f947dfe8226","head":{"label":"ranisalt:bye-bye-raids","ref":"bye-bye-raids","sha":"a23cb24c19cd06b17be39a6d9cb95f947dfe8226","user":{"login":"ranisalt","id":1993083,"avatar_url":"https://avatars0.githubusercontent.com/u/1993083?v=4","gravatar_id":"","url":"https://api.github.com/users/ranisalt","html_url":"https://github.com/ranisalt","followers_url":"https://api.github.com/users/ranisalt/followers","following_url":"https://api.github.com/users/ranisalt/following{/other_user}","gists_url":"https://api.github.com/users/ranisalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ranisalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranisalt/subscriptions","organizations_url":"https://api.github.com/users/ranisalt/orgs","repos_url":"https://api.github.com/users/ranisalt/repos","events_url":"https://api.github.com/users/ranisalt/events{/privacy}","received_events_url":"https://api.github.com/users/ranisalt/received_events","type":"User","site_admin":false},"repo":{"id":34152469,"name":"forgottenserver","full_name":"ranisalt/forgottenserver","owner":{"login":"ranisalt","id":1993083,"avatar_url":"https://avatars0.githubusercontent.com/u/1993083?v=4","gravatar_id":"","url":"https://api.github.com/users/ranisalt","html_url":"https://github.com/ranisalt","followers_url":"https://api.github.com/users/ranisalt/followers","following_url":"https://api.github.com/users/ranisalt/following{/other_user}","gists_url":"https://api.github.com/users/ranisalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ranisalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranisalt/subscriptions","organizations_url":"https://api.github.com/users/ranisalt/orgs","repos_url":"https://api.github.com/users/ranisalt/repos","events_url":"https://api.github.com/users/ranisalt/events{/privacy}","received_events_url":"https://api.github.com/users/ranisalt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ranisalt/forgottenserver","description":"A free and open-source MMORPG server emulator written in C++","fork":true,"url":"https://api.github.com/repos/ranisalt/forgottenserver","forks_url":"https://api.github.com/repos/ranisalt/forgottenserver/forks","keys_url":"https://api.github.com/repos/ranisalt/forgottenserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ranisalt/forgottenserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ranisalt/forgottenserver/teams","hooks_url":"https://api.github.com/repos/ranisalt/forgottenserver/hooks","issue_events_url":"https://api.github.com/repos/ranisalt/forgottenserver/issues/events{/number}","events_url":"https://api.github.com/repos/ranisalt/forgottenserver/events","assignees_url":"https://api.github.com/repos/ranisalt/forgottenserver/assignees{/user}","branches_url":"https://api.github.com/repos/ranisalt/forgottenserver/branches{/branch}","tags_url":"https://api.github.com/repos/ranisalt/forgottenserver/tags","blobs_url":"https://api.github.com/repos/ranisalt/forgottenserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ranisalt/forgottenserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ranisalt/forgottenserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/ranisalt/forgottenserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ranisalt/forgottenserver/statuses/{sha}","languages_url":"https://api.github.com/repos/ranisalt/forgottenserver/languages","stargazers_url":"https://api.github.com/repos/ranisalt/forgottenserver/stargazers","contributors_url":"https://api.github.com/repos/ranisalt/forgottenserver/contributors","subscribers_url":"https://api.github.com/repos/ranisalt/forgottenserver/subscribers","subscription_url":"https://api.github.com/repos/ranisalt/forgottenserver/subscription","commits_url":"https://api.github.com/repos/ranisalt/forgottenserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/ranisalt/forgottenserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/ranisalt/forgottenserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/ranisalt/forgottenserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/ranisalt/forgottenserver/contents/{+path}","compare_url":"https://api.github.com/repos/ranisalt/forgottenserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ranisalt/forgottenserver/merges","archive_url":"https://api.github.com/repos/ranisalt/forgottenserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ranisalt/forgottenserver/downloads","issues_url":"https://api.github.com/repos/ranisalt/forgottenserver/issues{/number}","pulls_url":"https://api.github.com/repos/ranisalt/forgottenserver/pulls{/number}","milestones_url":"https://api.github.com/repos/ranisalt/forgottenserver/milestones{/number}","notifications_url":"https://api.github.com/repos/ranisalt/forgottenserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ranisalt/forgottenserver/labels{/name}","releases_url":"https://api.github.com/repos/ranisalt/forgottenserver/releases{/id}","deployments_url":"https://api.github.com/repos/ranisalt/forgottenserver/deployments","created_at":"2015-04-18T04:34:37Z","updated_at":"2017-08-20T00:24:42Z","pushed_at":"2017-12-27T02:56:16Z","git_url":"git://github.com/ranisalt/forgottenserver.git","ssh_url":"git@github.com:ranisalt/forgottenserver.git","clone_url":"https://github.com/ranisalt/forgottenserver.git","svn_url":"https://github.com/ranisalt/forgottenserver","homepage":"","size":17283,"stargazers_count":6,"watchers_count":6,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":2,"open_issues":1,"watchers":6,"default_branch":"master"}},"base":{"label":"otland:master","ref":"master","sha":"8ec5ef788c572576f87b35dc4f0926e53fd76805","user":{"login":"otland","id":4956302,"avatar_url":"https://avatars2.githubusercontent.com/u/4956302?v=4","gravatar_id":"","url":"https://api.github.com/users/otland","html_url":"https://github.com/otland","followers_url":"https://api.github.com/users/otland/followers","following_url":"https://api.github.com/users/otland/following{/other_user}","gists_url":"https://api.github.com/users/otland/gists{/gist_id}","starred_url":"https://api.github.com/users/otland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otland/subscriptions","organizations_url":"https://api.github.com/users/otland/orgs","repos_url":"https://api.github.com/users/otland/repos","events_url":"https://api.github.com/users/otland/events{/privacy}","received_events_url":"https://api.github.com/users/otland/received_events","type":"Organization","site_admin":false},"repo":{"id":11081909,"name":"forgottenserver","full_name":"otland/forgottenserver","owner":{"login":"otland","id":4956302,"avatar_url":"https://avatars2.githubusercontent.com/u/4956302?v=4","gravatar_id":"","url":"https://api.github.com/users/otland","html_url":"https://github.com/otland","followers_url":"https://api.github.com/users/otland/followers","following_url":"https://api.github.com/users/otland/following{/other_user}","gists_url":"https://api.github.com/users/otland/gists{/gist_id}","starred_url":"https://api.github.com/users/otland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otland/subscriptions","organizations_url":"https://api.github.com/users/otland/orgs","repos_url":"https://api.github.com/users/otland/repos","events_url":"https://api.github.com/users/otland/events{/privacy}","received_events_url":"https://api.github.com/users/otland/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/otland/forgottenserver","description":"A free and open-source MMORPG server emulator written in C++","fork":false,"url":"https://api.github.com/repos/otland/forgottenserver","forks_url":"https://api.github.com/repos/otland/forgottenserver/forks","keys_url":"https://api.github.com/repos/otland/forgottenserver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/otland/forgottenserver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/otland/forgottenserver/teams","hooks_url":"https://api.github.com/repos/otland/forgottenserver/hooks","issue_events_url":"https://api.github.com/repos/otland/forgottenserver/issues/events{/number}","events_url":"https://api.github.com/repos/otland/forgottenserver/events","assignees_url":"https://api.github.com/repos/otland/forgottenserver/assignees{/user}","branches_url":"https://api.github.com/repos/otland/forgottenserver/branches{/branch}","tags_url":"https://api.github.com/repos/otland/forgottenserver/tags","blobs_url":"https://api.github.com/repos/otland/forgottenserver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/otland/forgottenserver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/otland/forgottenserver/git/refs{/sha}","trees_url":"https://api.github.com/repos/otland/forgottenserver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/otland/forgottenserver/statuses/{sha}","languages_url":"https://api.github.com/repos/otland/forgottenserver/languages","stargazers_url":"https://api.github.com/repos/otland/forgottenserver/stargazers","contributors_url":"https://api.github.com/repos/otland/forgottenserver/contributors","subscribers_url":"https://api.github.com/repos/otland/forgottenserver/subscribers","subscription_url":"https://api.github.com/repos/otland/forgottenserver/subscription","commits_url":"https://api.github.com/repos/otland/forgottenserver/commits{/sha}","git_commits_url":"https://api.github.com/repos/otland/forgottenserver/git/commits{/sha}","comments_url":"https://api.github.com/repos/otland/forgottenserver/comments{/number}","issue_comment_url":"https://api.github.com/repos/otland/forgottenserver/issues/comments{/number}","contents_url":"https://api.github.com/repos/otland/forgottenserver/contents/{+path}","compare_url":"https://api.github.com/repos/otland/forgottenserver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/otland/forgottenserver/merges","archive_url":"https://api.github.com/repos/otland/forgottenserver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/otland/forgottenserver/downloads","issues_url":"https://api.github.com/repos/otland/forgottenserver/issues{/number}","pulls_url":"https://api.github.com/repos/otland/forgottenserver/pulls{/number}","milestones_url":"https://api.github.com/repos/otland/forgottenserver/milestones{/number}","notifications_url":"https://api.github.com/repos/otland/forgottenserver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/otland/forgottenserver/labels{/name}","releases_url":"https://api.github.com/repos/otland/forgottenserver/releases{/id}","deployments_url":"https://api.github.com/repos/otland/forgottenserver/deployments","created_at":"2013-07-01T01:57:06Z","updated_at":"2017-12-26T20:11:34Z","pushed_at":"2017-12-27T15:26:54Z","git_url":"git://github.com/otland/forgottenserver.git","ssh_url":"git@github.com:otland/forgottenserver.git","clone_url":"https://github.com/otland/forgottenserver.git","svn_url":"https://github.com/otland/forgottenserver","homepage":"https://otland.net/","size":16955,"stargazers_count":526,"watchers_count":526,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":491,"mirror_url":null,"archived":false,"open_issues_count":190,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":491,"open_issues":190,"watchers":526,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/otland/forgottenserver/pulls/1813"},"html":{"href":"https://github.com/otland/forgottenserver/pull/1813"},"issue":{"href":"https://api.github.com/repos/otland/forgottenserver/issues/1813"},"comments":{"href":"https://api.github.com/repos/otland/forgottenserver/issues/1813/comments"},"review_comments":{"href":"https://api.github.com/repos/otland/forgottenserver/pulls/1813/comments"},"review_comment":{"href":"https://api.github.com/repos/otland/forgottenserver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/otland/forgottenserver/pulls/1813/commits"},"statuses":{"href":"https://api.github.com/repos/otland/forgottenserver/statuses/a23cb24c19cd06b17be39a6d9cb95f947dfe8226"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ranisalt"}}