Ticket #3222: t3222_handle_notifications.patch

File t3222_handle_notifications.patch, 1.7 KB (added by elexis, 9 years ago)
  • 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 maxNotifications = 20;
     142    for(var i = 0; i < maxNotifications; i++)
    151143    {
    152         error("notification without players found.\n"+uneval(notification))
    153         return;
     144        var notification = Engine.GuiInterfaceCall("GetNextNotification");
     145   
     146        if (!notification)
     147            return;
     148       
     149        if (!notification.type)
     150        {
     151            error("notification without type found.\n"+uneval(notification))
     152            continue;
     153        }
     154       
     155        if (!notification.players)
     156        {
     157            error("notification without players found.\n"+uneval(notification))
     158            continue;
     159        }
     160       
     161        var action = g_NotificationsTypes[notification.type];
     162        if (!action)
     163        {
     164            error("unknown notification type '" + notification.type + "' found.");
     165            continue;
     166        }
     167   
     168        for (var player of notification.players)
     169            action(notification, player);
    154170    }
    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);
    164171}
    165172
    166173function updateDiplomacy()
    167174{
    168175    g_Players = getPlayerData(g_PlayerAssignments);