CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
9.8k stars 4.08k forks source link

typified activity_actor #73807

Closed PatrikLundell closed 1 month ago

PatrikLundell commented 1 month ago

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.

Qrox commented 1 month ago

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.

https://github.com/CleverRaven/Cataclysm-DDA/blob/7f06e9f6eaf5b3096405085910bb21e2fa2b8647/src/creature_tracker.cpp#L446-L472

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.