#3222 closed defect (fixed)
[PATCH] handleNotifications() handles only one notification
Reported by: | elexis | Owned by: | leper |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
The function handleNotifications() in messages.js is called only on onSimulationUpdate(). It is supposed to process notifications that are displayed in the chat area, for example ("player has sent you amount" or "player is now at war with you"). It does process them properly, but only one per call, while the name suggests that all remaining messages should be displayed. Since handleNotifications() is also called only once per onSimulationUpdate(), the effect is that only one message will be displayed per turn.
The different message types are defined in g_NotificationsTypes in the same file. Almost all of them call the addChatMessage function.
The solution is simple, just loop while there are more messages ready to go. Patch attached. At most 20 messages per turn now processed.
This bug is the reason why spammed diplomacy-changed-messages are being displayed slowly (#3198) and why tributing many times 100 resources is also displayed slowly.
With this patch, the actual player chat will be overwritten instantaneously, if someone spams the tribute or diplomacy buttons. Thats why #3198 should be implemented in order to mitigate this side effect.
Attachments (4)
Change History (6)
by , 9 years ago
Attachment: | t3222_handle_notifications.patch added |
---|
by , 9 years ago
Attachment: | t3222_handle_notifications_v2.patch added |
---|
by , 9 years ago
Attachment: | t3222_handle_notifications_v4.patch added |
---|
Same patch as above, but changed 'for(var i = 0; i < notifications.length; ++i)' to 'for(var notification of notifications)'.
comment:2 by , 9 years ago
Keywords: | review removed |
---|
You missed a space between for
and (
. Thanks for the patch.
Simplifies the patch above. Also changes pop() to shift() so that the messages are displayed in the correct order. Test with 2 instances of 0ad and sending resources with the other player while the game is paused.