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

typified activity_actor #73807

Merged
merged 4 commits into from
May 19, 2024
Merged

typified activity_actor #73807

merged 4 commits into from
May 19, 2024

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented May 15, 2024

Summary

None

Purpose of change

Use typed tripoints in another piece of code.

Describe the solution

Look for tripoints in activity_actor.cpp and convert the code to use typed tripoint, including the change of the operations called (which typically resulted in a typed overload).

Describe alternatives you've considered

Testing

Loaded a save and walked until a monster was detected.

Additional context

I've gotten the help I needed with the issues mentioned here previously, so this is now ready for review. Many thanks @Qrox.

@PatrikLundell PatrikLundell marked this pull request as draft May 15, 2024 15:16
@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership Bionics CBM (Compact Bionic Modules) Map / Mapgen Overmap, Mapgen, Map extras, Map display Vehicles Vehicles, parts, mechanics & interactions Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Items: Containers Things that hold other things astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels May 15, 2024
@Qrox
Copy link
Contributor

Qrox commented May 16, 2024

In messages.h I tried to add a typed template along the untyped one (commented out with //###) but trying to use that causes linking errors with complaints about definitions already being present in fake_messages (which seems to be a lie, at least based on the cpp file).

Not sure why that happens, but I think you do need to add implementations of the newly added functions to tests/fake_messages.cpp so that the unit test can compile. (fake_messages.cpp is used to replace messages.cpp in the unit test.)

Trying to use the creature_tracker.h creature_at template for tripoint_bub_ms (already defined in master, so not of my doing) causes linking problems with rather unhelpful error messages.

It seems the required instantiation is not declared in creature_tracker.cpp.

template const monster *creature_tracker::creature_at<monster>( const tripoint &, bool ) const;
template const monster *creature_tracker::creature_at<monster>( const tripoint_bub_ms &,
bool ) const;
template const monster *creature_tracker::creature_at<monster>( const tripoint_abs_ms &,
bool ) const;
template monster *creature_tracker::creature_at<monster>( const tripoint &, bool );
template monster *creature_tracker::creature_at<monster>( const tripoint_bub_ms &, bool );
template monster *creature_tracker::creature_at<monster>( const tripoint_abs_ms &, bool );
template const npc *creature_tracker::creature_at<npc>( const tripoint &, bool ) const;
template const npc *creature_tracker::creature_at<npc>( const tripoint_abs_ms &, bool ) const;
template npc *creature_tracker::creature_at<npc>( const tripoint &, bool );
template npc *creature_tracker::creature_at<npc>( const tripoint_abs_ms &, bool );
template const avatar *creature_tracker::creature_at<avatar>( const tripoint &, bool ) const;
template const avatar *creature_tracker::creature_at<avatar>( const tripoint_abs_ms &, bool ) const;
template avatar *creature_tracker::creature_at<avatar>( const tripoint &, bool );
template avatar *creature_tracker::creature_at<avatar>( const tripoint_abs_ms &, bool );
template const Character *creature_tracker::creature_at<Character>( const tripoint &, bool ) const;
template const Character *creature_tracker::creature_at<Character>( const tripoint_abs_ms &,
bool ) const;
template Character *creature_tracker::creature_at<Character>( const tripoint &, bool );
template Character *creature_tracker::creature_at<Character>( const tripoint_abs_ms &, bool );
template const Creature *creature_tracker::creature_at<Creature>( const tripoint &, bool ) const;
template const Creature *creature_tracker::creature_at<Creature>( const tripoint_abs_ms &,
bool ) const;
template Creature *creature_tracker::creature_at<Creature>( const tripoint &, bool );
template Creature *creature_tracker::creature_at<Creature>( const tripoint_bub_ms &, bool );
template Creature *creature_tracker::creature_at<Creature>( const tripoint_abs_ms &, bool );

The tripoint_bub_ms overloads for npc, avatar, Character, and const Creature are not instantiated. For example, the Creature overload should be template const Creature *creature_tracker::creature_at<Creature>( const tripoint_bub_ms &, bool ) const; and added after line 467.

@PatrikLundell PatrikLundell marked this pull request as ready for review May 16, 2024 06:57
@Maleclypse Maleclypse merged commit bfbe559 into CleverRaven:master May 19, 2024
26 checks passed
@PatrikLundell PatrikLundell deleted the typify branch May 19, 2024 05:43
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 Bionics CBM (Compact Bionic Modules) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Items: Containers Things that hold other things json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display 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.

None yet

3 participants