Ticket #3222: t3222_handle_notifications_v2.patch

File t3222_handle_notifications_v2.patch, 2.3 KB (added by elexis, 9 years ago)

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.

  • binaries/data/mods/public/gui/session/messages.js

     
    136136};
    137137
    138138// Notifications
    139139function handleNotifications()
    140140{
    141     var notification = Engine.GuiInterfaceCall("GetNextNotification");
    142 
    143     if (!notification)
    144         return;
    145     if (!notification.type)
    146     {
    147         error("notification without type found.\n"+uneval(notification))
    148         return;
    149     }
    150     if (!notification.players)
     141    var notification;
     142    while((notification = Engine.GuiInterfaceCall("GetNextNotification")))
    151143    {
    152         error("notification without players found.\n"+uneval(notification))
    153         return;
     144       
     145        if (!notification.type)
     146        {
     147            error("Notification without type found.\n"+uneval(notification))
     148            continue;
     149        }
     150       
     151        if (!notification.players)
     152        {
     153            error("Notification without players found.\n"+uneval(notification))
     154            continue;
     155        }
     156       
     157        var action = g_NotificationsTypes[notification.type];
     158        if (!action)
     159        {
     160            error("Unknown notification type '" + notification.type + "' found.");
     161            continue;
     162        }
     163       
     164        for (var player of notification.players)
     165            action(notification, player);
    154166    }
    155     var action = g_NotificationsTypes[notification.type];
    156     if (!action)
    157     {
    158         error("unknown notification type '" + notification.type + "' found.");
    159         return;
    160     }
    161 
    162     for (var player of notification.players)
    163         action(notification, player);
    164167}
    165168
    166169function updateDiplomacy()
    167170{
    168171    g_Players = getPlayerData(g_PlayerAssignments);
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    735735};
    736736
    737737GuiInterface.prototype.GetNextNotification = function()
    738738{
    739739    if (this.notifications.length)
    740         return this.notifications.pop();
     740        return this.notifications.shift();
    741741    else
    742742        return false;
    743743};
    744744
    745745GuiInterface.prototype.GetAvailableFormations = function(player, wantedPlayer)