All pastes #28723 Raw Edit

Stuff

public text v1 · immutable
#28723 ·published 2005-11-14 22:44 UTC
rendered paste body
Index: C:/java/net/sf/l2j/gameserver/clientpackets/ValidatePosition.java
===================================================================
--- C:/java/net/sf/l2j/gameserver/clientpackets/ValidatePosition.java	(revision 1515)
+++ C:/java/net/sf/l2j/gameserver/clientpackets/ValidatePosition.java	(working copy)
@@ -25,6 +25,7 @@
 import net.sf.l2j.gameserver.ClientThread;
 import net.sf.l2j.gameserver.Universe;
 import net.sf.l2j.gameserver.model.L2PcInstance;
+import net.sf.l2j.gameserver.serverpackets.CharMoveToLocation;
 import net.sf.l2j.gameserver.serverpackets.ValidateLocation;
 
 /**
@@ -63,94 +64,44 @@
 		L2PcInstance activeChar = getClient().getActiveChar();
 		if (activeChar != null)
 		{
-			activeChar.setClientX(_x);
-			activeChar.setClientY(_y);
-			activeChar.setClientZ(_z);
-			activeChar.setClientHeading(_heading);
-			int realX = activeChar.getX();
+            int realX = activeChar.getX();
 			int realY = activeChar.getY();
 			int realZ = activeChar.getZ();
-			activeChar.setXYZ(activeChar.getX(),activeChar.getY(),_z);
 			int realHeading = activeChar.getHeading();
-			//activeChar.setHeading(_heading);
-			
-			//TODO: do we need to validate?
-			/*int dx = (_x - realX); 
-			int dy = (_y - realY); 
-			double dist = Math.sqrt(dx*dx + dy*dy);
-			if ((dist < 500)&&(dist > 2)) //check it wasnt teleportation, and char isn't there yet
-				activeChar.sendPacket(new CharMoveToLocation(activeChar));*/
-			
-			if (Config.DEBUG) {
-				_log.fine("client pos: "+ _x + " "+ _y + " "+ _z +" head "+ _heading);
-				_log.fine("server pos: "+ realX + " "+realY+ " "+realZ +" head "+realHeading);
-			}
-			
-			if (Config.ACTIVATE_POSITION_RECORDER && !activeChar.isFlying() && Universe.getInstance().shouldLog(activeChar.getObjectId()))
-				Universe.getInstance().registerHeight(realX, realY, _z);
-			
-			if (Config.DEVELOPER)
-			{
-			int dx = _x - realX;
-			int dy = _y - realY;
-			int diff2 = (dx*dx + dy*dy);
-			if (diff2 > 1000000) {
-				if (Config.DEBUG) _log.fine("client/server dist diff "+ (int)Math.sqrt(diff2));
-				sendPacket(new ValidateLocation(activeChar));
-			}
-			}
-			
-			activeChar.updateKnownObjects();
-//			// check for objects that are now out of range
-//			activeChar.updateKnownCounter += 1;
-//			if (activeChar.updateKnownCounter >3)
-//			{
-//				int delete = 0;
-//				Iterator<L2Object> known = activeChar.iterateKnownObjects();
-//				ArrayList<L2Object> toBeDeleted = new ArrayList<L2Object>();
-//				
-//				while (known.hasNext())
-//				{
-//					L2Object obj = known.next();
-//					if (distance(activeChar, obj) > 4000*4000)
-//					{
-//						toBeDeleted.add(obj);
-//						delete++;
-//					}
-//				}
-//				
-//				if (delete >0)
-//				{
-//					for (int i = 0; i < toBeDeleted.size(); i++)
-//					{
-//						L2Object obj = toBeDeleted.get(i);
-//						activeChar.removeKnownObject(obj);
-//						obj.removeKnownObject(activeChar);
-//						
-//					}
-//					if (Config.DEBUG) _log.fine("deleted " +delete+" objects");
-//				}
-//				
-//				
-//				// check for new objects that are now in range
-//				int newObjects = 0;
-//				L2Object[] visible = L2World.getInstance().getVisibleObjects(activeChar, 3000);
-//				for (int i = 0; i < visible.length; i++)
-//				{
-//					if (! activeChar.knownsObject(visible[i]))
-//					{
-//						activeChar.addKnownObject(visible[i]);
-//						visible[i].addKnownObject(activeChar);
-//						newObjects++;
-//					}
-//				}
-//				
-//				if (newObjects >0)
-//				{
-//					if (Config.DEBUG) _log.fine("added " + newObjects + " new objects");
-//				}
-//				activeChar.updateKnownCounter = 0;	
-//			}
+            
+            if (Config.DEBUG) {
+                _log.fine("Client pos: "+ _x + " "+ _y + " "+ _z +" head "+ _heading);
+                _log.fine("Server pos: "+ realX + " "+realY+ " "+realZ +" head "+realHeading);
+            }
+            
+            int diffX = (_x - realX);
+            int diffY = (_y - realY);
+            int diffZ = Math.abs(_z - realZ);
+            double dist = Math.sqrt(diffX*diffX + diffY*diffY);
+            if ((dist > 50 && dist < 500) || (diffZ > 100 && diffZ < 500))
+            {
+                if (Config.DEBUG)
+                {
+                    _log.fine("Client/server dist diff: " + dist);
+                    _log.fine("Client/server z-coord diff: " + diffZ);
+                }
+
+                activeChar.setClientX(realX);
+                activeChar.setClientY(realY);
+                activeChar.setClientZ(realZ - 50);
+                activeChar.setClientHeading(realHeading);
+
+                activeChar.setXYZ(realX,realY,realZ - 50);
+                activeChar.setHeading(_heading);
+                
+                activeChar.sendPacket(new CharMoveToLocation(activeChar));
+                activeChar.sendPacket(new ValidateLocation(activeChar));
+            }
+            else
+            {
+                if (Config.ACTIVATE_POSITION_RECORDER && !activeChar.isFlying() && Universe.getInstance().shouldLog(activeChar.getObjectId()))
+                    Universe.getInstance().registerHeight(realX, realY, _z);
+            }
 		}
 	}