2
0
Эх сурвалжийг харах

BETA: NPE fix in Hero diary and possible memory leak thanks JIV

Rumen Nikiforov 13 жил өмнө
parent
commit
bbb3b5e7b8

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Hero.java

@@ -527,7 +527,7 @@ public class Hero
 			List<StatsSet> _mainlist = _herodiary.get(charid);
 			NpcHtmlMessage DiaryReply = new NpcHtmlMessage(5);
 			final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(),"data/html/olympiad/herodiary.htm");
-			if (htmContent != null)
+			if (htmContent != null && _heroMessage.containsKey(charid))
 			{
 				DiaryReply.setHtml(htmContent);
 				DiaryReply.replace("%heroname%", CharNameTable.getInstance().getNameById(charid));

+ 7 - 14
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/L2GameClientPacket.java

@@ -27,7 +27,7 @@ import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
 
 /**
  * Packets received by the game server from clients
- * @author  KenM
+ * @author KenM
  */
 public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
 {
@@ -36,7 +36,7 @@ public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
 	@Override
 	public boolean read()
 	{
-		//_log.info(this.getType());
+		// _log.info(this.getType());
 		try
 		{
 			readImpl();
@@ -61,22 +61,19 @@ public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
 		{
 			runImpl();
 			
-			/* Removes onspawn protection - player has faster computer than average
-			 * Since GE: True for all packets
-			 * except RequestItemList and UseItem (in case the item is a Scroll of Escape (736)
+			/*
+			 * Removes onspawn protection - player has faster computer than average Since GE: True for all packets except RequestItemList and UseItem (in case the item is a Scroll of Escape (736)
 			 */
 			if (triggersOnActionRequest())
 			{
 				final L2PcInstance actor = getClient().getActiveChar();
-				if(actor != null && (actor.isSpawnProtected() || actor.isInvul()))
+				if (actor != null && (actor.isSpawnProtected() || actor.isInvul()))
 				{
 					actor.onActionRequest();
 					if (Config.DEBUG)
 						_log.info("Spawn protection for player " + actor.getName() + " removed by packet: " + getType());
 				}
 			}
-			
-			cleanUp();
 		}
 		catch (Throwable t)
 		{
@@ -100,15 +97,11 @@ public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
 	public abstract String getType();
 	
 	/**
-	 * Overridden with true value on some packets that should disable spawn protection
-	 * (RequestItemList and UseItem only)
-	 * @return 
+	 * Overridden with true value on some packets that should disable spawn protection (RequestItemList and UseItem only)
+	 * @return
 	 */
 	protected boolean triggersOnActionRequest()
 	{
 		return true;
 	}
-	
-	protected void cleanUp()
-	{}
 }

+ 1 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestPrivateStoreBuy.java

@@ -53,7 +53,7 @@ public final class RequestPrivateStoreBuy extends L2GameClientPacket
 		{
 			return;
 		}
-		_items = FastSet.newInstance();
+		_items = new FastSet<ItemRequest>();
 		
 		for (int i = 0; i < count; i++)
 		{
@@ -183,12 +183,6 @@ public final class RequestPrivateStoreBuy extends L2GameClientPacket
 		return _C__83_REQUESTPRIVATESTOREBUY;
 	}
 	
-	@Override
-	protected void cleanUp()
-	{
-		FastSet.recycle(_items);
-	}
-	
 	@Override
 	protected boolean triggersOnActionRequest()
 	{