{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/30050885","id":30050885,"diff_hunk":"@@ -0,0 +1,41 @@\n+#ifndef MONFACTION_H\n+#define MONFACTION_H\n+\n+#include \"string_id.h\"\n+#include \"int_id.h\"\n+#include <unordered_map>\n+\n+class monfaction;\n+class JsonObject;\n+\n+using mfaction_id = int_id<monfaction>;\n+using mfaction_str_id = string_id<monfaction>;\n+\n+enum mf_attitude {\n+    MFA_BY_MOOD = 0,    // Hostile if angry\n+    MFA_NEUTRAL,        // Neutral even when angry\n+    MFA_FRIENDLY        // Friendly\n+};\n+\n+typedef std::unordered_map< mfaction_id, mf_attitude > mfaction_att_map;\n+\n+namespace monfactions\n+{\n+void finalize_monfactions();\n+void load_monster_faction(JsonObject &jo);\n+mfaction_id get_or_add_faction( const std::string &name );\n+}","path":"src/monfaction.h","position":27,"original_position":27,"commit_id":"2b95683215388a434ec3c899e516ab717ba70a02","original_commit_id":"2b95683215388a434ec3c899e516ab717ba70a02","user":{"login":"BevapDin","id":5095435,"avatar_url":"https://avatars.githubusercontent.com/u/5095435?v=3","gravatar_id":"","url":"https://api.github.com/users/BevapDin","html_url":"https://github.com/BevapDin","followers_url":"https://api.github.com/users/BevapDin/followers","following_url":"https://api.github.com/users/BevapDin/following{/other_user}","gists_url":"https://api.github.com/users/BevapDin/gists{/gist_id}","starred_url":"https://api.github.com/users/BevapDin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BevapDin/subscriptions","organizations_url":"https://api.github.com/users/BevapDin/orgs","repos_url":"https://api.github.com/users/BevapDin/repos","events_url":"https://api.github.com/users/BevapDin/events{/privacy}","received_events_url":"https://api.github.com/users/BevapDin/received_events","type":"User","site_admin":false},"body":"A namespace is an interesting solution. I usually put this stuff as static functions into the classes that it refers to (but this here will work, too).\r\n\r\nHowever, I really don't like the pointless repetition of the name of the name of the finalized thing: `monfactions::finalize_monfactions`. This is only called once (exactly like this) from init.cpp (and should never be called from anywhere else. It should be pretty much clear, what is finalized. `monfactions::finalize` should be enough.","created_at":"2015-05-11T15:46:15Z","updated_at":"2015-05-11T15:46:15Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/12335#discussion_r30050885","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/30050885"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/12335#discussion_r30050885"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335","id":35077731,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/12335","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/12335.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/12335.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/12335","number":12335,"state":"open","locked":false,"title":"Rewrite monster faction system to use int/str_id","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":"Cleanup before monster AI enhancements.\r\n\r\nMoved the monster faction system out of monstergenerator and mtype into own files.\r\n\r\nChanged it to use the new BevapDin's string/int identifiers. No real need for type safety in monster factions (yet), but the wrappers help with readability and not having to pass pointers around.\r\n\r\n\r\nFunctionally, the only thing that changed is lack of hardcoded player and null factions on initialization.\r\n\r\nPlayer faction must exist (be somewhere in a json) or the game will crash. Later on I'll change it so that it is requested at the start of the game when NPC factions are created (each NPC faction will have a monster faction id, including player followers faction).\r\n\r\nInstead of a hardcoded null faction, the first faction that is its own parent becomes the root of the faction tree and adopts all orphan factions (factions not defined explicitly in a json are always orphans).","created_at":"2015-05-10T05:27:10Z","updated_at":"2015-05-11T15:46:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56e68b7d0bf4b67b38adca747ed1283f143732c5","assignee":{"login":"BevapDin","id":5095435,"avatar_url":"https://avatars.githubusercontent.com/u/5095435?v=3","gravatar_id":"","url":"https://api.github.com/users/BevapDin","html_url":"https://github.com/BevapDin","followers_url":"https://api.github.com/users/BevapDin/followers","following_url":"https://api.github.com/users/BevapDin/following{/other_user}","gists_url":"https://api.github.com/users/BevapDin/gists{/gist_id}","starred_url":"https://api.github.com/users/BevapDin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BevapDin/subscriptions","organizations_url":"https://api.github.com/users/BevapDin/orgs","repos_url":"https://api.github.com/users/BevapDin/repos","events_url":"https://api.github.com/users/BevapDin/events{/privacy}","received_events_url":"https://api.github.com/users/BevapDin/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335/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/12335/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/2b95683215388a434ec3c899e516ab717ba70a02","head":{"label":"Coolthulhu:faction-id","ref":"faction-id","sha":"2b95683215388a434ec3c899e516ab717ba70a02","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-05-08T12:17:07Z","pushed_at":"2015-05-11T11:12:33Z","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":442603,"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":"87093bf0ea982c4f92a5c4af0da28fedac3786bc","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-05-11T09:17:20Z","pushed_at":"2015-05-11T15:22:10Z","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":528554,"stargazers_count":653,"watchers_count":653,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":697,"mirror_url":null,"open_issues_count":952,"forks":697,"open_issues":952,"watchers":653,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/12335"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/12335"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/12335/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/12335/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/12335/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/2b95683215388a434ec3c899e516ab717ba70a02"}}}}