☂️ Game engine: Ongoing code migration projects
We have multiple code migration projects that we've inherited from DDA, it'd be nice to have them finished or somehow wrapped up:
- [ ] Splitting up
playerclass intoCharacterandavatar.playerclass has been used as dumping grounds for all NPC and player character code for a long time, resulting in a mess that became hard to use and debug in context of NPC AI. Theplayerclass should be eliminated, all code that uses it should be changed to use one of the 3 classes:npc,Character,avatar(which to use depends on context). - [ ] Modernizing JSON parser to accept type strings over raw integers: https://github.com/CleverRaven/Cataclysm-DDA/issues/36110. Typed strings are much easier to reason about, as you don't have to figure out and remember how JSON values map to ingame values (e.g.
"volume": 1used to mean250 ml, but it can now be explicitly specified with"volume": "250 ml"). - [ ] Migrating body parts from hardcoded enum to dynamically loaded
string_ids. This in theory could allow for dynamic anatomies (amputations, extra limbs, limb replacements, multiwielding), but may come with a performance hit (hardcode will always be faster than dynamic, and limbs are accessed and used extensively in the code). Original issue: https://github.com/CleverRaven/Cataclysm-DDA/pull/39068 - [ ] Migrating activities to activity actor system. Huge advantage of
activity_actors is they allow custom types and custom type names, which makes it much easier to understand, extend, debug and implement new activities. Original issue: https://github.com/CleverRaven/Cataclysm-DDA/issues/40013 - [ ] Migrating
pointandtripointAPIs to use type safe coord types. We've ported the original implementation ( https://github.com/CleverRaven/Cataclysm-DDA/pull/32017 ) and some of the following changes because it was required for other features, but no further systematic work has been done about it. - [ ] Migrating items with "magical" properties from artifact framework to relics. Main issue with artifacts is they are generated dynamically as new item types, which makes them "truly" unique but also extremely hard to reason about when it comes to static data analysis, legacy migrations and such. It's also a complete outlier from how all other data in game is immutable, and gets loaded from JSONs defined by
data/json/and mods. Tracking issue: #1816
### Tasks
- [ ] Split player class into Character and avatar
- [ ] https://github.com/cataclysmbnteam/Cataclysm-BN/issues/3311
- [ ] Migrate body parts from hardcoded enum to `string_id`
- [ ] Migrate `activities` to `activity actor` system
- [ ] Migrate `point` and `tripoint` to use type safe coord types
- [ ] #1816
Modernizing JSON parser to accept type strings over raw integers
i have a JSON mapping script, could you share some conversion guidelines?
It basically boils down to the following steps:
-
Finding where the parser supports loading both integer values and strings for units. For example, it seems that any
assign( ... )when used with units will accept both integers and typed strings: https://github.com/CleverRaven/Cataclysm-DDA/blob/d48717db010722fc43d6aaf8e3ff207de3a6d0a2/src/assign.cpp#L37-L40 There may be more hidden here and there. -
Updating these usages in JSON with a script, replacing integer values with typed strings
-
Some time in the future (when? #3302), dropping the integer support for migrated fields