@@ -609,7 +609,9 @@ public void HandlePacket(IPacketSender packetSender, Intersect.Network.Packets.S
609609 //AnnouncementPacket
610610 public void HandlePacket ( IPacketSender packetSender , AnnouncementPacket packet )
611611 {
612- Interface . Interface . GameUi . AnnouncementWindow . ShowAnnouncement ( packet . Message , packet . Duration ) ;
612+ Interface . Interface . EnqueueInGame (
613+ gameInterface => gameInterface . AnnouncementWindow . ShowAnnouncement ( packet . Message , packet . Duration )
614+ ) ;
613615 }
614616
615617 //ActionMsgPackets
@@ -914,17 +916,19 @@ public void HandlePacket(IPacketSender packetSender, MapEntityStatusPacket packe
914916
915917 entity . SortStatuses ( ) ;
916918
917- if ( Interface . Interface . GameUi != null )
919+ if ( ! Interface . Interface . HasInGameUI )
918920 {
919- //If its you or your target, update the entity box.
920- if ( en . Id == Globals . Me . Id && Interface . Interface . GameUi . PlayerStatusWindow != null )
921- {
922- Interface . Interface . GameUi . PlayerStatusWindow . ShouldUpdateStatuses = true ;
923- }
924- else if ( en . Id == Globals . Me . TargetId && Globals . Me . TargetBox != null )
925- {
926- Globals . Me . TargetBox . ShouldUpdateStatuses = true ;
927- }
921+ continue ;
922+ }
923+
924+ //If its you or your target, update the entity box.
925+ if ( en . Id == Globals . Me . Id && Interface . Interface . GameUi . PlayerStatusWindow != null )
926+ {
927+ Interface . Interface . GameUi . PlayerStatusWindow . ShouldUpdateStatuses = true ;
928+ }
929+ else if ( en . Id == Globals . Me . TargetId && Globals . Me . TargetBox != null )
930+ {
931+ Globals . Me . TargetBox . ShouldUpdateStatuses = true ;
928932 }
929933 }
930934 }
@@ -999,17 +1003,19 @@ public void HandlePacket(IPacketSender packetSender, EntityVitalsPacket packet)
9991003
10001004 en . SortStatuses ( ) ;
10011005
1002- if ( Interface . Interface . GameUi != null )
1006+ if ( ! Interface . Interface . HasInGameUI )
10031007 {
1004- //If its you or your target, update the entity box.
1005- if ( id == Globals . Me . Id && Interface . Interface . GameUi . PlayerStatusWindow != null )
1006- {
1007- Interface . Interface . GameUi . PlayerStatusWindow . ShouldUpdateStatuses = true ;
1008- }
1009- else if ( id == Globals . Me . TargetId && Globals . Me . TargetBox != null )
1010- {
1011- Globals . Me . TargetBox . ShouldUpdateStatuses = true ;
1012- }
1008+ return ;
1009+ }
1010+
1011+ //If its you or your target, update the entity box.
1012+ if ( id == Globals . Me . Id && Interface . Interface . GameUi . PlayerStatusWindow != null )
1013+ {
1014+ Interface . Interface . GameUi . PlayerStatusWindow . ShouldUpdateStatuses = true ;
1015+ }
1016+ else if ( id == Globals . Me . TargetId && Globals . Me . TargetBox != null )
1017+ {
1018+ Globals . Me . TargetBox . ShouldUpdateStatuses = true ;
10131019 }
10141020 }
10151021
@@ -1399,7 +1405,7 @@ public void HandlePacket(IPacketSender packetSender, CharacterCreationPacket pac
13991405 //AdminPanelPacket
14001406 public void HandlePacket ( IPacketSender packetSender , AdminPanelPacket packet )
14011407 {
1402- Interface . Interface . GameUi . NotifyOpenAdminWindow ( ) ;
1408+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyOpenAdminWindow ( ) ) ;
14031409 }
14041410
14051411 //SpellCastPacket
@@ -1691,7 +1697,7 @@ public void HandlePacket(IPacketSender packetSender, HidePicturePacket packet)
16911697 //ShopPacket
16921698 public void HandlePacket ( IPacketSender packetSender , ShopPacket packet )
16931699 {
1694- if ( Interface . Interface . GameUi == null )
1700+ if ( ! Interface . Interface . HasInGameUI )
16951701 {
16961702 throw new ArgumentNullException ( nameof ( Interface . Interface . GameUi ) ) ;
16971703 }
@@ -1705,12 +1711,12 @@ public void HandlePacket(IPacketSender packetSender, ShopPacket packet)
17051711 {
17061712 Globals . GameShop = new ShopBase ( ) ;
17071713 Globals . GameShop . Load ( packet . ShopData ) ;
1708- Interface . Interface . GameUi . NotifyOpenShop ( ) ;
1714+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyOpenShop ( ) ) ;
17091715 }
17101716 else
17111717 {
17121718 Globals . GameShop = null ;
1713- Interface . Interface . GameUi . NotifyCloseShop ( ) ;
1719+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyCloseShop ( ) ) ;
17141720 }
17151721 }
17161722
@@ -1721,11 +1727,11 @@ public void HandlePacket(IPacketSender packetSender, CraftingTablePacket packet)
17211727 {
17221728 Globals . ActiveCraftingTable = new CraftingTableBase ( ) ;
17231729 Globals . ActiveCraftingTable . Load ( packet . TableData ) ;
1724- Interface . Interface . GameUi . NotifyOpenCraftingTable ( packet . JournalMode ) ;
1730+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyOpenCraftingTable ( packet . JournalMode ) ) ;
17251731 }
17261732 else
17271733 {
1728- Interface . Interface . GameUi . NotifyCloseCraftingTable ( ) ;
1734+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyCloseCraftingTable ( ) ) ;
17291735 }
17301736 }
17311737
@@ -1741,11 +1747,11 @@ public void HandlePacket(IPacketSender packetSender, BankPacket packet)
17411747 HandlePacket ( itm ) ;
17421748 }
17431749 Globals . BankSlotCount = packet . Slots ;
1744- Interface . Interface . GameUi . NotifyOpenBank ( ) ;
1750+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyOpenBank ( ) ) ;
17451751 }
17461752 else
17471753 {
1748- Interface . Interface . GameUi . NotifyCloseBank ( ) ;
1754+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyCloseBank ( ) ) ;
17491755 }
17501756 }
17511757
@@ -2021,11 +2027,11 @@ public void HandlePacket(IPacketSender packetSender, TradePacket packet)
20212027 }
20222028 }
20232029
2024- Interface . Interface . GameUi . NotifyOpenTrading ( packet . TradePartner ) ;
2030+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyOpenTrading ( packet . TradePartner ) ) ;
20252031 }
20262032 else
20272033 {
2028- Interface . Interface . GameUi . NotifyCloseTrading ( ) ;
2034+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyCloseTrading ( ) ) ;
20292035 }
20302036 }
20312037
@@ -2100,11 +2106,11 @@ public void HandlePacket(IPacketSender packetSender, BagPacket packet)
21002106 if ( ! packet . Close )
21012107 {
21022108 Globals . BagSlots = new Item [ packet . Slots ] ;
2103- Interface . Interface . GameUi . NotifyOpenBag ( ) ;
2109+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyOpenBag ( ) ) ;
21042110 }
21052111 else
21062112 {
2107- Interface . Interface . GameUi . NotifyCloseBag ( ) ;
2113+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyCloseBag ( ) ) ;
21082114 }
21092115 }
21102116
@@ -2156,7 +2162,12 @@ public void HandlePacket(IPacketSender packetSender, FriendsPacket packet)
21562162 Globals . Me ? . Friends . Add ( f ) ;
21572163 }
21582164
2159- Interface . Interface . GameUi ? . NotifyUpdateFriendsList ( ) ;
2165+ if ( ! Interface . Interface . HasInGameUI )
2166+ {
2167+ return ;
2168+ }
2169+
2170+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyUpdateFriendsList ( ) ) ;
21602171 }
21612172
21622173 //FriendRequestPacket
@@ -2316,7 +2327,7 @@ public void HandlePacket(IPacketSender packetSender, GuildPacket packet)
23162327 if ( hasUpdates )
23172328 {
23182329 Globals . Me . GuildMembers = updatedGuildMembers ;
2319- Interface . Interface . GameUi . NotifyUpdateGuildList ( ) ;
2330+ Interface . Interface . EnqueueInGame ( gameInterface => gameInterface . NotifyUpdateGuildList ( ) ) ;
23202331 }
23212332 }
23222333
0 commit comments