소스 검색

remove id from spawns. not really needed and only makes conflicts.
removed also use for table custom_notspawned

JIV 14 년 전
부모
커밋
48f38242cb

+ 0 - 2
L2_GameServer/java/com/l2jserver/Config.java

@@ -586,7 +586,6 @@ public final class Config
 	public static boolean JAIL_DISABLE_TRANSACTION;
 	public static boolean CUSTOM_SPAWNLIST_TABLE;
 	public static boolean SAVE_GMSPAWN_ON_CUSTOM;
-	public static boolean DELETE_GMSPAWN_ON_CUSTOM;
 	public static boolean CUSTOM_NPC_TABLE;
 	public static boolean CUSTOM_NPC_SKILLS_TABLE;
 	public static boolean CUSTOM_ARMORSETS_TABLE;
@@ -1956,7 +1955,6 @@ public final class Config
 					JAIL_DISABLE_TRANSACTION = Boolean.parseBoolean(General.getProperty("JailDisableTransaction", "False"));
 					CUSTOM_SPAWNLIST_TABLE = Boolean.valueOf(General.getProperty("CustomSpawnlistTable", "false"));
 					SAVE_GMSPAWN_ON_CUSTOM = Boolean.valueOf(General.getProperty("SaveGmSpawnOnCustom", "false"));
-					DELETE_GMSPAWN_ON_CUSTOM = Boolean.valueOf(General.getProperty("DeleteGmSpawnOnCustom", "false"));
 					CUSTOM_NPC_TABLE = Boolean.valueOf(General.getProperty("CustomNpcTable", "false"));
 					CUSTOM_NPC_SKILLS_TABLE = Boolean.valueOf(General.getProperty("CustomNpcSkillsTable", "false"));
 					CUSTOM_ARMORSETS_TABLE = Boolean.valueOf(General.getProperty("CustomArmorSetsTable", "false"));

+ 2 - 1
L2_GameServer/java/com/l2jserver/gameserver/GeoData.java

@@ -18,6 +18,7 @@ import java.util.logging.Logger;
 
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.Location;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.util.Point3D;
@@ -78,7 +79,7 @@ public class GeoData
 	 * @param spawnid
 	 * @return
 	 */
-	public short getSpawnHeight(int x, int y, int zmin, int zmax, int spawnid)
+	public short getSpawnHeight(int x, int y, int zmin, int zmax, L2Spawn spawn)
 	{
 		return (short) zmin;
 	}

+ 6 - 5
L2_GameServer/java/com/l2jserver/gameserver/GeoEngine.java

@@ -35,6 +35,7 @@ import java.util.logging.Logger;
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.datatables.DoorTable;
 import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.Location;
 import com.l2jserver.gameserver.model.actor.instance.L2DefenderInstance;
@@ -91,9 +92,9 @@ public class GeoEngine extends GeoData
 	 * @see com.l2jserver.gameserver.GeoData#getSpawnHeight(int, int, int, int, int)
 	 */
 	@Override
-	public short getSpawnHeight(int x, int y, int zmin, int zmax, int spawnid)
+	public short getSpawnHeight(int x, int y, int zmin, int zmax, L2Spawn spawn)
 	{
-		return nGetSpawnHeight((x - L2World.MAP_MIN_X) >> 4, (y - L2World.MAP_MIN_Y) >> 4, zmin, zmax, spawnid);
+		return nGetSpawnHeight((x - L2World.MAP_MIN_X) >> 4, (y - L2World.MAP_MIN_Y) >> 4, zmin, zmax, spawn);
 	}
 	
 	/**
@@ -999,7 +1000,7 @@ public class GeoEngine extends GeoData
 	 * @param zmax
 	 * @return Z betwen zmin and zmax
 	 */
-	private static short nGetSpawnHeight(int geox, int geoy, int zmin, int zmax, int spawnid)
+	private static short nGetSpawnHeight(int geox, int geoy, int zmin, int zmax, L2Spawn spawn)
 	{
 		short region = getRegionOffset(geox, geoy);
 		int blockX = getBlock(geox);
@@ -1072,7 +1073,7 @@ public class GeoEngine extends GeoData
 			{
 				if (Config.DEBUG)
 					_log.warning("SpawnHeight Error - Couldnt find correct layer to spawn NPC - GeoData or Spawnlist Bug!: zmin: " + zmin
-							+ " zmax: " + zmax + " value: " + temph + " SpawnId: " + spawnid + " at: " + geox + " : " + geoy);
+							+ " zmax: " + zmax + " value: " + temph + " Spawn: " + spawn + " at: " + geox + " : " + geoy);
 				return (short) zmin;
 			}
 		}
@@ -1080,7 +1081,7 @@ public class GeoEngine extends GeoData
 		{
 			if (Config.DEBUG)
 				_log.warning("SpawnHeight Error - Spawnlist z value is wrong or GeoData error: zmin: " + zmin + " zmax: " + zmax
-						+ " value: " + temph + " SpawnId: " + spawnid + " at: " + geox + " : " + geoy);
+						+ " value: " + temph + " Spawn: " + spawn + " at: " + geox + " : " + geoy);
 			return (short) zmin;
 		}
 		return temph;

+ 40 - 90
L2_GameServer/java/com/l2jserver/gameserver/datatables/SpawnTable.java

@@ -17,11 +17,10 @@ package com.l2jserver.gameserver.datatables;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javolution.util.FastMap;
+import javolution.util.FastSet;
 
 import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
@@ -41,12 +40,10 @@ public class SpawnTable
 {
 	private static Logger _log = Logger.getLogger(SpawnTable.class.getName());
 	
-	private Map<Integer, L2Spawn> _spawntable = new FastMap<Integer, L2Spawn>().shared();
+	private FastSet<L2Spawn> _spawntable = new FastSet<L2Spawn>().shared();
 	private int _npcSpawnCount;
 	private int _customSpawnCount;
 	
-	private int _highestId;
-	
 	public static SpawnTable getInstance()
 	{
 		return SingletonHolder._instance;
@@ -58,7 +55,7 @@ public class SpawnTable
 			fillSpawnTable();
 	}
 	
-	public Map<Integer, L2Spawn> getSpawnTable()
+	public FastSet<L2Spawn> getSpawnTable()
 	{
 		return _spawntable;
 	}
@@ -71,14 +68,7 @@ public class SpawnTable
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement;
-			if (Config.DELETE_GMSPAWN_ON_CUSTOM)
-			{
-				statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM spawnlist where id NOT in ( select id from custom_notspawned where isCustom = false ) ORDER BY id");
-			}
-			else
-			{
-				statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM spawnlist ORDER BY id");
-			}
+			statement = con.prepareStatement("SELECT count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM spawnlist");
 			ResultSet rset = statement.executeQuery();
 			
 			L2Spawn spawnDat;
@@ -104,7 +94,6 @@ public class SpawnTable
 					else
 					{
 						spawnDat = new L2Spawn(template1);
-						spawnDat.setId(rset.getInt("id"));
 						spawnDat.setAmount(rset.getInt("count"));
 						spawnDat.setLocx(rset.getInt("locx"));
 						spawnDat.setLocy(rset.getInt("locy"));
@@ -129,9 +118,7 @@ public class SpawnTable
 								break;
 						}
 						
-						_spawntable.put(spawnDat.getId(), spawnDat);
-						if (spawnDat.getId() > _highestId)
-							_highestId = spawnDat.getId();
+						_spawntable.add(spawnDat);
 					}
 				}
 				else
@@ -160,14 +147,7 @@ public class SpawnTable
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
 				PreparedStatement statement;
-				if (Config.DELETE_GMSPAWN_ON_CUSTOM)
-				{
-					statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist where id NOT in ( select id from custom_notspawned where isCustom = true ) ORDER BY id");
-				}
-				else
-				{
-					statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist ORDER BY id");
-				}
+				statement = con.prepareStatement("SELECT count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist");
 				ResultSet rset = statement.executeQuery();
 				
 				L2Spawn spawnDat;
@@ -193,7 +173,6 @@ public class SpawnTable
 						else
 						{
 							spawnDat = new L2Spawn(template1);
-							spawnDat.setId(rset.getInt("id"));
 							spawnDat.setAmount(rset.getInt("count"));
 							spawnDat.setLocx(rset.getInt("locx"));
 							spawnDat.setLocy(rset.getInt("locy"));
@@ -219,9 +198,7 @@ public class SpawnTable
 									break;
 							}
 							
-							_spawntable.put(spawnDat.getId(), spawnDat);
-							if (spawnDat.getId() > _highestId)
-								_highestId = spawnDat.getId();
+							_spawntable.add(spawnDat);
 						}
 					}
 					else
@@ -250,16 +227,9 @@ public class SpawnTable
 		
 	}
 	
-	public L2Spawn getTemplate(int id)
-	{
-		return _spawntable.get(id);
-	}
-	
 	public void addNewSpawn(L2Spawn spawn, boolean storeInDb)
 	{
-		_highestId++;
-		spawn.setId(_highestId);
-		_spawntable.put(_highestId, spawn);
+		_spawntable.add(spawn);
 		
 		if (storeInDb)
 		{
@@ -274,16 +244,15 @@ public class SpawnTable
 			{
 				con = L2DatabaseFactory.getInstance().getConnection();
 				PreparedStatement statement = con.prepareStatement("INSERT INTO " + spawnTable
-						+ "(id,count,npc_templateid,locx,locy,locz,heading,respawn_delay,loc_id) values(?,?,?,?,?,?,?,?,?)");
-				statement.setInt(1, spawn.getId());
-				statement.setInt(2, spawn.getAmount());
-				statement.setInt(3, spawn.getNpcid());
-				statement.setInt(4, spawn.getLocx());
-				statement.setInt(5, spawn.getLocy());
-				statement.setInt(6, spawn.getLocz());
-				statement.setInt(7, spawn.getHeading());
-				statement.setInt(8, spawn.getRespawnDelay() / 1000);
-				statement.setInt(9, spawn.getLocation());
+						+ "(count,npc_templateid,locx,locy,locz,heading,respawn_delay,loc_id) values(?,?,?,?,?,?,?,?)");
+				statement.setInt(1, spawn.getAmount());
+				statement.setInt(2, spawn.getNpcid());
+				statement.setInt(3, spawn.getLocx());
+				statement.setInt(4, spawn.getLocy());
+				statement.setInt(5, spawn.getLocz());
+				statement.setInt(6, spawn.getHeading());
+				statement.setInt(7, spawn.getRespawnDelay() / 1000);
+				statement.setInt(8, spawn.getLocation());
 				statement.execute();
 				statement.close();
 			}
@@ -302,54 +271,35 @@ public class SpawnTable
 	public void deleteSpawn(L2Spawn spawn, boolean updateDb)
 	{
 		
-		if (_spawntable.remove(spawn.getId()) == null)
+		if (!_spawntable.remove(spawn))
 			return;
 		
 		if (updateDb)
 		{
 			Connection con = null;
-			if (Config.DELETE_GMSPAWN_ON_CUSTOM)
+			try
 			{
-				try
-				{
-					con = L2DatabaseFactory.getInstance().getConnection();
-					PreparedStatement statement = con.prepareStatement("Replace into custom_notspawned VALUES (?,?)");
-					statement.setInt(1, spawn.getId());
-					statement.setBoolean(2, spawn.isCustom());
-					statement.execute();
-					statement.close();
-				}
-				catch (Exception e)
-				{
-					// problem with inserting nospawn
-					_log.log(Level.WARNING, "SpawnTable: Spawn " + spawn.getId() + " could not be insert into DB: " + e.getMessage(), e);
-				}
-				finally
-				{
-					L2DatabaseFactory.close(con);
-				}
+				con = L2DatabaseFactory.getInstance().getConnection();
+				PreparedStatement statement = con.prepareStatement("DELETE FROM "
+						+ (spawn.isCustom() ? "custom_spawnlist" : "spawnlist") + " WHERE locx=? AND locy=? AND locz=? AND npc_templateid=? AND heading=?");
+				statement.setInt(1, spawn.getLocx());
+				statement.setInt(2, spawn.getLocy());
+				statement.setInt(3, spawn.getLocz());
+				statement.setInt(4, spawn.getNpcid());
+				statement.setInt(5, spawn.getHeading());
+				statement.execute();
+				statement.close();
 			}
-			else
+			catch (Exception e)
 			{
-				try
-				{
-					con = L2DatabaseFactory.getInstance().getConnection();
-					PreparedStatement statement = con.prepareStatement("DELETE FROM "
-							+ (spawn.isCustom() ? "custom_spawnlist" : "spawnlist") + " WHERE id=?");
-					statement.setInt(1, spawn.getId());
-					statement.execute();
-					statement.close();
-				}
-				catch (Exception e)
-				{
-					// problem with deleting spawn
-					_log.log(Level.WARNING, "SpawnTable: Spawn " + spawn.getId() + " could not be removed from DB: " + e.getMessage(), e);
-				}
-				finally
-				{
-					L2DatabaseFactory.close(con);
-				}
+				// problem with deleting spawn
+				_log.log(Level.WARNING, "SpawnTable: Spawn " + spawn + " could not be removed from DB: " + e.getMessage(), e);
 			}
+			finally
+			{
+				L2DatabaseFactory.close(con);
+			}
+			
 		}
 	}
 	
@@ -368,7 +318,7 @@ public class SpawnTable
 	public void findNPCInstances(L2PcInstance activeChar, int npcId, int teleportIndex, boolean showposition)
 	{
 		int index = 0;
-		for (L2Spawn spawn : _spawntable.values())
+		for (L2Spawn spawn : _spawntable)
 		{
 			
 			if (npcId == spawn.getNpcid())
@@ -388,9 +338,9 @@ public class SpawnTable
 				else
 				{
 					if(showposition && _npc != null)
-						activeChar.sendMessage(index + " - " + spawn.getTemplate().name + " (" + spawn.getId() + "): " + _npc.getX() + " "+ _npc.getY() + " " + _npc.getZ());
+						activeChar.sendMessage(index + " - " + spawn.getTemplate().name + " (" + spawn + "): " + _npc.getX() + " "+ _npc.getY() + " " + _npc.getZ());
 					else
-						activeChar.sendMessage(index + " - " + spawn.getTemplate().name + " (" + spawn.getId() + "): " + spawn.getLocx() + " "+ spawn.getLocy() + " " + spawn.getLocz());
+						activeChar.sendMessage(index + " - " + spawn.getTemplate().name + " (" + spawn + "): " + spawn.getLocx() + " "+ spawn.getLocy() + " " + spawn.getLocz());
 				}
 			}
 		}

+ 0 - 1
L2_GameServer/java/com/l2jserver/gameserver/instancemanager/FortSiegeGuardManager.java

@@ -119,7 +119,6 @@ public class FortSiegeGuardManager
 				if (template1 != null)
 				{
 					spawn1 = new L2Spawn(template1);
-					spawn1.setId(rs.getInt("id"));
 					spawn1.setAmount(1);
 					spawn1.setLocx(rs.getInt("x"));
 					spawn1.setLocy(rs.getInt("y"));

+ 0 - 1
L2_GameServer/java/com/l2jserver/gameserver/instancemanager/SiegeGuardManager.java

@@ -212,7 +212,6 @@ public class SiegeGuardManager
 				if (template1 != null)
 				{
 					spawn1 = new L2Spawn(template1);
-					spawn1.setId(rs.getInt("id"));
 					spawn1.setAmount(1);
 					spawn1.setLocx(rs.getInt("x"));
 					spawn1.setLocy(rs.getInt("y"));

+ 12 - 22
L2_GameServer/java/com/l2jserver/gameserver/model/L2Spawn.java

@@ -50,9 +50,6 @@ public class L2Spawn
 	/** The link on the L2NpcTemplate object containing generic and static properties of this spawn (ex : RewardExp, RewardSP, AggroRange...) */
 	private L2NpcTemplate _template;
 	
-	/** The Identifier of this spawn in the spawn table */
-	private int _id;
-	
 	// private String _location = DEFAULT_LOCATION;
 	
 	/** The identifier of the location area where L2NpcInstance can be spwaned */
@@ -185,14 +182,6 @@ public class L2Spawn
 		return _maximumCount;
 	}
 	
-	/**
-	 * Return the Identifier of this L2Spwan (used as key in the SpawnTable).<BR><BR>
-	 */
-	public int getId()
-	{
-		return _id;
-	}
-	
 	/**
 	 * Return the Identifier of the location area where L2NpcInstance can be spwaned.<BR><BR>
 	 */
@@ -271,14 +260,6 @@ public class L2Spawn
 		_maximumCount = amount;
 	}
 	
-	/**
-	 * Set the Identifier of this L2Spwan (used as key in the SpawnTable).<BR><BR>
-	 */
-	public void setId(int id)
-	{
-		_id = id;
-	}
-	
 	/**
 	 * Set the Identifier of the location area where L2NpcInstance can be spwaned.<BR><BR>
 	 */
@@ -513,7 +494,7 @@ public class L2Spawn
 			// Set the calculated position of the L2NpcInstance
 			newlocx = p[0];
 			newlocy = p[1];
-			newlocz = GeoData.getInstance().getSpawnHeight(newlocx, newlocy, p[2], p[3],_id);
+			newlocz = GeoData.getInstance().getSpawnHeight(newlocx, newlocy, p[2], p[3],this);
 		}
 		else
 		{
@@ -521,7 +502,7 @@ public class L2Spawn
 			newlocx = getLocx();
 			newlocy = getLocy();
 			if (Config.GEODATA > 0)
-				newlocz = GeoData.getInstance().getSpawnHeight(newlocx,newlocy,getLocz(),getLocz(),_id);
+				newlocz = GeoData.getInstance().getSpawnHeight(newlocx,newlocy,getLocz(),getLocz(),this);
 			else newlocz = getLocz();
 		}
 		
@@ -621,7 +602,7 @@ public class L2Spawn
 	public void setRespawnDelay(int i)
 	{
 		if (i < 0)
-			_log.warning("respawn delay is negative for spawnId:"+_id);
+			_log.warning("respawn delay is negative for spawn:"+this);
 		
 		if (i < 10)
 			i = 10;
@@ -660,4 +641,13 @@ public class L2Spawn
 	{
 		_instanceId = instanceId;
 	}
+	
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString()
+	{
+		return "L2Spawn [_template=" + getNpcid() + ", _locX=" + _locX + ", _locY=" + _locY + ", _locZ=" + _locZ + ", _heading=" + _heading + "]";
+	}
 }

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

@@ -4139,7 +4139,7 @@ public abstract class L2Character extends L2Object
 		&& GameTimeController.getGameTicks() % 10 == 0 // once a second to reduce possible cpu load
 		&& GeoData.getInstance().hasGeo(xPrev, yPrev))
 		{
-			short geoHeight = GeoData.getInstance().getSpawnHeight(xPrev, yPrev, zPrev-30, zPrev+30, this.getObjectId());
+			short geoHeight = GeoData.getInstance().getSpawnHeight(xPrev, yPrev, zPrev-30, zPrev+30, null);
 			dz = m._zDestination - geoHeight;
 			// quite a big difference, compare to validatePosition packet
 			if (this instanceof L2PcInstance

+ 1 - 1
L2_GameServer/java/com/l2jserver/gameserver/model/olympiad/OlympiadAnnouncer.java

@@ -38,7 +38,7 @@ public final class OlympiadAnnouncer implements Runnable
 
 	public OlympiadAnnouncer()
 	{
-		for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable().values())
+		for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
 		{
 			if (spawn != null && spawn.getNpcid() == OLY_MANAGER)
 				_managers.add(spawn);