Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

☂️ Game engine: Ongoing code migration projects #3271

Open
1 of 6 tasks
olanti-p opened this issue Sep 26, 2023 · 2 comments
Open
1 of 6 tasks

☂️ Game engine: Ongoing code migration projects #3271

olanti-p opened this issue Sep 26, 2023 · 2 comments
Labels
easy Simple task that doesn't require understanding the code much ☂️ umbrella tracks multiple issues at once

Comments

@olanti-p
Copy link
Contributor

olanti-p commented Sep 26, 2023

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 player class into Character and avatar. player class 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. The player class 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: Obsolete legacy JSON CleverRaven/Cataclysm-DDA#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": 1 used to mean 250 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: Jsonize Anatomy: replace enum body_part with bodypart_id CleverRaven/Cataclysm-DDA#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: Migrate legacy activities to the activity actor system CleverRaven/Cataclysm-DDA#40013
  • Migrating point and tripoint APIs to use type safe coord types. We've ported the original implementation ( Provide point types with coordinate system type-safety CleverRaven/Cataclysm-DDA#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: [TODO] Finish moving from artifacts to relics #1816

Tasks

Preview Give feedback
  1. 0 of 2
  2. enhancement port request
@olanti-p olanti-p added the easy Simple task that doesn't require understanding the code much label Sep 26, 2023
@scarf005
Copy link
Member

Modernizing JSON parser to accept type strings over raw integers

i have a JSON mapping script, could you share some conversion guidelines?

@olanti-p
Copy link
Contributor Author

olanti-p commented Sep 28, 2023

It basically boils down to the following steps:

  1. 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.

  2. Updating these usages in JSON with a script, replacing integer values with typed strings

  3. Some time in the future (when? Backwards compatibility limit #3302), dropping the integer support for migrated fields

@scarf005 scarf005 added this to Roadmap Jan 7, 2024
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Jan 7, 2024
@scarf005 scarf005 changed the title Game engine: Ongoing code migration projects ☂️ Game engine: Ongoing code migration projects Mar 22, 2024
@scarf005 scarf005 added the ☂️ umbrella tracks multiple issues at once label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy Simple task that doesn't require understanding the code much ☂️ umbrella tracks multiple issues at once
Projects
Status: Todo
Development

No branches or pull requests

2 participants