COMMITTED: NPC signal update
It's a pretty rare case, but I've seen threads related to the issue before and now I'm doing some work where it is relevant and easy to demonstrate so I figured I would post my changes.
Basically, the NPC signal check is called every AI_Process(), which is 150ms from what I'm seeing in the latest source. There is a slim chance that two signals can be sent to the same NPC in that time window and those signals will overwrite one another since NPC only has storage for one signal at a time. This just trades signal_id for a deque of signal_id's and changes CheckSignal and SignalNPC accordingly. Code:
Index: npc.h |
Very cool, Tabasco :)
I have always just set a 1 second timer between multiple signals, but this solution is much better. |
has anyone tested this out? I would love to get this committed to the SVN for PEQ to start using it.
|
I haven't had time to test it yet, but I think you should be OK to just commit it. Looks like a pretty straight-forward change. If it causes any issues, it can always be reverted easy enough.
Probably don't need to add this line though: Code:
+ //int signal_id; |
I'd use if(signal_q.empty()) instead of if(signal_q.size() < 1), but it looks good to me.
In case anyone cares about the longer explanation, the empty() function is guaranteed to be constant time where the size() function is not. In practice, for most containers including deque they are both constant time and empty() just returns size() == 0, but there are some implementations where that isn't true. It's talked about in Effective STL #4. |
Committed in rev2010 with some minor changes.
Tested this by creating 5 npcs that send a signal on their death to a 6th, and then AEd the 5 npcs to death. The controller receiving the signals happily counted all of their deaths. |
Quote:
http://www.uml.org.cn/c++/pdf/EffectiveSTL.pdf |
All times are GMT -4. The time now is 07:37 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.