NPCBuffer Bug?

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Ninja
Posts: 48
Joined: Fri Jul 10, 2009 6:54 pm

NPCBuffer Bug?

Post by Ninja »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:

Code: Select all

else if (command.startsWith("Buff"))		{			String[] buffGroupArray = command.substring(5).split(" "); 			for (String buffGroupList : buffGroupArray)			{				if (buffGroupList == null)				{					_log.warning("NPC Buffer Warning: npcId = " + npcId + " has no buffGroup set in the bypass for the buff selected.");					return;				} 				int buffGroup = Integer.parseInt(buffGroupList); 				int[] npcBuffGroupInfo = NpcBufferTable.getInstance().getSkillInfo(npcId, buffGroup); 				if (npcBuffGroupInfo == null) [color=#FF0000][b]<------ I THINK RETURNS 0 NOT NULL[/b][/color]				{					_log.warning("NPC Buffer Warning: npcId = " + npcId + " Location: " + getX() + ", " + getY() + ", " + getZ() + " Player: " + player.getName() + " has tried to use skill group (" + buffGroup + ") not assigned to the NPC Buffer!");					return;				} 				int skillId = npcBuffGroupInfo[0];				int skillLevel = npcBuffGroupInfo[1];				int skillFeeId = npcBuffGroupInfo[2];				int skillFeeAmount = npcBuffGroupInfo[3]; 				if (skillFeeId != 0)				{					L2ItemInstance itemInstance = player.getInventory().getItemByItemId(skillFeeId); 					if (itemInstance == null || (!itemInstance.isStackable() && player.getInventory().getInventoryItemCount(skillFeeId, -1) < skillFeeAmount))					{						SystemMessage sm = new SystemMessage(SystemMessageId.THERE_ARE_NOT_ENOUGH_NECESSARY_ITEMS_TO_USE_THE_SKILL);						player.sendPacket(sm);						continue;					} 					if (itemInstance.isStackable())					{						if (!player.destroyItemByItemId("Npc Buffer", skillFeeId, skillFeeAmount, player.getTarget(), true))						{							SystemMessage sm = new SystemMessage(SystemMessageId.THERE_ARE_NOT_ENOUGH_NECESSARY_ITEMS_TO_USE_THE_SKILL);							player.sendPacket(sm);							continue;						}					}					else					{						for (int i = 0; i < skillFeeAmount; ++i)						{							player.destroyItemByItemId("Npc Buffer", skillFeeId, 1, player.getTarget(), true);						}					}				} 				L2Skill skill;				skill = SkillTable.getInstance().getInfo(skillId, skillLevel); 				if (skill != null)					skill.getEffects(player, player);			} 			showChatWindow(player, pageVal);		}
I think "npcBuffGroupInfo" returns 0. For example if you insert into your buffer HTM a buff that does not exist in the database the npcBuffGroupInfo returns 0. I am not a programmer but I think null and 0 are completely 2 different values.
_DS_
L2j Veteran
L2j Veteran
Posts: 3437
Joined: Wed Apr 30, 2008 8:53 am
Location: Russia

Re: NPCBuffer Bug?

Post by _DS_ »

npcBuffGroupInfo is an array and array itself cant be 0, only null.
Commiter of the shit
public static final int PI = 3.1415926535897932384626433832795;
Ninja
Posts: 48
Joined: Fri Jul 10, 2009 6:54 pm

Re: NPCBuffer Bug?

Post by Ninja »

_DS_ wrote:npcBuffGroupInfo is an array and array itself cant be 0, only null.
True but my explanation was wrong. Let me rephrase it again. The problem is that when I write a skill in the NPCBuffer.htm file (for example bypass -h npc_%objectId%_Buff 1323 <- nobles skill) and the skill is not in the npc_buffer database table it should return the following error _log.warning("NPC Buffer Warning: npcId = " + npcId + " Location: " + getX() + ", " + getY() + ", " + getZ() + " Player: " + player.getName() + " has tried to use skill group (" + buffGroup + ") not assigned to the NPC Buffer!");

But I think npcBuffGroupInfo returns the following values npcBuffGroupInfo[0] = 0, npcBuffGroupInfo[1] = 0, npcBuffGroupInfo[2] = 0, npcBuffGroupInfo[3] = 0 and because the array contains the values 0 npcBuffGroupInfo == null will never be true. The code continues to give you the skill but it is not happening because there is no skill with id=0.
_DS_
L2j Veteran
L2j Veteran
Posts: 3437
Joined: Wed Apr 30, 2008 8:53 am
Location: Russia

Re: NPCBuffer Bug?

Post by _DS_ »

Replace it with
if (npcBuffGroupInfo == null || npcBuffGroupInfo[0] == 0)
Commiter of the shit
public static final int PI = 3.1415926535897932384626433832795;
Post Reply