Browse Source

BETA: Petition Feedback feature (thanks plim)
And little optimization of RequestAcquireSkillInfo
Also typo fix for ExBrBuffEventState

Rumen Nikiforov 14 years ago
parent
commit
4788b1bb18

+ 8 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/instancemanager/PetitionManager.java

@@ -32,6 +32,7 @@ import com.l2jserver.gameserver.network.clientpackets.Say2;
 import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
 import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
 import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
 import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.gameserver.network.serverpackets.PetitionVotePacket;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.util.StringUtil;
 import com.l2jserver.util.StringUtil;
 
 
@@ -144,9 +145,12 @@ public final class PetitionManager
 				}
 				}
 			}
 			}
 			
 			
-			// End petition consultation and inform them, if they are still online.
+			// End petition consultation and inform them, if they are still online. And if petitioner is online, enable Evaluation button
 			if (getPetitioner() != null && getPetitioner().isOnline())
 			if (getPetitioner() != null && getPetitioner().isOnline())
+			{
 				getPetitioner().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_END_THE_PETITION_PLEASE_PROVIDE_FEEDBACK));
 				getPetitioner().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THIS_END_THE_PETITION_PLEASE_PROVIDE_FEEDBACK));
+				getPetitioner().sendPacket(new PetitionVotePacket());
+			}
 			
 			
 			getCompletedPetitions().put(getId(), this);
 			getCompletedPetitions().put(getId(), this);
 			return (getPendingPetitions().remove(getId()) != null);
 			return (getPendingPetitions().remove(getId()) != null);
@@ -274,6 +278,9 @@ public final class PetitionManager
 		sm = SystemMessage.getSystemMessage(SystemMessageId.STARTING_PETITION_WITH_C1);
 		sm = SystemMessage.getSystemMessage(SystemMessageId.STARTING_PETITION_WITH_C1);
 		sm.addString(currPetition.getPetitioner().getName());
 		sm.addString(currPetition.getPetitioner().getName());
 		currPetition.sendResponderPacket(sm);
 		currPetition.sendResponderPacket(sm);
+		
+		// Set responder name on petitioner instance
+		currPetition.getPetitioner().setLastPetitionGmName(currPetition.getResponder().getName());
 		return true;
 		return true;
 	}
 	}
 	
 	

+ 14 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -1023,6 +1023,10 @@ public final class L2PcInstance extends L2Playable
 			return _target;
 			return _target;
 		}
 		}
 	}
 	}
+	
+	// Save responder name for log it
+	private String _lastPetitionGmName = null;
+
 	/**
 	/**
 	 * Create a new L2PcInstance and add it in the characters table of the database.<BR><BR>
 	 * Create a new L2PcInstance and add it in the characters table of the database.<BR><BR>
 	 *
 	 *
@@ -15100,4 +15104,14 @@ public final class L2PcInstance extends L2Playable
 		// Maintain = 1
 		// Maintain = 1
 		return 0;
 		return 0;
 	}
 	}
+	
+	public void setLastPetitionGmName(String gmName)
+	{
+		_lastPetitionGmName = gmName;
+	}
+	
+	public String getLastPetitionGmName()
+	{
+		return _lastPetitionGmName;
+	}
 }
 }

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/L2GamePacketHandler.java

@@ -661,7 +661,7 @@ public final class L2GamePacketHandler implements IPacketHandler<L2GameClient>,
 						msg = new RequestSSQStatus();
 						msg = new RequestSSQStatus();
 						break;
 						break;
 					case 0xc9:
 					case 0xc9:
-						// PetitionVote
+						msg = new RequestPetitionFeedback();
 						break;
 						break;
 					case 0xcb:
 					case 0xcb:
 						msg = new GameGuardReply();
 						msg = new GameGuardReply();

+ 134 - 128
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestAcquireSkillInfo.java

@@ -34,7 +34,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2TransformManagerInstance;
 import com.l2jserver.gameserver.model.quest.Quest;
 import com.l2jserver.gameserver.model.quest.Quest;
 import com.l2jserver.gameserver.network.serverpackets.AcquireSkillInfo;
 import com.l2jserver.gameserver.network.serverpackets.AcquireSkillInfo;
 
 
-
 /**
 /**
  * This class ...
  * This class ...
  *
  *
@@ -62,7 +61,7 @@ public class RequestAcquireSkillInfo extends L2GameClientPacket
 	{
 	{
 		if (_id <= 0 || _level <= 0) // minimal sanity check
 		if (_id <= 0 || _level <= 0) // minimal sanity check
 			return;
 			return;
-
+		
 		final L2PcInstance activeChar = getClient().getActiveChar();
 		final L2PcInstance activeChar = getClient().getActiveChar();
 		
 		
 		if (activeChar == null)
 		if (activeChar == null)
@@ -82,171 +81,178 @@ public class RequestAcquireSkillInfo extends L2GameClientPacket
 		if (skill == null)
 		if (skill == null)
 		{
 		{
 			if (Config.DEBUG)
 			if (Config.DEBUG)
-				_log.warning("skill id " + _id + " level " + _level
-						+ " is undefined. aquireSkillInfo failed.");
+				_log.warning("skill id " + _id + " level " + _level + " is undefined. aquireSkillInfo failed.");
 			return;
 			return;
 		}
 		}
 		
 		
-		if (_skillType == 0)
+		switch (_skillType)
 		{
 		{
-			if (trainer instanceof L2TransformManagerInstance)
+			case 0:
 			{
 			{
-				int itemId = 0;
-				L2TransformSkillLearn[] skillst = SkillTreeTable.getInstance().getAvailableTransformSkills(activeChar);
+				if (trainer instanceof L2TransformManagerInstance)
+				{
+					int itemId = 0;
+					L2TransformSkillLearn[] skillst = SkillTreeTable.getInstance().getAvailableTransformSkills(activeChar);
+					
+					for (L2TransformSkillLearn s : skillst)
+					{
+						if (s.getId() == _id && s.getLevel() == _level)
+						{
+							canteach = true;
+							itemId = s.getItemId();
+							break;
+						}
+					}
+					
+					if (!canteach)
+						return; // cheater
+						
+					int requiredSp = 0;
+					AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), requiredSp, 0);
+					
+					// all transformations require scrolls
+					asi.addRequirement(99, itemId, 1, 50);
+					sendPacket(asi);
+					return;
+				}
+				
+				if (!trainer.getTemplate().canTeach(activeChar.getSkillLearningClassId()))
+					return; // cheater
+					
+				L2SkillLearn[] skills = SkillTreeTable.getInstance().getAvailableSkills(activeChar, activeChar.getSkillLearningClassId());
 				
 				
-				for (L2TransformSkillLearn s : skillst)
+				for (L2SkillLearn s : skills)
 				{
 				{
 					if (s.getId() == _id && s.getLevel() == _level)
 					if (s.getId() == _id && s.getLevel() == _level)
 					{
 					{
 						canteach = true;
 						canteach = true;
-						itemId = s.getItemId();
 						break;
 						break;
 					}
 					}
 				}
 				}
 				
 				
 				if (!canteach)
 				if (!canteach)
 					return; // cheater
 					return; // cheater
+					
+				int requiredSp = SkillTreeTable.getInstance().getSkillCost(activeChar, skill);
+				AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), requiredSp, 0);
 				
 				
-				int requiredSp = 0;
-				AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), requiredSp,0);
+				int spbId = -1;
+				if (Config.DIVINE_SP_BOOK_NEEDED && skill.getId() == L2Skill.SKILL_DIVINE_INSPIRATION)
+					spbId = SkillSpellbookTable.getInstance().getBookForSkill(skill, _level);
+				else if (Config.SP_BOOK_NEEDED && skill.getLevel() == 1)
+					spbId = SkillSpellbookTable.getInstance().getBookForSkill(skill);
+				
+				if (spbId > -1)
+					asi.addRequirement(99, spbId, 1, 50);
 				
 				
-				// all transformations require scrolls
-				asi.addRequirement(99, itemId, 1, 50);
 				sendPacket(asi);
 				sendPacket(asi);
-				return;
+				break;
 			}
 			}
-			
-			if (!trainer.getTemplate().canTeach(activeChar.getSkillLearningClassId()))
-				return; // cheater
-			
-			L2SkillLearn[] skills = SkillTreeTable.getInstance().getAvailableSkills(activeChar, activeChar.getSkillLearningClassId());
-			
-			for (L2SkillLearn s : skills)
+			case 2:
 			{
 			{
-				if (s.getId() == _id && s.getLevel() == _level)
+				int requiredRep = 0;
+				int itemId = 0;
+				int itemCount = 0;
+				L2PledgeSkillLearn[] skills = SkillTreeTable.getInstance().getAvailablePledgeSkills(activeChar);
+				
+				for (L2PledgeSkillLearn s : skills)
 				{
 				{
-					canteach = true;
-					break;
+					if (s.getId() == _id && s.getLevel() == _level)
+					{
+						canteach = true;
+						requiredRep = s.getRepCost();
+						itemId = s.getItemId();
+						itemCount = s.getItemCount();
+						break;
+					}
 				}
 				}
+				
+				if (!canteach)
+					return; // cheater
+					
+				AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), requiredRep, 2);
+				
+				if (Config.LIFE_CRYSTAL_NEEDED)
+					asi.addRequirement(1, itemId, itemCount, 0);
+				
+				sendPacket(asi);
+				break;
 			}
 			}
-			
-			if (!canteach)
-				return; // cheater
-			
-			int requiredSp = SkillTreeTable.getInstance().getSkillCost(activeChar, skill);
-			AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), requiredSp,0);
-			
-			int spbId = -1;
-			if (Config.DIVINE_SP_BOOK_NEEDED && skill.getId() == L2Skill.SKILL_DIVINE_INSPIRATION)
-				spbId = SkillSpellbookTable.getInstance().getBookForSkill(skill, _level);
-			else if (Config.SP_BOOK_NEEDED && skill.getLevel() == 1)
-				spbId = SkillSpellbookTable.getInstance().getBookForSkill(skill);
-			
-			if (spbId > -1)
-				asi.addRequirement(99, spbId, 1, 50);
-			
-			sendPacket(asi);
-		}
-		else if (_skillType == 2)
-		{
-			int requiredRep = 0;
-			int itemId = 0;
-			int itemCount = 0;
-			L2PledgeSkillLearn[] skills = SkillTreeTable.getInstance().getAvailablePledgeSkills(activeChar);
-			
-			for (L2PledgeSkillLearn s : skills)
+			case 3:
 			{
 			{
-				if (s.getId() == _id && s.getLevel() == _level)
+				if (trainer instanceof L2SquadTrainer)
 				{
 				{
-					canteach = true;
-					requiredRep = s.getRepCost();
-					itemId = s.getItemId();
-					itemCount = s.getItemCount();
-					break;
+					SubUnitSkill sus = SubPledgeSkillTree.getInstance().getSkill(SkillTable.getSkillHashCode(skill));
+					AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), sus.getReputation(), 3);
+					asi.addRequirement(0, sus.getItemId(), sus.getCount(), 0);
+					sendPacket(asi);
 				}
 				}
+				break;
 			}
 			}
-			
-			if (!canteach)
-				return; // cheater
-			
-			AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), requiredRep, 2);
-			
-			if (Config.LIFE_CRYSTAL_NEEDED)
-				asi.addRequirement(1, itemId, itemCount, 0);
-			
-			sendPacket(asi);
-		}
-		else if (_skillType == 3)
-		{
-			if (trainer instanceof L2SquadTrainer)
+			case 4:
+			case 5:
 			{
 			{
-				SubUnitSkill sus = SubPledgeSkillTree.getInstance().getSkill(SkillTable.getSkillHashCode(skill));
-				AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), sus.getReputation(), 3);
-				asi.addRequirement(0, sus.getItemId(), sus.getCount(), 0);
-				sendPacket(asi);
-			}
-		}
-		else if (_skillType == 4 || _skillType == 5)
-		{
-			Quest[] qlst = trainer.getTemplate().getEventQuests(Quest.QuestEventType.ON_SKILL_LEARN);
-			if ((qlst != null) && qlst.length == 1)
-			{
-				if (!qlst[0].notifyAcquireSkillInfo(trainer, activeChar, skill))
+				Quest[] qlst = trainer.getTemplate().getEventQuests(Quest.QuestEventType.ON_SKILL_LEARN);
+				if ((qlst != null) && qlst.length == 1)
 				{
 				{
-					qlst[0].notifyAcquireSkillList(trainer, activeChar);
-					return;
+					if (!qlst[0].notifyAcquireSkillInfo(trainer, activeChar, skill))
+					{
+						qlst[0].notifyAcquireSkillList(trainer, activeChar);
+						return;
+					}
 				}
 				}
+				else
+					return;
+				break;
 			}
 			}
-			else
+			case 6:
 			{
 			{
-				return;
-			}
-		}
-		else if (_skillType == 6)
-		{
-			int costid = 0;
-			int costcount = 0;
-			L2SkillLearn[] skillsc = SkillTreeTable.getInstance().getAvailableSpecialSkills(activeChar);
-			for (L2SkillLearn s : skillsc)
-			{
-				L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
-				
-				if (sk == null || sk != skill)
-					continue;
+				int costid = 0;
+				int costcount = 0;
+				L2SkillLearn[] skillsc = SkillTreeTable.getInstance().getAvailableSpecialSkills(activeChar);
+				for (L2SkillLearn s : skillsc)
+				{
+					L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
+					
+					if (sk == null || sk != skill)
+						continue;
+					
+					canteach = true;
+					costid = s.getIdCost();
+					costcount = s.getCostCount();
+				}
 				
 				
-				canteach = true;
-				costid = s.getIdCost();
-				costcount = s.getCostCount();
+				AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), 0, 6);
+				asi.addRequirement(5, costid, costcount, 0);
+				sendPacket(asi);
+				break;
 			}
 			}
-			
-			AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), 0, 6);
-			asi.addRequirement(5, costid, costcount, 0);
-			sendPacket(asi);
-		}
-		else // Common Skills
-		{
-			int costid = 0;
-			int costcount = 0;
-			int spcost = 0;
-			
-			L2SkillLearn[] skillsc = SkillTreeTable.getInstance().getAvailableSkills(activeChar);
-			
-			for (L2SkillLearn s : skillsc)
+			default: // Common Skills
 			{
 			{
-				L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
+				int costid = 0;
+				int costcount = 0;
+				int spcost = 0;
 				
 				
-				if (sk == null || sk != skill)
-					continue;
+				L2SkillLearn[] skillsc = SkillTreeTable.getInstance().getAvailableSkills(activeChar);
 				
 				
-				canteach = true;
-				costid = s.getIdCost();
-				costcount = s.getCostCount();
-				spcost = s.getSpCost();
+				for (L2SkillLearn s : skillsc)
+				{
+					L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
+					
+					if (sk == null || sk != skill)
+						continue;
+					
+					canteach = true;
+					costid = s.getIdCost();
+					costcount = s.getCostCount();
+					spcost = s.getSpCost();
+				}
+				
+				AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), spcost, 1);
+				asi.addRequirement(4, costid, costcount, 0);
+				sendPacket(asi);
+				break;
 			}
 			}
-			
-			AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), spcost, 1);
-			asi.addRequirement(4, costid, costcount, 0);
-			sendPacket(asi);
 		}
 		}
 	}
 	}
 	
 	

+ 94 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestPetitionFeedback.java

@@ -0,0 +1,94 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.network.clientpackets;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author Plim
+ */
+public class RequestPetitionFeedback extends L2GameClientPacket
+{
+	private static final String _C__C9_REQUESTPETITIONFEEDBACK = "[C] C9 RequestPetitionFeedback";
+	private static final Logger _log = Logger.getLogger(RequestPetitionFeedback.class.getName());
+	
+	private static final String INSERT_FEEDBACK = "INSERT INTO petition_feedback VALUES (?,?,?,?,?)";
+	
+	//cdds
+	//private int _unknown;
+	private int _rate; // 4=VeryGood, 3=Good, 2=Fair, 1=Poor, 0=VeryPoor
+	private String _message;
+	
+	@Override
+	protected void readImpl()
+	{
+		//_unknown = 
+		readD(); // unknown
+		_rate = readD();
+		_message = readS();
+	}
+	
+	@Override
+	protected void runImpl()
+	{
+		L2PcInstance player = getClient().getActiveChar();
+		
+		if (player == null || player.getLastPetitionGmName() == null)
+			return;
+		
+		if (_rate > 4 || _rate < 0) // Ilegal vote
+			return;
+		
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(INSERT_FEEDBACK);
+			statement.setString(1, player.getName());
+			statement.setString(2, player.getLastPetitionGmName());
+			statement.setInt(3, _rate);
+			statement.setString(4, _message);
+			statement.setLong(5, System.currentTimeMillis());
+			
+			statement.execute();
+			statement.close();
+		}
+		catch (SQLException e)
+		{
+			_log.log(Level.SEVERE, "Error while saving petition feedback");
+		}
+		finally
+		{
+			L2DatabaseFactory.close(con);
+			player.setLastPetitionGmName(null);
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _C__C9_REQUESTPETITIONFEEDBACK;
+	}
+}

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExBrBuffEventState.java

@@ -40,7 +40,7 @@ public class ExBrBuffEventState extends L2GameServerPacket
 	@Override
 	@Override
 	public String getType()
 	public String getType()
 	{
 	{
-		return "[S] FE:D8 ExBrBuffEventState";
+		return "[S] FE:DB ExBrBuffEventState";
 	}
 	}
 	
 	
 	/* (non-Javadoc)
 	/* (non-Javadoc)
@@ -50,7 +50,7 @@ public class ExBrBuffEventState extends L2GameServerPacket
 	protected void writeImpl()
 	protected void writeImpl()
 	{
 	{
 		writeC(0xFE);
 		writeC(0xFE);
-		writeH(0xD8);
+		writeH(0xDB);
 		writeD(_type);
 		writeD(_type);
 		writeD(_value);
 		writeD(_value);
 		writeD(_state);
 		writeD(_state);

+ 42 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/PetitionVotePacket.java

@@ -0,0 +1,42 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.network.serverpackets;
+
+/**
+ * @author Plim
+ */
+public class PetitionVotePacket extends L2GameServerPacket
+{
+	private static final String _S__FC_PETITIONVOTEPACKET = "[S] FC PetitionVotePacket";
+	
+	public PetitionVotePacket()
+	{
+	}
+	
+	@Override
+	protected void writeImpl()
+	{
+		writeC(0xFC);
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _S__FC_PETITIONVOTEPACKET;
+	}
+}