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

Accessing the bulletin board in a mansion base rotates zones around the camp's center. #51459

Closed
Divreus opened this issue Sep 7, 2021 · 6 comments · Fixed by #51703
Closed
Labels
<Bug> This needs to be fixed Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones Player Faction Base / Camp All about the player faction base/camp/site

Comments

@Divreus
Copy link

Divreus commented Sep 7, 2021

Describe the bug

As the title says. Placed zones pivot around the center of the camp tile whenever the bulletin board is accessed.

Steps To Reproduce

  1. Load the save, note the locations of the zones in the zones manager
  2. Access the bulletin board
  3. Open the zones manager again to see that their positions have changed

Expected behavior

Zones ought to stay where they ought to stay.

Screenshots

No response

Versions and configuration

  • OS: Windows
    • OS Version: 10.0 2009
  • Game Version: 20bf2de [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Bionic Professions [package_bionic_professions],
    Blaze Industries [blazeindustries],
    C.R.I.T Expansion Mod [crt_expansion],
    Magiclysm [magiclysm],
    No Fungal Monsters [No_Fungi],
    Fuji's Military Profession Pack [fuji_mpp],
    SpeedyDex [speedydex],
    Stats Through Kills [stats_through_kills],
    Stats Through Skills [StatsThroughSkills]
    ]

Additional context

My friend could reproduce it when he loaded the save, and the bug isn't present when starting a new camp on a nearby field tile.
Osnabrock.zip

@actual-nh actual-nh added <Bug> This needs to be fixed Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones Player Faction Base / Camp All about the player faction base/camp/site labels Sep 8, 2021
@eltank
Copy link
Contributor

eltank commented Sep 18, 2021

Well, I know why it's happening, but not so much what to do about it.

The code that checks what farm actions are available on the central tile of the mansion (which is tagged as farmable) loads that OMT into a tinymap and calls generate() on it (mainly to find terrain that hasn't been plowed). This involves a rotation operation since the mansion placement in the world is a rotated version of the template in the json. Due to the way #30150 was coded, the rotation operation also calls zone_manager::rotate_zones intending to rotate NPC zones from the mapgen template but actually rotating any zones that exist at that location.

I think the main problem here is the call to map::generate, which really shouldn't be called on top of an already-generated OMT. Hmm, maybe if we give it some coordinates up in the sky?

#1  0x00007ff680e535f5 in zone_manager::rotate_zones(map&, int) ()
#2  0x00007ff6812174ad in map::rotate(int, bool) ()
#3  0x00007ff681228fb7 in mapgen_function_json::generate(mapgendata&) ()
#4  0x00007ff6818a2482 in mapgen_factory::generate(mapgendata&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) const ()
#5  0x00007ff681237648 in map::draw_map(mapgendata&) ()
#6  0x00007ff681237c4a in map::generate(tripoint const&, time_point const&) ()
#7  0x00007ff680f48db1 in farm_action(coords::coord_point<tripoint, (coords::origin)1, (coords::scale)2> const&, farm_ops, std::__shared_ptr<npc, (__gnu_cxx::_Lock_policy)0> const&) ()
#8  0x00007ff680f49c75 in basecamp::farm_description[abi:cxx11](coords::coord_point<tripoint, (coords::origin)1, (coords::scale)2> const&, unsigned long long&, farm_ops) ()
#9  0x00007ff680f4d530 in basecamp::get_available_missions_by_dir(mission_data&, point const&) ()
#10 0x00007ff680f4f71b in basecamp::get_available_missions(mission_data&) ()
#11 0x00007ff680fff02b in iexamine::bulletin_board(Character&, tripoint const&) ()
#12 0x00007ff680fb8974 in game::examine(tripoint const&) ()
#13 0x00007ff680fb8fc5 in game::examine() ()
#14 0x00007ff680fe7e5b in game::do_regular_action(action_id&, avatar&, cata::optional<tripoint> const&) ()
#15 0x00007ff680fed333 in game::handle_action() ()
#16 0x00007ff680ef6558 in do_turn() ()
#17 0x00007ff681be3745 in main ()

@eltank
Copy link
Contributor

eltank commented Sep 18, 2021

@jbytheway Do you know of a way to invoke mapgen for a specific OMT type on a temporary tinymap instance without affecting the game world? I only know of map::generate but that just takes a tripoint (omt coordinates), looks up the OMT from the overmap buffer and performs mapgen at that location (which happens to mess up any zones at that location).

@jbytheway
Copy link
Contributor

There's some code somewhere that performs mapgen on OMT (0, 0, -10) in the hopes that it can be done there without breaking anything. Maybe you could do a trick like that here? But, yes, it sounds like what should really be happening is that you want to load it without generating it. There must be other places that do that. For example, maybe look into what happens when update_mapgen is triggered from a dialog action?

@anothersimulacrum
Copy link
Member

anothersimulacrum commented Sep 18, 2021

#36582
#35262

#34078
#35534

@eltank
Copy link
Contributor

eltank commented Sep 18, 2021

Thanks for the context, @anothersimulacrum.
It looks like the object to use when generating a temporary in-memory map is fake_map. However, because it inherits code from map it can still have global side-effects during mapgen (like rotating existing npcs and zones).

I should be able to change this buggy faction_camp code to either use a fake_map with underground coordinates or else make more changes to map and fake_map to eliminate global side-effects when using fake_map. The latter would be better but is likely much more difficult.

Either way, I'll remove the no_rotate_npcs workaround while I'm at it. (#47730)

@eltank
Copy link
Contributor

eltank commented Sep 19, 2021

I got something that fixes the bug, I just need to test a bit more to make sure it doesn't break something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bug> This needs to be fixed Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants