{"action":"created","issue":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/19512","repository_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/19512/labels{/name}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/19512/comments","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/19512/events","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/19512","id":191881942,"number":19512,"title":"Hacking on vehicle IDs","user":{"login":"mutability","id":3055062,"avatar_url":"https://avatars.githubusercontent.com/u/3055062?v=3","gravatar_id":"","url":"https://api.github.com/users/mutability","html_url":"https://github.com/mutability","followers_url":"https://api.github.com/users/mutability/followers","following_url":"https://api.github.com/users/mutability/following{/other_user}","gists_url":"https://api.github.com/users/mutability/gists{/gist_id}","starred_url":"https://api.github.com/users/mutability/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mutability/subscriptions","organizations_url":"https://api.github.com/users/mutability/orgs","repos_url":"https://api.github.com/users/mutability/repos","events_url":"https://api.github.com/users/mutability/events{/privacy}","received_events_url":"https://api.github.com/users/mutability/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-11-27T20:04:00Z","updated_at":"2016-12-20T22:52:42Z","closed_at":"2016-12-20T22:52:42Z","pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/19512","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/19512","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/19512.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/19512.patch"},"body":"Related to #19437. Not intended to be merged, this is just to throw ideas around.\r\n\r\nA quick overview:\r\n\r\nAll the ID-related stuff is templated around the target type. Here I'm using `vehicle` but it should generalize to other types without too much trouble.\r\n\r\n`PersistentID<vehicle>` is the long-term ID for a vehicle. It is a wrapper around a `long` mostly for improved type safety\r\n\r\n`PersistentHandle<vehicle>` is a handle to a `vehicle`. It behaves somewhat like `weak_ptr`: you can get a handle from a `vehicle*` and if the vehicle is later deleted, all handles that refer to it are safely invalidated (`get()` will return `nullptr`). This isn't really used much yet, but the intent is that you can store PersistentHandles in long-lived structures where you need to have a safe, long-lived, fast reference to some other object that might move or be destroyed.\r\n\r\nYou can construct a `PersistentHandle<vehicle>` from just a `PersistentID<vehicle>`; the handle will try to locate the vehicle on demand. A `PersistentHandle<vehicle>` that refers to a `vehicle` that got deleted will also try to re-locate the vehicle by ID. The intent here is that handle-based references will survive a save/load cycle and will survive the target moving out/in of the reality bubble. What to do if you need to deal with a target that's currently out of the bubble is an unresolved question.\r\n\r\nLocating vehicles is done by a specialization of `PersistentID<vehicle>::find_by_id`. In this implementation it just goes looking for a matching vehicle in the reality bubble.\r\n\r\n`Persistent<vehicle>` is a helper mixin that `vehicle` inherits to provide the basic persistent ID hooks and invalidation of handles on destruction.\r\n\r\nIDs are allocated on first use and are persisted in the saved json.\r\n\r\nplayer_activity can store handles (they get serialized as the underlying ID).\r\n\r\nI updated the vehicle interaction stuff to store the ID in the activity and use it to re-find the vehicle when the action completes. The other obvious place (that I haven't done yet) is the jumper cable stuff.\r\n\r\npaging @mugling @Coolthulhu to the thread.."},"comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments/268382740","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/19512#issuecomment-268382740","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/19512","id":268382740,"user":{"login":"mutability","id":3055062,"avatar_url":"https://avatars.githubusercontent.com/u/3055062?v=3","gravatar_id":"","url":"https://api.github.com/users/mutability","html_url":"https://github.com/mutability","followers_url":"https://api.github.com/users/mutability/followers","following_url":"https://api.github.com/users/mutability/following{/other_user}","gists_url":"https://api.github.com/users/mutability/gists{/gist_id}","starred_url":"https://api.github.com/users/mutability/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mutability/subscriptions","organizations_url":"https://api.github.com/users/mutability/orgs","repos_url":"https://api.github.com/users/mutability/repos","events_url":"https://api.github.com/users/mutability/events{/privacy}","received_events_url":"https://api.github.com/users/mutability/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T22:52:42Z","updated_at":"2016-12-20T22:52:42Z","body":"Not much point prototyping this further as kevin has mututally-incompatible ideas about the requirements for persistent IDs."}}
{"actor":{"display_login":"mutability"}}