Browse Source

FriendList packet rework.

JIV 15 years ago
parent
commit
621ff14547

+ 3 - 0
L2_GameServer/java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java

@@ -85,6 +85,7 @@ class OlympiadManager implements Runnable
 				}
 				}
 				catch (InterruptedException ex)
 				catch (InterruptedException ex)
 				{
 				{
+					return;
 				}
 				}
 				continue;
 				continue;
 			}
 			}
@@ -281,6 +282,7 @@ class OlympiadManager implements Runnable
 					}
 					}
 					catch (InterruptedException e)
 					catch (InterruptedException e)
 					{
 					{
+						return;
 					}
 					}
 				}
 				}
 			}
 			}
@@ -292,6 +294,7 @@ class OlympiadManager implements Runnable
 			}
 			}
 			catch (InterruptedException e)
 			catch (InterruptedException e)
 			{
 			{
+				return;
 			}
 			}
 		}
 		}
 		
 		

+ 1 - 1
L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java

@@ -365,7 +365,7 @@ public class EnterWorld extends L2GameClientPacket
 		//Expand Skill
 		//Expand Skill
 		activeChar.sendPacket(new ExStorageMaxCount(activeChar));
 		activeChar.sendPacket(new ExStorageMaxCount(activeChar));
 
 
-		sendPacket(new FriendList());
+		sendPacket(new FriendList(activeChar));
 		
 		
 		SystemMessage sm = new SystemMessage(SystemMessageId.FRIEND_S1_HAS_LOGGED_IN);
 		SystemMessage sm = new SystemMessage(SystemMessageId.FRIEND_S1_HAS_LOGGED_IN);
 		sm.addString(activeChar.getName());
 		sm.addString(activeChar.getName());

+ 32 - 23
L2_GameServer/java/com/l2jserver/gameserver/network/serverpackets/FriendList.java

@@ -16,6 +16,8 @@ package com.l2jserver.gameserver.network.serverpackets;
 
 
 import java.util.List;
 import java.util.List;
 
 
+import javolution.util.FastList;
+
 import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -40,16 +42,33 @@ public class FriendList extends L2GameServerPacket
 {
 {
 	// private static Logger _log = Logger.getLogger(FriendList.class.getName());
 	// private static Logger _log = Logger.getLogger(FriendList.class.getName());
 	private static final String _S__FA_FRIENDLIST = "[S] 75 FriendList";
 	private static final String _S__FA_FRIENDLIST = "[S] 75 FriendList";
-	private List<Integer> _friends;
-	private L2PcInstance _activeChar;
+	private List<FriendInfo> _info;
 	
 	
-	@Override
-	public void runImpl()
+	private class FriendInfo
+	{
+		int objId;
+		String name;
+		boolean online;
+	
+		public FriendInfo(int objId, String name, boolean online)
+		{
+			this.objId = objId;
+			this.name = name;
+			this.online = online;
+		}
+	}
+	
+	public FriendList(L2PcInstance player)
 	{
 	{
-		if (getClient() != null && getClient().getActiveChar() != null)
+		_info = new FastList<FriendInfo>(player.getFriendList().size());
+		for (int objId : player.getFriendList())
 		{
 		{
-			_activeChar = getClient().getActiveChar();
-			_friends = _activeChar.getFriendList();
+			String name = CharNameTable.getInstance().getNameById(objId);
+			L2PcInstance player1 = L2World.getInstance().getPlayer(objId);
+			boolean online = false;
+			if (player1 != null && player1.isOnline() == 1)
+				online = true;
+			_info.add(new FriendInfo(objId, name, online));
 		}
 		}
 	}
 	}
 	
 	
@@ -57,24 +76,14 @@ public class FriendList extends L2GameServerPacket
 	protected final void writeImpl()
 	protected final void writeImpl()
 	{
 	{
 		writeC(0x75);
 		writeC(0x75);
-		if (_friends != null)
+		writeD(_info.size());
+		for (FriendInfo info : _info)
 		{
 		{
-			writeD(_friends.size());
-			for (int ObjId : _friends)
-			{
-				String name = CharNameTable.getInstance().getNameById(ObjId); //TODO move to constructor
-				L2PcInstance player = L2World.getInstance().getPlayer(ObjId);
-				boolean online = false;
-				if (player != null && player.isOnline() == 1)
-					online = true;
-				writeD(ObjId); // character id
-				writeS(name);
-				writeD(online ? 0x01 : 0x00); // online
-				writeD(online ? ObjId : 0x00); // object id if online
-			}
+			writeD(info.objId); // character id
+			writeS(info.name);
+			writeD(info.online ? 0x01 : 0x00); // online
+			writeD(info.online ? info.objId : 0x00); // object id if online
 		}
 		}
-		else
-			writeD(0);
 	}
 	}
 	
 	
 	/*
 	/*