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

Mapified pos_bub, posx, and posy in the talker class hierarchy #79753

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented Feb 20, 2025

Summary

None

Purpose of change

Make map dependencies explicit. This time a bit of the talker class hierarchy and users.
Edit:
Made the 'pos_x' and 'pos_y' JSON talker operations absolute, not reality bubble relative. JSON doesn't know anything about the reality bubble, and certainly not where its anchor point happens to be. All position operations used from JSON will have to be relative to talkers, so it's better if those talker positions are better absolute (it also makes it possible for future talkers to operate on a map other than "the" reality bubble).
Also updated the tests for those to be more in line with what might actually be used when this functionality is used outside of the tests (didn't bother with the reading tests, those are still silly).

Describe the solution

Add a map parameter to pos_bub, posx, and posy in the talker class hierarchy and adjust callers accordingly.
It resulted in a whole lost of definitions of local constants of various pos_bub() calls and usage of the constants rather than repeated calls. It also led to most posx() and posy() usages disappearing because the constants could be used instead.

I encountered some weird code in glide_activity_actor::do_turn(), where the visibility cache is updated with both x, y, and z coordinates, which doesn't make any sense at all, since the parameter is the z parameter. Thus, I removed the x and y calls.

Describe alternatives you've considered

I tried to get rid of the JSON usages of pos_x, pos_y, and pos_z, but those were cleverly hidden by 'pos_x' rather than "pos_x", so I had to restore that functionality (with ugly get_map() calls). Fortunately, it blew up immediately when I tried to test it.

Testing

Apart from the weird visibility cache update, no functionality should have changed.
Load save, walk up ramp, jump into car, run through hay bales, run over zombie corpse with inventory, run over turkeys, smash into stationary vehicle. Nothing odd seen.

Additional context

Why does 'talker' have 'set_pos' and everyone else(?) 'setpos'? Is it to intentionally to not override the operation, or should it be changed to 'setpos' and be overridden?

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership Vehicles Vehicles, parts, mechanics & interactions Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Melee Melee weapons, tactics, techniques, reach attack Mechanics: Weather Rain, snow, portal storms and non-temperature environment Mechanics: Enchantments / Spells Enchantments and spells Items: Armor / Clothing Armor and clothing EOC: Effects On Condition Anything concerning Effects On Condition labels Feb 20, 2025
@github-actions github-actions bot requested a review from KorGgenT February 20, 2025 13:32
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Feb 20, 2025
@PatrikLundell PatrikLundell marked this pull request as draft February 20, 2025 17:35
@PatrikLundell
Copy link
Contributor Author

PatrikLundell commented Feb 20, 2025

Something is badly broken somewhere. Tests fail, and I get an exception thrown because the get_player_view() is null in at least one test (and probably more).
I've tried the obvious change (return the calling line to the previous format), but as the cause isn't the data called, but the object calling, that didn't help (reverting to master and running tests work normally, so it's definitely something in the PR, somehow).

We'll see if I'll manage to figure out what's going on.

Edit:
It helps to try to understand the correct call chain...
Making progress with sorting out the issues, so I think it's mostly a matter of time (waiting for rather lengthy tests to reach the next problem).

Edit 2:
I think I'm stuck on the last (known) failure.
For some reason npc_talk_test test case "npc_arithmetic", "[npc_talk]" fails on setting of pos_z, and I can't figure out why. Debugging doesn't really help, as the code that should be called, as well as that for pos_y, which does work, is claimed not to be linked into the tests (that's probably a lie, caused by the code being inside a lambda: breakpoints outside the lambda triggered during test initiation, but not during the tests), and trying to follow the call ends up in template hell and seemed to somehow call "empty_guts" or something similar rather than pos_z.

Edit 3:
If you introduce a new virtual operation with an empty implementation but forget to override it, the virtual operation gets used without complaints. No idea why clear_guts::do_turn() showed up when debugging, though.

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [JSON] Changes (can be) made in JSON [Markdown] Markdown issues and PRs labels Feb 21, 2025
@PatrikLundell PatrikLundell marked this pull request as ready for review February 21, 2025 08:17
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. EOC: Effects On Condition Anything concerning Effects On Condition Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Items: Armor / Clothing Armor and clothing [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs Mechanics: Enchantments / Spells Enchantments and spells Mechanics: Weather Rain, snow, portal storms and non-temperature environment Melee Melee weapons, tactics, techniques, reach attack Monsters Monsters both friendly and unfriendly. NPC / Factions NPCs, AI, Speech, Factions, Ownership Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant