{"action":"created","issue":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15453","repository_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15453/labels{/name}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15453/comments","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15453/events","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/15453","id":134627101,"number":15453,"title":"Separate the logic of `use_function` and `iuse_actor`. ","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},"labels":[],"state":"open","locked":false,"assignee":{"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},"milestone":null,"comments":1,"created_at":"2016-02-18T16:24:06Z","updated_at":"2016-02-18T23:38:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/15453","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/15453","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/15453.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/15453.patch"},"body":"Currently we have `use_function`, which behaves like a class with virtual functions (dispatches calls to `call` via an enumeration), but actually isn't. And we have `iuse_actor` with a similar interface (also has a `call` function, named `use`).\r\n\r\nThis PR changes `use_function` to be a simple wrapper, it does not contain any game logic. The raw C++ function pointer (`use_function_pointer`) and the Lua callback id are wrapped into their own classes (inheriting from `iuse_actor`). This allows `use_function` to only store a pointer to `iuse_actor`, making it a simple wrapper of `unique_ptr<iuse_actor>`.\r\n\r\nIt adds copy construction, copy assignment (both forwarding to `iuse_actor::clone` to do the actually copy), and wrapper for calls to `iuse_actor` functions. The class can be used with a null as actor (functions will do nothing or return a default value).\r\n\r\nIt allows to move more things into their specific actors. For example the name shown in the item action menu could be moved there. That way it can automatically contain specific data from the actor like the materials that can be repaired with the repair actor. Also the required charge count for each action can be moved there.\r\n\r\nNew things can be added to the `iuse_actor` classes as virtual functions, optionally with a simple wrapper function in `use_function` that handles null pointers."},"comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments/185980930","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/15453#issuecomment-185980930","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/15453","id":185980930,"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},"created_at":"2016-02-18T23:38:07Z","updated_at":"2016-02-18T23:38:07Z","body":"Works for C++ `iuse`s and `iuse_actor`s, but the sample manhack lua mod doesn't. It could be just that sample mod, though. Or my attempt at using it.\r\n\r\nI don't know of any non-sample mods using lua iuses, so I'd be fine with merging it, but I'll wait for others to comment on this."}}