0ad/source/simulation2
josue fc6a908775 Don't send redundant PositionChanged messages
UnitAI constantly calls FaceTowardsTarget while attacking or gathering,
broadcasting an MT_PositionChanged message each time even when the
entity already faces the target. With many units fighting, that floods
the message bus (range manager, obstruction, minimap, AI proxy, ...)
every turn.

This was attempted in 080599442f by returning early from TurnTo, but
MoveAndTurnTo relies on TurnTo to advertise the movement, so units
walking in a straight line stopped advertising their position and LOS
broke (#6844), which led to the revert in 3fb7319df7.

Instead, deduplicate in AdvertisePositionChanges itself: remember the
data of the last message sent and skip the message when it wouldn't
change anything. Since the comparison covers the whole message data, a
movement with an unchanged angle is still advertised.

Add a regression test covering both #7654 and the #6844 scenario.

Fixes: #7654

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 15:32:07 +02:00
..
components Don't send redundant PositionChanged messages 2026-06-12 15:32:07 +02:00
docs Remove UNUSED 2025-06-26 17:25:05 +02:00
helpers Replace M_PI with C++ numbers 2026-06-04 20:29:48 +02:00
scripting Remove Script::CreateArray 2026-02-08 19:27:50 +01:00
serialization Remove ScriptTypes and ScriptExtraHeaders headers 2025-09-14 13:17:18 +02:00
system Start the serializationtest at a specivic turn 2026-05-10 14:18:48 +02:00
tests Fix disabled serializer tests 2026-06-07 10:00:40 +02:00
MessageTypes.h Fix includes in source/simulation2 2025-08-08 07:10:11 +02:00
Simulation2.cpp Start the serializationtest at a specivic turn 2026-05-10 14:18:48 +02:00
Simulation2.h Remove LoadScripts from CSimualation2 2026-01-01 17:27:54 +01:00
TypeList.h Store whether a player is activ in C++ 2025-01-05 19:57:12 +01:00