Browse Source

BETA: Misc fixes:
* On first login 20 recommendations must be given.
* Patch by: St3eT
* Minor logic fix for [5809], isAttackingNow() is overridden in L2Summon changing it's behavior.
* Patch by: Tavo22
* In L2Attackable avoiding iterating over keys to get values inside the loop.
* Added set(String, int) method to !QuestState to avoid casting to String on every script.
* Minor refactoring on player creation.

Zoey76 12 years ago
parent
commit
9400d26be2

+ 3 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Attackable.java

@@ -1108,10 +1108,8 @@ public class L2Attackable extends L2Npc
 				return;
 			}
 			
-			for (L2Character aggroed : getAggroList().keySet())
+			for (AggroInfo ai : getAggroList().values())
 			{
-				AggroInfo ai = getAggroList().get(aggroed);
-				
 				if (ai == null)
 				{
 					return;
@@ -1120,7 +1118,6 @@ public class L2Attackable extends L2Npc
 			}
 			
 			amount = getHating(mostHated);
-			
 			if (amount <= 0)
 			{
 				((L2AttackableAI) getAI()).setGlobalAggro(-25);
@@ -1130,14 +1127,14 @@ public class L2Attackable extends L2Npc
 			}
 			return;
 		}
-		AggroInfo ai = getAggroList().get(target);
 		
+		AggroInfo ai = getAggroList().get(target);
 		if (ai == null)
 		{
 			return;
 		}
-		ai.addHate(-amount);
 		
+		ai.addHate(-amount);
 		if (ai.getHate() <= 0)
 		{
 			if (getMostHated() == null)

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -2574,7 +2574,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder
 	 */
 	public boolean isAttackingDisabled()
 	{
-		return isFlying() || isStunned() || isSleeping() || isAttackingNow() || isAlikeDead() || isParalyzed() || isPhysicalAttackMuted() || isCoreAIDisabled();
+		return isFlying() || isStunned() || isSleeping() || (_attackEndTime > GameTimeController.getGameTicks()) || isAlikeDead() || isParalyzed() || isPhysicalAttackMuted() || isCoreAIDisabled();
 	}
 	
 	public final Calculator[] getCalculators()

+ 6 - 19
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -1087,41 +1087,28 @@ public final class L2PcInstance extends L2Playable
 	 * <li>Set the name, the Hair Style, the Hair Color and the Face type of the L2PcInstance</li>
 	 * <li>Add the player in the characters table of the database</li>
 	 * </ul>
-	 * @param objectId Identifier of the object to initialized
 	 * @param template The L2PcTemplate to apply to the L2PcInstance
 	 * @param accountName The name of the L2PcInstance
 	 * @param name The name of the L2PcInstance
-	 * @param hairStyle The hair style Identifier of the L2PcInstance
-	 * @param hairColor The hair color Identifier of the L2PcInstance
-	 * @param face The face type Identifier of the L2PcInstance
-	 * @param sex
+	 * @param app the player's appearance
 	 * @return The L2PcInstance added to the database or null
 	 */
-	public static L2PcInstance create(int objectId, L2PcTemplate template, String accountName, String name, byte hairStyle, byte hairColor, byte face, boolean sex)
+	public static L2PcInstance create(L2PcTemplate template, String accountName, String name, PcAppearance app)
 	{
 		// Create a new L2PcInstance with an account name
-		PcAppearance app = new PcAppearance(face, hairColor, hairStyle, sex);
-		L2PcInstance player = new L2PcInstance(objectId, template, accountName, app);
-		
+		L2PcInstance player = new L2PcInstance(IdFactory.getInstance().getNextId(), template, accountName, app);
 		// Set the name of the L2PcInstance
 		player.setName(name);
-		
 		// Set Character's create time
 		player.setCreateDate(Calendar.getInstance());
-		
 		// Set the base class ID to that of the actual class ID.
 		player.setBaseClass(player.getClassId());
 		// Kept for backwards compatibility.
 		player.setNewbie(1);
+		// Give 20 recommendations
+		player.setRecomLeft(20);
 		// Add the player in the characters table of the database
-		boolean ok = player.createDb();
-		
-		if (!ok)
-		{
-			return null;
-		}
-		
-		return player;
+		return player.createDb() ? player : null;
 	}
 	
 	public static L2PcInstance createDummyPlayer(int objectId, String name)

+ 2 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -2211,16 +2211,14 @@ public class Quest extends ManagedScript
 		if ((party == null) || (party.getMembers().isEmpty()))
 		{
 			temp = player.getQuestState(getName());
-			if ((temp != null) && (temp.get(var) != null) && (temp.get(var)).equalsIgnoreCase(value))
+			if ((temp != null) && temp.isSet(var) && temp.get(var).equalsIgnoreCase(value))
 			{
 				return player; // match
 			}
-			
 			return null; // no match
 		}
 		
-		// if the player is in a party, gather a list of all matching party members (possibly
-		// including this player)
+		// if the player is in a party, gather a list of all matching party members (possibly including this player)
 		List<L2PcInstance> candidates = new ArrayList<>();
 		// get the target for enforcing distance limitations.
 		L2Object target = player.getTarget();
@@ -2246,7 +2244,6 @@ public class Quest extends ManagedScript
 		{
 			return null;
 		}
-		// TODO where's the range check?
 		// if a match was found from the party, return one of them at random.
 		return candidates.get(Rnd.get(candidates.size()));
 	}

+ 5 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/QuestState.java

@@ -214,6 +214,11 @@ public final class QuestState
 		return val;
 	}
 	
+	public String set(String var, int val)
+	{
+		return set(var, String.valueOf(val));
+	}
+	
 	/**
 	 * Return value of parameter "val" after adding the couple (var,val) in class variable "vars".<br>
 	 * Actions:<br>
@@ -241,9 +246,7 @@ public final class QuestState
 			val = "";
 		}
 		
-		// FastMap.put() returns previous value associated with specified key, or null if there was no mapping for key.
 		String old = _vars.put(var, val);
-		
 		if (old != null)
 		{
 			Quest.updateQuestVarInDb(this, var, val);

+ 3 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java

@@ -33,11 +33,11 @@ import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.datatables.CharTemplateTable;
 import com.l2jserver.gameserver.datatables.SkillTable;
 import com.l2jserver.gameserver.datatables.SkillTreesData;
-import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.instancemanager.QuestManager;
 import com.l2jserver.gameserver.model.L2ShortCut;
 import com.l2jserver.gameserver.model.L2SkillLearn;
 import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.appearance.PcAppearance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.stat.PcStat;
 import com.l2jserver.gameserver.model.actor.templates.L2PcTemplate;
@@ -187,7 +187,6 @@ public final class CharacterCreate extends L2GameClientPacket
 			}
 			
 			template = CharTemplateTable.getInstance().getTemplate(_classId);
-			
 			if ((template == null) || (template.getClassBaseLevel() > 1))
 			{
 				if (Config.DEBUG)
@@ -198,9 +197,8 @@ public final class CharacterCreate extends L2GameClientPacket
 				sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED));
 				return;
 			}
-			
-			int objectId = IdFactory.getInstance().getNextId();
-			newChar = L2PcInstance.create(objectId, template, getClient().getAccountName(), _name, _hairStyle, _hairColor, _face, _sex != 0);
+			final PcAppearance app = new PcAppearance(_face, _hairColor, _hairStyle, _sex != 0);
+			newChar = L2PcInstance.create(template, getClient().getAccountName(), _name, app);
 		}
 		
 		newChar.setCurrentHp(template.getBaseHpMax());