Skip to content

refactor!: Massive absolute coordinate migration - #9710

Open
AzmodiusX wants to merge 118 commits into
cataclysmbn:mainfrom
AzmodiusX:Iteration-Consolidation
Open

refactor!: Massive absolute coordinate migration#9710
AzmodiusX wants to merge 118 commits into
cataclysmbn:mainfrom
AzmodiusX:Iteration-Consolidation

Conversation

@AzmodiusX

@AzmodiusX AzmodiusX commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Ready for review, NOT ready for merge!

This needs a large amount of verification and play-testing, far exceeding nearly any other PR. This PR is almost entirely manually written and not automated. 90% of the code is actual mechanical changes in some way, or migration to a system that hasn't been battle tested. Scrutinize and be cautious.

Purpose of change (The Why)

Continuation of #9566

Describe the solution (The How)

Refactor pathfinding (depreciated legacy for simplicity)
Migrated a massive chunk of the code base to absolute coordinates
Implemented new simulated islands system to handle iterations, along with better usage of absolute tile lookups
Implemented better out-of-bubble handling for lighting and sound systems that are cheap simplifications of player relative mechanics
Made item location vectors more authoritative, removing position parameters where appropriate
Migrated a significant amount of activities to the modern activity_handler system to avoid wacky coordinate handling, especially with the vehicle activities
Re-enabled fire loading as a mechanic, and added vehicle footprint loading as well. This allows vehicles that intersect the reality bubble to load any submaps that it needs to be fully loaded and therefore allows them to be rendered. It is also optional.
Made temperature handling from weather and fire absolute. Turns out there wasn't anything special going on with that, and there was no reliance on the reality bubble caches.
Fixed outdoor / sheltered handling and cache construction

Testing

Rewrote many automated tests, alongside testing in a world with NPCs and monsters that existed in an area loaded by power portals

Additional context

This has been a fever dream. I'm asking everyone to pitch in to test this monster once it's stable enough to consider. I'm sure the first bit will have us noticing new bugs immediately.
Hopefully this gives us enough of a push that others can theoretically continue the work without my help. Not that I want to offload it, just feels like a good place to be.
I likely will be taking a bit of a break from this feature set and moving onto UI and compositing.

AI disclosure

I used deepseek-v4-flash as an assistant and helper for auditing. Not exactly impressed, tbh. But it worked well enough to help me keep track of stuff and helping me find potential bug sources.
I also used gpt-5.6 luna high. This PR took that long, that I casually swapped models. I used it more extensively, and some of the latest fixes are using AI code, hence the large comments by luna. I especially had issues with the item location vector issues, gonna be honest.

Warning

This touches a LOT of code, and does so in ways that are likely to lead to confusing outcomes at edge cases. We need a lot of testing. I do promise this has a payoff worth the effort.

Tester Checklist

I'll add a list of things that should be tested by multiple devs here.

  • General maap loading
  • Pathfinding
  • Monster and NPC spawning
  • Sounds
  • Explosions, especially near reality bubble edge
  • Vehicle movement
  • Vehicle spawning
  • Various activities such as crafting, butchering, etc; If you need to, check the diff to see modified activities
  • Item interactions & rotting
  • Lighting / visibility

Build Artifacts

PR build for commit b691364 (style(autofix.ci): automated formatting) on 2026-08-06 01:02:09

@AzmodiusX
AzmodiusX marked this pull request as draft June 28, 2026 08:52
@github-actions github-actions Bot added src changes related to source code. JSON related to game datas in JSON format. tests changes related to tests lua PRs and issues related to Lua scripting labels Jun 28, 2026
@autofix-ci

autofix-ci Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Night vision seems a bit weird, there's a zombie southwest, pretty sure I'd see it in main.
image

The zombie was on a sink.
Likewise, if I am the one on the sink
image
I can't see the zombie to my right

Hm but here there were two zombies to my right and I also didn't see them
image

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Reading did not show the percentage progress and it stopped earlier than a full level.
image

It stops after one iteration of reading, actually.

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Tried using the furniture seen above in the screenshot to train athletics and it got the error
image

Lost tool used for long repair

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Zombies do not attack fences
image

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Attempting to read a map (subway maintenance) at z=-1 (subway station) resulted in segfault
It was after traversing the tunnel to a new area.

./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0    [unknown func]
…/src/game_object.cpp:0    game_object<item>::bub_pos() const
 …/src/inventory_ui.cpp:1,265    inventory_selector::add_items(inventory_column&, std::function<item* (item*)> const&, std::vector<std::__cxx11::list<item*, std::allocator<item*> >, std::allocator<std::__cxx11::list<item*, std::allocator<item*> > > > const&, item_category const*)
    …/src/inventory_ui.cpp:1,328    inventory_selector::add_map_items(coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> const&)
    …/src/inventory_ui.cpp:1,362    inventory_selector::add_nearby_items(int)

It does work on the surface at z=0.
The map was still on the furniture rack.
This one is trickier to reproduce, a map that was already read can still be used at z=-1 (it shouldn't) but it does not crash. A map that wasn't read showed the correct result in the starting area (says it cant be used underground).

Not sure what caused it exactly.

Might be related to wielding and dropping an item because its full?

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Rain is showing up inside
image

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Created a world with multiple in-repo mods, like Arcana.
Spawned 20 refined blood effigies and started using them, game froze after two.
Spawned 20 rat serums, could mutate fully.
Spawned 20 raptor serums, froze after using 4.
Could it be a regression of mutation pushing off items?

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Detonating a mininuke at my feet in the lab caused error
image

Loop in terrain bashing for type t_flat_roof

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

By displacing a horse I am leading with a leash on the rails of a building (z=2)
I can occupy the same tile
image

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Trying to autotravel on foot from worldmap stops after one step
image

With a car, it does not move and says Can't see a path forward in broad daylight and an open space.

Tried with a canoe in the nearby river and it managed to drive.

@ChrisLR

ChrisLR commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Now this is one odd bug.
From the inside a vehicle I teleported next to water, while walking around I was stopped by the vehicle's walls
image

@ChrisLR

ChrisLR commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

It says there is a roof above my head, nope.
image
From the island prison start

@ChrisLR

ChrisLR commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Something super weird here, there was a mag showing as 30/30 and a rifle showing as 6/30
Mag was in locker, reloaded the rifle, both show up as 6/30 now.
image

Could reproduce by spawning a mag at my feet and reloading again

Even worse, firing the gun and coming back to the mags, they have the same ammo count.
image

Refs be fucky wucky
Unloading the gun afterwards made the game real unhappy, jumped into an infinite loop
Reloaded using debug and paused it, here stack
image

@ChrisLR

ChrisLR commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Trying to wield an unrelated gun taken from a corpse later and segfaulty boi
image

    0x619,f11,1cf,603    …/src/debug.cpp:965    bt_full(backtrace_state*, int, std::function<int (unsigned long, char const*, int, char const*)> const&, std::function<void (char const*, int)> const&)
    0x619,f11,1cf,603    …/src/debug.cpp:1,349    debug_write_backtrace(std::ostream&)
    0x619,f11,19b,9bd    …/src/crash.cpp:104    log_crash(char const*, char const*)
    0x619,f11,19b,5f6    …/src/crash.cpp:153    signal_handler(int)
    0x76a,eed,130,8cf    ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0    [unknown func]
    0x619,f11,fd1,2c5    …/src/pickup.cpp:537    pickup::stack_for_pickup_ui(std::vector<location_vector<item>::iterator, std::allocator<location_vector<item>::iterator> > const&)
    0x619,f11,fd2,efa    …/src/pickup.cpp:647    (anonymous namespace)::pick_up_from_items(std::vector<location_vector<item>::iterator, std::allocator<location_vector<item>::iterator> > const&, int, std::optional<coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> > const&)
    0x619,f11,fd2,6c6    …/src/pickup.cpp:1,328    pickup::pick_up(coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> const&, int, pickup::from_where)
    0x619,f11,408,476    …/src/game.cpp:8,664    game::pickup(coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> const&)
    0x619,f11,408,048    …/src/game.cpp:8,647    game::pickup()
    0x619,f11,4d6,7de    …/src/handle_action.cpp:2,403    game::handle_action()
    0x619,f11,3cf,453    …/src/game.cpp:2,169    game::do_turn()

I can pickup a stick on the same corpse but picking up a gun is strictly forbidden

@ChrisLR

ChrisLR commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Auto foraging seems borked, foraged manually worked, activated auto forage, set to bush but nothing :(
image

Actually it did work after moving a couple tiles down and back up, weird 🤔

@ChrisLR

ChrisLR commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Automove from the overmap while on foot is still borked btw

@ChrisLR

ChrisLR commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Playing guitar also did a segfaulty boi
image

    0x5df,861,d42,a8d    …/src/cata_tiles_color.cpp:108    (anonymous namespace)::tint_from_data_vars(data_vars::data_set const&, std::pair<tint_config, tint_config> const&)
    0x5df,861,d43,257    …/src/cata_tiles_color.cpp:224    cata_tiles::get_item_color(item const&, map const&, coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> const&) const
    0x5df,861,d10,41e    …/src/cata_tiles.cpp:5,614    cata_tiles::draw_field_or_item(coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> const&, lit_level, int&, bool const (&) [5], int)
    0x5df,861,d0a,e60    …/src/cata_tiles.cpp:3,781    cata_tiles::draw(point, coords::coord_point<tripoint, (coords::origin)2, (coords::scale)0> const&, int, int, std::multimap<point, formatted_text, std::less<point>, std::allocator<std::pair<point const, formatted_text> > >&, std::pair<unsigned int, std::multimap<point, SDL_Color, std::less<point>, std::allocator<std::pair<point const, SDL_Color> > > >&)
    0x5df,865,69f,0d4    …/src/sdltiles.cpp:1,629    cata_cursesport::curses_drawwindow(catacurses::window const&)
    0x5df,864,8c1,8d4    …/src/game.cpp:4,647    game::draw(ui_adaptor&)
    0x5df,865,7bf,ddb    /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/std_function.h:591    std::function<void (ui_adaptor&)>::operator()(ui_adaptor&) const
    0x5df,865,7bf,ddb    …/src/ui_manager.cpp:413    ui_adaptor::redraw_invalidated()
    0x5df,864,9a6,eca    …/src/handle_action.cpp:490    game::get_player_input(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
    0x5df,864,9a7,b1e    …/src/handle_action.cpp:1,876    game::handle_action()
    0x5df,864,8a4,453    …/src/game.cpp:2,169    game::do_turn()
    0x5df,865,980,8be    …/src/main.cpp:928    main
    ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JSON related to game datas in JSON format. lua PRs and issues related to Lua scripting mods PR changes related to mods. src changes related to source code. tests changes related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants