Снять Ограничения

Статус
В этой теме нельзя размещать новые ответы.

lxtopxm

Выдающийся
Местный
Сообщения
379
Розыгрыши
0
Репутация
239
Реакции
45
Баллы
1 375
Кто может помочь снять ограничения на онлайн ?
На пивасик дам очень нада.

Код:
/*      */ package atavism.server.plugins;

/*      */

/*      */ import atavism.agis.database.AccountDatabase;

/*      */ import atavism.agis.events.QuestResponse;

/*      */ import atavism.agis.plugins.CombatClient;

/*      */ import atavism.msgsys.FilterUpdate;

/*      */ import atavism.msgsys.Message;

/*      */ import atavism.msgsys.MessageAgent;

/*      */ import atavism.msgsys.MessageType;

/*      */ import atavism.msgsys.MessageTypeFilter;

/*      */ import atavism.msgsys.TargetMessage;

/*      */ import atavism.server.engine.BasicWorldNode;

/*      */ import atavism.server.engine.Database;

/*      */ import atavism.server.engine.Engine;

/*      */ import atavism.server.engine.EnginePlugin;

/*      */ import atavism.server.engine.Event;

/*      */ import atavism.server.engine.HookManager;

/*      */ import atavism.server.engine.Namespace;

/*      */ import atavism.server.engine.OID;

/*      */ import atavism.server.events.ActivateItemEvent;

/*      */ import atavism.server.events.AttachEvent;

/*      */ import atavism.server.events.AuthorizedLoginEvent;

/*      */ import atavism.server.events.AuthorizedLoginResponseEvent;

/*      */ import atavism.server.events.AutoAttackEvent;

/*      */ import atavism.server.events.ComEvent;

/*      */ import atavism.server.events.CommandEvent;

/*      */ import atavism.server.events.DirLocOrientEvent;

/*      */ import atavism.server.events.ExtensionMessageEvent;

/*      */ import atavism.server.events.ModelInfoEvent;

/*      */ import atavism.server.events.NewLightEvent;

/*      */ import atavism.server.events.NotifyFreeObjectEvent;

/*      */ import atavism.server.messages.PerceptionFilter;

/*      */ import atavism.server.messages.PerceptionMessage;

/*      */ import atavism.server.messages.PerceptionMessage.ObjectNote;

/*      */ import atavism.server.messages.PropertyMessage;

/*      */ import atavism.server.network.AOByteBuffer;

/*      */ import atavism.server.network.ClientConnection;

/*      */ import atavism.server.objects.DisplayContext;

/*      */ import atavism.server.objects.InstanceEntryCallback;

/*      */ import atavism.server.objects.InstanceRestorePoint;

/*      */ import atavism.server.objects.ObjectType;

/*      */ import atavism.server.objects.OceanData;

/*      */ import atavism.server.objects.Player;

/*      */ import atavism.server.objects.PlayerManager;

/*      */ import atavism.server.objects.ProxyExtensionHook;

/*      */ import atavism.server.objects.ProxyLoginCallback;

/*      */ import atavism.server.util.AORuntimeException;

/*      */ import atavism.server.util.Base64;

/*      */ import atavism.server.util.CountLogger;

/*      */ import atavism.server.util.CountLogger.Counter;

/*      */ import atavism.server.util.Log;

/*      */ import atavism.server.util.Logger;

/*      */ import atavism.server.util.SquareQueue;

/*      */ import java.io.OutputStreamWriter;

/*      */ import java.net.InetAddress;

/*      */ import java.net.InetSocketAddress;

/*      */ import java.net.URLConnection;

/*      */ import java.net.URLEncoder;

/*      */ import java.util.ArrayList;

/*      */ import java.util.HashMap;

/*      */ import java.util.HashSet;

/*      */ import java.util.LinkedHashMap;

/*      */ import java.util.LinkedList;

/*      */ import java.util.List;

/*      */ import java.util.Map;

/*      */ import java.util.Set;

/*      */ import java.util.concurrent.locks.Lock;

/*      */

/*      */ public class ProxyPlugin extends EnginePlugin implements atavism.msgsys.MessageCallback, atavism.server.network.ClientConnection.AcceptCallback, atavism.server.network.ClientConnection.MessageCallback

/*      */ {

/*      */   public static final int PERCEPTION_GAIN_THRESHOLD = 20;

/*      */   Thread periodicGC;

/*      */   

/*      */   public ProxyPlugin()

/*      */   {

/*   76 */     setPluginType("Proxy");

/*      */     try

/*      */     {

/*   79 */       proxyPluginName = Engine.getAgent().getDomainClient().allocName("PLUGIN",

/*   80 */         getPluginType() + "#");

/*      */     } catch (java.io.IOException e) { String proxyPluginName;

/*   82 */       throw new AORuntimeException("Could not allocate proxy plugin name", e);

/*      */     }

/*      */     

/*      */     String proxyPluginName;

/*   86 */     setName(proxyPluginName);

/*      */     

/*      */

/*   89 */     this.serverVersion = ("2018.3.1 " + atavism.server.util.ServerVersion.getBuildNumber());

/*      */     

/*      */

/*      */

/*   93 */     setMessageHandler(null);

/*   94 */     this.countMsgPerception = this.countLogger.addCounter("ao.PERCEPTION_INFO");

/*   95 */     this.countMsgPerceptionGain = this.countLogger.addCounter("Perception.gain");

/*   96 */     this.countMsgPerceptionLost = this.countLogger.addCounter("Perception.lost");

/*   97 */     this.countMsgUpdateWNodeIn = this.countLogger.addCounter("ao.UPDATEWNODE.in");

/*   98 */     this.countMsgUpdateWNodeOut = this.countLogger.addCounter("ao.UPDATEWNODE.out");

/*   99 */     this.countMsgPropertyIn = this.countLogger.addCounter("ao.PROPERTY.in");

/*  100 */     this.countMsgPropertyOut = this.countLogger.addCounter("ao.PROPERTY.out");

/*      */     

/*  102 */     this.countMsgTargetedProperty = this.countLogger.addCounter("ao.TARGETED_PROPERTY");

/*  103 */     this.countMsgWNodeCorrectIn = this.countLogger.addCounter("ao.WNODECORRECT.in");

/*  104 */     this.countMsgWNodeCorrectOut = this.countLogger.addCounter("ao.WNODECORRECT.out");

/*  105 */     this.countMsgMobPathIn = this.countLogger.addCounter("ao.MOB_PATH.in");

/*  106 */     this.countMsgMobPathOut = this.countLogger.addCounter("ao.MOB_PATH.out");

/*      */     

/*  108 */     atavism.agis.database.ContentDatabase ctDB = new atavism.agis.database.ContentDatabase(false);

/*  109 */     String _silenceTimeout = ctDB.loadGameSetting("PLAYER_SILENCE_TIMEOUT");

/*  110 */     if (_silenceTimeout != null) {

/*  111 */       silenceTimeout = Integer.parseInt(_silenceTimeout);

/*      */     }

/*      */     

/*      */

/*  115 */     addProxyExtensionHook("ao.heartbeat", new PlayerHeartbeat(null));

/*      */     

/*  117 */     new Thread(new PlayerTimeout(null), "PlayerTimeout").start();

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*  125 */   CountLogger countLogger = new CountLogger("ProxyMsg", 5000, 2);

/*      */   

/*      */   CountLogger.Counter countMsgPerception;

/*      */   

/*      */   CountLogger.Counter countMsgPerceptionGain;

/*      */   

/*      */   CountLogger.Counter countMsgPerceptionLost;

/*      */   

/*      */   CountLogger.Counter countMsgUpdateWNodeIn;

/*      */   

/*      */   CountLogger.Counter countMsgUpdateWNodeOut;

/*      */   

/*      */   CountLogger.Counter countMsgPropertyIn;

/*      */   

/*      */   CountLogger.Counter countMsgPropertyOut;

/*      */   

/*      */   CountLogger.Counter countMsgTargetedProperty;

/*      */   

/*      */   CountLogger.Counter countMsgWNodeCorrectIn;

/*      */   

/*      */   CountLogger.Counter countMsgWNodeCorrectOut;

/*      */   

/*      */   CountLogger.Counter countMsgMobPathIn;

/*      */   

/*      */   CountLogger.Counter countMsgMobPathOut;

/*      */   

/*      */   public static boolean isOnBlockList(OID subject, OID target)

/*      */   {

/*  153 */     Log.error("SocialClient.isOnBlockList: subject:" + subject + "  target:" + target);

/*  154 */     WorldManagerClient.ExtensionMessage message = new WorldManagerClient.ExtensionMessage(atavism.agis.plugins.SocialClient.MSG_TYPE_IS_ON_BLOCK_LIST, "ao.IS_ON_BLOCK_LIST", subject);

/*  155 */     message.setProperty("targetOid", target);

/*  156 */     return Engine.getAgent().sendRPCReturnBoolean(message).booleanValue();

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public boolean isDevMode()

/*      */   {

/*  165 */     return this.devMode;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void setDevMode(boolean mode)

/*      */   {

/*  173 */     this.devMode = mode;

/*      */   }

/*      */   

/*      */   public List<MessageType> getExtraPlayerMessageTypes() {

/*  177 */     return this.extraPlayerMessageTypes;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void setExtraPlayerMessageTypes(List<MessageType> extraPlayerMessageTypes)

/*      */   {

/*  188 */     this.extraPlayerMessageTypes = extraPlayerMessageTypes;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addExtraPlayerMessageType(MessageType messageType)

/*      */   {

/*  198 */     if (this.extraPlayerMessageTypes == null)

/*  199 */       this.extraPlayerMessageTypes = new LinkedList();

/*  200 */     this.extraPlayerMessageTypes.add(messageType);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addExtraPlayerExtensionMessageType(MessageType messageType)

/*      */   {

/*  210 */     addExtraPlayerMessageType(messageType);

/*  211 */     getHookManager().addHook(messageType, new ExtensionHook());

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addProxyExtensionHook(String subType, ProxyExtensionHook hook)

/*      */   {

/*  225 */     synchronized (this.extensionHooks) {

/*  226 */       List<ProxyExtensionHook> hookList = (List)this.extensionHooks.get(subType);

/*  227 */       if (hookList == null) {

/*  228 */         hookList = new ArrayList();

/*  229 */         this.extensionHooks.put(subType, hookList);

/*      */       }

/*  231 */       hookList.add(hook);

/*      */     }

/*      */   }

/*      */   

/*      */   public Map<String, List<ProxyExtensionHook>> getProxyExtensionHooks(String subType)

/*      */   {

/*  237 */     return this.extensionHooks;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void onActivate()

/*      */   {

/*      */     try

/*      */     {

/*  264 */       atavism.server.network.PacketAggregator.initializeAggregation(Engine.getProperties());

/*      */       

/*      */

/*  267 */       String logProxyHistograms = Engine.properties.getProperty("atavism.log_proxy_histograms");

/*  268 */       if ((logProxyHistograms != null) && (logProxyHistograms.equals("true"))) {

/*  269 */         int interval = 5000;

/*      */         

/*  271 */         String intervalString = Engine.properties.getProperty("atavism.log_proxy_histograms_interval");

/*  272 */         if (intervalString != null) {

/*  273 */           int newInterval = Integer.parseInt(intervalString);

/*  274 */           if (newInterval > 0)

/*  275 */             interval = newInterval;

/*      */         }

/*  277 */         this.proxyQueueHistogram = new atavism.server.util.TimeHistogram("TimeInQ", Integer.valueOf(interval));

/*      */         

/*  279 */         this.proxyCallbackHistogram = new atavism.server.util.TimeHistogram("TimeInCallback", Integer.valueOf(interval));

/*  280 */         this.countLogger.start();

/*      */       }

/*      */       

/*      */

/*  284 */       this.filteredProps = new HashSet();

/*  285 */       this.playerSpecificProps = new HashSet();

/*  286 */       this.cachedPlayerSpecificFilterProps = new HashSet();

/*      */       

/*  288 */       addFilteredProperty("inv.bag");

/*  289 */       addFilteredProperty(":loc");

/*  290 */       addFilteredProperty("masterOid");

/*  291 */       addFilteredProperty("agisobj.basedc");

/*  292 */       addFilteredProperty("aoobj.dc");

/*  293 */       addFilteredProperty("aoobj.followsterrainflag");

/*  294 */       addFilteredProperty("aoobj.perceiver");

/*  295 */       addFilteredProperty("aoobj.scale");

/*  296 */       addFilteredProperty("aoobj.mobflag");

/*  297 */       addFilteredProperty("aoobj.structflag");

/*  298 */       addFilteredProperty("aoobj.userflag");

/*  299 */       addFilteredProperty("aoobj.itemflag");

/*  300 */       addFilteredProperty("aoobj.lightflag");

/*  301 */       addFilteredProperty("namespace");

/*  302 */       addFilteredProperty("regenEffectMap");

/*  303 */       addFilteredProperty(WorldManagerClient.MOB_PATH_PROPERTY);

/*  304 */       addFilteredProperty(WorldManagerClient.TEMPL_SOUND_DATA_LIST);

/*  305 */       addFilteredProperty(WorldManagerClient.TEMPL_TERRAIN_DECAL_DATA);

/*  306 */       addFilteredProperty("instanceStack");

/*  307 */       addFilteredProperty("currentInstanceName");

/*  308 */       addFilteredProperty("ignored_oids");

/*      */       

/*      */

/*  311 */       registerHooks();

/*      */       

/*      */

/*      */

/*  315 */       PluginMessageCallback pluginMessageCallback = new PluginMessageCallback();

/*  316 */       MessageTypeFilter filter = new MessageTypeFilter();

/*  317 */       filter.addType(WorldManagerClient.MSG_TYPE_SYS_CHAT);

/*  318 */       Engine.getAgent().createSubscription(filter, pluginMessageCallback);

/*      */       

/*      */

/*      */

/*  322 */       this.perceptionFilter = new PerceptionFilter();

/*  323 */       LinkedList<MessageType> types = new LinkedList();

/*  324 */       types.add(WorldManagerClient.MSG_TYPE_PERCEPTION_INFO);

/*  325 */       types.add(WorldManagerClient.MSG_TYPE_ANIMATION);

/*  326 */       types.add(WorldManagerClient.MSG_TYPE_DISPLAY_CONTEXT);

/*  327 */       types.add(WorldManagerClient.MSG_TYPE_DETACH);

/*  328 */       types.add(PropertyMessage.MSG_TYPE_PROPERTY);

/*  329 */       types.add(WorldManagerClient.MSG_TYPE_COM);

/*  330 */       types.add(atavism.agis.plugins.SocialClient.MSG_TYPE_BLOCK_LIST);

/*  331 */       types.add(CombatClient.MSG_TYPE_DAMAGE);

/*  332 */       types.add(WorldManagerClient.MSG_TYPE_UPDATEWNODE);

/*  333 */       types.add(WorldManagerClient.MSG_TYPE_MOB_PATH);

/*  334 */       types.add(WorldManagerClient.MSG_TYPE_WNODECORRECT);

/*  335 */       types.add(WorldManagerClient.MSG_TYPE_ORIENT);

/*  336 */       types.add(WorldManagerClient.MSG_TYPE_SOUND);

/*  337 */       types.add(atavism.agis.plugins.AnimationClient.MSG_TYPE_INVOKE_EFFECT);

/*  338 */       types.add(WorldManagerClient.MSG_TYPE_EXTENSION);

/*  339 */       types.add(WorldManagerClient.MSG_TYPE_P2P_EXTENSION);

/*      */       

/*      */

/*  342 */       types.add(InventoryClient.MSG_TYPE_INV_UPDATE);

/*      */       

/*  344 */       types.add(CombatClient.MSG_TYPE_ABILITY_STATUS);

/*  345 */       types.add(CombatClient.MSG_TYPE_ABILITY_UPDATE);

/*  346 */       types.add(WorldManagerClient.MSG_TYPE_FOG);

/*  347 */       types.add(WorldManagerClient.MSG_TYPE_ROAD);

/*  348 */       types.add(WorldManagerClient.MSG_TYPE_NEW_DIRLIGHT);

/*  349 */       types.add(WorldManagerClient.MSG_TYPE_SET_AMBIENT);

/*  350 */       types.add(WorldManagerClient.MSG_TYPE_TARGETED_PROPERTY);

/*  351 */       types.add(WorldManagerClient.MSG_TYPE_FREE_OBJECT);

/*  352 */       types.add(MSG_TYPE_VOICE_PARMS);

/*  353 */       types.add(MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST);

/*  354 */       types.add(MSG_TYPE_GET_MATCHING_PLAYERS);

/*  355 */       types.add(MSG_TYPE_ADD_STATIC_PERCEPTION);

/*  356 */       types.add(MSG_TYPE_REMOVE_STATIC_PERCEPTION);

/*      */       

/*  358 */       if (this.extraPlayerMessageTypes != null)

/*  359 */         types.addAll(this.extraPlayerMessageTypes);

/*  360 */       this.perceptionFilter.setTypes(types);

/*      */       

/*      */

/*      */

/*      */

/*      */

/*  366 */       this.perceptionFilter.setMatchAllSubjects(true);

/*      */       

/*  368 */       atavism.server.messages.PerceptionTrigger perceptionTrigger = new atavism.server.messages.PerceptionTrigger();

/*  369 */       this.perceptionSubId = Engine.getAgent().createSubscription(this.perceptionFilter, this.playerMessageCallback, 0, perceptionTrigger);

/*      */       

/*      */

/*      */

/*  373 */       this.responderFilter = new PerceptionFilter();

/*  374 */       types.clear();

/*  375 */       types.add(InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ);

/*  376 */       types.add(MSG_TYPE_PLAYER_IGNORE_LIST_REQ);

/*  377 */       types.add(MSG_TYPE_GET_PLAYER_LOGIN_STATUS);

/*  378 */       types.add(MSG_TYPE_LOGOUT_PLAYER);

/*  379 */       this.responderFilter.setTypes(types);

/*  380 */       this.responderSubId = Engine.getAgent().createSubscription(this.responderFilter, this.playerMessageCallback, 8);

/*      */       

/*      */

/*      */

/*  384 */       types.clear();

/*  385 */       types.add(atavism.management.Management.MSG_TYPE_GET_PLUGIN_STATUS);

/*  386 */       Engine.getAgent().createSubscription(new MessageTypeFilter(types), pluginMessageCallback, 8);

/*      */       

/*      */

/*  389 */       MessageTypeFilter filter3 = new MessageTypeFilter();

/*      */       

/*  391 */       filter3.addType(MSG_TYPE_ACCOUNT_LOGIN);

/*  392 */       Engine.getAgent().createSubscription(filter3, this);

/*      */       

/*      */

/*      */

/*      */

/*  397 */       this.serverSocket = new atavism.server.network.rdp.RDPServerSocket();

/*      */       

/*  399 */       String log_rdp_counters = Engine.getProperty("atavism.log_rdp_counters");

/*  400 */       if ((log_rdp_counters == null) || (log_rdp_counters.equals("false")))

/*  401 */         atavism.server.network.rdp.RDPServer.setCounterLogging(false);

/*  402 */       atavism.server.network.rdp.RDPServer.startRDPServer();

/*  403 */       this.serverSocket.registerAcceptCallback(this);

/*      */       

/*  405 */       initializeVoiceServerInformation();

/*      */       

/*  407 */       registerExtensionSubtype("voice_parms", MSG_TYPE_VOICE_PARMS);

/*  408 */       registerExtensionSubtype("player_path_req", MSG_TYPE_PLAYER_PATH_REQ);

/*  409 */       registerExtensionSubtype("player_path_req", MSG_TYPE_PLAYER_PATH_REQ);

/*  410 */       registerExtensionSubtype("ao.UPDATE_PLAYER_IGNORE_LIST", MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST);

/*  411 */       registerExtensionSubtype("ao.GET_MATCHING_PLAYERS", MSG_TYPE_GET_MATCHING_PLAYERS);

/*  412 */       registerExtensionSubtype("ao.PLAYER_IGNORE_LIST_REQ", MSG_TYPE_PLAYER_IGNORE_LIST_REQ);

/*      */       

/*  414 */       Log.debug("ProxyPlugin before bindAddress");

/*  415 */       InetSocketAddress bindAddress = getBindAddress();

/*  416 */       Log.debug("ProxyPlugin after bindAddress " + bindAddress.getHostName() + " " + bindAddress.getAddress() + " " + bindAddress.getPort());

/*  417 */       if (Log.loggingDebug) {

/*  418 */         Log.debug("BIND: binding for client tcp and rdp packets on port " + bindAddress.getPort() + " with rdpsocket: " + this.serverSocket.toString());

/*      */       }

/*      */       

/*      */

/*  422 */       Log.debug("ProxyPlugin before server socket");

/*  423 */       this.serverSocket.bind(Integer.valueOf(Integer.parseInt(Engine.getProperty("atavism.proxy.bindport"))), serverSocketReceiveBufferSize);

/*  424 */       Log.debug("BIND: bound server socket");

/*  425 */       this.clientTCPMessageIO = atavism.server.network.ClientTCPMessageIO.setup(bindAddress, this, this);

/*  426 */       Log.debug("BIND: setup clientTCPMessage");

/*  427 */       this.clientTCPMessageIO.start("ClientIO");

/*  428 */       Log.debug("BIND: started clientTCPMessage");

/*      */       

/*      */

/*  431 */       InetSocketAddress externalAddress = getExternalAddress(bindAddress);

/*  432 */       Log.debug("BIND: got external Address " + externalAddress.getHostName() + " " + externalAddress.getAddress() + " " + externalAddress.getPort());

/*      */       

/*  434 */       setPluginInfo("host=" + Engine.getProperty("atavism.proxy.externaladdress") + ",port=" + externalAddress.getPort());

/*  435 */       Log.debug("Registering proxy plugin");

/*  436 */       Engine.registerStatusReportingPlugin(this);

/*  437 */       Log.debug("Proxy: activation done");

/*      */       

/*      */

/*      */

/*  441 */       runCheck();

/*      */     }

/*      */     catch (Exception e) {

/*  444 */       throw new AORuntimeException("activate failed", e);

/*      */     }

/*      */   }

/*      */   

/*      */   private InetSocketAddress getBindAddress() throws java.io.IOException

/*      */   {

/*  450 */     String propStr = Engine.getProperty("atavism.proxy.bindport");

/*  451 */     Log.debug("Proxy: getBindAddress propStr=" + propStr);

/*      */     int port;

/*  453 */     if (propStr != null) {

/*  454 */       int port = Integer.parseInt(propStr.trim());

/*  455 */       Log.debug("Proxy: getBindAddress port=" + port);

/*      */     }

/*      */     else {

/*  458 */       port = Integer.parseInt(Engine.getProperty("atavism.proxyport").trim());

/*      */     }

/*  460 */     Log.debug("Proxy: getBindAddress port=" + port);

/*      */     

/*      */

/*      */

/*  464 */     propStr = Engine.getProperty("atavism.proxy.bindaddress");

/*  465 */     Log.debug("Proxy: getBindAddress propStr=" + propStr + " " + Character.digit(propStr.charAt(0), 16) + " " + Character.digit(propStr.charAt(1), 16) + " " +

/*  466 */       Character.digit(propStr.charAt(2), 16) + " c=");

/*      */     

/*  468 */     int count = 0;

/*  469 */     if (propStr.contains(".")) {

/*  470 */       for (int i = 0; i < propStr.length(); i++) {

/*  471 */         if (propStr.charAt(i) == '.') {

/*  472 */           count++;

/*      */         }

/*      */       }

/*      */     }

/*  476 */     InetAddress address = null;

/*  477 */     InetAddress[] address2 = null;

/*      */     

/*  479 */     if (((count != 3) || (Character.digit(propStr.charAt(0), 10) == -1)) ||

/*      */     

/*      */

/*      */

/*      */

/*  484 */       (propStr != null)) {

/*      */       try {

/*  486 */         address = InetAddress.getByName(propStr.trim());

/*  487 */         address2 = InetAddress.getAllByName(propStr.trim());

/*  488 */         for (InetAddress ai : address2) {

/*  489 */           Log.debug("Proxy: getBindAddress address2=" + ai + " " + ai.getHostName() + " " + ai.getHostAddress());

/*      */         }

/*      */         

/*  492 */         Log.debug("Proxy: getBindAddress address=" + address + " " + address.getHostName() + " " + address.getHostAddress());

/*      */       } catch (java.net.UnknownHostException e) {

/*  494 */         log.error("getBindAddress " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */       }

/*      */     }

/*  497 */     Log.debug("Proxy: getBindAddress address=" + address + " " + address.getHostName() + " " + address.getAddress());

/*      */     

/*  499 */     return new InetSocketAddress(address, port);

/*      */   }

/*      */   

/*      */   private InetSocketAddress getExternalAddress(InetSocketAddress bindAddress) throws java.io.IOException

/*      */   {

/*  504 */     String propStr = Engine.getProperty("atavism.proxy.externalport");

/*  505 */     Log.debug("Proxy: getExternalAddress propStr=" + propStr);

/*      */     int port;

/*  507 */     int port; if (propStr != null) {

/*  508 */       port = Integer.parseInt(propStr.trim());

/*      */     } else {

/*  510 */       port = bindAddress.getPort();

/*      */     }

/*  512 */     Log.debug("Proxy: getExternalAddress port=" + port);

/*      */     

/*      */

/*  515 */     propStr = Engine.getProperty("atavism.proxy.externaladdress");

/*  516 */     Log.debug("Proxy: getExternalAddress propStr=" + propStr);

/*      */     InetAddress address;

/*  518 */     InetAddress address; if (propStr != null) {

/*  519 */       address = InetAddress.getByName(propStr.trim());

/*      */     } else {

/*  521 */       address = bindAddress.getAddress();

/*  522 */       Log.debug("Proxy: getExternalAddress else address=" + address);

/*  523 */       if (address.isAnyLocalAddress())

/*      */       {

/*  525 */         address = InetAddress.getLocalHost();

/*  526 */         Log.debug("Proxy: getExternalAddress get local host address=" + address + " " + address.getHostName() + " " + address.getHostAddress());

/*      */       }

/*      */     }

/*  529 */     Log.debug("Proxy: getExternalAddress address=" + address + " " + address.getHostName() + " " + address.getAddress());

/*      */     

/*  531 */     return new InetSocketAddress(address, port);

/*      */   }

/*      */   

/*  534 */   private String howla() { String characters = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijklmnoprstquwxyz123456789";

/*  535 */     String k = "";

/*  536 */     for (int i = 0; i < 14; i++) {

/*  537 */       java.util.Random random = new java.util.Random();

/*  538 */       k = k + characters.charAt(random.nextInt(characters.length() - 1));

/*      */     }

/*      */     

/*      */

/*  542 */     return k;

/*      */   }

/*      */   

/*      */   private void runCheck() {

/*  546 */     String email = Engine.getProperty("atavism.licence.email");

/*  547 */     String licencekey = Engine.getProperty("atavism.licence.key");

/*      */     

/*  549 */     String url = "https://apanel.atavismonline.com/login/verifyserver.php";

/*      */     

/*      */     try

/*      */     {

/*  553 */       String res = "";

/*  554 */       java.net.URL urlObj = new java.net.URL(url);

/*  555 */       URLConnection lu = urlObj.openConnection();

/*      */       

/*  557 */       String resSor = howla();

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*  566 */       String data = "email=" + URLEncoder.encode(email, "UTF-8") + "&licence=" + URLEncoder.encode(licencekey, "UTF-8") + "&ver=" + URLEncoder.encode("2018.3.1", "UTF-8") + "&addr=" + URLEncoder.encode(Engine.getProperty("atavism.proxy.bindaddress"), "UTF-8") + "&sor=" + URLEncoder.encode(resSor, "UTF-8") + "&c=" + URLEncoder.encode("0", "UTF-8") + "&cp=" + this.playerManager.getPlayerCount();

/*      */       

/*  568 */       lu.setDoOutput(true);

/*  569 */       OutputStreamWriter wr = new OutputStreamWriter(lu.getOutputStream());

/*  570 */       wr.write(data);

/*  571 */       wr.flush();

/*      */       

/*      */

/*  574 */       java.io.BufferedReader rd = new java.io.BufferedReader(new java.io.InputStreamReader(lu.getInputStream()));

/*  575 */       String line = "";

/*  576 */       while ((line = rd.readLine()) != null) {

/*  577 */         res = res + line;

/*      */       }

/*  579 */       wr.flush();

/*  580 */       wr.close();

/*      */       

/*  582 */       res = atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(res));

/*      */       

/*  584 */       String[] output = res.split(":");

/*  585 */       if ((atavism.server.util.EncryptionHelper.passwordMD5Check(output[0], getTemp())) && (resSor.equals(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[2]))))) {

/*  586 */         this.connectionLimit = Integer.parseInt(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[1])));

/*  587 */         recheck reCheck = new recheck(resSor);

/*  588 */         Engine.getExecutor().scheduleAtFixedRate(reCheck, 300L, 300L, java.util.concurrent.TimeUnit.SECONDS);

/*      */       } else {

/*  590 */         System.out.println("\nLicense verification failed");

/*  591 */         Log.error("License verification failed");

/*      */       }

/*  593 */       Log.debug("CONNECTOR: connections set to: " + this.connectionLimit);

/*      */     } catch (Exception e) {

/*  595 */       Log.error("CONNECTOR: failed verifying account with : " + e);

/*      */     }

/*      */   }

/*      */   

/*      */   class recheck implements Runnable

/*      */   {

/*  601 */     protected String sec = "";

/*      */     

/*  603 */     public recheck(String sec) { this.sec = sec; }

/*      */     

/*      */     public void run() {

/*  606 */       Log.debug("CONNECTOR: ");

/*  607 */       String email = Engine.getProperty("atavism.licence.email");

/*  608 */       String licencekey = Engine.getProperty("atavism.licence.key");

/*  609 */       String url = "https://apanel.atavismonline.com/login/verifyserver.php";

/*      */       try

/*      */       {

/*  612 */         String res = "";

/*  613 */         java.net.URL urlObj = new java.net.URL(url);

/*  614 */         URLConnection lu = urlObj.openConnection();

/*      */         

/*      */

/*      */

/*      */

/*      */

/*      */

/*  621 */         String data = "email=" + URLEncoder.encode(email, "UTF-8") + "&licence=" + URLEncoder.encode(licencekey, "UTF-8") + "&ver=" + URLEncoder.encode("2018.3.1", "UTF-8") + "&addr=" + URLEncoder.encode(Engine.getProperty("atavism.proxy.bindaddress"), "UTF-8") + "&sor=" + URLEncoder.encode(this.sec, "UTF-8") + "&c=" + URLEncoder.encode("1", "UTF-8") + "&cp=" + ProxyPlugin.this.playerManager.getPlayerCount();

/*      */         

/*  623 */         lu.setDoOutput(true);

/*  624 */         OutputStreamWriter wr = new OutputStreamWriter(lu.getOutputStream());

/*  625 */         wr.write(data);

/*  626 */         wr.flush();

/*      */         

/*      */

/*  629 */         java.io.BufferedReader rd = new java.io.BufferedReader(new java.io.InputStreamReader(lu.getInputStream()));

/*  630 */         String line = "";

/*  631 */         while ((line = rd.readLine()) != null) {

/*  632 */           res = res + line;

/*      */         }

/*      */         

/*  635 */         wr.flush();

/*  636 */         wr.close();

/*      */         

/*  638 */         res = atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(res));

/*      */         

/*  640 */         String[] output = res.split(":");

/*  641 */         if ((atavism.server.util.EncryptionHelper.passwordMD5Check(output[0], ProxyPlugin.this.getTemp())) && (this.sec.equals(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[2]))))) {

/*  642 */           ProxyPlugin.this.connectionLimit = Integer.parseInt(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[1])));

/*      */         } else {

/*  644 */           System.out.println("\nLicense verification failed");

/*  645 */           Log.error("License verification failed");

/*  646 */           ProxyPlugin.this.connectionLimit = 0;

/*      */         }

/*  648 */         Log.debug("CONNECTOR: connections set to: " + ProxyPlugin.this.connectionLimit);

/*      */       } catch (Exception e) {

/*  650 */         Log.error("CONNECTOR: failed verifying account with : " + e);

/*      */       }

/*      */     }

/*      */     

/*      */

/*      */

/*      */     private static final long serialVersionUID = 1L;

/*      */   }

/*      */   

/*      */

/*      */   public Map<String, String> getStatusMap()

/*      */   {

/*  662 */     Map<String, String> status = new HashMap();

/*  663 */     status.put("players", Integer.toString(this.playerManager.getPlayerCount()));

/*  664 */     return status;

/*      */   }

/*      */   

/*      */   /* Error */

/*      */   public void registerCommand(String command, CommandParser parser)

/*      */   {

/*      */     // Byte code:

/*      */     //   0: aload_0

/*      */     //   1: getfield 18    atavism/server/plugins/ProxyPlugin:commandMapLock    Ljava/util/concurrent/locks/Lock;

/*      */     //   4: invokeinterface 405 1 0

/*      */     //   9: aload_0

/*      */     //   10: getfield 21    atavism/server/plugins/ProxyPlugin:commandMap    Ljava/util/Map;

/*      */     //   13: aload_1

/*      */     //   14: new 406    atavism/server/plugins/ProxyPlugin$RegisteredCommand

/*      */     //   17: dup

/*      */     //   18: aload_2

/*      */     //   19: aload_0

/*      */     //   20: getfield 24    atavism/server/plugins/ProxyPlugin:defaultCommandAccess    Latavism/server/plugins/ProxyPlugin$CommandAccessCheck;

/*      */     //   23: invokespecial 407    atavism/server/plugins/ProxyPlugin$RegisteredCommand:<init>    (Latavism/server/plugins/ProxyPlugin$CommandParser;Latavism/server/plugins/ProxyPlugin$CommandAccessCheck;)V

/*      */     //   26: invokeinterface 163 3 0

/*      */     //   31: pop

/*      */     //   32: aload_0

/*      */     //   33: getfield 18    atavism/server/plugins/ProxyPlugin:commandMapLock    Ljava/util/concurrent/locks/Lock;

/*      */     //   36: invokeinterface 408 1 0

/*      */     //   41: goto +15 -> 56

/*      */     //   44: astore_3

/*      */     //   45: aload_0

/*      */     //   46: getfield 18    atavism/server/plugins/ProxyPlugin:commandMapLock    Ljava/util/concurrent/locks/Lock;

/*      */     //   49: invokeinterface 408 1 0

/*      */     //   54: aload_3

/*      */     //   55: athrow

/*      */     //   56: return

/*      */     // Line number table:

/*      */     //   Java source line #815    -> byte code offset #0

/*      */     //   Java source line #817    -> byte code offset #9

/*      */     //   Java source line #820    -> byte code offset #32

/*      */     //   Java source line #821    -> byte code offset #41

/*      */     //   Java source line #820    -> byte code offset #44

/*      */     //   Java source line #822    -> byte code offset #56

/*      */     // Local variable table:

/*      */     //   start    length    slot    name    signature

/*      */     //   0    57    0    this    ProxyPlugin

/*      */     //   0    57    1    command    String

/*      */     //   0    57    2    parser    CommandParser

/*      */     //   44    11    3    localObject    Object

/*      */     // Exception table:

/*      */     //   from    to    target    type

/*      */     //   9    32    44    finally

/*      */   }

/*      */   

/*      */   class ReceivedMessage

/*      */     implements Runnable

/*      */   {

/*      */     Message message;

/*      */     int flags;

/*      */     

/*      */     ReceivedMessage(Message message, int flags)

/*      */     {

/*  669 */       this.message = message;

/*  670 */       this.flags = flags;

/*      */     }

/*      */     

/*      */     public void run() {

/*  674 */       ProxyPlugin.this.callEngineOnMessage(this.message, this.flags);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public class PluginMessageCallback

/*      */     implements atavism.msgsys.MessageCallback

/*      */   {

/*      */     public PluginMessageCallback() {}

/*      */     

/*      */

/*      */     public void handleMessage(Message message, int flags)

/*      */     {

/*  688 */       this.executor.execute(new ProxyPlugin.ReceivedMessage(ProxyPlugin.this, message, flags));

/*      */     }

/*      */     

/*  691 */     java.util.concurrent.ExecutorService executor = java.util.concurrent.Executors.newSingleThreadExecutor();

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public class PlayerMessageCallback

/*      */     implements atavism.msgsys.MessageCallback

/*      */   {

/*      */     public PlayerMessageCallback() {}

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void handleMessage(Message message, int flags)

/*      */     {

/*  718 */       if ((message instanceof TargetMessage)) {

/*  719 */         if (message.getMsgType() == WorldManagerClient.MSG_TYPE_TARGETED_PROPERTY) {

/*  720 */           ProxyPlugin.this.countMsgTargetedProperty.add();

/*      */         }

/*      */         

/*  723 */         OID playerOid = ((TargetMessage)message).getTarget();

/*  724 */         Player player = ProxyPlugin.this.playerManager.getPlayer(playerOid);

/*  725 */         if (player == null) {

/*  726 */           Log.debug("TargetMessage: player " + playerOid + " not found");

/*      */           

/*  728 */           if (message.isRPC()) {

/*  729 */             if (message.getMsgType() == InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ) {

/*  730 */               Engine.getAgent().sendBooleanResponse(message,

/*  731 */                 Boolean.valueOf(false));

/*  732 */             } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_PLAYER_IGNORE_LIST_REQ) {

/*  733 */               Engine.getAgent().sendObjectResponse(message, null);

/*  734 */             } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_GET_PLAYER_LOGIN_STATUS) {

/*  735 */               Engine.getAgent().sendObjectResponse(message, null);

/*  736 */             } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_LOGOUT_PLAYER) {

/*  737 */               Engine.getAgent().sendObjectResponse(message, null);

/*      */             } else {

/*  739 */               throw new RuntimeException("Unexpected RPC message " + message + " for player " + player);

/*      */             }

/*      */           }

/*      */         }

/*      */         else

/*      */         {

/*  745 */           message.setEnqueueTime();

/*      */           

/*  747 */           ProxyPlugin.this.messageQQ.insert(player, message);

/*      */         }

/*  749 */         return; }

/*  750 */       if ((message instanceof atavism.msgsys.SubjectMessage))

/*      */       {

/*  752 */         List<Player> perceivers = ProxyPlugin.this.playerManager.getPerceivers(((atavism.msgsys.SubjectMessage)message).getSubject());

/*  753 */         if (perceivers == null) {

/*  754 */           Log.warn("No perceivers for " + message);

/*  755 */           return;

/*      */         }

/*  757 */         if ((message instanceof WorldManagerClient.UpdateWorldNodeMessage)) {

/*  758 */           WorldManagerClient.UpdateWorldNodeMessage wMsg = (WorldManagerClient.UpdateWorldNodeMessage)message;

/*      */           

/*  760 */           DirLocOrientEvent dloEvent = new DirLocOrientEvent(wMsg.getSubject(), wMsg.getWorldNode());

/*  761 */           wMsg.setEventBuf(dloEvent.toBytes());

/*      */         }

/*      */         

/*      */

/*  765 */         if (message.getMsgType() == WorldManagerClient.MSG_TYPE_UPDATEWNODE) {

/*  766 */           ProxyPlugin.this.countMsgUpdateWNodeIn.add();

/*  767 */           ProxyPlugin.this.countMsgUpdateWNodeOut.add(perceivers.size());

/*  768 */         } else if (message.getMsgType() == PropertyMessage.MSG_TYPE_PROPERTY) {

/*  769 */           ProxyPlugin.this.countMsgPropertyIn.add();

/*  770 */           ProxyPlugin.this.countMsgPropertyOut.add(perceivers.size());

/*  771 */         } else if (message.getMsgType() == WorldManagerClient.MSG_TYPE_WNODECORRECT) {

/*  772 */           ProxyPlugin.this.countMsgWNodeCorrectIn.add();

/*  773 */           ProxyPlugin.this.countMsgWNodeCorrectOut.add(perceivers.size());

/*  774 */         } else if (message.getMsgType() == WorldManagerClient.MSG_TYPE_MOB_PATH) {

/*  775 */           ProxyPlugin.this.countMsgMobPathIn.add();

/*  776 */           ProxyPlugin.this.countMsgMobPathOut.add(perceivers.size());

/*      */         }

/*  778 */       } else { if ((message instanceof PerceptionMessage)) {

/*  779 */           PerceptionMessage pMsg = (PerceptionMessage)message;

/*  780 */           ProxyPlugin.this.countMsgPerception.add();

/*  781 */           ProxyPlugin.this.countMsgPerceptionGain.add(pMsg.getGainObjectCount());

/*  782 */           ProxyPlugin.this.countMsgPerceptionLost.add(pMsg.getLostObjectCount());

/*      */           

/*  784 */           OID playerOid = pMsg.getTarget();

/*  785 */           Log.debug("PERCEP: got perception message with player: " + playerOid);

/*  786 */           Player player = ProxyPlugin.this.playerManager.getPlayer(playerOid);

/*  787 */           if (player == null) {

/*  788 */             Log.debug("PerceptionMessage: player " + playerOid + " not found");

/*      */           } else {

/*  790 */             message.setEnqueueTime();

/*  791 */             ProxyPlugin.this.messageQQ.insert(player, message);

/*  792 */             Log.debug("PERCEP: added perception message to messageQQ: ");

/*      */           }

/*  794 */           return;

/*      */         }

/*  796 */         Log.error("PlayerMessageCallback unknown type=" + message.getMsgType()); return;

/*      */       }

/*      */       

/*      */       List<Player> perceivers;

/*  800 */       message.setEnqueueTime();

/*  801 */       ProxyPlugin.this.messageQQ.insert(perceivers, message);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void registerCommand(String command, CommandParser parser, CommandAccessCheck access)

/*      */   {

/*  836 */     this.commandMapLock.lock();

/*      */     try {

/*  838 */       this.commandMap.put(command, new RegisteredCommand(parser, access));

/*      */     } finally {

/*  840 */       this.commandMapLock.unlock();

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public static abstract interface CommandParser

/*      */   {

/*      */     public abstract void parse(CommandEvent paramCommandEvent);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public static abstract interface CommandAccessCheck

/*      */   {

/*      */     public abstract boolean allowed(CommandEvent paramCommandEvent, ProxyPlugin paramProxyPlugin);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   private static class RegisteredCommand

/*      */   {

/*      */     public ProxyPlugin.CommandParser parser;

/*      */     

/*      */     public ProxyPlugin.CommandAccessCheck access;

/*      */     

/*      */

/*      */     public RegisteredCommand(ProxyPlugin.CommandParser p, ProxyPlugin.CommandAccessCheck a)

/*      */     {

/*  869 */       this.parser = p;

/*  870 */       this.access = a;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*  878 */   protected Lock commandMapLock = atavism.server.util.LockFactory.makeLock("CommandMapLock");

/*      */   

/*  880 */   Map<String, RegisteredCommand> commandMap = new HashMap();

/*      */   

/*  882 */   CommandAccessCheck defaultCommandAccess = new DefaultCommandAccess(null);

/*      */   

/*      */   private static class DefaultCommandAccess implements ProxyPlugin.CommandAccessCheck {

/*      */     public boolean allowed(CommandEvent event, ProxyPlugin proxy) {

/*  886 */       return true;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   void registerHooks()

/*      */   {

/*  895 */     log.debug("registering hooks");

/*      */     

/*  897 */     getHookManager().addHook(atavism.agis.plugins.SocialClient.MSG_TYPE_BLOCK_LIST, new BlockListHook());

/*      */     

/*  899 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_DISPLAY_CONTEXT, new DisplayContextHook());

/*  900 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_DETACH, new DetachHook());

/*  901 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_ANIMATION, new AnimationHook());

/*  902 */     getHookManager().addHook(atavism.agis.plugins.AnimationClient.MSG_TYPE_INVOKE_EFFECT, new InvokeEffectHook());

/*  903 */     getHookManager().addHook(PropertyMessage.MSG_TYPE_PROPERTY, new PropertyHook());

/*  904 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_EXTENSION, new ExtensionHook());

/*  905 */     getHookManager().addHook(CombatClient.MSG_TYPE_ABILITY_STATUS, new AbilityStatusHook());

/*  906 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_TARGETED_PROPERTY, new TargetedPropertyHook());

/*  907 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_PERCEPTION_INFO, new PerceptionHook());

/*  908 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_COM, new ComHook());

/*      */     

/*  910 */     getHookManager().addHook(CombatClient.MSG_TYPE_DAMAGE, new DamageHook());

/*  911 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_SYS_CHAT, new SysChatHook());

/*  912 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_UPDATEWNODE, new UpdateWNodeHook());

/*  913 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_MOB_PATH, new UpdateMobPathHook());

/*  914 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_WNODECORRECT, new WNodeCorrectHook());

/*  915 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_ORIENT, new OrientHook());

/*  916 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_SOUND, new SoundHook());

/*  917 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_FOG, new FogHook());

/*  918 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_ROAD, new RoadHook());

/*  919 */     getHookManager().addHook(InventoryClient.MSG_TYPE_INV_UPDATE, new InvUpdateHook());

/*  920 */     getHookManager().addHook(CombatClient.MSG_TYPE_ABILITY_UPDATE, new AbilityUpdateHook());

/*  921 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_NEW_DIRLIGHT, new NewDirLightHook());

/*  922 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_FREE_OBJECT, new FreeObjectHook());

/*  923 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_SET_AMBIENT, new SetAmbientHook());

/*  924 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_P2P_EXTENSION, new P2PExtensionHook());

/*  925 */     getHookManager().addHook(MSG_TYPE_VOICE_PARMS, new VoiceParmsHook());

/*  926 */     getHookManager().addHook(MSG_TYPE_PLAYER_PATH_REQ, new PlayerPathReqHook());

/*  927 */     getHookManager().addHook(InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ, new InstanceEntryReqHook());

/*  928 */     getHookManager().addHook(atavism.management.Management.MSG_TYPE_GET_PLUGIN_STATUS, new GetPluginStatusHook());

/*  929 */     getHookManager().addHook(MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST, new UpdatePlayerIgnoreListHook());

/*  930 */     getHookManager().addHook(MSG_TYPE_GET_MATCHING_PLAYERS, new GetMatchingPlayersHook());

/*  931 */     getHookManager().addHook(MSG_TYPE_PLAYER_IGNORE_LIST_REQ, new PlayerIgnoreListReqHook());

/*  932 */     getHookManager().addHook(MSG_TYPE_GET_PLAYER_LOGIN_STATUS, new GetPlayerLoginStatusHook(null));

/*  933 */     getHookManager().addHook(MSG_TYPE_LOGOUT_PLAYER, new LogoutPlayerHook(null));

/*  934 */     getHookManager().addHook(MSG_TYPE_ADD_STATIC_PERCEPTION, new AddStaticPerceptionHook(null));

/*  935 */     getHookManager().addHook(MSG_TYPE_REMOVE_STATIC_PERCEPTION, new RemoveStaticPerceptionHook(null));

/*  936 */     getHookManager().addHook(MSG_TYPE_ACCOUNT_LOGIN, new AccountLoginHook(null));

/*      */   }

/*      */   

/*      */   class MatchedMessage { final Long sub;

/*      */     

/*  941 */     MatchedMessage(Long sub, Message message) { this.sub = sub;

/*  942 */       this.message = message;

/*  943 */       this.enqueueTime = System.currentTimeMillis();

/*      */     }

/*      */     

/*      */     public String toString() {

/*  947 */       return "MatchedMessage[subId=" + this.sub + ", enqueueTime=" + this.enqueueTime + ",msg=" + this.message;

/*      */     }

/*      */     

/*      */

/*      */     final Message message;

/*      */     final long enqueueTime;

/*      */   }

/*      */   

/*  955 */   private static final Player loginSerializer = new Player(null, null);

/*      */   

/*      */   void callEngineOnMessage(Message message, int flags) {

/*  958 */     super.handleMessage(message, flags);

/*      */   }

/*      */   

/*      */

/*      */   protected void initializeVoiceServerInformation()

/*      */   {

/*  964 */     voiceServerHost = Engine.properties.getProperty("atavism.voiceserver");

/*  965 */     String s = Engine.properties.getProperty("atavism.voiceport");

/*  966 */     if (s != null) {

/*  967 */       voiceServerPort = Integer.valueOf(Integer.parseInt(s));

/*      */     }

/*  969 */     if (Log.loggingDebug) {

/*  970 */       log.debug("initializeVoiceServerInformation: voiceServerHost " + voiceServerHost + ", voiceServerPort " + voiceServerPort);

/*      */     }

/*      */   }

/*      */   

/*      */   class MessageCallback

/*      */     implements atavism.server.util.SQCallback

/*      */   {

/*      */     protected ProxyPlugin proxyPlugin;

/*      */     

/*      */     public MessageCallback(ProxyPlugin proxyPlugin)

/*      */     {

/*  981 */       this.proxyPlugin = proxyPlugin;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void doWork(Object value, Object key)

/*      */     {

/*  997 */       Message message = (Message)value;

/*  998 */       Player player = (Player)key;

/*      */       

/*      */

/* 1001 */       if (message == null) {

/* 1002 */         Log.dumpStack("DOMESSAGE: Message for oid=" + player.getOid() + " is not a Message: " + value);

/* 1003 */         return;

/*      */       }

/*      */       

/* 1006 */       if ((message instanceof ProxyPlugin.ConnectionResetMessage)) {

/* 1007 */         if (player == ProxyPlugin.loginSerializer) {

/* 1008 */           ProxyPlugin.this.processConnectionResetInternal((ProxyPlugin.ConnectionResetMessage)message);

/*      */         } else {

/* 1010 */           ProxyPlugin.this.messageQQ.insert(ProxyPlugin.loginSerializer, message);

/*      */         }

/* 1012 */         return;

/*      */       }

/*      */       

/*      */

/*      */

/* 1017 */       int status = player.getStatus();

/* 1018 */       if ((status == 3) || (status == 0))

/*      */       {

/* 1020 */         Log.debug(

/* 1021 */           "Ignoring message: id=" + message.getMsgId() + " type=" + message.getMsgType() + " for " + player);

/* 1022 */         if (message.isRPC()) {

/* 1023 */           if (message.getMsgType() == InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ) {

/* 1024 */             Engine.getAgent().sendBooleanResponse(message, Boolean.valueOf(false));

/* 1025 */           } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_PLAYER_IGNORE_LIST_REQ) {

/* 1026 */             Engine.getAgent().sendObjectResponse(message, null);

/* 1027 */           } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_GET_PLAYER_LOGIN_STATUS) {

/* 1028 */             Engine.getAgent().sendObjectResponse(message, null);

/* 1029 */           } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_LOGOUT_PLAYER) {

/* 1030 */             Engine.getAgent().sendObjectResponse(message, null);

/*      */           } else {

/* 1032 */             throw new RuntimeException("Unexpected RPC message " + message + " for player " + player);

/*      */           }

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1045 */         return;

/*      */       }

/*      */       try

/*      */       {

/* 1049 */         long inQueue = 0L;

/* 1050 */         if (Log.loggingDebug) {

/* 1051 */           inQueue = System.nanoTime() - message.getEnqueueTime();

/* 1052 */           Log.debug("DOINGSVRMESSAGE: Message for oid=" + player.getOid() + ",msgId=" + message.getMsgId() + ",in-queue=" + inQueue / 1000L + " usec: " + message

/* 1053 */             .getMsgType());

/*      */         }

/* 1055 */         if ((Log.loggingInfo) && (ProxyPlugin.this.proxyQueueHistogram != null)) {

/* 1056 */           ProxyPlugin.this.proxyQueueHistogram.addTime(inQueue);

/*      */         }

/*      */         

/* 1059 */         List<atavism.server.engine.Hook> hooks = ProxyPlugin.this.getHookManager().getHooks(message

/* 1060 */           .getMsgType());

/* 1061 */         long callbackStart = System.nanoTime();

/*      */         

/* 1063 */         for (atavism.server.engine.Hook hook : hooks) {

/* 1064 */           ((ProxyHook)hook).processMessage(message, 0, player);

/*      */         }

/* 1066 */         long callbackTime = 0L;

/* 1067 */         if ((Log.loggingDebug) || (Log.loggingInfo)) {

/* 1068 */           callbackTime = System.nanoTime() - callbackStart;

/*      */         }

/* 1070 */         if (Log.loggingDebug) {

/* 1071 */           Log.debug(

/* 1072 */             "DONESVRMESSAGE: Message for oid=" + player.getOid() + ",msgId=" + message.getMsgId() + ",in-queue=" + inQueue / 1000L + " usec: ,execute=" + callbackTime / 1000L + " usec: " + message.getMsgType());

/*      */         }

/* 1074 */         if ((Log.loggingInfo) && (ProxyPlugin.this.proxyCallbackHistogram != null)) {

/* 1075 */           ProxyPlugin.this.proxyCallbackHistogram.addTime(callbackTime);

/*      */         }

/*      */       } catch (Exception ex) {

/* 1078 */         Log.exception("SQ MessageCallback", ex);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1088 */   SquareQueue<Player, Message> messageQQ = new SquareQueue("Message");

/*      */   

/* 1090 */   atavism.server.util.SQThreadPool messageThreadPool = new atavism.server.util.SQThreadPool(this.messageQQ, new MessageCallback(this));

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void acceptConnection(ClientConnection con)

/*      */   {

/* 1100 */     Log.info("ProxyPlugin: CONNECTION remote=" + con);

/* 1101 */     con.registerMessageCallback(this);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void processPacket(ClientConnection con, AOByteBuffer buf)

/*      */   {

/*      */     try

/*      */     {

/* 1114 */       if (Log.loggingNet) {

/* 1115 */         if (ClientConnection.getLogMessageContents()) {

/* 1116 */           Log.net("ProxyPlugin.processPacket: con " + con + ", length " + buf.limit() + ", packet " + atavism.server.util.DebugUtils.byteArrayToHexString(buf));

/*      */         } else {

/* 1118 */           Log.net("ProxyPlugin.processPacket: con " + con + ", buf " + buf);

/*      */         }

/*      */       }

/* 1121 */       Event event = Engine.getEventServer().parseBytes(buf, con);

/* 1122 */       if (event == null) {

/* 1123 */         Log.error("Engine: could not parse packet data, remote=" + con);

/* 1124 */         return;

/*      */       }

/*      */       

/* 1127 */       Player player = (Player)con.getAssociation();

/* 1128 */       if (player == null) {

/* 1129 */         player = loginSerializer;

/* 1130 */         if ((event instanceof AuthorizedLoginEvent)) {

/* 1131 */           Log.info("ProxyPlugin: LOGIN_RECV remote=" + con + " playerOid=" + ((AuthorizedLoginEvent)event).getOid());

/*      */         }

/*      */       }

/* 1134 */       this.playerManager.processEvent(player, event, this.eventQQ);

/*      */     }

/*      */     catch (AORuntimeException e) {

/* 1137 */       Log.exception("ProxyPlugin.processPacket caught exception", e);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public class EventCallback

/*      */     implements atavism.server.util.SQCallback

/*      */   {

/*      */     public EventCallback() {}

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void doWork(Object value, Object key)

/*      */     {

/* 1158 */       Event event = (Event)value;

/* 1159 */       if (event == null) {

/* 1160 */         Log.dumpStack("EventCallback.doWork: event object is null, for key " + key);

/* 1161 */         return;

/*      */       }

/*      */       try {

/* 1164 */         ClientConnection con = event.getConnection();

/* 1165 */         Player player = (Player)key;

/*      */         

/*      */

/*      */

/* 1169 */         long startTime = System.currentTimeMillis();

/* 1170 */         long inQueue = startTime - event.getEnqueueTime();

/* 1171 */         Log.info("ProxyPlugin: EventCallback doWork  value" + value + " key=" + key + " in-queue=" + inQueue + " ms player:" + player);

/*      */         

/* 1173 */         if ((player == ProxyPlugin.loginSerializer) && ((event instanceof AuthorizedLoginEvent))) {

/* 1174 */           AuthorizedLoginEvent loginEvent = (AuthorizedLoginEvent)event;

/* 1175 */           OID playerOid = loginEvent.getOid();

/*      */           

/* 1177 */           Log.info("ProxyPlugin: LOGIN_BEGIN remote=" + con + " playerOid=" + playerOid + " in-queue=" + inQueue + " ms");

/*      */           

/* 1179 */           boolean loginOK = ProxyPlugin.this.processLogin(con, loginEvent);

/*      */           

/* 1181 */           Player newPlayer = ProxyPlugin.this.playerManager.getPlayer(playerOid);

/* 1182 */           String playerName = null;

/* 1183 */           if (newPlayer != null)

/* 1184 */             playerName = newPlayer.getName();

/* 1185 */           Log.info(

/* 1186 */             "ProxyPlugin: LOGIN_END remote=" + con + (loginOK ? " SUCCESS " : " FAILURE ") + " playerOid=" + playerOid + " name=" + playerName + " in-queue=" + inQueue + " ms processing=" + (System.currentTimeMillis() - startTime) + " ms nPlayers=" + ProxyPlugin.this.playerManager.getPlayerCount());

/* 1187 */           return;

/*      */         }

/*      */         

/* 1190 */         if (player == ProxyPlugin.loginSerializer) {

/* 1191 */           Log.error("ClientEvent: Illegal event for loginSerializer: " + event.getClass().getName() + ", con=" + con);

/* 1192 */           return;

/*      */         }

/*      */         

/* 1195 */         if (Log.loggingDebug)

/* 1196 */           Log.debug("ClientEvent: player=" + player + ", in-queue=" + inQueue + " ms: " + event.getName());

/* 1197 */         if ((Log.loggingInfo) && (inQueue > 2000L)) {

/* 1198 */           Log.info("LONG IN-QUEUE: " + inQueue + " ms: player=" + player + " " + event.getName());

/*      */         }

/*      */         

/* 1201 */         Lock objLock = ProxyPlugin.this.getObjectLockManager().getLock(player.getOid());

/* 1202 */         objLock.lock();

/*      */         try {

/* 1204 */           if (Log.loggingDebug)

/* 1205 */             Log.debug("ClientEvent: event detail: " + event);

/* 1206 */           if ((event instanceof ComEvent)) {

/* 1207 */             ProxyPlugin.this.processCom(con, (ComEvent)event);

/* 1208 */           } else if ((event instanceof DirLocOrientEvent)) {

/* 1209 */             ProxyPlugin.this.processDirLocOrient(con, (DirLocOrientEvent)event);

/* 1210 */           } else if ((event instanceof CommandEvent)) {

/* 1211 */             ProxyPlugin.this.processCommand(con, (CommandEvent)event);

/* 1212 */           } else if ((event instanceof AutoAttackEvent)) {

/* 1213 */             ProxyPlugin.this.processAutoAttack(con, (AutoAttackEvent)event);

/* 1214 */           } else if ((event instanceof ExtensionMessageEvent)) {

/* 1215 */             ProxyPlugin.this.processExtensionMessageEvent(con, (ExtensionMessageEvent)event);

/*      */           }

/* 1217 */           else if ((event instanceof atavism.agis.events.AbilityStatusEvent)) {

/* 1218 */             ProxyPlugin.this.processAbilityStatusEvent(con, (atavism.agis.events.AbilityStatusEvent)event);

/*      */           }

/* 1220 */           else if ((event instanceof atavism.agis.events.RequestQuestInfo)) {

/* 1221 */             ProxyPlugin.this.processRequestQuestInfo(con, (atavism.agis.events.RequestQuestInfo)event);

/* 1222 */           } else if ((event instanceof QuestResponse)) {

/* 1223 */             ProxyPlugin.this.processQuestResponse(con, (QuestResponse)event);

/* 1224 */           } else if ((event instanceof atavism.agis.events.ConcludeQuest)) {

/* 1225 */             ProxyPlugin.this.processReqConcludeQuest(con, (atavism.agis.events.ConcludeQuest)event);

/* 1226 */           } else if ((event instanceof ActivateItemEvent)) {

/* 1227 */             ProxyPlugin.this.processActivateItem(con, (ActivateItemEvent)event);

/* 1228 */           } else if ((event instanceof atavism.server.events.LogoutEvent)) {

/* 1229 */             ProxyPlugin.this.processLogout(con, (atavism.server.events.LogoutEvent)event);

/* 1230 */           } else if ((event instanceof atavism.server.events.SceneLoadedEvent)) {

/* 1231 */             ProxyPlugin.this.processSceneLoaded(con, (atavism.server.events.SceneLoadedEvent)event);

/*      */           } else {

/* 1233 */             throw new RuntimeException("Unknown event: " + event);

/*      */           }

/* 1235 */           long elapsed = System.currentTimeMillis() - startTime;

/* 1236 */           if (Log.loggingDebug) {

/* 1237 */             Log.debug("ClientEvent: processed event " + event + ", player=" + player + ", processing=" + elapsed + " ms");

/*      */             

/*      */

/* 1240 */             ProxyPlugin.this.clientMsgMeter.add(Long.valueOf(elapsed));

/*      */           }

/* 1242 */           if (elapsed > 2000L) {

/* 1243 */             Log.info(

/* 1244 */               "LONG PROCESS: " + elapsed + " ms: player=" + player + " " + event.getName());

/*      */           }

/*      */         } catch (Exception e) {

/* 1247 */           throw new RuntimeException("ProxyPlugin.EventCallback " + event + " processing error ", e);

/*      */         } finally {

/* 1249 */           objLock.unlock();

/*      */         }

/*      */       } catch (Exception e) {

/* 1252 */         throw new RuntimeException("ProxyPlugin.EventCallback " + event + " ", e);

/*      */       }

/* 1254 */       ProxyPlugin.log.debug("ProxyPlugin.EventCallback " + event + " doWork End");

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/* 1261 */   SquareQueue<Player, Event> eventQQ = new SquareQueue("Event");

/*      */   

/* 1263 */   atavism.server.util.SQThreadPool eventThreadPool = new atavism.server.util.SQThreadPool(this.eventQQ, new EventCallback());

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public Set<OID> getPlayerOids()

/*      */   {

/* 1272 */     List<Player> players = new ArrayList(this.playerManager.getPlayerCount());

/* 1273 */     this.playerManager.getPlayers(players);

/* 1274 */     Set<OID> result = new HashSet(players.size());

/* 1275 */     for (Player player : players) {

/* 1276 */       result.add(player.getOid());

/*      */     }

/* 1278 */     return result;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public List<String> getPlayerNames()

/*      */   {

/* 1287 */     List<Player> players = new ArrayList(this.playerManager.getPlayerCount());

/* 1288 */     Log.debug("ProxyPlugin.getPlayerNames: count is " + this.playerManager.getPlayerCount());

/* 1289 */     this.playerManager.getPlayers(players);

/* 1290 */     List<String> result = new ArrayList(players.size());

/* 1291 */     for (Player player : players) {

/* 1292 */       result.add(player.getName());

/*      */     }

/* 1294 */     return result;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public List<Player> getPlayers()

/*      */   {

/* 1302 */     List<Player> players = new ArrayList(this.playerManager.getPlayerCount());

/* 1303 */     this.playerManager.getPlayers(players);

/* 1304 */     return players;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public Player getPlayer(OID oid)

/*      */   {

/* 1314 */     return this.playerManager.getPlayer(oid);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public void addPlayerMessage(Message message, Player player)

/*      */   {

/* 1321 */     message.setEnqueueTime();

/* 1322 */     this.messageQQ.insert(player, message);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addFilteredProperty(String filteredProperty)

/*      */   {

/* 1333 */     this.filteredProps.add(filteredProperty);

/* 1334 */     this.cachedPlayerSpecificFilterProps.add(filteredProperty);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addPlayerSpecificProperty(String filteredProperty)

/*      */   {

/* 1346 */     this.playerSpecificProps.add(filteredProperty);

/* 1347 */     this.cachedPlayerSpecificFilterProps.add(filteredProperty);

/*      */   }

/*      */   

/*      */   protected void recreatePlayerSpecificCache() {

/* 1351 */     this.cachedPlayerSpecificFilterProps = new HashSet();

/* 1352 */     this.cachedPlayerSpecificFilterProps.addAll(this.filteredProps);

/* 1353 */     this.cachedPlayerSpecificFilterProps.addAll(this.playerSpecificProps);

/*      */   }

/*      */   

/* 1356 */   atavism.server.util.AOMeter clientMsgMeter = new atavism.server.util.AOMeter("ClientEventProcessorMeter");

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean processLogin(ClientConnection con, AuthorizedLoginEvent loginEvent)

/*      */   {

/* 1371 */     OID playerOid = loginEvent.getOid();

/*      */     

/* 1373 */     String version = loginEvent.getVersion();

/* 1374 */     int nPlayers = this.playerManager.getPlayerCount();

/*      */     

/* 1376 */     String[] clientVersionCapabilities = null;

/* 1377 */     if ((version != null) && (version.length() > 0)) {

/* 1378 */       clientVersionCapabilities = version.split(",");

/*      */     }

/* 1380 */     LinkedList<String> clientCapabilities = new LinkedList();

/* 1381 */     String clientVersion = "";

/* 1382 */     if ((clientVersionCapabilities != null) && (clientVersionCapabilities.length > 0)) {

/* 1383 */       clientVersion = clientVersionCapabilities[0];

/* 1384 */       for (int i = 1; i < clientVersionCapabilities.length; i++) {

/* 1385 */         clientCapabilities.add(clientVersionCapabilities[i].trim());

/*      */       }

/*      */     }

/*      */     

/* 1389 */     int versionCompare = atavism.server.util.ServerVersion.compareVersionStrings(clientVersion, "2018.3.1");

/* 1390 */     if ((versionCompare != 1) && (versionCompare != 0)) {

/* 1391 */       Log.warn("processLogin: unsupported version " + clientVersion + " from player: " + playerOid);

/* 1392 */       AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed: Unsupported client version", this.serverVersion);

/* 1393 */       con.send(loginResponse.toBytes());

/* 1394 */       return false;

/*      */     }

/*      */     

/*      */

/* 1398 */     if ((!isAdmin(playerOid)) || (nPlayers >= this.connectionLimit)) {

/* 1399 */       Log.debug("processLogin: player is not admin");

/* 1400 */       if ((nPlayers >= MaxConcurrentUsers) || (nPlayers >= this.connectionLimit)) {

/* 1401 */         Log.warn("processLogin: too many users, failed for player: " + playerOid);

/* 1402 */         Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, this.capacityError, this.serverVersion);

/* 1403 */         con.send(loginResponse.toBytes());

/* 1404 */         return false;

/*      */       }

/*      */     } else {

/* 1407 */       Log.debug("processLogin: player is admin, bypassing max check");

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 1413 */     atavism.server.util.SecureToken token = atavism.server.util.SecureTokenManager.getInstance().importToken(loginEvent.getWorldToken());

/* 1414 */     boolean validToken = true;

/* 1415 */     if (!token.getValid()) {

/* 1416 */       Log.debug("token is not valid");

/* 1417 */       validToken = false;

/*      */     }

/* 1419 */     OID characterOid = (OID)token.getProperty("character_oid");

/* 1420 */     Log.debug("PlayerOID: " + playerOid);

/* 1421 */     Log.debug("CharacterOID: " + characterOid);

/* 1422 */     if (!playerOid.equals(characterOid)) {

/* 1423 */       Log.debug("playerOid does not match character_oid");

/* 1424 */       validToken = false;

/*      */     }

/* 1426 */     if (!token.getProperty("proxy_server").equals(Engine.getAgent().getName())) {

/* 1427 */       Log.debug("proxy_server does not match engine agent name");

/* 1428 */       validToken = false;

/*      */     }

/* 1430 */     if (!validToken) {

/* 1431 */       Log.error("processLogin: invalid proxy token");

/* 1432 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, this.tokenError, this.serverVersion);

/* 1433 */       con.send(loginResponse.toBytes());

/* 1434 */       return false;

/*      */     }

/*      */     try

/*      */     {

/* 1438 */       TargetMessage getPlayerLoginStatus = new TargetMessage(MSG_TYPE_GET_PLAYER_LOGIN_STATUS, playerOid);

/*      */       

/* 1440 */       PlayerLoginStatus loginStatus = (PlayerLoginStatus)Engine.getAgent().sendRPCReturnObject(getPlayerLoginStatus);

/* 1441 */       if (this.proxyLoginCallback.duplicateLogin(loginStatus, con)) {

/* 1442 */         if (loginStatus != null) {

/* 1443 */           Log.info("processLogin: LOGIN_DUPLICATE remote=" + con + " playerOid=" + playerOid + " name=" + loginStatus.name + " existingCon=" + loginStatus.clientCon + " existingProxy=" + loginStatus.proxyPluginName);

/*      */         }

/*      */         else {

/* 1446 */           Log.info("processLogin: LOGIN_DUPLICATE remote=" + con + " playerOid=" + playerOid + " loginStatus is null");

/*      */         }

/* 1448 */         AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed: Already connected", this.serverVersion);

/* 1449 */         con.send(loginResponse.toBytes());

/* 1450 */         return false;

/*      */       }

/*      */     } catch (atavism.msgsys.NoRecipientsException e) {

/* 1453 */       log.debug("processLogin: OK! player is not logged " + e);

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1469 */     Player player = new Player(playerOid, con);

/* 1470 */     player.setStatus(1);

/* 1471 */     if (!this.playerManager.addPlayer(player))

/*      */     {

/* 1473 */       player = this.playerManager.getPlayer(playerOid);

/* 1474 */       Log.info("processLogin: LOGIN_DUPLICATE remote=" + con + " playerOid=" + playerOid + " existing=" + player.getConnection());

/* 1475 */       AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed: Already connected", this.serverVersion);

/*      */       

/*      */

/* 1478 */       con.send(loginResponse.toBytes());

/* 1479 */       return false;

/*      */     }

/* 1481 */     con.setAssociation(player);

/*      */     

/* 1483 */     player.setVersion(clientVersion);

/* 1484 */     player.setCapabilities(clientCapabilities);

/*      */     

/* 1486 */     String errorMessage = this.proxyLoginCallback.preLoad(player, con);

/* 1487 */     if (errorMessage != null) {

/* 1488 */       this.playerManager.removePlayer(playerOid);

/* 1489 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, errorMessage, this.serverVersion);

/*      */       

/* 1491 */       con.send(loginResponse.toBytes());

/* 1492 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 1498 */     if (Log.loggingDebug) {

/* 1499 */       Log.debug("processLogin: loading object: " + playerOid + ", con=" + con);

/*      */     }

/* 1501 */     if (!loadPlayerObject(player)) {

/* 1502 */       Log.error("processLogin: could not load object " + playerOid);

/* 1503 */       this.playerManager.removePlayer(playerOid);

/* 1504 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed", this.serverVersion);

/* 1505 */       con.send(loginResponse.toBytes());

/* 1506 */       return false;

/*      */     }

/* 1508 */     if (Log.loggingDebug) {

/* 1509 */       Log.debug("processLogin: loaded player object: " + playerOid);

/*      */     }

/*      */     

/* 1512 */     errorMessage = this.proxyLoginCallback.postLoad(player, con);

/* 1513 */     if (errorMessage != null) {

/* 1514 */       this.playerManager.removePlayer(playerOid);

/* 1515 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, errorMessage, this.serverVersion);

/* 1516 */       con.send(loginResponse.toBytes());

/* 1517 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 1523 */     AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, true, "Login Succeeded", this.serverVersion + ", " + this.serverCapabilitiesSentToClient);

/* 1524 */     con.send(loginResponse.toBytes());

/* 1525 */     if (Log.loggingDebug) {

/* 1526 */       Log.debug("Login response sent for playerOid=" + playerOid + " the authorized login response message is : " + loginResponse.getMessage());

/*      */     }

/*      */     

/*      */

/*      */

/* 1531 */     this.playerManager.addStaticPerception(player, playerOid);

/*      */     

/* 1533 */     boolean loginOK = processLoginHelper(con, player);

/* 1534 */     if (!loginOK)

/*      */     {

/*      */

/*      */

/*      */

/*      */

/* 1540 */       if (Log.loggingDebug) {

/* 1541 */         Log.debug("processLogin: loading object: " + playerOid + ", con=" + con + " login failed disconect player");

/*      */       }

/*      */       

/* 1544 */       con.setAssociation(null);

/* 1545 */       if (this.perceptionFilter.removeTarget(playerOid)) {

/* 1546 */         FilterUpdate filterUpdate = new FilterUpdate(1);

/* 1547 */         filterUpdate.removeFieldValue(1, playerOid);

/* 1548 */         Engine.getAgent().applyFilterUpdate(this.perceptionSubId, filterUpdate);

/* 1549 */         this.responderFilter.removeTarget(playerOid);

/* 1550 */         Engine.getAgent().applyFilterUpdate(this.responderSubId, filterUpdate);

/*      */       }

/* 1552 */       this.playerManager.removeStaticPerception(player, playerOid);

/* 1553 */       this.playerManager.removePlayer(playerOid);

/* 1554 */       con.close();

/*      */     } else {

/* 1556 */       this.proxyLoginCallback.postSpawn(player, con);

/*      */       

/* 1558 */       this.playerManager.loginComplete(player, this.eventQQ);

/*      */       

/* 1560 */       atavism.msgsys.SubjectMessage loginSpawned = new atavism.msgsys.SubjectMessage(MSG_TYPE_LOGIN_SPAWNED);

/* 1561 */       loginSpawned.setSubject(playerOid);

/* 1562 */       Engine.getAgent().sendBroadcast(loginSpawned);

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1569 */       processPlayerIgnoreList(player);

/*      */       

/*      */

/*      */

/* 1573 */       OID accountID = (OID)EnginePlugin.getObjectProperty(playerOid, WorldManagerClient.NAMESPACE, "accountId");

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1585 */       this.clientConnections.put(accountID, con);

/*      */     }

/* 1587 */     log.debug("processLogin: loginOK:" + loginOK + " end");

/* 1588 */     return loginOK;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean loadPlayerObject(Player player)

/*      */   {

/* 1598 */     InstanceRestorePoint restorePoint = null;

/* 1599 */     LinkedList restoreStack = null;

/* 1600 */     boolean first = true;

/* 1601 */     OID playerOid = player.getOid();

/*      */     

/*      */

/* 1604 */     List<Namespace> namespaces = new ArrayList();

/* 1605 */     OID oidResult = ObjectManagerClient.loadSubObject(playerOid, namespaces);

/* 1606 */     if (oidResult == null) {

/* 1607 */       return false;

/*      */     }

/*      */     

/* 1610 */     atavism.server.math.Point location = new atavism.server.math.Point();

/* 1611 */     OID instanceOid = Engine.getDatabase().getLocation(playerOid, WorldManagerClient.NAMESPACE, location);

/* 1612 */     if (Log.loggingDebug) {

/* 1613 */       log.debug("loadPlayerObject instanceOid " + instanceOid + " instanceEntryAllowed:" + instanceEntryAllowed(playerOid, instanceOid, location));

/*      */     }

/* 1615 */     if (Log.loggingDebug)

/* 1616 */       log.debug("POP: trying to load player into instance: " + instanceOid);

/* 1617 */     AccountDatabase aDB = new AccountDatabase(false);

/* 1618 */     int guildID = aDB.GetGuildId(playerOid);

/*      */     try {

/*      */       for (;;) {

/* 1621 */         OID result = null;

/* 1622 */         if (instanceEntryAllowed(playerOid, instanceOid, location)) {

/* 1623 */           InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073);

/* 1624 */           if (Log.loggingDebug) {

/* 1625 */             log.debug("loadPlayerObject InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid + " start do ");

/*      */           }

/*      */           

/*      */

/* 1629 */           if ((instanceInfo.oid != null) && ((instanceInfo.populationLimit < 1) || (instanceInfo.playerPopulation < instanceInfo.populationLimit)))

/*      */           {

/*      */

/* 1632 */             result = ObjectManagerClient.loadObject(playerOid);

/* 1633 */             if (Log.loggingDebug) {

/* 1634 */               Log.debug("POP: loading player into instance: " + instanceInfo.oid + " of ID: " + instanceInfo.templateID);

/*      */             }

/*      */           }

/*      */         }

/*      */         

/* 1639 */         if ((restoreStack != null) && (!restorePoint.getFallbackFlag())) {

/* 1640 */           EnginePlugin.setObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack", restoreStack);

/*      */         }

/*      */         

/* 1643 */         if (result != null) {

/* 1644 */           if (restorePoint == null) break;

/* 1645 */           EnginePlugin.setObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "currentInstanceName", Integer.valueOf(restorePoint.getInstanceID()));

/* 1646 */           if (!Log.loggingDebug) break;

/* 1647 */           log.debug("INSTANCE: setting current instance prop: " + restorePoint.getInstanceID()); break;

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/*      */

/* 1654 */         if (first)

/*      */         {

/* 1656 */           Integer instanceID = (Integer)EnginePlugin.getObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "currentInstanceName");

/* 1657 */           if (Log.loggingDebug)

/* 1658 */             log.debug("Failed initial load, retrying with current instanceID=" + instanceID);

/* 1659 */           if (Log.loggingDebug) {

/* 1660 */             log.debug(" loadPlayerObject " + instanceID + "  " + playerOid);

/*      */           }

/* 1662 */           if (instanceID.intValue() > 0)

/*      */           {

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1673 */             instanceOid = this.instanceEntryCallback.selectInstance(player, instanceID.intValue(), playerOid, guildID);

/* 1674 */             if (Log.loggingDebug)

/* 1675 */               log.debug("loadPlayerObject instanceOid:" + instanceOid);

/* 1676 */             if (instanceOid != null)

/*      */             {

/* 1678 */               InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073, false);

/* 1679 */               if (Log.loggingDebug) {

/* 1680 */                 log.debug(" loadPlayerObject InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid);

/*      */               }

/* 1682 */               if (instanceInfo.oid != null) {

/* 1683 */                 if ((instanceInfo.populationLimit > 0) && (instanceInfo.playerPopulation >= instanceInfo.populationLimit)) {

/* 1684 */                   if (Log.loggingDebug)

/* 1685 */                     Log.debug("POP: got population: " + instanceInfo.playerPopulation + " and limit: " + instanceInfo.populationLimit);

/* 1686 */                   instanceOid = handleFullInstance(instanceInfo.templateID, instanceInfo);

/* 1687 */                   instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073);

/* 1688 */                   log.debug(" loadPlayerObject 2 InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid);

/*      */                 }

/*      */                 

/* 1691 */                 if (Log.loggingDebug)

/* 1692 */                   log.debug("Failed initial load, retrying with instanceOid=" + instanceOid + " and instanceName: " + instanceInfo.name);

/* 1693 */                 BasicWorldNode wnode = new BasicWorldNode();

/* 1694 */                 wnode.setInstanceOid(instanceOid);

/* 1695 */                 ObjectManagerClient.fixWorldNode(playerOid, wnode);

/* 1696 */                 first = false;

/* 1697 */                 continue;

/*      */               }

/*      */             }

/*      */           }

/*      */         }

/*      */         

/*      */

/* 1704 */         if ((restorePoint != null) && (restorePoint.getFallbackFlag())) {

/* 1705 */           if (Log.loggingDebug) {

/* 1706 */             log.debug("loadPlayerObject instanceOid " + instanceOid + " restorePoint:" + restorePoint + " restorePoint.getFallbackFlag():" + restorePoint.getFallbackFlag() + " return false");

/*      */           }

/* 1708 */           return false;

/*      */         }

/*      */         

/*      */

/* 1712 */         restoreStack = (LinkedList)EnginePlugin.getObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack");

/*      */         

/* 1714 */         if ((restoreStack == null) || (restoreStack.size() == 0)) {

/* 1715 */           Log.error("Failed finding matching instance, and restore stack is null or empty?" + restoreStack + " return false");

/* 1716 */           return false;

/*      */         }

/*      */         

/*      */

/* 1720 */         int size = restoreStack.size();

/* 1721 */         restorePoint = (InstanceRestorePoint)restoreStack.get(size - 1);

/*      */         

/* 1723 */         instanceOid = restorePoint.getInstanceOid();

/*      */         

/* 1725 */         if (restorePoint.getInstanceID() > 0) {

/* 1726 */           instanceOid = this.instanceEntryCallback.selectInstance(player, restorePoint.getInstanceID());

/* 1727 */           Log.debug("Failed finding matching instance, retrying with restore point instanceID=" + restorePoint.getInstanceID() + " result: " + instanceOid);

/*      */         }

/*      */         

/* 1730 */         if (instanceOid != null) {

/* 1731 */           BasicWorldNode wnode = new BasicWorldNode();

/* 1732 */           wnode.setInstanceOid(instanceOid);

/*      */           

/* 1734 */           wnode.setLoc(restorePoint.getLoc());

/* 1735 */           wnode.setOrientation(restorePoint.getOrientation());

/* 1736 */           wnode.setDir(new atavism.server.math.AOVector(0.0F, 0.0F, 0.0F));

/*      */           

/* 1738 */           boolean rc = ObjectManagerClient.fixWorldNode(playerOid, wnode);

/*      */           

/* 1740 */           if (!rc) {

/* 1741 */             if (Log.loggingDebug) {

/* 1742 */               log.debug("loadPlayerObject instanceOid " + instanceOid + " rc:" + rc + " return false");

/*      */             }

/* 1744 */             return false;

/*      */           }

/* 1746 */           location = restorePoint.getLoc();

/*      */         }

/* 1748 */         first = false;

/*      */         

/* 1750 */         if (!restorePoint.getFallbackFlag()) {

/* 1751 */           restoreStack.remove(size - 1);

/*      */         }

/*      */       }

/*      */     }

/*      */     catch (Exception e) {

/* 1756 */       log.error("loadPlayerObject instanceOid " + instanceOid + " Exception: " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */     }

/*      */     

/* 1759 */     if (Log.loggingDebug) {

/* 1760 */       log.debug("loadPlayerObject instanceOid " + instanceOid + " END return true");

/*      */     }

/* 1762 */     return true;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean processLoginHelper(ClientConnection con, Player player)

/*      */   {

/* 1776 */     OID playerOid = player.getOid();

/*      */     

/*      */

/*      */

/* 1780 */     WorldManagerClient.ObjectInfo objInfo = WorldManagerClient.getObjectInfo(playerOid);

/* 1781 */     if (Log.loggingDebug)

/* 1782 */       log.debug("processLoginHelper objInfo " + objInfo.instanceOid);

/* 1783 */     if (objInfo == null) {

/* 1784 */       Log.error("processLogin: Could not get player ObjectInfo oid=" + playerOid);

/*      */       

/* 1786 */       return false;

/*      */     }

/*      */     

/* 1789 */     if (atavism.server.objects.World.FollowsTerrainOverride != null) {

/* 1790 */       Log.debug("using follows terrain override");

/* 1791 */       objInfo.followsTerrain = atavism.server.objects.World.FollowsTerrainOverride.booleanValue();

/*      */     }

/* 1793 */     if (Log.loggingDebug) {

/* 1794 */       Log.debug("processLogin: got object info: " + objInfo);

/*      */     }

/* 1796 */     player.setName(objInfo.name);

/*      */     

/* 1798 */     InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(objInfo.instanceOid, -131073);

/*      */     

/* 1800 */     if (Log.loggingDebug)

/* 1801 */       log.debug("InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid);

/* 1802 */     if (instanceInfo == null) {

/* 1803 */       Log.error("processLogin: unknown instanceOid=" + objInfo.instanceOid);

/*      */       

/* 1805 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/* 1812 */     atavism.server.messages.LoginMessage loginMessage = new atavism.server.messages.LoginMessage(playerOid, objInfo.name);

/* 1813 */     loginMessage.setInstanceOid(objInfo.instanceOid);

/* 1814 */     AsyncRPCCallback asyncRPCCallback = new AsyncRPCCallback(player, "processLogin: got LoginMessage response");

/*      */     

/* 1816 */     int expectedResponses = Engine.getAgent().sendBroadcastRPC(loginMessage, asyncRPCCallback);

/*      */     

/* 1818 */     asyncRPCCallback.waitForResponses(expectedResponses);

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1829 */     Log.debug("processLogin: sending template (scene) name: " + instanceInfo.templateName);

/*      */     

/*      */

/* 1832 */     Event worldFileEvent = new atavism.server.events.WorldFileEvent(instanceInfo.templateName);

/* 1833 */     con.send(worldFileEvent.toBytes());

/* 1834 */     player.sceneLoading(true);

/*      */     

/*      */

/* 1837 */     Log.debug("INFO: process login helper");

/* 1838 */     con.send(objInfo.toBuffer(playerOid));

/*      */     

/*      */

/* 1841 */     DisplayContext dc = WorldManagerClient.getDisplayContext(playerOid);

/* 1842 */     ModelInfoEvent modelInfoEvent = new ModelInfoEvent(playerOid);

/* 1843 */     modelInfoEvent.setDisplayContext(dc);

/* 1844 */     if (Log.loggingDebug) {

/* 1845 */       Log.debug("processLogin: got dc: " + dc);

/*      */     }

/* 1847 */     con.send(modelInfoEvent.toBytes());

/*      */     

/*      */

/* 1850 */     Map<String, DisplayContext> childMap = dc.getChildDCMap();

/* 1851 */     if ((childMap != null) && (!childMap.isEmpty())) {

/* 1852 */       for (String slot : childMap.keySet()) {

/* 1853 */         DisplayContext attachDC = (DisplayContext)childMap.get(slot);

/* 1854 */         if (attachDC == null) {

/* 1855 */           throw new AORuntimeException("attach DC is null for obj: " + playerOid);

/*      */         }

/*      */         

/* 1858 */         OID attacheeOID = attachDC.getObjRef();

/* 1859 */         if (attacheeOID == null) {

/* 1860 */           throw new AORuntimeException("attachee oid is null for obj: " + playerOid);

/*      */         }

/*      */         

/*      */

/* 1864 */         if (Log.loggingDebug) {

/* 1865 */           Log.debug("processLogin: sending attach message to " + playerOid + " attaching to obj " + playerOid + ", object being attached=" + attacheeOID + " to slot " + slot + ", attachmentDC=" + attachDC);

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/* 1871 */         AttachEvent event = new AttachEvent(playerOid, attacheeOID, slot, attachDC);

/*      */         

/* 1873 */         con.send(event.toBytes());

/*      */       }

/* 1875 */       Log.debug("processLogin: done with processing attachments");

/*      */     }

/*      */     

/*      */

/*      */

/* 1880 */     if (this.perceptionFilter.addTarget(playerOid)) {

/* 1881 */       FilterUpdate filterUpdate = new FilterUpdate(1);

/* 1882 */       filterUpdate.addFieldValue(1, playerOid);

/* 1883 */       Engine.getAgent().applyFilterUpdate(this.perceptionSubId, filterUpdate);

/* 1884 */       this.responderFilter.addTarget(playerOid);

/* 1885 */       Engine.getAgent().applyFilterUpdate(this.responderSubId, filterUpdate);

/*      */     }

/*      */     

/*      */

/*      */

/* 1890 */     WorldManagerClient.updateObject(playerOid, playerOid);

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1972 */     WorldManagerClient.TargetedExtensionMessage spawnBegin = new WorldManagerClient.TargetedExtensionMessage(playerOid, playerOid);

/*      */     

/* 1974 */     spawnBegin.setExtensionType("ao.SCENE_BEGIN");

/* 1975 */     spawnBegin.setProperty("action", "login");

/* 1976 */     spawnBegin.setProperty("name", instanceInfo.name);

/*      */     

/* 1978 */     spawnBegin.setProperty("templateName", instanceInfo.templateName);

/*      */     

/*      */

/* 1981 */     WorldManagerClient.TargetedExtensionMessage spawnEnd = new WorldManagerClient.TargetedExtensionMessage(playerOid, playerOid);

/*      */     

/* 1983 */     spawnEnd.setExtensionType("ao.SCENE_END");

/* 1984 */     spawnEnd.setProperty("action", "login");

/* 1985 */     spawnEnd.setProperty("name", instanceInfo.name);

/*      */     

/* 1987 */     spawnEnd.setProperty("templateName", instanceInfo.templateName);

/*      */     

/*      */

/*      */

/*      */

/*      */

/* 1993 */     Integer perceptionCount = WorldManagerClient.spawn(playerOid, spawnBegin, spawnEnd);

/*      */     

/* 1995 */     if (perceptionCount.intValue() < 0) {

/* 1996 */       Log.error("processLogin: spawn failed error=" + perceptionCount + " playerOid=" + playerOid);

/*      */       

/* 1998 */       if (perceptionCount.intValue() == -2)

/*      */       {

/*      */

/* 2001 */         return false;

/*      */       }

/* 2003 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 2015 */     if ((perceptionCount.intValue() == 0) && (player.supportsLoadingState())) {

/* 2016 */       player.setLoadingState(1);

/* 2017 */       con.send(new atavism.server.events.LoadingStateEvent(false).toBytes());

/*      */     }

/*      */     

/* 2020 */     if (Log.loggingDebug) {

/* 2021 */       Log.debug("processLogin: During login, perceptionCount is " + perceptionCount);

/*      */       

/* 2023 */       Log.debug("processLogin: spawned player, master playerOid=" + playerOid);

/*      */     }

/*      */     

/*      */

/*      */

/* 2028 */     if (Log.loggingDebug) {

/* 2029 */       Log.debug("processLogin: sending over instance information for player " + playerOid + ", instance=" + instanceInfo.name + ", instanceOid=" + instanceInfo.oid);

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 2035 */     updateInstancePerception(player.getOid(), null, instanceInfo.oid, instanceInfo.name);

/*      */     

/*      */

/* 2038 */     return true;

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public ProxyLoginCallback getProxyLoginCallback()

/*      */   {

/* 2045 */     return this.proxyLoginCallback;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void setProxyLoginCallback(ProxyLoginCallback callback)

/*      */   {

/* 2053 */     this.proxyLoginCallback = callback;

/*      */   }

/*      */   

/*      */   private static class DefaultProxyLoginCallback

/*      */     implements ProxyLoginCallback

/*      */   {

/*      */     public boolean duplicateLogin(ProxyPlugin.PlayerLoginStatus existingLogin, ClientConnection con)

/*      */     {

/* 2061 */       return existingLogin != null;

/*      */     }

/*      */     

/*      */     public String preLoad(Player player, ClientConnection con) {

/* 2065 */       return null;

/*      */     }

/*      */     

/*      */     public String postLoad(Player player, ClientConnection con) {

/* 2069 */       return null;

/*      */     }

/*      */     

/*      */

/*      */     public void postSpawn(Player player, ClientConnection con) {}

/*      */   }

/*      */   

/*      */

/*      */   private boolean instanceEntryAllowed(OID playerOid, OID instanceOid, atavism.server.math.Point location)

/*      */   {

/* 2079 */     if (instanceOid == null) {

/* 2080 */       return false;

/*      */     }

/* 2082 */     return this.instanceEntryCallback.instanceEntryAllowed(playerOid, instanceOid, location);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public InstanceEntryCallback getInstanceEntryCallback()

/*      */   {

/* 2090 */     return this.instanceEntryCallback;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void setInstanceEntryCallback(InstanceEntryCallback callback)

/*      */   {

/* 2098 */     this.instanceEntryCallback = callback;

/*      */   }

/*      */   

/*      */   private static class DefaultInstanceEntryCallback implements InstanceEntryCallback

/*      */   {

/*      */     public boolean instanceEntryAllowed(OID playerOid, OID instanceOid, atavism.server.math.Point location)

/*      */     {

/* 2105 */       return true;

/*      */     }

/*      */     

/*      */     public OID selectInstance(Player player, int instanceID) {

/* 2109 */       return InstanceClient.getInstanceOid(instanceID, player.getOid(), null, -1, false);

/*      */     }

/*      */     

/*      */     public OID selectInstance(Player player, int instanceID, OID playerOid) {

/* 2113 */       return InstanceClient.getInstanceOid(instanceID, player.getOid(), playerOid, -1, false);

/*      */     }

/*      */     

/* 2116 */     public OID selectInstance(Player player, int instanceID, OID playerOid, int guildId) { return InstanceClient.getInstanceOid(instanceID, player.getOid(), playerOid, guildId, false); }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public void processRequestQuestInfo(ClientConnection con, atavism.agis.events.RequestQuestInfo event)

/*      */   {

/* 2125 */     OID npcOid = event.getQuestNpcOid();

/* 2126 */     Player player = verifyPlayer("processRequestQuestInfo", event, con);

/* 2127 */     if (Log.loggingDebug) {

/* 2128 */       Log.debug("processRequestQuestInfo: player=" + player + ", npc=" + npcOid);

/*      */     }

/* 2130 */     atavism.agis.plugins.QuestClient.requestQuestInfo(npcOid, player.getOid());

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public void processQuestResponse(ClientConnection con, QuestResponse event)

/*      */   {

/* 2137 */     Player player = verifyPlayer("processQuestResponse", event, con);

/* 2138 */     boolean acceptStatus = event.getResponse();

/* 2139 */     OID npcOid = event.getQuestNpcOid();

/* 2140 */     OID questOid = event.getQuestId();

/*      */     

/* 2142 */     if (Log.loggingDebug) {

/* 2143 */       Log.debug("processQuestResponse: player=" + player + ", npcOid=" + npcOid + ", acceptStatus=" + acceptStatus);

/*      */     }

/*      */     

/*      */

/*      */

/* 2148 */     atavism.agis.plugins.QuestClient.QuestResponseMessage msg = new atavism.agis.plugins.QuestClient.QuestResponseMessage(npcOid, player.getOid(), questOid, acceptStatus);

/*      */     

/* 2150 */     Engine.getAgent().sendBroadcast(msg);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void processReqConcludeQuest(ClientConnection con, atavism.agis.events.ConcludeQuest event)

/*      */   {

/* 2158 */     Player player = verifyPlayer("processReqConcludeQuest", event, con);

/* 2159 */     OID mobOid = event.getQuestNpcOid();

/* 2160 */     if (Log.loggingDebug) {

/* 2161 */       Log.debug("processReqConclude: player=" + player + ", mobOid=" + mobOid);

/*      */     }

/* 2163 */     atavism.agis.plugins.QuestClient.requestConclude(mobOid, player.getOid());

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void connectionReset(ClientConnection con)

/*      */   {

/* 2175 */     Player player = (Player)con.getAssociation();

/*      */     

/* 2177 */     if (player == null) {

/* 2178 */       Log.info("ProxyPlugin: DISCONNECT remote=" + con);

/* 2179 */       return;

/*      */     }

/* 2181 */     Log.info(

/* 2182 */       "ProxyPlugin: DISCONNECT remote=" + con + " playerOid=" + player.getOid() + " name=" + player.getName());

/*      */     

/* 2184 */     if (this.playerManager.logout(player)) {

/* 2185 */       ConnectionResetMessage message = new ConnectionResetMessage(con, player);

/*      */       

/* 2187 */       message.setEnqueueTime(System.currentTimeMillis());

/* 2188 */       this.messageQQ.insert(player, message); } }

/*      */   

/*      */   class ConnectionResetMessage extends Message { ClientConnection con;

/*      */     Player player;

/*      */     public static final long serialVersionUID = 1L;

/*      */     

/* 2194 */     ConnectionResetMessage(ClientConnection con, Player player) { this.con = con;

/* 2195 */       this.player = player;

/*      */     }

/*      */     

/*      */     public Player getPlayer() {

/* 2199 */       return this.player;

/*      */     }

/*      */     

/*      */     public ClientConnection getConnection() {

/* 2203 */       return this.con;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void processConnectionResetInternal(ConnectionResetMessage message)

/*      */   {

/* 2218 */     long startTime = System.currentTimeMillis();

/* 2219 */     ClientConnection con = message.getConnection();

/* 2220 */     Player player = message.getPlayer();

/* 2221 */     OID playerOid = player.getOid();

/*      */     

/* 2223 */     Log.info("ProxyPlugin: LOGOUT_BEGIN remote=" + con + " playerOid=" + player.getOid() + " name=" + player.getName());

/*      */     

/*      */

/* 2226 */     if (player.getStatus() != 3) {

/* 2227 */       log.error("processConnectionReset: player status is " +

/* 2228 */         Player.statusToString(player.getStatus()) + " should be " +

/* 2229 */         Player.statusToString(3));

/*      */     }

/*      */     

/*      */     try

/*      */     {

/* 2234 */       if (!WorldManagerClient.despawn(playerOid)) {

/* 2235 */         log.warn("processConnectionReset: despawn player failed for " + playerOid);

/*      */       }

/* 2237 */       Log.debug("processConnectionResetInternal Removing perceptionFilter for palyer: " + playerOid);

/* 2238 */       if (this.perceptionFilter.removeTarget(playerOid)) {

/* 2239 */         FilterUpdate filterUpdate = new FilterUpdate(1);

/* 2240 */         filterUpdate.removeFieldValue(1, playerOid);

/* 2241 */         Log.debug("processConnectionResetInternal Removing perceptionFilter applyFilterUpdate for palyer: " + playerOid);

/* 2242 */         Engine.getAgent().applyFilterUpdate(this.perceptionSubId, filterUpdate);

/* 2243 */         Log.debug("processConnectionResetInternal Removing responderFilter for palyer: " + playerOid);

/* 2244 */         this.responderFilter.removeTarget(playerOid);

/* 2245 */         Log.debug("processConnectionResetInternal Removing perceptionFilter applyFilterUpdate for palyer: " + playerOid);

/* 2246 */         Engine.getAgent().applyFilterUpdate(this.responderSubId, filterUpdate);

/*      */       }

/*      */       

/*      */

/*      */

/* 2251 */       atavism.server.messages.LogoutMessage logoutMessage = new atavism.server.messages.LogoutMessage(playerOid, player.getName());

/* 2252 */       Log.debug("processConnectionResetInternal: Send LogoutMessage for player: " + playerOid + "  and wait for response");

/* 2253 */       AsyncRPCCallback asyncRPCCallback = new AsyncRPCCallback(player, "processLogout: got LogoutMessage response");

/* 2254 */       int expectedResponses = Engine.getAgent().sendBroadcastRPCBlocking(logoutMessage, asyncRPCCallback);

/* 2255 */       Log.debug("processConnectionResetInternal: Send LogoutMessage for player: " + playerOid + "  and wait for response expectedResponses=" + expectedResponses);

/*      */       

/* 2257 */       OID accountID = (OID)EnginePlugin.getObjectProperty(playerOid, WorldManagerClient.NAMESPACE, "accountId");

/* 2258 */       Log.debug("Removing connection from client connection map for account: " + accountID);

/* 2259 */       this.clientConnections.remove(accountID);

/*      */       

/*      */

/* 2262 */       if (!ObjectManagerClient.unloadObject(playerOid).booleanValue()) {

/* 2263 */         log.warn("processConnectionReset: unloadObject failed oid=" + playerOid);

/*      */       }

/*      */     } catch (atavism.msgsys.NoRecipientsException nre) {

/* 2266 */       log.exception("ProxyPlugin.processConnectionResetInternal(): NoRecipientsException ", nre);

/*      */     } catch (atavism.msgsys.RPCTimeoutException nre) {

/* 2268 */       log.exception("ProxyPlugin.processConnectionResetInternal(): RPCTimeoutException ", nre);

/*      */     } catch (Exception nre) {

/* 2270 */       log.exception("ProxyPlugin.processConnectionResetInternal(): Exception ", nre);

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 2276 */     this.messageQQ.removeKey(player);

/* 2277 */     this.eventQQ.removeKey(player);

/*      */     

/* 2279 */     this.playerManager.removeStaticPerception(player, playerOid);

/* 2280 */     this.playerManager.removePlayer(playerOid);

/*      */     

/* 2282 */     Log.info("ProxyPlugin: LOGOUT_END remote=" + con + " playerOid=" + player.getOid() + " name=" + player.getName() + " in-queue=" + (startTime - message.getEnqueueTime()) + " processing=" + (

/* 2283 */       System.currentTimeMillis() - startTime) + " nPlayers=" + this.playerManager.getPlayerCount());

/*      */     

/* 2285 */     synchronized (player) {

/* 2286 */       player.clearConnection();

/* 2287 */       player.notifyAll();

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   protected void processDirLocOrient(ClientConnection con, DirLocOrientEvent event)

/*      */   {

/* 2296 */     if (Log.loggingDebug)

/* 2297 */       Log.debug("processDirLocOrient: got dir loc orient event: " + event);

/* 2298 */     Player player = verifyPlayer("processDirLoc", event, con);

/*      */     

/*      */

/* 2301 */     BasicWorldNode wnode = new BasicWorldNode();

/* 2302 */     wnode.setDir(event.getDir());

/* 2303 */     wnode.setLoc(event.getLoc());

/* 2304 */     wnode.setOrientation(event.getQuaternion());

/*      */     

/* 2306 */     WorldManagerClient.updateWorldNode(player.getOid(), wnode);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   protected void processCom(ClientConnection con, ComEvent event)

/*      */   {

/* 2314 */     Player player = verifyPlayer("processCom", event, con);

/*      */     

/* 2316 */     Log.info("ProxyPlugin: CHAT_SENT player=" + player + " channel=" + event

/* 2317 */       .getChannelId() + " msg=[" + event.getMessage() + "]");

/* 2318 */     AccountDatabase aDB = new AccountDatabase(false);

/* 2319 */     log.debug("processCom: CHAT_SENT");

/*      */     

/*      */

/* 2322 */     if (aDB.isOnBlackList(player.getOid(), event.getObjectOid()))

/*      */     {

/* 2324 */       aDB.close();

/* 2325 */       return;

/*      */     }

/* 2327 */     incrementChatCount();

/* 2328 */     WorldManagerClient.sendChatMsg(player.getOid(), player.getName(), event.getChannelId(), event

/* 2329 */       .getMessage());

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void processCommand(ClientConnection con, CommandEvent event)

/*      */   {

/* 2339 */     Player player = verifyPlayer("processCommand", event, con);

/*      */     

/* 2341 */     String cmd = event.getCommand().split(" ")[0];

/* 2342 */     if (Log.loggingDebug) {

/* 2343 */       log.debug("processCommand: cmd=" + cmd + ", fullCmd=" + event

/* 2344 */         .getCommand());

/*      */     }

/*      */     

/*      */

/* 2348 */     this.commandMapLock.lock();

/*      */     try {

/* 2350 */       command = (RegisteredCommand)this.commandMap.get(cmd);

/*      */     } finally { RegisteredCommand command;

/* 2352 */       this.commandMapLock.unlock(); }

/*      */     RegisteredCommand command;

/* 2354 */     if (command == null) {

/* 2355 */       Log.warn(

/* 2356 */         "processCommand: no parser for command: " + event.getCommand());

/* 2357 */       command = (RegisteredCommand)this.commandMap.get("/unknowncmd");

/* 2358 */       if (command != null) {

/* 2359 */         Engine.setCurrentPlugin(this);

/* 2360 */         command.parser.parse(event);

/* 2361 */         Engine.setCurrentPlugin(null);

/*      */       }

/* 2363 */       return;

/*      */     }

/*      */     

/* 2366 */     Engine.setCurrentPlugin(this);

/* 2367 */     if (command.access.allowed(event, this))

/*      */     {

/* 2369 */       command.parser.parse(event);

/*      */     } else

/* 2371 */       Log.warn(

/* 2372 */         "Player " + player + " not allowed to run command '" + event.getCommand() + "'");

/* 2373 */     Engine.setCurrentPlugin(null);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   protected void processAutoAttack(ClientConnection con, AutoAttackEvent event)

/*      */   {

/* 2380 */     CombatClient.autoAttack(event.getAttackerOid(), event.getTargetOid(), event

/* 2381 */       .getAttackStatus());

/*      */   }

/*      */   

/*      */   protected void processActivateItem(ClientConnection con, ActivateItemEvent event)

/*      */   {

/* 2386 */     InventoryClient.activateObject(event.getItemOid(), event

/* 2387 */       .getObjectOid(), event.getTargetOid());

/*      */   }

/*      */   

/*      */   protected void processAbilityStatusEvent(ClientConnection con, atavism.agis.events.AbilityStatusEvent event)

/*      */   {

/* 2392 */     Player player = (Player)con.getAssociation();

/*      */     

/*      */

/* 2395 */     atavism.agis.events.AbilityStatusMessage msg = new atavism.agis.events.AbilityStatusMessage(CombatClient.MSG_TYPE_ABILITY_STATUS, player.getOid(), event.getPropertyMap());

/* 2396 */     Engine.getAgent().sendBroadcast(msg);

/*      */   }

/*      */   

/*      */

/*      */   protected void processLogout(ClientConnection con, atavism.server.events.LogoutEvent event) {}

/*      */   

/*      */

/*      */   protected void processSceneLoaded(ClientConnection con, atavism.server.events.SceneLoadedEvent event)

/*      */   {

/* 2405 */     Player player = (Player)con.getAssociation();

/* 2406 */     player.sceneLoading(false);

/* 2407 */     Log.debug("SCENE: sceneLoading set to false for player: " + player.getOid());

/*      */   }

/*      */   

/*      */   protected void processExtensionMessageEvent(ClientConnection con, ExtensionMessageEvent event)

/*      */   {

/* 2412 */     String key = (String)event.getPropertyMap().get("ext_msg_subtype");

/* 2413 */     OID target = event.getTargetOid();

/* 2414 */     Player player = (Player)con.getAssociation();

/*      */     

/* 2416 */     if (Log.loggingDebug) {

/* 2417 */       Log.debug("processExtensionMessageEvent: " + player + " subType=" + key + " target=" + target);

/*      */     }

/*      */     

/* 2420 */     List<ProxyExtensionHook> proxyHookList = (List)this.extensionHooks.get(key);

/* 2421 */     if (proxyHookList != null) {

/* 2422 */       for (ProxyExtensionHook hook : proxyHookList) {

/* 2423 */         hook.processExtensionEvent(event, player, this);

/*      */       }

/* 2425 */       return;

/*      */     }

/*      */     

/* 2428 */     if (target != null)

/*      */     {

/*      */

/*      */

/* 2432 */       WorldManagerClient.TargetedExtensionMessage msg = new WorldManagerClient.TargetedExtensionMessage(WorldManagerClient.MSG_TYPE_EXTENSION, target, player.getOid(), event.getClientTargeted(), event.getPropertyMap());

/* 2433 */       if (event.getClientTargeted().booleanValue()) {

/* 2434 */         msg.setMsgType(WorldManagerClient.MSG_TYPE_P2P_EXTENSION);

/* 2435 */         if (allowClientToClientMessage(player, target, msg))

/* 2436 */           Engine.getAgent().sendBroadcast(msg);

/*      */       } else {

/* 2438 */         MessageType msgType = getExtensionMessageType(key);

/* 2439 */         if (msgType == null) {

/* 2440 */           Log.error("processExtensionMessageEvent: key '" + key + "' has no corresponding MessageType");

/*      */           

/* 2442 */           return;

/*      */         }

/* 2444 */         msg.setMsgType(msgType);

/* 2445 */         Engine.getAgent().sendBroadcast(msg);

/*      */       }

/*      */     } else {

/* 2448 */       MessageType msgType = getExtensionMessageType(key);

/* 2449 */       if (msgType == null) {

/* 2450 */         Log.error("processExtensionMessageEvent: key '" + key + "' has no corresponding MessageType");

/*      */         

/* 2452 */         return;

/*      */       }

/*      */       

/* 2455 */       WorldManagerClient.ExtensionMessage msg = new WorldManagerClient.ExtensionMessage(msgType, player.getOid(), event.getPropertyMap());

/* 2456 */       Engine.getAgent().sendBroadcast(msg);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public void registerExtensionSubtype(String subtype, MessageType type)

/*      */   {

/* 2466 */     this.extensionMessageRegistry.put(subtype, type);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public MessageType unregisterExtensionSubtype(String subtype)

/*      */   {

/* 2473 */     return (MessageType)this.extensionMessageRegistry.remove(subtype);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public MessageType getExtensionMessageType(String subtype)

/*      */   {

/* 2480 */     return (MessageType)this.extensionMessageRegistry.get(subtype);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public boolean allowClientToClientMessage(Player sender, OID targetOid, WorldManagerClient.TargetedExtensionMessage message)

/*      */   {

/* 2501 */     return this.defaultAllowClientToClientMessage;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 2508 */   public boolean defaultAllowClientToClientMessage = false;

/*      */   

/* 2510 */   protected HashMap<String, MessageType> extensionMessageRegistry = new HashMap();

/*      */   protected PerceptionFilter perceptionFilter;

/*      */   protected long perceptionSubId;

/*      */   protected PerceptionFilter responderFilter;

/*      */   protected long responderSubId;

/*      */   

/*      */   abstract class BasicProxyHook implements ProxyHook { BasicProxyHook() {}

/*      */     

/* 2518 */     public boolean processMessage(Message msg, int flags) { return true; }

/*      */     

/*      */

/*      */

/*      */     public abstract void processMessage(Message paramMessage, int paramInt, Player paramPlayer);

/*      */   }

/*      */   

/*      */

/*      */   class DisplayContextHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2529 */     DisplayContextHook() { super(); }

/*      */     

/* 2531 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.DisplayContextMessage dcMsg = (WorldManagerClient.DisplayContextMessage)msg;

/*      */       

/* 2533 */       OID dcObjOid = dcMsg.getSubject();

/* 2534 */       DisplayContext dc = dcMsg.getDisplayContext();

/* 2535 */       if (Log.loggingDebug) {

/* 2536 */         ProxyPlugin.log.debug("handleDC: oid=" + dcObjOid + " dc=" + dc);

/*      */       }

/* 2538 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2541 */       if (dc != null) {

/* 2542 */         ModelInfoEvent event = new ModelInfoEvent(dcObjOid);

/* 2543 */         event.setDisplayContext(dc);

/* 2544 */         event.setForceInstantLoad(dcMsg.getForceInstantLoad());

/* 2545 */         con.send(event.toBytes());

/*      */       }

/*      */       

/*      */

/* 2549 */       Map<String, DisplayContext> childMap = dc.getChildDCMap();

/* 2550 */       if ((childMap != null) && (!childMap.isEmpty())) {

/* 2551 */         for (String slot : childMap.keySet()) {

/* 2552 */           DisplayContext attachDC = (DisplayContext)childMap.get(slot);

/* 2553 */           if (attachDC == null) {

/* 2554 */             throw new AORuntimeException("attach DC is null for obj: " + dcObjOid);

/*      */           }

/*      */           

/* 2557 */           OID attacheeOID = attachDC.getObjRef();

/* 2558 */           if (attacheeOID == null) {

/* 2559 */             throw new AORuntimeException("attachee oid is null for obj: " + dcObjOid);

/*      */           }

/*      */           

/*      */

/* 2563 */           if (Log.loggingDebug) {

/* 2564 */             ProxyPlugin.log.debug("DisplayContextHook: sending attach message to " + player

/* 2565 */               .getOid() + " attaching to obj " + dcObjOid + ", object being attached=" + attacheeOID + " to slot " + slot + ", attachmentDC=" + attachDC);

/*      */           }

/*      */           

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 2574 */           AttachEvent event = new AttachEvent(dcObjOid, attacheeOID, slot, attachDC);

/*      */           

/* 2576 */           con.send(event.toBytes());

/*      */         }

/* 2578 */         ProxyPlugin.log.debug("DisplayContextHook: done with processing attachments");

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class NewDirLightHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2587 */     NewDirLightHook() { super(); }

/*      */     

/* 2589 */     public void processMessage(Message m, int flags, Player player) { WorldManagerClient.NewDirLightMessage msg = (WorldManagerClient.NewDirLightMessage)m;

/* 2590 */       OID playerOid = msg.getTarget();

/* 2591 */       OID lightOid = msg.getSubject();

/* 2592 */       atavism.server.objects.LightData lightData = msg.getLightData();

/*      */       

/* 2594 */       if (!playerOid.equals(player.getOid())) {

/* 2595 */         Log.error("Message target and perceiver mismatch");

/*      */       }

/*      */       

/* 2598 */       ClientConnection con = player.getConnection();

/*      */       

/* 2600 */       if (Log.loggingDebug) {

/* 2601 */         ProxyPlugin.log.debug("NewDirLightHook: notifyOid=" + playerOid + ", lightOid=" + lightOid + ", light=" + lightData);

/*      */       }

/* 2603 */       NewLightEvent lightEvent = new NewLightEvent(playerOid, lightOid, lightData);

/*      */       

/* 2605 */       con.send(lightEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/*      */   class FreeObjectHook extends ProxyPlugin.BasicProxyHook {

/* 2610 */     FreeObjectHook() { super(); }

/*      */     

/* 2612 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.FreeObjectMessage message = (WorldManagerClient.FreeObjectMessage)msg;

/*      */       

/* 2614 */       player.getConnection().send(message.toBuffer());

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class SetAmbientHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2622 */     SetAmbientHook() { super(); }

/*      */     

/* 2624 */     public void processMessage(Message m, int flags, Player player) { WorldManagerClient.SetAmbientLightMessage msg = (WorldManagerClient.SetAmbientLightMessage)m;

/* 2625 */       atavism.server.objects.Color ambientLight = msg.getColor();

/* 2626 */       OID playerOid = msg.getTarget();

/*      */       

/* 2628 */       if (!playerOid.equals(player.getOid())) {

/* 2629 */         Log.error("Message target and perceiver mismatch");

/*      */       }

/*      */       

/* 2632 */       ClientConnection con = player.getConnection();

/*      */       

/* 2634 */       if (Log.loggingDebug) {

/* 2635 */         ProxyPlugin.log.debug("SetAmbientHook: targetOid=" + playerOid + ", ambient=" + ambientLight);

/*      */       }

/*      */       

/* 2638 */       Event ambientLightEvent = new atavism.server.events.AmbientLightEvent(ambientLight);

/* 2639 */       con.send(ambientLightEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/*      */   class DetachHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2646 */     DetachHook() { super(); }

/*      */     

/* 2648 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.DetachMessage dMsg = (WorldManagerClient.DetachMessage)msg;

/*      */       

/* 2650 */       OID dcObjOid = dMsg.getSubject();

/* 2651 */       OID objBeingDetached = dMsg.getObjBeingDetached();

/* 2652 */       String socket = dMsg.getSocketName();

/* 2653 */       if (Log.loggingDebug) {

/* 2654 */         ProxyPlugin.log.debug("DetachHook: dcObjOid=" + dcObjOid + ", objBeingDetached=" + objBeingDetached + ", socket=" + socket);

/*      */       }

/*      */       

/*      */

/*      */

/* 2659 */       ClientConnection con = player.getConnection();

/*      */       

/* 2661 */       atavism.server.events.DetachEvent detachEvent = new atavism.server.events.DetachEvent(dcObjOid, objBeingDetached, socket);

/*      */       

/* 2663 */       con.send(detachEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/*      */   class AnimationHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2670 */     AnimationHook() { super(); }

/*      */     

/*      */     public void processMessage(Message msg, int flags, Player player) {

/* 2673 */       WorldManagerClient.AnimationMessage animMsg = (WorldManagerClient.AnimationMessage)msg;

/*      */       

/*      */

/* 2676 */       OID playerOid = player.getOid();

/* 2677 */       ClientConnection con = player.getConnection();

/*      */       

/* 2679 */       OID objOid = animMsg.getSubject();

/* 2680 */       List<atavism.server.util.AnimationCommand> animList = animMsg.getAnimationList();

/*      */       

/*      */

/* 2683 */       atavism.server.events.NotifyPlayAnimationEvent animEvent = new atavism.server.events.NotifyPlayAnimationEvent(objOid);

/*      */       

/* 2685 */       animEvent.setAnimList(animList);

/*      */       

/*      */

/* 2688 */       con.send(animEvent.toBytes());

/* 2689 */       if (Log.loggingDebug) {

/* 2690 */         ProxyPlugin.log.debug("AnimationHook: send anim msg for playerOid " + playerOid + ", objId=" + objOid + ", animEvent=" + animEvent);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class InvokeEffectHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2699 */     InvokeEffectHook() { super(); }

/*      */     

/* 2701 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.AnimationClient.InvokeEffectMessage effectMsg = (atavism.agis.plugins.AnimationClient.InvokeEffectMessage)msg;

/*      */       

/* 2703 */       OID objOid = effectMsg.getSubject();

/*      */       

/* 2705 */       if (Log.loggingDebug) {

/* 2706 */         ProxyPlugin.log.debug("InvokeEffectHook: got msg=" + effectMsg.toString());

/*      */       }

/*      */       

/* 2709 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2712 */       AOByteBuffer buf = effectMsg.toBuffer(player.getVersion());

/* 2713 */       if (buf != null) {

/* 2714 */         con.send(buf);

/* 2715 */         if (Log.loggingDebug)

/* 2716 */           ProxyPlugin.log.debug("InvokeEffectHook: sent ext msg for notifyOid " + objOid);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   class AbilityStatusHook extends ProxyPlugin.BasicProxyHook {

/* 2722 */     AbilityStatusHook() { super(); }

/*      */     

/* 2724 */     public void processMessage(Message msg, int flags, Player player) { AOByteBuffer buf = null;

/* 2725 */       ClientConnection con = player.getConnection();

/* 2726 */       atavism.agis.events.AbilityStatusMessage asMsg = (atavism.agis.events.AbilityStatusMessage)msg;

/* 2727 */       buf = asMsg.toBuffer();

/* 2728 */       if (buf != null) {

/* 2729 */         con.send(buf);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   class ExtensionHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2737 */     ExtensionHook() { super(); }

/*      */     

/* 2739 */     public void processMessage(Message msg, int flags, Player player) { AOByteBuffer buf = null;

/*      */       

/* 2741 */       ClientConnection con = player.getConnection();

/* 2742 */       OID subject = null;

/* 2743 */       OID target = null;

/* 2744 */       String subType = null;

/*      */       

/* 2746 */       if ((msg instanceof WorldManagerClient.TargetedExtensionMessage)) {

/* 2747 */         WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/*      */         

/* 2749 */         subject = extMsg.getSubject();

/* 2750 */         target = extMsg.getTarget();

/* 2751 */         subType = extMsg.getExtensionType();

/*      */         

/* 2753 */         if (Log.loggingDebug) {

/* 2754 */           Set<String> keySet = extMsg.keySet();

/* 2755 */           for (String key : keySet) {

/* 2756 */             ProxyPlugin.log.debug("ExtensionHook: playerOid=" + player.getOid() + ", oid=" + subject + ", key " + key + ", value=" + extMsg

/*      */             

/* 2758 */               .getProperty(key));

/*      */           }

/*      */         }

/*      */         

/*      */

/* 2763 */         buf = extMsg.toBuffer(player.getVersion());

/*      */       }

/*      */       else {

/* 2766 */         WorldManagerClient.ExtensionMessage extMsg = (WorldManagerClient.ExtensionMessage)msg;

/*      */         

/* 2768 */         subject = extMsg.getSubject();

/* 2769 */         subType = extMsg.getExtensionType();

/*      */         

/* 2771 */         if (Log.loggingDebug) {

/* 2772 */           Set<String> keySet = extMsg.keySet();

/* 2773 */           for (String key : keySet) {

/* 2774 */             ProxyPlugin.log.debug("ExtensionHook: playerOid=" + player.getOid() + ", oid=" + subject + ", key " + key + ", value=" + extMsg

/*      */             

/* 2776 */               .getProperty(key));

/*      */           }

/*      */         }

/*      */         

/*      */

/* 2781 */         buf = extMsg.toBuffer(player.getVersion());

/*      */       }

/*      */       

/* 2784 */       if (buf != null) {

/* 2785 */         con.send(buf);

/* 2786 */         if (Log.loggingDebug) {

/* 2787 */           ProxyPlugin.log.debug("ExtensionHook: sent subType " + subType + " for playerOid=" + player

/* 2788 */             .getOid() + ", target=" + target + ", subject=" + subject);

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   class P2PExtensionHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2797 */     P2PExtensionHook() { super(); }

/*      */     

/* 2799 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/*      */       

/* 2801 */       OID objOid = extMsg.getSubject();

/*      */       

/* 2803 */       Set<String> keySet = extMsg.keySet();

/* 2804 */       for (String key : keySet) {

/* 2805 */         if (Log.loggingDebug) {

/* 2806 */           ProxyPlugin.log.debug("P2PExtensionHook: playerOid=" + player.getOid() + ", oid = " + objOid + ", got key " + key + ", value=" + extMsg

/*      */           

/* 2808 */             .getProperty(key));

/*      */         }

/*      */       }

/*      */       

/* 2812 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2815 */       AOByteBuffer buf = extMsg.toBuffer(player.getVersion());

/* 2816 */       if (buf != null) {

/* 2817 */         con.send(buf);

/* 2818 */         if (Log.loggingDebug) {

/* 2819 */           ProxyPlugin.log.debug("P2PExtensionHook: sent ext msg for notifyOid " + objOid);

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class PropertyHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2829 */     PropertyHook() { super(); }

/*      */     

/* 2831 */     public boolean processMessage(Message msg, int flags) { return true; }

/*      */     

/*      */     public void processMessage(Message msg, int flags, Player player)

/*      */     {

/* 2835 */       PropertyMessage propMsg = (PropertyMessage)msg;

/*      */       

/* 2837 */       OID subjectOid = propMsg.getSubject();

/*      */       

/* 2839 */       if (Log.loggingDebug) {

/* 2840 */         Set<String> keySet = propMsg.keySet();

/* 2841 */         for (String key : keySet) {

/* 2842 */           ProxyPlugin.log.debug("handlePropertyMsg: player=" + player + ", oid=" + subjectOid + ", got key " + key + ", value=" + propMsg

/*      */           

/* 2844 */             .getProperty(key));

/*      */         }

/*      */       }

/*      */       

/* 2848 */       ClientConnection con = player.getConnection();

/*      */       

/* 2850 */       AOByteBuffer buf = null;

/* 2851 */       if ((ProxyPlugin.this.playerSpecificProps.size() > 0) && (subjectOid != player.getOid())) {

/* 2852 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.cachedPlayerSpecificFilterProps);

/*      */       }

/*      */       else {

/* 2855 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.filteredProps);

/*      */       }

/* 2857 */       if (buf != null) {

/* 2858 */         con.send(buf);

/* 2859 */         if (Log.loggingDebug) {

/* 2860 */           ProxyPlugin.log.debug("sent prop msg for player " + player + ", subjectId=" + subjectOid);

/*      */         }

/* 2862 */       } else if (Log.loggingDebug) {

/* 2863 */         ProxyPlugin.log.debug("filtered out prop msg for player " + player + ", subjectId=" + subjectOid + " because all props were filtered");

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   class TargetedPropertyHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2873 */     TargetedPropertyHook() { super(); }

/*      */     

/* 2875 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedPropertyMessage propMsg = (WorldManagerClient.TargetedPropertyMessage)msg;

/*      */       

/* 2877 */       OID targetOid = propMsg.getTarget();

/* 2878 */       OID subjectOid = propMsg.getSubject();

/*      */       

/* 2880 */       if (Log.loggingDebug) {

/* 2881 */         Set<String> keySet = propMsg.keySet();

/* 2882 */         for (String key : keySet) {

/* 2883 */           ProxyPlugin.log.debug("handleTargetedPropertyMsg: playerOid=" + player

/* 2884 */             .getOid() + ", targetOid=" + targetOid + ", oid = " + subjectOid + ", got key " + key + ", value=" + propMsg

/*      */             

/* 2886 */             .getProperty(key));

/*      */         }

/*      */       }

/*      */       

/*      */

/* 2891 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2894 */       AOByteBuffer buf = null;

/* 2895 */       if ((ProxyPlugin.this.playerSpecificProps.size() > 0) && (subjectOid != player.getOid())) {

/* 2896 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.cachedPlayerSpecificFilterProps);

/*      */       }

/*      */       else

/* 2899 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.filteredProps);

/* 2900 */       if (buf != null) {

/* 2901 */         con.send(buf);

/* 2902 */         if (Log.loggingDebug) {

/* 2903 */           ProxyPlugin.log.debug("sent targeted prop msg for targetOid " + targetOid + ", subjectOid=" + subjectOid);

/*      */         }

/* 2905 */       } else if (Log.loggingDebug) {

/* 2906 */         ProxyPlugin.log.debug("filtered out targeted prop msg for targetOid " + targetOid + ", subjectOid=" + subjectOid + " because all props were filtered");

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean specialCaseNewProcessing(PerceptionMessage.ObjectNote objectNote, Player player)

/*      */   {

/* 2927 */     long start = System.currentTimeMillis();

/*      */     

/* 2929 */     ClientConnection con = player.getConnection();

/*      */     

/* 2931 */     OID objOid = objectNote.getSubject();

/* 2932 */     ObjectType objType = objectNote.getObjectType();

/*      */     

/*      */

/*      */

/* 2936 */     if (objType == atavism.server.objects.ObjectTypes.light) {

/* 2937 */       Log.debug("specialCaseNewProcessing: got a light object");

/*      */       

/* 2939 */       atavism.server.objects.LightData lightData = (atavism.server.objects.LightData)EnginePlugin.getObjectProperty(objOid, Namespace.WORLD_MANAGER, atavism.server.objects.Light.LightDataPropertyKey);

/*      */       

/* 2941 */       if (Log.loggingDebug)

/* 2942 */         Log.debug("specialCaseNewProcessing: light data=" + lightData);

/* 2943 */       NewLightEvent lightEvent = new NewLightEvent(player.getOid(), objOid, lightData);

/*      */       

/* 2945 */       con.send(lightEvent.toBytes());

/* 2946 */       return true;

/*      */     }

/*      */     

/* 2949 */     if (objType.equals(WorldManagerClient.TEMPL_OBJECT_TYPE_TERRAIN_DECAL)) {

/* 2950 */       Log.debug("specialCaseNewProcessing: got a terrain decal object");

/*      */       

/* 2952 */       atavism.server.objects.TerrainDecalData decalData = (atavism.server.objects.TerrainDecalData)EnginePlugin.getObjectProperty(objOid, Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_TERRAIN_DECAL_DATA);

/*      */       

/* 2954 */       if (Log.loggingDebug) {

/* 2955 */         Log.debug("specialCaseNewProcessing: terrain decal data=" + decalData);

/*      */       }

/* 2957 */       atavism.server.events.NewTerrainDecalEvent decalEvent = new atavism.server.events.NewTerrainDecalEvent(objOid, decalData);

/*      */       

/* 2959 */       con.send(decalEvent.toBytes());

/* 2960 */       return true;

/*      */     }

/*      */     

/* 2963 */     if (objType.equals(WorldManagerClient.TEMPL_OBJECT_TYPE_POINT_SOUND)) {

/* 2964 */       Log.debug("specialCaseNewProcessing: got a point sound object");

/*      */       

/* 2966 */       List<atavism.server.objects.SoundData> soundData = (List)EnginePlugin.getObjectProperty(objOid, Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_SOUND_DATA_LIST);

/*      */       

/* 2968 */       if (Log.loggingDebug) {

/* 2969 */         Log.debug("specialCaseNewProcessing: sound data=" + soundData);

/*      */       }

/* 2971 */       WorldManagerClient.SoundMessage soundMsg = new WorldManagerClient.SoundMessage(objOid);

/* 2972 */       soundMsg.setSoundData(soundData);

/* 2973 */       con.send(soundMsg.toBuffer());

/* 2974 */       return true;

/*      */     }

/*      */     

/*      */

/* 2978 */     WorldManagerClient.PerceptionInfo perceptionInfo = (WorldManagerClient.PerceptionInfo)objectNote.getObjectInfo();

/*      */     

/*      */

/* 2981 */     if (perceptionInfo.objectInfo == null)

/*      */     {

/* 2983 */       return true;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 2989 */     WorldManagerClient.MobPathMessage pathMsg = (WorldManagerClient.MobPathMessage)perceptionInfo.objectInfo.getProperty(WorldManagerClient.MOB_PATH_PROPERTY);

/*      */     

/* 2991 */     con.send(perceptionInfo.objectInfo.toBuffer(player.getOid()));

/*      */     

/*      */

/* 2994 */     if (perceptionInfo.displayContext != null) {

/* 2995 */       ModelInfoEvent modelInfoEvent = new ModelInfoEvent(objOid);

/* 2996 */       modelInfoEvent.setDisplayContext(perceptionInfo.displayContext);

/* 2997 */       con.send(modelInfoEvent.toBytes());

/*      */     }

/* 2999 */     else if (Log.loggingDebug) {

/* 3000 */       Log.debug("No display context for " + objOid + " " + perceptionInfo.objectInfo);

/*      */     }

/*      */     

/*      */

/* 3004 */     if (pathMsg != null)

/*      */     {

/* 3006 */       if (pathMsg.pathExpired()) {

/* 3007 */         if (Log.loggingDebug) {

/* 3008 */           Log.debug(

/* 3009 */             "specialCaseNewProcessing: for mob " + objOid + ", last mob path expired " + pathMsg.toString());

/*      */         }

/*      */       }

/*      */       else {

/* 3013 */         if (Log.loggingDebug)

/* 3014 */           Log.debug(

/* 3015 */             "specialCaseNewProcessing: for mob " + objOid + ", sending last mob path " + pathMsg.toString());

/* 3016 */         AOByteBuffer pathBuf = pathMsg.toBuffer();

/* 3017 */         con.send(pathBuf);

/*      */       }

/*      */     }

/*      */     

/*      */

/* 3022 */     Map<String, DisplayContext> childMap = null;

/* 3023 */     if (perceptionInfo.displayContext != null)

/* 3024 */       childMap = perceptionInfo.displayContext.getChildDCMap();

/* 3025 */     if ((childMap != null) && (!childMap.isEmpty())) {

/* 3026 */       for (String slot : childMap.keySet()) {

/* 3027 */         DisplayContext attachDC = (DisplayContext)childMap.get(slot);

/* 3028 */         if (attachDC == null) {

/* 3029 */           throw new AORuntimeException("attach DC is null for obj: " + objOid);

/*      */         }

/*      */         

/* 3032 */         OID attacheeOID = attachDC.getObjRef();

/* 3033 */         if (attacheeOID == null) {

/* 3034 */           throw new AORuntimeException("attachee oid is null for obj: " + objOid);

/*      */         }

/*      */         

/*      */

/* 3038 */         if (Log.loggingDebug) {

/* 3039 */           Log.debug(

/* 3040 */             "specialCaseNewProcessing: sending attach message to " + player.getOid() + " attaching to obj " + objOid + ", object being attached=" + attacheeOID + " to slot " + slot + ", attachmentDC=" + attachDC);

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3049 */         AttachEvent event = new AttachEvent(objOid, attacheeOID, slot, attachDC);

/*      */         

/* 3051 */         con.send(event.toBytes());

/*      */       }

/* 3053 */       if (Log.loggingDebug) {

/* 3054 */         Log.debug("specialCaseNewProcessing: done with processing attachments");

/*      */       }

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3070 */     long finish = System.currentTimeMillis();

/* 3071 */     if (Log.loggingDebug) {

/* 3072 */       Log.debug(

/* 3073 */         "specialCaseNewProcessing: finished.\tplayerOid=" + player.getOid() + ", oid=" + objOid + " in " + (finish - start) + " ms");

/*      */     }

/* 3075 */     return false;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean specialCaseFreeProcessing(PerceptionMessage.ObjectNote objectNote, Player player)

/*      */   {

/* 3091 */     if (player.getOid().equals(objectNote.getSubject())) {

/* 3092 */       Log.debug("ignoring free object message to self");

/* 3093 */       return true;

/*      */     }

/*      */     

/* 3096 */     ClientConnection con = player.getConnection();

/* 3097 */     if (!con.isOpen()) {

/* 3098 */       con = null;

/*      */     }

/* 3100 */     OID objOid = objectNote.getSubject();

/*      */     

/* 3102 */     if (objectNote.getObjectType() == atavism.server.objects.ObjectTypes.road) {

/* 3103 */       if (Log.loggingDebug)

/* 3104 */         Log.debug(

/* 3105 */           "specialCaseFreeProcessing: playerOid=" + player.getOid() + ", roadSegmentOid=" + objOid);

/* 3106 */       handleFreeRoad(con, objOid);

/* 3107 */       return true;

/*      */     }

/* 3109 */     if (objectNote.getObjectType().equals(WorldManagerClient.TEMPL_OBJECT_TYPE_TERRAIN_DECAL))

/*      */     {

/* 3111 */       if (Log.loggingDebug)

/* 3112 */         Log.debug(

/* 3113 */           "specialCaseFreeProcessing: playerOid=" + player.getOid() + ", decalOid=" + objOid);

/* 3114 */       atavism.server.events.FreeTerrainDecalEvent decalEvent = new atavism.server.events.FreeTerrainDecalEvent(objOid);

/* 3115 */       if (con != null)

/* 3116 */         con.send(decalEvent.toBytes());

/* 3117 */       return true;

/*      */     }

/*      */     

/*      */

/* 3121 */     if (Log.loggingDebug) {

/* 3122 */       Log.debug("specialCaseFreeProcessing: playerOid=" + player.getOid() + ", objOid=" + objOid);

/*      */     }

/*      */     

/*      */

/* 3126 */     NotifyFreeObjectEvent freeEvent = new NotifyFreeObjectEvent(player.getOid(), objOid);

/*      */     

/* 3128 */     if (con != null) {

/* 3129 */       con.send(freeEvent.toBytes());

/*      */     }

/* 3131 */     return false;

/*      */   }

/*      */   

/*      */

/*      */

/*      */   protected void handleFreeRoad(ClientConnection con, OID objOid)

/*      */   {

/* 3138 */     WorldManagerClient.FreeRoadMessage freeRoadMsg = new WorldManagerClient.FreeRoadMessage(objOid);

/*      */     

/* 3140 */     AOByteBuffer buf = freeRoadMsg.toBuffer();

/* 3141 */     if (con != null) {

/* 3142 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class PerceptionHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3150 */     PerceptionHook() { super(); }

/*      */     

/* 3152 */     public void processMessage(Message msg, int flags, Player player) { PerceptionMessage perceptionMessage = (PerceptionMessage)msg;

/*      */       

/*      */

/* 3155 */       List<PerceptionMessage.ObjectNote> gain = perceptionMessage.getGainObjects();

/*      */       

/* 3157 */       List<PerceptionMessage.ObjectNote> lost = perceptionMessage.getLostObjects();

/*      */       

/* 3159 */       if (Log.loggingDebug) {

/* 3160 */         Log.debug(

/*      */         

/* 3162 */           "PerceptionHook.processMessage: start " + (gain == null ? 0 : gain.size()) + " gain and " + (lost == null ? 0 : lost.size()) + " lost");

/*      */       }

/* 3164 */       if (player.getOid().equals(atavism.server.objects.World.DEBUG_OID)) {

/* 3165 */         Log.info(

/*      */         

/* 3167 */           "PerceptionHook: oid=" + atavism.server.objects.World.DEBUG_OID + " start " + (gain == null ? 0 : gain.size()) + " gain and " + (lost == null ? 0 : lost.size()) + " lost");

/*      */       }

/* 3169 */       ClientConnection con = player.getConnection();

/*      */       List<OID> newSubjects;

/* 3171 */       synchronized (ProxyPlugin.this.playerManager) {

/* 3172 */         newSubjects = new LinkedList();

/* 3173 */         List<OID> deleteSubjects = new LinkedList();

/* 3174 */         if (lost != null) {

/* 3175 */           ProxyPlugin.this.playerManager.removeWorldPerception(player, lost, deleteSubjects);

/*      */         }

/* 3177 */         if (gain != null)

/* 3178 */           ProxyPlugin.this.playerManager.addWorldPerception(player, gain, newSubjects);

/* 3179 */         if ((deleteSubjects.size() > 0) || (newSubjects.size() > 0))

/*      */         {

/* 3181 */           FilterUpdate perceptionUpdate = new FilterUpdate(deleteSubjects.size() + newSubjects.size());

/*      */           

/*      */

/*      */

/*      */

/* 3186 */           for (OID oid : newSubjects) {

/* 3187 */             perceptionUpdate.addFieldValue(2, oid);

/*      */           }

/*      */           

/*      */

/* 3191 */           if (player.getOid().equals(atavism.server.objects.World.DEBUG_OID)) {

/* 3192 */             Log.info(

/* 3193 */               "subject changes: " + newSubjects.size() + " gained " + deleteSubjects.size() + " lost");

/*      */           }

/*      */           

/*      */

/*      */

/* 3198 */           Engine.getAgent().applyFilterUpdate(ProxyPlugin.this.perceptionSubId, perceptionUpdate, 0, perceptionMessage);

/*      */         }

/*      */       }

/*      */       

/*      */

/*      */

/* 3204 */       boolean loadingState = false;

/* 3205 */       if ((player.supportsLoadingState()) && (

/* 3206 */         (player.getLoadingState() == 0) || ((gain != null) &&

/* 3207 */         (gain.size() > 20)) || ((lost != null) &&

/* 3208 */         (lost.size() > 20))))

/*      */       {

/*      */

/* 3211 */         con.send(new atavism.server.events.LoadingStateEvent(true).toBytes());

/* 3212 */         loadingState = true;

/*      */       }

/*      */       

/* 3215 */       if (lost != null) {

/* 3216 */         for (PerceptionMessage.ObjectNote objectNote : lost) {

/* 3217 */           ProxyPlugin.this.specialCaseFreeProcessing(objectNote, player);

/*      */         }

/*      */       }

/*      */       

/* 3221 */       if (gain != null) {

/* 3222 */         for (PerceptionMessage.ObjectNote objectNote : gain) {

/*      */           try {

/* 3224 */             ProxyPlugin.this.specialCaseNewProcessing(objectNote, player);

/* 3225 */             WorldManagerClient.updateObject(player.getOid(), objectNote

/* 3226 */               .getSubject());

/*      */           } catch (Exception e) {

/* 3228 */             Log.exception(

/*      */             

/* 3230 */               "specialCaseNewProcessing: player=" + player + " oid=" + objectNote.getSubject(), e);

/*      */           }

/*      */         }

/*      */       }

/*      */       

/* 3235 */       if (loadingState) {

/* 3236 */         player.setLoadingState(1);

/* 3237 */         con.send(new atavism.server.events.LoadingStateEvent(false).toBytes());

/*      */       }

/*      */     } }

/*      */   

/*      */   public static class AddStaticPerceptionMessage extends TargetMessage { private String name;

/*      */     private ObjectType type;

/*      */     private boolean objectInfoProvided;

/*      */     

/*      */     public AddStaticPerceptionMessage() {}

/*      */     

/* 3247 */     public AddStaticPerceptionMessage(MessageType type) { super(); }

/*      */     

/*      */     public String getName()

/*      */     {

/* 3251 */       return this.name;

/*      */     }

/*      */     

/*      */     public void setName(String name) {

/* 3255 */       this.name = name;

/*      */     }

/*      */     

/*      */     public ObjectType getType() {

/* 3259 */       return this.type;

/*      */     }

/*      */     

/*      */     public void setType(ObjectType type) {

/* 3263 */       this.type = type;

/*      */     }

/*      */     

/*      */     public boolean hasObjectInfo() {

/* 3267 */       return this.objectInfoProvided;

/*      */     }

/*      */     

/*      */     public void setHasObjectInfo(boolean flag) {

/* 3271 */       this.objectInfoProvided = flag;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public static void addStaticPerception(OID playerOid, OID oid)

/*      */   {

/* 3282 */     addStaticPerception(playerOid, oid, null, null, false);

/*      */   }

/*      */   

/*      */   public static void addStaticPerception(OID oid, OID oid2, String name, ObjectType type)

/*      */   {

/* 3287 */     addStaticPerception(oid, oid2, name, type, true);

/*      */   }

/*      */   

/*      */   private static void addStaticPerception(OID playerOid, OID oid, String name, ObjectType type, boolean hasObjectInfo)

/*      */   {

/* 3292 */     AddStaticPerceptionMessage message = new AddStaticPerceptionMessage(MSG_TYPE_ADD_STATIC_PERCEPTION);

/*      */     

/* 3294 */     message.setTarget(playerOid);

/* 3295 */     message.setSubject(oid);

/* 3296 */     message.setName(name);

/* 3297 */     message.setType(type);

/* 3298 */     message.setHasObjectInfo(hasObjectInfo);

/* 3299 */     Engine.getAgent().sendBroadcast(message);

/*      */   }

/*      */   

/*      */   public static void removeStaticPerception(OID playerOid, OID oid) {

/* 3303 */     TargetMessage message = new TargetMessage(MSG_TYPE_REMOVE_STATIC_PERCEPTION);

/*      */     

/* 3305 */     message.setTarget(playerOid);

/* 3306 */     message.setSubject(oid);

/* 3307 */     Engine.getAgent().sendBroadcast(message);

/*      */   }

/*      */   

/* 3310 */   private class AddStaticPerceptionHook extends ProxyPlugin.BasicProxyHook { private AddStaticPerceptionHook() { super(); }

/*      */     

/* 3312 */     public void processMessage(Message msg, int flags, Player player) { ProxyPlugin.AddStaticPerceptionMessage message = (ProxyPlugin.AddStaticPerceptionMessage)msg;

/* 3313 */       if (Log.loggingDebug) {

/* 3314 */         Log.debug(

/* 3315 */           "AddStaticPerceptionHook: player=" + player.getOid() + ", subject=" + message.getSubject());

/*      */       }

/*      */       

/* 3318 */       if (!message.hasObjectInfo())

/*      */       {

/* 3320 */         ObjectManagerClient.ObjectStatus objectStatus = ObjectManagerClient.getObjectStatus(message.getSubject());

/* 3321 */         if ((objectStatus == null) || (objectStatus.namespaces == null)) {

/* 3322 */           Log.error(

/* 3323 */             "AddStaticPerceptionHook: ignoring unknown subject=" + message.getSubject() + " added to " + player);

/*      */           

/*      */

/* 3326 */           return;

/*      */         }

/* 3328 */         message.setName(objectStatus.name);

/* 3329 */         message.setType(objectStatus.type);

/*      */       }

/*      */       

/* 3332 */       boolean perceptionGain = ProxyPlugin.this.playerManager.addStaticPerception(player, message

/* 3333 */         .getSubject());

/*      */       

/* 3335 */       if (perceptionGain) {

/* 3336 */         FilterUpdate perceptionUpdate = new FilterUpdate(1);

/* 3337 */         perceptionUpdate.addFieldValue(2, message

/* 3338 */           .getSubject());

/* 3339 */         Engine.getAgent().applyFilterUpdate(ProxyPlugin.this.perceptionSubId, perceptionUpdate, 0);

/*      */         

/*      */

/*      */

/* 3343 */         WorldManagerClient.ObjectInfo info = new WorldManagerClient.ObjectInfo();

/* 3344 */         info.oid = message.getSubject();

/* 3345 */         info.name = message.getName();

/* 3346 */         info.objType = message.getType();

/* 3347 */         info.dir = new atavism.server.math.AOVector(0.0F, 0.0F, 0.0F);

/* 3348 */         Log.debug("INFO: add static perception hook");

/* 3349 */         player.getConnection().send(info.toBuffer(player.getOid()));

/*      */         

/*      */

/* 3352 */         WorldManagerClient.updateObject(player.getOid(), message

/* 3353 */           .getSubject());

/*      */       }

/*      */     }

/*      */   }

/*      */   

/* 3358 */   private class RemoveStaticPerceptionHook extends ProxyPlugin.BasicProxyHook { private RemoveStaticPerceptionHook() { super(); }

/*      */     

/* 3360 */     public void processMessage(Message msg, int flags, Player player) { TargetMessage message = (TargetMessage)msg;

/* 3361 */       boolean proxyPerceptionLoss = ProxyPlugin.this.playerManager.removeStaticPerception(player, message

/* 3362 */         .getSubject());

/* 3363 */       Log.debug("ProxyPlugin.RemoveStaticPerceptionHook(): proxyPerceptionLoss = " + proxyPerceptionLoss + ", playerOid=" + player

/*      */       

/*      */

/* 3366 */         .getOid() + ", oid=" + message.getSubject());

/* 3367 */       if (proxyPerceptionLoss) {

/* 3368 */         FilterUpdate proxyPerceptionUpdate = new FilterUpdate(1);

/* 3369 */         proxyPerceptionUpdate.removeFieldValue(2, message

/* 3370 */           .getSubject());

/* 3371 */         Engine.getAgent().applyFilterUpdate(ProxyPlugin.this.perceptionSubId, proxyPerceptionUpdate, 0);

/*      */       }

/*      */       

/*      */

/* 3375 */       NotifyFreeObjectEvent freeEvent = new NotifyFreeObjectEvent(player.getOid(), message.getSubject());

/* 3376 */       player.getConnection().send(freeEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/* 3380 */   class VoiceParmsHook extends ProxyPlugin.BasicProxyHook { VoiceParmsHook() { super(); }

/*      */     

/*      */     public void processMessage(Message msg, int flags, Player player)

/*      */     {

/* 3384 */       WorldManagerClient.TargetedExtensionMessage extMsg = new WorldManagerClient.TargetedExtensionMessage("voice_parms_response", player.getOid());

/* 3385 */       extMsg.setProperty("host", ProxyPlugin.voiceServerHost);

/* 3386 */       extMsg.setProperty("port", ProxyPlugin.voiceServerPort);

/*      */       

/*      */

/*      */

/* 3390 */       atavism.server.util.SecureTokenSpec tokenSpec = new atavism.server.util.SecureTokenSpec((byte)2, Engine.getAgent().getName(), System.currentTimeMillis() + 30000L);

/* 3391 */       tokenSpec.setProperty("player_oid", player.getOid());

/* 3392 */       byte[] authToken = atavism.server.util.SecureTokenManager.getInstance().generateToken(tokenSpec);

/*      */       

/* 3394 */       extMsg.setProperty("auth_token", Base64.encodeBytes(authToken));

/*      */       

/*      */

/* 3397 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 3400 */       AOByteBuffer buf = extMsg.toBuffer(player.getVersion());

/* 3401 */       if (buf != null) {

/* 3402 */         con.send(buf);

/* 3403 */         if (Log.loggingDebug) {

/* 3404 */           ProxyPlugin.log.debug("VoiceParmsHook: sent voice_parm_response ext msg for player " + player

/* 3405 */             .getOid());

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void processPlayerIgnoreList(Player player)

/*      */   {

/* 3419 */     if (player.getStatus() == 3) {

/* 3420 */       Log.error("ProxyPlugin.processPlayerIgnoreList: Aborting... player.getStatus() is STATUS_LOGOUT");

/* 3421 */       return;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3429 */     sendPlayerIgnoreList(player);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void sendPlayerIgnoreList(Player player)

/*      */   {

/* 3440 */     String missing = " Missing ";

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void updateIgnoredOids(Player player, List<OID> nowIgnored, List<OID> noLongerIgnored) {}

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   class UpdatePlayerIgnoreListHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3468 */     UpdatePlayerIgnoreListHook() { super(); }

/*      */     

/* 3470 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/*      */       

/* 3472 */       LinkedList<OID> nowIgnored = (LinkedList)extMsg.getProperty("now_ignored");

/*      */       

/* 3474 */       LinkedList<OID> noLongerIgnored = (LinkedList)extMsg.getProperty("no_longer_ignored");

/* 3475 */       ProxyPlugin.this.updateIgnoredOids(player, nowIgnored, noLongerIgnored);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   class GetMatchingPlayersHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3517 */     GetMatchingPlayersHook() { super(); }

/*      */     

/* 3519 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/* 3520 */       String playerName = (String)extMsg.getProperty("player_name");

/* 3521 */       Boolean exactMatch = (Boolean)extMsg.getProperty("exact_match");

/* 3522 */       boolean match = exactMatch == null ? true : exactMatch.booleanValue();

/*      */       

/* 3524 */       List<Object> matchLists = Engine.getDatabase().getOidsAndNamesMatchingName(playerName, match);

/*      */       

/* 3526 */       WorldManagerClient.TargetedExtensionMessage response = new WorldManagerClient.TargetedExtensionMessage("player_ignore_list", player.getOid());

/* 3527 */       response.setSubject(player.getOid());

/* 3528 */       List<OID> oids = (List)matchLists.get(0);

/* 3529 */       List<String> names = (List)matchLists.get(1);

/* 3530 */       response.setProperty("ignored_oids", (java.io.Serializable)oids);

/* 3531 */       response.setProperty("ignored_player_names", (java.io.Serializable)names);

/* 3532 */       if (Log.loggingDebug)

/* 3533 */         ProxyPlugin.log.debug("ProxyPlugin.GetMatchingPlayersHook: For player " + player

/* 3534 */           .getOid() + ", found " + (oids == null ? 0 : oids

/* 3535 */           .size()) + " players: " +

/* 3536 */           Database.makeOidCollectionString(oids) + " " + (match ? "exactly matching" : "starting with") + " name '" + playerName + "':" +

/*      */           

/*      */

/* 3539 */           Database.makeNameCollectionString(names));

/* 3540 */       player.getConnection().send(response.toBuffer(player.getVersion()));

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public List<Object> matchingPlayers(Player player, String playerName, Boolean exactMatch)

/*      */   {

/* 3552 */     boolean match = exactMatch == null ? true : exactMatch.booleanValue();

/*      */     

/* 3554 */     List<Object> matchLists = Engine.getDatabase().getOidsAndNamesMatchingName(playerName, match);

/* 3555 */     List<OID> oids = (List)matchLists.get(0);

/* 3556 */     List<String> names = (List)matchLists.get(1);

/* 3557 */     if (Log.loggingDebug)

/* 3558 */       log.debug("ProxyPlugin.matchingPlayers: For player " + player

/* 3559 */         .getOid() + ", found " + (oids == null ? 0 : oids

/* 3560 */         .size()) + " players: " +

/* 3561 */         Database.makeOidCollectionString(oids) + " " + (match ? "exactly matching" : "starting with") + " name '" + playerName + "':" +

/*      */         

/*      */

/* 3564 */         Database.makeNameCollectionString(names));

/* 3565 */     return matchLists;

/*      */   }

/*      */   

/* 3568 */   class PlayerIgnoreListReqHook extends ProxyPlugin.BasicProxyHook { PlayerIgnoreListReqHook() { super(); }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void processMessage(Message msg, int flags, Player player) {}

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   class PlayerPathReqHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3585 */     PlayerPathReqHook() { super(); }

/*      */     

/* 3587 */     public void processMessage(Message msg, int flags, Player player) { OID playerOid = player.getOid();

/* 3588 */       BasicWorldNode wnode = WorldManagerClient.getWorldNode(playerOid);

/* 3589 */       WorldManagerClient.ExtensionMessage extMsg = (WorldManagerClient.ExtensionMessage)msg;

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3600 */       WorldManagerClient.PlayerPathWMReqMessage reqMsg = new WorldManagerClient.PlayerPathWMReqMessage(playerOid, wnode.getInstanceOid(), (String)extMsg.getProperty("room_id"), (atavism.server.math.AOVector)extMsg.getProperty("start"), ((Float)extMsg.getProperty("speed")).floatValue(), (atavism.server.math.Quaternion)extMsg.getProperty("start_orient"), (atavism.server.math.AOVector)extMsg.getProperty("dest"), (atavism.server.math.Quaternion)extMsg.getProperty("dest_orient"), (List)extMsg.getProperty("boundary"), (List)extMsg.getProperty("obstacles"), ((Float)extMsg.getProperty("avatar_width")).floatValue());

/* 3601 */       Engine.getAgent().sendBroadcast(reqMsg);

/*      */     }

/*      */   }

/*      */   

/* 3605 */   class BlockListHook extends ProxyPlugin.BasicProxyHook { BlockListHook() { super(); }

/*      */     

/* 3607 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.SocialClient.BlockListMessage dmgMsg = (atavism.agis.plugins.SocialClient.BlockListMessage)msg;

/* 3608 */       ProxyPlugin.log.error("BlockListHook Start");

/* 3609 */       player.setIgnoredOids(dmgMsg.getBlockList());

/* 3610 */       ProxyPlugin.log.error("BlockListHook End");

/*      */     }

/*      */   }

/*      */   

/*      */   class ComHook extends ProxyPlugin.BasicProxyHook {

/* 3615 */     ComHook() { super(); }

/*      */     

/* 3617 */     public void processMessage(Message msg, int flags, Player player) { AOByteBuffer buf = null;

/*      */       

/* 3619 */       if ((msg instanceof WorldManagerClient.ComMessage)) {

/* 3620 */         WorldManagerClient.ComMessage comMsg = (WorldManagerClient.ComMessage)msg;

/* 3621 */         AccountDatabase aDB = new AccountDatabase(false);

/*      */         

/*      */

/* 3624 */         OID oid = comMsg.getSubject();

/* 3625 */         Log.debug("ComHook.processMessage: ComMessage player:" + player + " plyOid:" + player.getOid() + " getSubject:" + oid + " comMsg:" + comMsg);

/*      */         

/* 3627 */         if (atavism.agis.plugins.SocialClient.isOnBlockList(player.getOid(), oid))

/*      */         {

/*      */

/* 3630 */           if (Log.loggingDebug) {

/* 3631 */             Log.debug(

/*      */             

/*      */

/* 3634 */               "ComHook.processMessage: Ignoring chat from player " + oid + " to player " + player.getOid() + " because originator is in the player's ignored list");

/*      */           }

/*      */           

/* 3637 */           return;

/*      */         }

/*      */         

/*      */

/* 3641 */         buf = comMsg.toBuffer();

/* 3642 */         Log.info("ProxyPlugin: CHAT_RECV player=" + player + " from=" + comMsg

/* 3643 */           .getSubject() + " private=false msg=[" + comMsg

/* 3644 */           .getString() + "]");

/* 3645 */       } else if ((msg instanceof WorldManagerClient.TargetedComMessage)) {

/* 3646 */         WorldManagerClient.TargetedComMessage comMsg = (WorldManagerClient.TargetedComMessage)msg;

/* 3647 */         AccountDatabase aDB = new AccountDatabase(false);

/* 3648 */         OID oid = comMsg.getSubject();

/* 3649 */         Log.debug("ComHook.processMessage: TargetedComMessage player:" + player + " plyOid:" + player.getOid() + " getSubject:" + oid + " comMsg:" + comMsg);

/*      */         

/*      */

/* 3652 */         if (atavism.agis.plugins.SocialClient.isOnBlockList(player.getOid(), oid))

/*      */         {

/*      */

/* 3655 */           if (Log.loggingDebug) {

/* 3656 */             Log.debug(

/*      */             

/*      */

/* 3659 */               "ComHook.processMessage: Ignoring chat from player " + oid + " to player " + player.getOid() + " because originator is in the player's ignored list");

/*      */           }

/*      */           

/* 3662 */           return;

/*      */         }

/*      */         

/* 3665 */         buf = comMsg.toBuffer();

/* 3666 */         Log.info("ProxyPlugin: CHAT_RECV player=" + player + " from=" + comMsg

/* 3667 */           .getSubject() + " private=true msg=[" + comMsg

/* 3668 */           .getString() + "]");

/*      */       }

/*      */       else {

/* 3671 */         Log.debug("ComHook.processMessage: else player:" + player + " plyOid:" + player.getOid() + " msg " + msg);

/*      */         

/*      */

/* 3674 */         return;

/*      */       }

/* 3676 */       ClientConnection con = player.getConnection();

/* 3677 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/* 3681 */   class DamageHook extends ProxyPlugin.BasicProxyHook { DamageHook() { super(); }

/*      */     

/* 3683 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.CombatClient.DamageMessage dmgMsg = (atavism.agis.plugins.CombatClient.DamageMessage)msg;

/*      */       

/* 3685 */       OID attackerOid = dmgMsg.getAttackerOid();

/* 3686 */       OID targetOid = dmgMsg.getTargetOid();

/*      */       

/*      */

/* 3689 */       AOByteBuffer buf = dmgMsg.toBuffer();

/*      */       

/* 3691 */       ClientConnection con = player.getConnection();

/* 3692 */       if (Log.loggingDebug)

/* 3693 */         ProxyPlugin.log.debug("DamageHook: attackerOid= " + attackerOid + ", attacks targetOid=" + targetOid + " for " + dmgMsg

/*      */         

/* 3695 */           .getDmg() + " damage");

/* 3696 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/*      */   class SysChatHook implements atavism.server.engine.Hook { SysChatHook() {}

/*      */     

/* 3702 */     public boolean processMessage(Message msg, int flags) { WorldManagerClient.SysChatMessage sysMsg = (WorldManagerClient.SysChatMessage)msg;

/*      */       

/* 3704 */       AOByteBuffer buf = sysMsg.toBuffer();

/*      */       

/* 3706 */       if (Log.loggingDebug) {

/* 3707 */         ProxyPlugin.log.debug("syschathook:\t " + sysMsg.getString());

/*      */       }

/* 3709 */       java.util.Collection<Player> players = new ArrayList(ProxyPlugin.this.playerManager.getPlayerCount());

/* 3710 */       ProxyPlugin.this.playerManager.getPlayers(players);

/* 3711 */       for (Player pp : players) {

/* 3712 */         pp.getConnection().send(buf);

/*      */       }

/* 3714 */       return true;

/*      */     }

/*      */   }

/*      */   

/* 3718 */   class UpdateWNodeHook extends ProxyPlugin.BasicProxyHook { UpdateWNodeHook() { super(); }

/*      */     

/* 3720 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.UpdateWorldNodeMessage wMsg = (WorldManagerClient.UpdateWorldNodeMessage)msg;

/* 3721 */       OID subjectOid = wMsg.getSubject();

/* 3722 */       OID playerOid = player.getOid();

/* 3723 */       if (Log.loggingDebug) {

/* 3724 */         Log.debug("UpdateWNodeHook.processMessage: subjectOid=" + subjectOid + ", playerOid=" + playerOid + " msg=" + msg);

/*      */       }

/*      */       

/* 3727 */       if (playerOid.equals(subjectOid))

/*      */       {

/* 3729 */         if (Log.loggingDebug) {

/* 3730 */           Log.debug("UpdateWNodeHook.processMessage: subjectOid=" + subjectOid + ", ignoring msg since playerOid matches subjectOid");

/*      */         }

/*      */         

/* 3733 */         return;

/*      */       }

/*      */       

/* 3736 */       player.getConnection().send(wMsg.getEventBuf());

/*      */     }

/*      */   }

/*      */   

/* 3740 */   class UpdateMobPathHook extends ProxyPlugin.BasicProxyHook { UpdateMobPathHook() { super(); }

/*      */     

/* 3742 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.MobPathMessage pathMsg = (WorldManagerClient.MobPathMessage)msg;

/* 3743 */       OID subjectOid = pathMsg.getSubject();

/* 3744 */       if (Log.loggingDebug) {

/* 3745 */         ProxyPlugin.log.debug("UpdateMobPathHook.processMessage: subjectOid=" + subjectOid + ", msg=" + msg);

/*      */       }

/* 3747 */       AOByteBuffer buf = pathMsg.toBuffer();

/* 3748 */       ClientConnection con = player.getConnection();

/* 3749 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/* 3753 */   class WNodeCorrectHook extends ProxyPlugin.BasicProxyHook { WNodeCorrectHook() { super(); }

/*      */     

/* 3755 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.WorldNodeCorrectMessage wMsg = (WorldManagerClient.WorldNodeCorrectMessage)msg;

/*      */       

/* 3757 */       OID oid = wMsg.getSubject();

/*      */       

/* 3759 */       if (Log.loggingDebug) {

/* 3760 */         ProxyPlugin.log.debug("WNodeCorrectHook.processMessage: oid=" + oid + ", msg=" + msg);

/*      */       }

/*      */       

/*      */

/*      */

/*      */

/* 3766 */       AOByteBuffer buf = wMsg.toBuffer();

/* 3767 */       ClientConnection con = player.getConnection();

/* 3768 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/* 3772 */   class OrientHook extends ProxyPlugin.BasicProxyHook { OrientHook() { super(); }

/*      */     

/* 3774 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.OrientMessage oMsg = (WorldManagerClient.OrientMessage)msg;

/*      */       

/*      */

/* 3777 */       AOByteBuffer buf = oMsg.toBuffer();

/*      */       

/* 3779 */       ClientConnection con = player.getConnection();

/* 3780 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/*      */   class SoundHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3787 */     SoundHook() { super(); }

/*      */     

/* 3789 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.SoundMessage sMsg = (WorldManagerClient.SoundMessage)msg;

/*      */       

/*      */

/* 3792 */       OID target = sMsg.getTarget();

/* 3793 */       if ((target != null) && (!target.equals(player.getOid()))) {

/* 3794 */         return;

/*      */       }

/* 3796 */       ClientConnection con = player.getConnection();

/* 3797 */       con.send(sMsg.toBuffer());

/*      */     }

/*      */   }

/*      */   

/* 3801 */   class InvUpdateHook extends ProxyPlugin.BasicProxyHook { InvUpdateHook() { super(); }

/*      */     

/* 3803 */     public void processMessage(Message msg, int flags, Player player) { InventoryClient.InvUpdateMessage uMsg = (InventoryClient.InvUpdateMessage)msg;

/*      */       

/*      */

/* 3806 */       if (!player.getOid().equals(uMsg.getSubject()))

/* 3807 */         return;

/* 3808 */       ClientConnection con = player.getConnection();

/* 3809 */       if (Log.loggingDebug) {

/* 3810 */         ProxyPlugin.log.debug("InvUpdateHook: sending update to player " + player

/* 3811 */           .getOid() + " msgOid=" + uMsg.getSubject());

/*      */       }

/* 3813 */       con.send(uMsg.toBuffer());

/*      */     }

/*      */   }

/*      */   

/* 3817 */   class FogHook extends ProxyPlugin.BasicProxyHook { FogHook() { super(); }

/*      */     

/* 3819 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.FogMessage fogMsg = (WorldManagerClient.FogMessage)msg;

/* 3820 */       atavism.server.objects.FogRegionConfig fogConfig = fogMsg.getFogConfig();

/* 3821 */       OID targetOid = fogMsg.getTarget();

/* 3822 */       ClientConnection con = player.getConnection();

/*      */       

/* 3824 */       WorldManagerClient.FogMessage fogMessage = new WorldManagerClient.FogMessage(null, fogConfig);

/* 3825 */       con.send(fogMessage.toBuffer());

/* 3826 */       if (Log.loggingDebug) {

/* 3827 */         ProxyPlugin.log.debug("FogHook: sending new fog to targetOid " + targetOid + fogConfig);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   class RoadHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3839 */     RoadHook() { super(); }

/*      */     

/* 3841 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.RoadMessage roadMsg = (WorldManagerClient.RoadMessage)msg;

/* 3842 */       Set<atavism.server.objects.Road> roads = roadMsg.getRoads();

/* 3843 */       if (Log.loggingDebug)

/* 3844 */         ProxyPlugin.log.debug("RoadHook: got " + roads.size() + " roads");

/* 3845 */       OID targetOid = roadMsg.getTarget();

/* 3846 */       ClientConnection con = player.getConnection();

/* 3847 */       List<AOByteBuffer> bufList = roadMsg.toBuffer();

/* 3848 */       for (AOByteBuffer buf : bufList) {

/* 3849 */         con.send(buf);

/*      */       }

/* 3851 */       if (Log.loggingDebug)

/* 3852 */         ProxyPlugin.log.debug("RoadHook: sent new roads to targetOid " + targetOid);

/*      */     }

/*      */   }

/*      */   

/* 3856 */   class AbilityUpdateHook extends ProxyPlugin.BasicProxyHook { AbilityUpdateHook() { super(); }

/*      */     

/* 3858 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.CombatClient.AbilityUpdateMessage pMsg = (atavism.agis.plugins.CombatClient.AbilityUpdateMessage)msg;

/* 3859 */       if (Log.loggingDebug) {

/* 3860 */         ProxyPlugin.log.debug("AbilityUpdateHook: got AbilityUpdate message: " + msg);

/*      */       }

/*      */       

/* 3863 */       ClientConnection con = player.getConnection();

/* 3864 */       con.send(pMsg.toBuffer());

/*      */     }

/*      */   }

/*      */   

/*      */   class GetPluginStatusHook implements atavism.server.engine.Hook { GetPluginStatusHook() {}

/*      */     

/* 3870 */     public boolean processMessage(Message msg, int flags) { LinkedHashMap<String, java.io.Serializable> status = new LinkedHashMap();

/* 3871 */       status.put("plugin", ProxyPlugin.this.getName());

/* 3872 */       status.put("user", Integer.valueOf(ProxyPlugin.this.playerManager.getPlayerCount()));

/* 3873 */       status.put("login", Integer.valueOf(ProxyPlugin.this.playerManager.getLoginCount()));

/* 3874 */       status.put("login_sec", Integer.valueOf(ProxyPlugin.this.playerManager.getLoginSeconds()));

/* 3875 */       status.put("instance_entry", Integer.valueOf(ProxyPlugin.this.instanceEntryCount));

/* 3876 */       status.put("chat", Integer.valueOf(ProxyPlugin.this.chatSentCount));

/* 3877 */       status.put("private_chat", Integer.valueOf(ProxyPlugin.this.privateChatSentCount));

/* 3878 */       Engine.getAgent().sendObjectResponse(msg, status);

/* 3879 */       return true; } }

/*      */   

/*      */   public static class PlayerLoginStatus { public OID oid;

/*      */     public int status;

/*      */     public String name;

/*      */     public String clientCon;

/*      */     public String proxyPluginName;

/*      */     private static final long serialVersionUID = 1L;

/*      */     

/* 3888 */     public String toString() { return "[PlayerLoginStatus: oid=" + this.oid + ", status=" + this.status + ", name=" + this.name + ", proxyPluginName=" + this.proxyPluginName + "]"; }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   private class GetPlayerLoginStatusHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3906 */     private GetPlayerLoginStatusHook() { super(); }

/*      */     

/* 3908 */     public void processMessage(Message msg, int flags, Player player) { Log.debug("GetPlayerLoginStatusHook: player=" + player);

/* 3909 */       ProxyPlugin.PlayerLoginStatus loginStatus = new ProxyPlugin.PlayerLoginStatus();

/* 3910 */       loginStatus.oid = player.getOid();

/* 3911 */       loginStatus.status = player.getStatus();

/* 3912 */       loginStatus.name = player.getName();

/* 3913 */       loginStatus.clientCon = player.getConnection().toString();

/* 3914 */       loginStatus.proxyPluginName = ProxyPlugin.this.getName();

/* 3915 */       Log.debug("GetPlayerLoginStatusHook: response=" + loginStatus);

/* 3916 */       Engine.getAgent().sendObjectResponse(msg, loginStatus);

/*      */     }

/*      */   }

/*      */   

/* 3920 */   private class LogoutPlayerHook extends ProxyPlugin.BasicProxyHook { private LogoutPlayerHook() { super(); }

/*      */     

/*      */

/* 3923 */     public void processMessage(Message message, int flags, Player player) { new Thread(new ProxyPlugin.LogoutPlayerRPCThread(ProxyPlugin.this, message, player), "LogoutPlayer" + player.getOid()).start(); }

/*      */   }

/*      */   

/*      */   private class LogoutPlayerRPCThread implements Runnable { private Player player;

/*      */     private Message message;

/*      */     

/* 3929 */     public LogoutPlayerRPCThread(Message message, Player player) { this.player = player;

/* 3930 */       this.message = message;

/*      */     }

/*      */     

/*      */     public void run() {

/* 3934 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.run(): start");

/*      */       try {

/* 3936 */         Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.run(): try { logoutPlayer(); }");

/* 3937 */         logoutPlayer();

/*      */       } catch (Exception e) {

/* 3939 */         Log.exception("LogoutPlayer", e);

/* 3940 */         Engine.getAgent().sendObjectResponse(this.message, null);

/*      */       }

/* 3942 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.run(): done");

/*      */     }

/*      */     

/*      */     public void logoutPlayer() {

/* 3946 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.logoutPlayer(): start");

/* 3947 */       ProxyPlugin.PlayerLoginStatus loginStatus = new ProxyPlugin.PlayerLoginStatus();

/* 3948 */       loginStatus.oid = this.player.getOid();

/* 3949 */       loginStatus.status = this.player.getStatus();

/* 3950 */       loginStatus.name = this.player.getName();

/* 3951 */       loginStatus.clientCon = this.player.getConnection().toString();

/* 3952 */       loginStatus.proxyPluginName = ProxyPlugin.this.getName();

/*      */       

/*      */

/*      */

/* 3956 */       WorldManagerClient.ComMessage comMessage = new WorldManagerClient.ComMessage(this.player.getOid(), "", 0, "Your player logged in from a different location.");

/*      */       

/* 3958 */       this.player.getConnection().sendInternal(comMessage.toBuffer());

/*      */       try {

/* 3960 */         Thread.sleep(20L);

/*      */       }

/*      */       catch (InterruptedException localInterruptedException) {}

/* 3963 */       this.player.getConnection().close();

/*      */       

/* 3965 */       synchronized (this.player) {

/* 3966 */         while (this.player.getConnection() != null) {

/*      */           try {

/* 3968 */             this.player.wait();

/*      */           }

/*      */           catch (InterruptedException localInterruptedException1) {}

/*      */         }

/*      */       }

/* 3973 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.logoutPlayer(): Engine.getAgent().sendObjectResponse() message=" + this.message + ", loginStatus=" + loginStatus);

/*      */       

/* 3975 */       Engine.getAgent().sendObjectResponse(this.message, loginStatus);

/* 3976 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.logoutPlayer(): done");

/*      */     }

/*      */   }

/*      */   

/*      */   private class AccountLoginHook implements atavism.server.engine.Hook

/*      */   {

/*      */     private AccountLoginHook() {}

/*      */     

/*      */     public boolean processMessage(Message msg, int flags)

/*      */     {

/* 3986 */       Log.debug("AccountLoginHook hit");

/* 3987 */       atavism.msgsys.GenericMessage tMsg = (atavism.msgsys.GenericMessage)msg;

/* 3988 */       OID accountId = (OID)tMsg.getProperty("accountId");

/* 3989 */       Log.debug("AccountLoginHook accountId=" + accountId + "; map=" + ProxyPlugin.this.clientConnections);

/* 3990 */       if (ProxyPlugin.this.clientConnections.containsKey(accountId)) {

/* 3991 */         Log.debug("Closing client connection");

/* 3992 */         ((ClientConnection)ProxyPlugin.this.clientConnections.get(accountId)).close();

/* 3993 */         ProxyPlugin.this.clientConnections.remove(accountId);

/*      */       }

/* 3995 */       return true;

/*      */     }

/*      */   }

/*      */   

/*      */   static class InstanceEntryState {

/* 4000 */     int step = 1;

/*      */     InstanceClient.InstanceInfo instanceInfo;

/*      */     LinkedList restoreStack;

/*      */     BasicWorldNode previousLoc;

/*      */   }

/*      */   

/*      */   class InstanceEntryReqHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 4009 */     InstanceEntryReqHook() { super(); }

/*      */     

/* 4011 */     public void processMessage(Message msg, int flags, Player player) { InstanceClient.InstanceEntryReqMessage entryMessage = (InstanceClient.InstanceEntryReqMessage)msg;

/* 4012 */       ProxyPlugin.log.debug("InstanceEntryReqHook ");

/*      */       

/* 4014 */       ProxyPlugin.InstanceEntryState state = (ProxyPlugin.InstanceEntryState)entryMessage.getProcessingState();

/* 4015 */       if (state == null) {

/* 4016 */         state = new ProxyPlugin.InstanceEntryState();

/* 4017 */         entryMessage.setProcessingState(state);

/*      */       }

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4027 */       if (state.step == 1) {

/* 4028 */         entryStep1(entryMessage, state, player);

/* 4029 */       } else if (state.step == 2) {

/* 4030 */         entryStep2(entryMessage, state, player);

/*      */       }

/*      */     }

/*      */     

/*      */     protected void entryStep1(InstanceClient.InstanceEntryReqMessage entryMessage, ProxyPlugin.InstanceEntryState state, Player player)

/*      */     {

/* 4036 */       ProxyPlugin.log.debug("entryStep1 ");

/* 4037 */       BasicWorldNode destination = entryMessage.getWorldNode();

/* 4038 */       int entryFlags = entryMessage.getFlags();

/*      */       

/* 4040 */       String flagStr = "";

/* 4041 */       if ((entryFlags & 0x1) != 0)

/* 4042 */         flagStr = flagStr + "push,";

/* 4043 */       if ((entryFlags & 0x2) != 0) {

/* 4044 */         flagStr = flagStr + "pop,";

/*      */       }

/* 4046 */       Log.info("ProxyPlugin: INSTANCE_BEGIN player=" + player + " destination=" + destination + " flags=" + flagStr);

/*      */       

/*      */

/* 4049 */       if (((entryFlags & 0x1) != 0) && ((entryFlags & 0x2) != 0))

/*      */       {

/* 4051 */         Log.debug(

/* 4052 */           "InstanceEntryReqHook: push and pop flags cannot be combined oid=" + player.getOid());

/* 4053 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4055 */         return;

/*      */       }

/*      */       

/* 4058 */       if (((entryFlags & 0x1) != 0) &&

/* 4059 */         (destination == null)) {

/* 4060 */         Log.debug(

/* 4061 */           "InstanceEntryReqHook: push without destination oid=" + player.getOid());

/* 4062 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4064 */         return;

/*      */       }

/*      */       

/* 4067 */       if (((entryFlags & 0x2) != 0) &&

/* 4068 */         (destination != null)) {

/* 4069 */         Log.debug(

/* 4070 */           "InstanceEntryReqHook: pop with destination oid=" + player.getOid());

/* 4071 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4073 */         return;

/*      */       }

/*      */       

/*      */

/* 4077 */       if (player.getStatus() != 2) {

/* 4078 */         Log.debug("InstanceEntryReqHook: invalid player status " + player);

/*      */         

/* 4080 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4082 */         return;

/*      */       }

/*      */       

/* 4085 */       if ((entryFlags & 0x2) != 0)

/*      */       {

/*      */

/* 4088 */         LinkedList restoreStack = (LinkedList)EnginePlugin.getObjectProperty(player.getOid(), Namespace.OBJECT_MANAGER, "instanceStack");

/*      */         

/* 4090 */         if ((restoreStack == null) || (restoreStack.size() == 0)) {

/* 4091 */           Log.debug("InstanceEntryReqHook: player has no stack to pop " + player);

/*      */           

/* 4093 */           Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */           

/* 4095 */           return;

/*      */         }

/* 4097 */         state.restoreStack = restoreStack;

/*      */         

/* 4099 */         InstanceRestorePoint restorePoint = (InstanceRestorePoint)restoreStack.get(restoreStack.size() - 1);

/* 4100 */         if (restoreStack.size() == 1) {

/* 4101 */           if (restorePoint.getFallbackFlag()) {

/* 4102 */             Log.warn("InstanceEntryReqHook: popping to fallback restore point " + player);

/*      */           }

/*      */           else {

/* 4105 */             Log.warn("InstanceEntryReqHook: popping last instance restore point " + player);

/*      */           }

/*      */         }

/* 4108 */         destination = new BasicWorldNode();

/* 4109 */         OID instanceOid = restorePoint.getInstanceOid();

/* 4110 */         if (restorePoint.getInstanceID() > 0) {

/* 4111 */           instanceOid = ProxyPlugin.this.instanceEntryCallback.selectInstance(player, restorePoint

/* 4112 */             .getInstanceID());

/*      */         }

/* 4114 */         if (instanceOid != null) {

/* 4115 */           destination.setInstanceOid(instanceOid);

/* 4116 */           destination.setLoc(restorePoint.getLoc());

/* 4117 */           destination.setOrientation(restorePoint.getOrientation());

/* 4118 */           destination.setDir(new atavism.server.math.AOVector(0.0F, 0.0F, 0.0F));

/*      */         }

/* 4120 */         entryMessage.setWorldNode(destination);

/*      */       }

/*      */       

/* 4123 */       if (!ProxyPlugin.this.instanceEntryAllowed(player.getOid(), destination

/* 4124 */         .getInstanceOid(), destination.getLoc())) {

/* 4125 */         Log.info("ProxyPlugin: INSTANCE_REJECT player=" + player + " current=" + state.previousLoc + " destination=" + destination);

/*      */         

/*      */

/* 4128 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4130 */         return;

/*      */       }

/*      */       

/* 4133 */       state.instanceInfo = InstanceClient.getInstanceInfo(destination

/* 4134 */         .getInstanceOid(), -131073);

/*      */       

/* 4136 */       if (state.instanceInfo.oid == null) {

/* 4137 */         Log.error(

/* 4138 */           "InstanceEntryReqHook: unknown instanceOid=" + destination.getInstanceOid());

/* 4139 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4141 */         return;

/*      */       }

/*      */       

/* 4144 */       Log.debug("POP: got population: " + state.instanceInfo.playerPopulation + " and limit: " + state.instanceInfo.populationLimit);

/* 4145 */       if ((state.instanceInfo.populationLimit > 0) && (state.instanceInfo.playerPopulation >= state.instanceInfo.populationLimit)) {

/* 4146 */         OID instanceOid = ProxyPlugin.handleFullInstance(state.instanceInfo.templateID, state.instanceInfo);

/* 4147 */         destination.setInstanceOid(instanceOid);

/* 4148 */         state.instanceInfo = InstanceClient.getInstanceInfo(destination

/* 4149 */           .getInstanceOid(), -131073);

/*      */       }

/*      */       

/* 4152 */       if (Log.loggingDebug) {

/* 4153 */         Log.debug("InstanceEntryReqHook: instance terrain config: " + state.instanceInfo.terrainConfig);

/*      */       }

/*      */       

/*      */

/* 4157 */       WorldManagerClient.TargetedExtensionMessage instanceBegin = new WorldManagerClient.TargetedExtensionMessage(player.getOid(), player.getOid());

/* 4158 */       instanceBegin.setExtensionType("ao.SCENE_BEGIN");

/* 4159 */       instanceBegin.setProperty("action", "instance");

/* 4160 */       instanceBegin.setProperty("name", state.instanceInfo.name);

/*      */       

/* 4162 */       instanceBegin.setProperty("templateName", state.instanceInfo.templateName);

/*      */       

/*      */

/*      */

/*      */

/* 4167 */       boolean rc = WorldManagerClient.despawn(player.getOid(), instanceBegin, null);

/*      */       

/* 4169 */       if (!rc) {

/* 4170 */         Log.error("InstanceEntryReqHook: despawn failed " + player);

/* 4171 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4173 */         return;

/*      */       }

/*      */       

/*      */

/* 4177 */       state.previousLoc = WorldManagerClient.getWorldNode(player.getOid());

/*      */       

/* 4179 */       Log.info("ProxyPlugin: INSTANCE_STEP1 player=" + player + " current=" + state.previousLoc + " destination=" + destination + " destName=" + state.instanceInfo.name);

/*      */       

/*      */

/*      */

/*      */

/*      */

/* 4185 */       ArrayList<Namespace> unloadWM = new ArrayList(1);

/* 4186 */       unloadWM.add(WorldManagerClient.NAMESPACE);

/* 4187 */       rc = ObjectManagerClient.unloadSubObject(player.getOid(), unloadWM).booleanValue();

/* 4188 */       if (!rc) {

/* 4189 */         Log.error("InstanceEntryReqHook: unload wm sub-object failed " + player);

/*      */         

/* 4191 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4193 */         return;

/*      */       }

/* 4195 */       state.step = 2;

/* 4196 */       ProxyPlugin.this.messageQQ.insert(player, entryMessage);

/*      */     }

/*      */     

/*      */     protected void entryStep2(InstanceClient.InstanceEntryReqMessage entryMessage, ProxyPlugin.InstanceEntryState state, Player player)

/*      */     {

/* 4201 */       ProxyPlugin.log.debug(" entryStep1 ");

/*      */       

/* 4203 */       int entryFlags = entryMessage.getFlags();

/* 4204 */       ClientConnection con = player.getConnection();

/* 4205 */       BasicWorldNode destination = entryMessage.getWorldNode();

/* 4206 */       BasicWorldNode previousLoc = state.previousLoc;

/*      */       

/* 4208 */       BasicWorldNode restoreLoc = null;

/* 4209 */       if ((entryFlags & 0x1) != 0) {

/* 4210 */         restoreLoc = entryMessage.getRestoreNode();

/* 4211 */         if (restoreLoc == null)

/* 4212 */           restoreLoc = previousLoc;

/*      */       }

/*      */       InstanceClient.InstanceInfo instanceInfo;

/*      */       for (;;) {

/* 4216 */         boolean rc = ObjectManagerClient.fixWorldNode(player.getOid(), destination);

/*      */         

/* 4218 */         if (!rc) {

/* 4219 */           Log.debug("InstanceEntryReqHook: fixWorldNode failed " + player + " node=" + destination);

/*      */           

/* 4221 */           Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */           

/* 4223 */           return;

/*      */         }

/*      */         

/* 4226 */         instanceInfo = InstanceClient.getInstanceInfo(destination

/* 4227 */           .getInstanceOid(), 8);

/*      */         

/* 4229 */         EnginePlugin.setObjectProperty(player.getOid(), Namespace.OBJECT_MANAGER, "currentInstanceName",

/*      */         

/*      */

/* 4232 */           Integer.valueOf(instanceInfo.templateID));

/* 4233 */         Log.debug("INSTANCE: storing current instance prop: " + instanceInfo.templateID);

/*      */         

/*      */

/*      */

/*      */

/* 4238 */         Log.debug("instanceReq: sending template (scene) name: " + state.instanceInfo.templateName);

/*      */         

/*      */

/* 4241 */         Event worldFileEvent = new atavism.server.events.WorldFileEvent(state.instanceInfo.templateName, destination.getLoc());

/* 4242 */         con.send(worldFileEvent.toBytes());

/* 4243 */         player.sceneLoading(true);

/*      */         

/*      */

/*      */

/*      */

/*      */

/* 4249 */         WorldManagerClient.WorldNodeCorrectMessage correctMsg = new WorldManagerClient.WorldNodeCorrectMessage(player.getOid(), destination);

/* 4250 */         con.send(correctMsg.toBuffer());

/*      */         

/* 4252 */         if ((entryFlags & 0x1) != 0) {

/* 4253 */           ProxyPlugin.this.pushInstanceRestorePoint(player, restoreLoc);

/*      */         }

/*      */         

/* 4256 */         WorldManagerClient.TargetedExtensionMessage instanceEnd = new WorldManagerClient.TargetedExtensionMessage(player.getOid(), player.getOid());

/* 4257 */         instanceEnd.setExtensionType("ao.SCENE_END");

/* 4258 */         instanceEnd.setProperty("action", "instance");

/* 4259 */         instanceEnd.setProperty("name", state.instanceInfo.name);

/*      */         

/* 4261 */         instanceEnd.setProperty("templateName", state.instanceInfo.templateName);

/*      */         

/*      */

/*      */

/* 4265 */         ArrayList<Namespace> loadWM = new ArrayList(1);

/* 4266 */         loadWM.add(WorldManagerClient.NAMESPACE);

/* 4267 */         OID oid = ObjectManagerClient.loadSubObject(player.getOid(), loadWM);

/*      */         

/* 4269 */         if (oid == null) {

/* 4270 */           Log.error("InstanceEntryReqHook: load wm sub-object failed " + player);

/*      */           

/* 4272 */           if ((previousLoc != null) && (destination != previousLoc)) {

/* 4273 */             Log.error("InstanceEntryReqHook: attempting to restore previous location " + player + " previous=" + previousLoc);

/*      */             

/* 4275 */             destination = previousLoc;

/* 4276 */             entryFlags &= 0xFFFFFFFD;

/* 4277 */             continue;

/*      */           }

/*      */         }

/*      */         

/* 4281 */         Integer result = WorldManagerClient.spawn(player.getOid(), null, instanceEnd);

/*      */         

/* 4283 */         if (result.intValue() >= 0) break label578;

/* 4284 */         Log.error("InstanceEntryReqHook: spawn failed " + player);

/* 4285 */         if ((result.intValue() != -2) || (previousLoc == null) || (destination == previousLoc))

/*      */           break;

/* 4287 */         Log.error("InstanceEntryReqHook: attempting to restore previous location " + player + " previous=" + previousLoc);

/*      */         

/* 4289 */         destination = previousLoc;

/* 4290 */         entryFlags &= 0xFFFFFFFD;

/*      */       }

/*      */       

/* 4293 */       Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */       

/* 4295 */       return;

/*      */       

/*      */

/*      */

/*      */

/*      */       label578:

/*      */       

/*      */

/*      */

/* 4304 */       WorldManagerClient.correctWorldNode(player.getOid(), destination);

/*      */       

/*      */

/* 4307 */       ProxyPlugin.this.updateInstancePerception(player.getOid(), previousLoc

/* 4308 */         .getInstanceOid(), destination.getInstanceOid(), instanceInfo.name);

/*      */       

/*      */

/*      */

/*      */

/*      */

/* 4314 */       Log.info("ProxyPlugin: INSTANCE_END player=" + player + " destination=" + destination);

/*      */       

/*      */

/*      */

/* 4318 */       if ((entryFlags & 0x2) != 0) {

/* 4319 */         LinkedList restoreStack = state.restoreStack;

/*      */         

/* 4321 */         InstanceRestorePoint top = (InstanceRestorePoint)restoreStack.get(restoreStack.size() - 1);

/* 4322 */         if (!top.getFallbackFlag()) {

/* 4323 */           restoreStack.remove(restoreStack.size() - 1);

/* 4324 */           EnginePlugin.setObjectProperty(player.getOid(), Namespace.OBJECT_MANAGER, "instanceStack", restoreStack);

/*      */         }

/*      */       }

/*      */       

/*      */

/*      */

/*      */

/* 4331 */       ProxyPlugin.access$1208(ProxyPlugin.this);

/* 4332 */       Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.TRUE);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public static OID handleFullInstance(int instanceTemplateID, InstanceClient.InstanceInfo instanceInfo)

/*      */   {

/* 4344 */     Log.debug("POP: instance full with template: " + instanceTemplateID);

/*      */     

/* 4346 */     int instanceNum = 1;

/* 4347 */     String instanceName = "";

/*      */     OID instanceOid;

/*      */     for (;;)

/*      */     {

/* 4351 */       instanceName = instanceTemplateID + "_" + instanceNum;

/* 4352 */       instanceOid = InstanceClient.getInstanceOid(instanceName);

/* 4353 */       if (instanceOid != null) {

/* 4354 */         instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073);

/* 4355 */         if (instanceInfo.populationLimit < 1) break; if (instanceInfo.playerPopulation < instanceInfo.populationLimit) {

/*      */           break;

/*      */         }

/*      */       } else {

/* 4359 */         atavism.server.objects.Template overrideTemplate = new atavism.server.objects.Template();

/* 4360 */         overrideTemplate.put(Namespace.INSTANCE, "name", instanceName);

/* 4361 */         instanceOid = InstanceClient.createInstance(instanceTemplateID, overrideTemplate);

/* 4362 */         if (instanceOid != null) {

/*      */           break;

/*      */         }

/*      */       }

/* 4366 */       instanceNum++;

/*      */     }

/*      */     

/* 4369 */     return instanceOid;

/*      */   }

/*      */   

/*      */   private void updateInstancePerception(OID playerOid, OID prevInstanceOid, OID destInstanceOid, String destInstanceName)

/*      */   {

/* 4374 */     if (prevInstanceOid != null)

/*      */     {

/* 4376 */       removeStaticPerception(playerOid, prevInstanceOid);

/*      */     }

/*      */     

/*      */

/* 4380 */     addStaticPerception(playerOid, destInstanceOid, destInstanceName, atavism.server.objects.ObjectTypes.instance);

/*      */   }

/*      */   

/*      */   protected void pushInstanceRestorePoint(Player player, BasicWorldNode loc)

/*      */   {

/* 4385 */     OID playerOid = player.getOid();

/* 4386 */     log.debug("pushInstanceRestorePoint " + playerOid);

/* 4387 */     InstanceRestorePoint restorePoint = new InstanceRestorePoint();

/* 4388 */     restorePoint.setInstanceOid(loc.getInstanceOid());

/* 4389 */     restorePoint.setLoc(loc.getLoc());

/* 4390 */     restorePoint.setOrientation(loc.getOrientation());

/*      */     

/* 4392 */     InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(loc

/* 4393 */       .getInstanceOid(), 8);

/* 4394 */     restorePoint.setInstanceID(instanceInfo.templateID);

/*      */     

/*      */

/* 4397 */     LinkedList<Object> restoreStack = (LinkedList)EnginePlugin.getObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack");

/*      */     

/* 4399 */     if (restoreStack == null) {

/* 4400 */       restoreStack = new LinkedList();

/*      */     }

/*      */     

/* 4403 */     restoreStack.add(restorePoint);

/*      */     

/* 4405 */     EnginePlugin.setObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack", restoreStack);

/*      */   }

/*      */   

/*      */

/*      */   protected void sendOceanData(OceanData oceanData, Player player)

/*      */   {

/* 4411 */     WorldManagerClient.TargetedExtensionMessage oceanMsg = new ClientParameter.ClientParameterMessage(player.getOid());

/* 4412 */     oceanMsg.setProperty("Ocean.DisplayOcean", oceanData.displayOcean

/* 4413 */       .toString());

/* 4414 */     if (oceanData.useParams != null) {

/* 4415 */       oceanMsg.setProperty("Ocean.UseParams", oceanData.useParams

/* 4416 */         .toString());

/*      */     }

/* 4418 */     if (oceanData.waveHeight != null) {

/* 4419 */       oceanMsg.setProperty("Ocean.WaveHeight", oceanData.waveHeight

/* 4420 */         .toString());

/*      */     }

/* 4422 */     if (oceanData.seaLevel != null) {

/* 4423 */       oceanMsg.setProperty("Ocean.SeaLevel", oceanData.seaLevel

/* 4424 */         .toString());

/*      */     }

/* 4426 */     if (oceanData.bumpScale != null) {

/* 4427 */       oceanMsg.setProperty("Ocean.BumpScale", oceanData.bumpScale

/* 4428 */         .toString());

/*      */     }

/* 4430 */     if (oceanData.bumpSpeedX != null) {

/* 4431 */       oceanMsg.setProperty("Ocean.BumpSpeedX", oceanData.bumpSpeedX

/* 4432 */         .toString());

/*      */     }

/* 4434 */     if (oceanData.bumpSpeedZ != null) {

/* 4435 */       oceanMsg.setProperty("Ocean.BumpSpeedZ", oceanData.bumpSpeedZ

/* 4436 */         .toString());

/*      */     }

/* 4438 */     if (oceanData.textureScaleX != null) {

/* 4439 */       oceanMsg.setProperty("Ocean.TextureScaleX", oceanData.textureScaleX

/* 4440 */         .toString());

/*      */     }

/* 4442 */     if (oceanData.textureScaleZ != null) {

/* 4443 */       oceanMsg.setProperty("Ocean.TextureScaleZ", oceanData.textureScaleZ

/* 4444 */         .toString());

/*      */     }

/* 4446 */     if (oceanData.deepColor != null) {

/* 4447 */       oceanMsg.setProperty("Ocean.DeepColor", oceanData.deepColor

/* 4448 */         .toString());

/*      */     }

/* 4450 */     if (oceanData.shallowColor != null) {

/* 4451 */       oceanMsg.setProperty("Ocean.ShallowColor", oceanData.shallowColor

/* 4452 */         .toString());

/*      */     }

/* 4454 */     player.getConnection().send(oceanMsg.toBuffer(player.getVersion()));

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   protected Player verifyPlayer(String context, Event event, ClientConnection con)

/*      */   {

/* 4462 */     Player player = (Player)con.getAssociation();

/* 4463 */     if (!player.getOid().equals(event.getObjectOid())) {

/* 4464 */       throw new AORuntimeException(context + ": con doesn't match player " + player + " against eventOid " + event.getObjectOid());

/*      */     }

/* 4466 */     return player;

/*      */   }

/*      */   

/*      */   private class PlayerTimeout implements Runnable {

/*      */     private PlayerTimeout() {}

/*      */     

/*      */     public void run() {

/* 4473 */       for (;;) { try { Log.debug("PlayerTimeout thread running..");

/* 4474 */           timeoutPlayers();

/*      */         } catch (Exception e) {

/* 4476 */           Log.exception("PlayerTimeout", e);

/*      */         }

/*      */         try {

/* 4479 */           Thread.sleep(10000L);

/*      */         }

/*      */         catch (InterruptedException localInterruptedException) {}

/*      */       }

/*      */     }

/*      */     

/*      */     private void timeoutPlayers() {

/* 4486 */       List<Player> timedoutPlayers = ProxyPlugin.this.playerManager.getTimedoutPlayers(ProxyPlugin.idleTimeout * 1000, ProxyPlugin.silenceTimeout * 1000, ProxyPlugin.silenceLoadingTimeout * 1000);

/*      */       

/* 4488 */       for (Player player : timedoutPlayers) {

/* 4489 */         if (!ProxyPlugin.this.isAdmin(player.getOid())) {

/* 4490 */           Log.info(

/* 4491 */             "ProxyPlugin: IDLE_TIMEOUT remote=" + player.getConnection() + " player=" + player);

/* 4492 */           player.getConnection().close();

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   private static class PlayerHeartbeat

/*      */     implements ProxyExtensionHook

/*      */   {

/*      */     public void processExtensionEvent(ExtensionMessageEvent event, Player player, ProxyPlugin proxy)

/*      */     {

/* 4503 */       Map<String, java.io.Serializable> props = new HashMap();

/* 4504 */       props.put("ext_msg_subtype", "ao.heartbeat");

/*      */       

/*      */

/* 4507 */       WorldManagerClient.TargetedExtensionMessage msg = new WorldManagerClient.TargetedExtensionMessage(WorldManagerClient.MSG_TYPE_EXTENSION, player.getOid(), player.getOid(), Boolean.valueOf(false), props);

/* 4508 */       Engine.getAgent().sendBroadcast(msg);

/*      */     } }

/*      */   

/*      */   static class AsyncRPCCallback implements atavism.msgsys.ResponseCallback { Player player;

/*      */     String debugPrefix;

/*      */     

/* 4514 */     AsyncRPCCallback(Player player, String debugPrefix) { this.player = player;

/* 4515 */       this.debugPrefix = debugPrefix;

/*      */     }

/*      */     

/*      */     public synchronized void handleResponse(atavism.msgsys.ResponseMessage response) {

/* 4519 */       this.responders -= 1;

/* 4520 */       Log.debug(this.debugPrefix + ", fromAgent=" + response.getSenderName() + " playerOid=" + this.player.getOid() + " responders=" + this.responders);

/* 4521 */       if (this.responders < 1)

/* 4522 */         notify();

/*      */     }

/*      */     

/*      */     public synchronized void waitForResponses(int expectedResponses) {

/* 4526 */       Log.debug(this.debugPrefix + ", playerOid=" + this.player.getOid() + " responders=" + this.responders + " expectedResponses=" + expectedResponses);

/* 4527 */       this.responders += expectedResponses;

/* 4528 */       Log.debug(this.debugPrefix + ", playerOid=" + this.player.getOid() + " responders=" + this.responders + " expectedResponses=" + expectedResponses + " after");

/* 4529 */       while (this.responders > 0) {

/*      */         try {

/* 4531 */           wait();

/*      */         } catch (InterruptedException e) {

/* 4533 */           ProxyPlugin.log.error("waitForResponses wait InterruptedException: " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */         } catch (Exception e) {

/* 4535 */           ProxyPlugin.log.error("waitForResponses wait InterruptedException: " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */         }

/*      */       }

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/* 4544 */     int responders = 0;

/*      */   }

/*      */   

/*      */   public void incrementChatCount() {

/* 4548 */     this.chatSentCount += 1;

/*      */   }

/*      */   

/*      */   public void incrementPrivateChatCount() {

/* 4552 */     this.privateChatSentCount += 1;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4563 */   protected atavism.server.network.rdp.RDPServerSocket serverSocket = null;

/*      */   

/*      */   protected int clientPort;

/*      */   

/* 4567 */   protected static final Logger log = new Logger("ProxyPlugin");

/*      */   

/* 4569 */   PlayerMessageCallback playerMessageCallback = new PlayerMessageCallback();

/*      */   

/* 4571 */   protected PlayerManager playerManager = new PlayerManager();

/*      */   

/* 4573 */   protected atavism.server.util.TimeHistogram proxyQueueHistogram = null;

/*      */   

/* 4575 */   protected atavism.server.util.TimeHistogram proxyCallbackHistogram = null;

/*      */   

/* 4577 */   protected List<MessageType> extraPlayerMessageTypes = null;

/*      */   

/* 4579 */   private ProxyLoginCallback proxyLoginCallback = new DefaultProxyLoginCallback(null);

/*      */   

/* 4581 */   private InstanceEntryCallback instanceEntryCallback = new DefaultInstanceEntryCallback(null);

/*      */   

/* 4583 */   private int instanceEntryCount = 0;

/*      */   

/* 4585 */   private int chatSentCount = 0;

/*      */   

/* 4587 */   private int privateChatSentCount = 0;

/*      */   

/*      */

/* 4590 */   public static final MessageType MSG_TYPE_VOICE_PARMS = MessageType.intern("ao.VOICE_PARMS");

/*      */   

/*      */

/* 4593 */   public static final MessageType MSG_TYPE_PLAYER_PATH_REQ = MessageType.intern("ao.PLAYER_PATH_REQ");

/*      */   

/*      */

/* 4596 */   public static final MessageType MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST = MessageType.intern("ao.UPDATE_PLAYER_IGNORE_LIST");

/*      */   

/*      */

/* 4599 */   public static final MessageType MSG_TYPE_GET_MATCHING_PLAYERS = MessageType.intern("ao.GET_MATCHING_PLAYERS");

/*      */   

/*      */

/* 4602 */   public static final MessageType MSG_TYPE_PLAYER_IGNORE_LIST = MessageType.intern("ao.PLAYER_IGNORE_LIST");

/*      */   

/*      */

/* 4605 */   public static final MessageType MSG_TYPE_PLAYER_IGNORE_LIST_REQ = MessageType.intern("ao.PLAYER_IGNORE_LIST_REQ");

/*      */   

/*      */

/* 4608 */   public static final MessageType MSG_TYPE_RELAY_UPDATE_PLAYER_IGNORE_LIST = MessageType.intern("ao.RELAY_UPDATE_PLAYER_IGNORE_LIST");

/*      */   

/*      */

/* 4611 */   public static final MessageType MSG_TYPE_GET_PLAYER_LOGIN_STATUS = MessageType.intern("ao.GET_PLAYER_LOGIN_STATUS");

/*      */   

/*      */

/* 4614 */   public static final MessageType MSG_TYPE_LOGOUT_PLAYER = MessageType.intern("ao.LOGOUT_PLAYER");

/*      */   

/*      */

/* 4617 */   public static final MessageType MSG_TYPE_ADD_STATIC_PERCEPTION = MessageType.intern("ao.ADD_STATIC_PERCEPTION");

/*      */   

/*      */

/* 4620 */   public static final MessageType MSG_TYPE_REMOVE_STATIC_PERCEPTION = MessageType.intern("ao.REMOVE_STATIC_PERCEPTION");

/*      */   

/*      */

/* 4623 */   public static final MessageType MSG_TYPE_LOGIN_SPAWNED = MessageType.intern("ao.LOGIN_SPAWNED");

/*      */   

/*      */

/* 4626 */   public static final MessageType MSG_TYPE_ACCOUNT_LOGIN = MessageType.intern("ao.ACCOUNT_LOGIN");

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4633 */   protected static String voiceServerHost = "";

/*      */   

/* 4635 */   protected static Integer voiceServerPort = null;

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4643 */   public String serverCapabilitiesSentToClient = "DirLocOrient";

/*      */   

/*      */

/*      */

/*      */

/* 4648 */   static int serverSocketReceiveBufferSize = 131072;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4654 */   public static int MaxConcurrentUsers = 1000;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4660 */   public static int idleTimeout = 900;

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4668 */   public static int silenceTimeout = 30;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4674 */   public static int silenceLoadingTimeout = 900;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4680 */   public static int maxMessagesBeforeConnectionReset = 15000;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4686 */   public static int maxByteCountBeforeConnectionReset = 2000000;

/*      */   

/*      */

/*      */

/*      */

/* 4691 */   public String capacityError = "Login Failed: Servers at capacity, please try again later.";

/*      */   

/*      */

/*      */

/*      */

/* 4696 */   public String tokenError = "Login Failed: Secure token invalid.";

/*      */   

/*      */

/*      */

/*      */

/* 4701 */   private atavism.server.network.ClientTCPMessageIO clientTCPMessageIO = null;

/*      */   

/*      */   /* Error */

/*      */   public void addAdmin(OID oid)

/*      */   {

/*      */     // Byte code:

/*      */     //   0: getstatic 287    atavism/server/util/Log:loggingDebug    Z

/*      */     //   3: ifeq +29 -> 32

/*      */     //   6: getstatic 331    atavism/server/plugins/ProxyPlugin:log    Latavism/server/util/Logger;

/*      */     //   9: new 82    java/lang/StringBuilder

/*      */     //   12: dup

/*      */     //   13: invokespecial 83    java/lang/StringBuilder:<init>    ()V

/*      */     //   16: ldc_w 1046

/*      */     //   19: invokevirtual 85    java/lang/StringBuilder:append    (Ljava/lang/String;)Ljava/lang/StringBuilder;

/*      */     //   22: aload_1

/*      */     //   23: invokevirtual 140    java/lang/StringBuilder:append    (Ljava/lang/Object;)Ljava/lang/StringBuilder;

/*      */     //   26: invokevirtual 87    java/lang/StringBuilder:toString    ()Ljava/lang/String;

/*      */     //   29: invokevirtual 410    atavism/server/util/Logger:debug    (Ljava/lang/String;)V

/*      */     //   32: aload_0

/*      */     //   33: getfield 1047    atavism/server/plugins/ProxyPlugin:lock    Ljava/util/concurrent/locks/Lock;

/*      */     //   36: invokeinterface 405 1 0

/*      */     //   41: aload_0

/*      */     //   42: getfield 69    atavism/server/plugins/ProxyPlugin:adminSet    Ljava/util/Set;

/*      */     //   45: aload_1

/*      */     //   46: invokeinterface 524 2 0

/*      */     //   51: pop

/*      */     //   52: aload_0

/*      */     //   53: getfield 1047    atavism/server/plugins/ProxyPlugin:lock    Ljava/util/concurrent/locks/Lock;

/*      */     //   56: invokeinterface 408 1 0

/*      */     //   61: goto +15 -> 76

/*      */     //   64: astore_2

/*      */     //   65: aload_0

/*      */     //   66: getfield 1047    atavism/server/plugins/ProxyPlugin:lock    Ljava/util/concurrent/locks/Lock;

/*      */     //   69: invokeinterface 408 1 0

/*      */     //   74: aload_2

/*      */     //   75: athrow

/*      */     //   76: return

/*      */     // Line number table:

/*      */     //   Java source line #4708    -> byte code offset #0

/*      */     //   Java source line #4709    -> byte code offset #6

/*      */     //   Java source line #4710    -> byte code offset #32

/*      */     //   Java source line #4712    -> byte code offset #41

/*      */     //   Java source line #4714    -> byte code offset #52

/*      */     //   Java source line #4715    -> byte code offset #61

/*      */     //   Java source line #4714    -> byte code offset #64

/*      */     //   Java source line #4716    -> byte code offset #76

/*      */     // Local variable table:

/*      */     //   start    length    slot    name    signature

/*      */     //   0    77    0    this    ProxyPlugin

/*      */     //   0    77    1    oid    OID

/*      */     //   64    11    2    localObject    Object

/*      */     // Exception table:

/*      */     //   from    to    target    type

/*      */     //   41    52    64    finally

/*      */   }

/*      */   

/*      */   public Set<OID> getAdmins()

/*      */   {

/* 4722 */     this.lock.lock();

/*      */     try {

/* 4724 */       return new HashSet(this.adminSet);

/*      */     } finally {

/* 4726 */       this.lock.unlock();

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public boolean isAdmin(OID playerOid)

/*      */   {

/* 4734 */     this.lock.lock();

/*      */     try { boolean bool;

/* 4736 */       if (playerOid == null) {

/* 4737 */         return false;

/*      */       }

/* 4739 */       return this.adminSet.contains(playerOid);

/*      */     } finally {

/* 4741 */       this.lock.unlock();

/*      */     }

/*      */   }

/*      */   

/*      */

/* 4746 */   Set<OID> adminSet = new HashSet();

/*      */   

/* 4748 */   HashMap<OID, ClientConnection> clientConnections = new HashMap();

/*      */   

/*      */

/* 4751 */   Set<String> filteredProps = null;

/*      */   

/*      */

/*      */

/* 4755 */   Set<String> playerSpecificProps = null;

/*      */   

/*      */

/*      */

/* 4759 */   Set<String> cachedPlayerSpecificFilterProps = null;

/*      */   

/*      */

/* 4762 */   String serverVersion = null;

/*      */   

/* 4764 */   protected Map<String, List<ProxyExtensionHook>> extensionHooks = new HashMap();

/*      */   

/* 4766 */   private int connectionLimit = 0;

/*      */   

/* 4768 */   boolean devMode = true;

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected Object createMBeanInstance()

/*      */   {

/* 4777 */     return new ProxyJMX();

/*      */   }

/*      */   

/*      */   public static abstract interface ProxyJMXMBean

/*      */   {

/*      */     public abstract int getMaxConcurrentUsers();

/*      */     

/*      */     public abstract void setMaxConcurrentUsers(int paramInt);

/*      */     

/*      */     public abstract int getIdleTimeout();

/*      */     

/*      */     public abstract void setIdleTimeout(int paramInt);

/*      */     

/*      */     public abstract int getSilenceTimeout();

/*      */     

/*      */     public abstract void setSilenceTimeout(int paramInt);

/*      */     

/*      */     public abstract int getCurrentUsers();

/*      */     

/*      */     public abstract int getPeakUsers();

/*      */     

/*      */     public abstract int getLoginCount();

/*      */     

/*      */     public abstract int getLogoutCount();

/*      */     

/*      */     public abstract int getClientPort();

/*      */     

/*      */     public abstract int getMaxMessagesBeforeConnectionReset();

/*      */     

/*      */     public abstract void setMaxMessagesBeforeConnectionReset(int paramInt);

/*      */     

/*      */     public abstract int getMaxByteCountBeforeConnectionReset();

/*      */     

/*      */     public abstract void setMaxByteCountBeforeConnectionReset(int paramInt);

/*      */     

/*      */     public abstract String getCapacityErrorMessage();

/*      */     

/*      */     public abstract void setCapacityErrorMessage(String paramString);

/*      */   }

/*      */   

/*      */   protected class ProxyJMX implements ProxyPlugin.ProxyJMXMBean {

/*      */     protected ProxyJMX() {}

/*      */     

/*      */     public int getMaxConcurrentUsers() {

/* 4821 */       return ProxyPlugin.MaxConcurrentUsers;

/*      */     }

/*      */     

/*      */     public void setMaxConcurrentUsers(int users) {

/* 4825 */       if (users >= 0)

/* 4826 */         ProxyPlugin.MaxConcurrentUsers = users;

/*      */     }

/*      */     

/*      */     public int getIdleTimeout() {

/* 4830 */       return ProxyPlugin.idleTimeout;

/*      */     }

/*      */     

/*      */     public void setIdleTimeout(int timeout) {

/* 4834 */       if (timeout > 0)

/* 4835 */         ProxyPlugin.idleTimeout = timeout;

/*      */     }

/*      */     

/*      */     public int getSilenceTimeout() {

/* 4839 */       return ProxyPlugin.silenceTimeout;

/*      */     }

/*      */     

/*      */     public void setSilenceTimeout(int timeout) {

/* 4843 */       if (timeout > 0)

/* 4844 */         ProxyPlugin.silenceTimeout = timeout;

/*      */     }

/*      */     

/*      */     public int getCurrentUsers() {

/* 4848 */       return ProxyPlugin.this.playerManager.getPlayerCount();

/*      */     }

/*      */     

/*      */     public int getPeakUsers() {

/* 4852 */       return ProxyPlugin.this.playerManager.getPeakPlayerCount();

/*      */     }

/*      */     

/*      */     public int getLoginCount() {

/* 4856 */       return ProxyPlugin.this.playerManager.getLoginCount();

/*      */     }

/*      */     

/*      */     public int getLogoutCount() {

/* 4860 */       return ProxyPlugin.this.playerManager.getLogoutCount();

/*      */     }

/*      */     

/*      */     public int getClientPort() {

/* 4864 */       return ProxyPlugin.this.clientPort;

/*      */     }

/*      */     

/*      */     public int getMaxMessagesBeforeConnectionReset() {

/* 4868 */       return ProxyPlugin.maxMessagesBeforeConnectionReset;

/*      */     }

/*      */     

/*      */     public void setMaxMessagesBeforeConnectionReset(int count) {

/* 4872 */       if (count > 0)

/* 4873 */         ProxyPlugin.maxMessagesBeforeConnectionReset = count;

/*      */     }

/*      */     

/*      */     public int getMaxByteCountBeforeConnectionReset() {

/* 4877 */       return ProxyPlugin.maxByteCountBeforeConnectionReset;

/*      */     }

/*      */     

/*      */     public void setMaxByteCountBeforeConnectionReset(int bytes) {

/* 4881 */       if (bytes > 0)

/* 4882 */         ProxyPlugin.maxByteCountBeforeConnectionReset = bytes;

/*      */     }

/*      */     

/*      */     public String getCapacityErrorMessage() {

/* 4886 */       return ProxyPlugin.this.capacityError;

/*      */     }

/*      */     

/*      */     public void setCapacityErrorMessage(String errorMessage) {

/* 4890 */       if (errorMessage != null) {

/* 4891 */         ProxyPlugin.this.capacityError = errorMessage;

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   private String getTemp()

/*      */   {

/* 4898 */     return "53d9e7ed9b24ad39cb3b5b514cf061b8";

/*      */   }

/*      */   

/*      */   class PeriodicGC implements Runnable {

/*      */     PeriodicGC() {}

/*      */     

/*      */     public void run() {

/* 4905 */       int count = 1;

/*      */       for (;;) {

/*      */         try {

/* 4908 */           Thread.sleep(60000L);

/*      */         }

/*      */         catch (InterruptedException localInterruptedException) {}

/* 4911 */         System.out.println("Proxy running GC " + count);

/* 4912 */         System.gc();

/* 4913 */         count++;

/*      */       }

/*      */     }

/*      */   }

/*      */ }





/* Location:              C:\atavism.jar!\atavism\server\plugins\ProxyPlugin.class

 * Java compiler version: 8 (52.0)

 * JD-Core Version:       0.7.1

 */
Код:

Код:
/*      */ package atavism.server.plugins;

/*      */

/*      */ import atavism.agis.database.AccountDatabase;

/*      */ import atavism.agis.events.QuestResponse;

/*      */ import atavism.agis.plugins.CombatClient;

/*      */ import atavism.msgsys.FilterUpdate;

/*      */ import atavism.msgsys.Message;

/*      */ import atavism.msgsys.MessageAgent;

/*      */ import atavism.msgsys.MessageType;

/*      */ import atavism.msgsys.MessageTypeFilter;

/*      */ import atavism.msgsys.TargetMessage;

/*      */ import atavism.server.engine.BasicWorldNode;

/*      */ import atavism.server.engine.Database;

/*      */ import atavism.server.engine.Engine;

/*      */ import atavism.server.engine.EnginePlugin;

/*      */ import atavism.server.engine.Event;

/*      */ import atavism.server.engine.HookManager;

/*      */ import atavism.server.engine.Namespace;

/*      */ import atavism.server.engine.OID;

/*      */ import atavism.server.events.ActivateItemEvent;

/*      */ import atavism.server.events.AttachEvent;

/*      */ import atavism.server.events.AuthorizedLoginEvent;

/*      */ import atavism.server.events.AuthorizedLoginResponseEvent;

/*      */ import atavism.server.events.AutoAttackEvent;

/*      */ import atavism.server.events.ComEvent;

/*      */ import atavism.server.events.CommandEvent;

/*      */ import atavism.server.events.DirLocOrientEvent;

/*      */ import atavism.server.events.ExtensionMessageEvent;

/*      */ import atavism.server.events.ModelInfoEvent;

/*      */ import atavism.server.events.NewLightEvent;

/*      */ import atavism.server.events.NotifyFreeObjectEvent;

/*      */ import atavism.server.messages.PerceptionFilter;

/*      */ import atavism.server.messages.PerceptionMessage;

/*      */ import atavism.server.messages.PerceptionMessage.ObjectNote;

/*      */ import atavism.server.messages.PropertyMessage;

/*      */ import atavism.server.network.AOByteBuffer;

/*      */ import atavism.server.network.ClientConnection;

/*      */ import atavism.server.objects.DisplayContext;

/*      */ import atavism.server.objects.InstanceEntryCallback;

/*      */ import atavism.server.objects.InstanceRestorePoint;

/*      */ import atavism.server.objects.ObjectType;

/*      */ import atavism.server.objects.OceanData;

/*      */ import atavism.server.objects.Player;

/*      */ import atavism.server.objects.PlayerManager;

/*      */ import atavism.server.objects.ProxyExtensionHook;

/*      */ import atavism.server.objects.ProxyLoginCallback;

/*      */ import atavism.server.util.AORuntimeException;

/*      */ import atavism.server.util.Base64;

/*      */ import atavism.server.util.CountLogger;

/*      */ import atavism.server.util.CountLogger.Counter;

/*      */ import atavism.server.util.Log;

/*      */ import atavism.server.util.Logger;

/*      */ import atavism.server.util.SquareQueue;

/*      */ import java.io.OutputStreamWriter;

/*      */ import java.net.InetAddress;

/*      */ import java.net.InetSocketAddress;

/*      */ import java.net.URLConnection;

/*      */ import java.net.URLEncoder;

/*      */ import java.util.ArrayList;

/*      */ import java.util.HashMap;

/*      */ import java.util.HashSet;

/*      */ import java.util.LinkedHashMap;

/*      */ import java.util.LinkedList;

/*      */ import java.util.List;

/*      */ import java.util.Map;

/*      */ import java.util.Set;

/*      */ import java.util.concurrent.locks.Lock;

/*      */

/*      */ public class ProxyPlugin extends EnginePlugin implements atavism.msgsys.MessageCallback, atavism.server.network.ClientConnection.AcceptCallback, atavism.server.network.ClientConnection.MessageCallback

/*      */ {

/*      */   public static final int PERCEPTION_GAIN_THRESHOLD = 20;

/*      */   Thread periodicGC;

/*      */   

/*      */   public ProxyPlugin()

/*      */   {

/*   76 */     setPluginType("Proxy");

/*      */     try

/*      */     {

/*   79 */       proxyPluginName = Engine.getAgent().getDomainClient().allocName("PLUGIN",

/*   80 */         getPluginType() + "#");

/*      */     } catch (java.io.IOException e) { String proxyPluginName;

/*   82 */       throw new AORuntimeException("Could not allocate proxy plugin name", e);

/*      */     }

/*      */     

/*      */     String proxyPluginName;

/*   86 */     setName(proxyPluginName);

/*      */     

/*      */

/*   89 */     this.serverVersion = ("2018.3.1 " + atavism.server.util.ServerVersion.getBuildNumber());

/*      */     

/*      */

/*      */

/*   93 */     setMessageHandler(null);

/*   94 */     this.countMsgPerception = this.countLogger.addCounter("ao.PERCEPTION_INFO");

/*   95 */     this.countMsgPerceptionGain = this.countLogger.addCounter("Perception.gain");

/*   96 */     this.countMsgPerceptionLost = this.countLogger.addCounter("Perception.lost");

/*   97 */     this.countMsgUpdateWNodeIn = this.countLogger.addCounter("ao.UPDATEWNODE.in");

/*   98 */     this.countMsgUpdateWNodeOut = this.countLogger.addCounter("ao.UPDATEWNODE.out");

/*   99 */     this.countMsgPropertyIn = this.countLogger.addCounter("ao.PROPERTY.in");

/*  100 */     this.countMsgPropertyOut = this.countLogger.addCounter("ao.PROPERTY.out");

/*      */     

/*  102 */     this.countMsgTargetedProperty = this.countLogger.addCounter("ao.TARGETED_PROPERTY");

/*  103 */     this.countMsgWNodeCorrectIn = this.countLogger.addCounter("ao.WNODECORRECT.in");

/*  104 */     this.countMsgWNodeCorrectOut = this.countLogger.addCounter("ao.WNODECORRECT.out");

/*  105 */     this.countMsgMobPathIn = this.countLogger.addCounter("ao.MOB_PATH.in");

/*  106 */     this.countMsgMobPathOut = this.countLogger.addCounter("ao.MOB_PATH.out");

/*      */     

/*  108 */     atavism.agis.database.ContentDatabase ctDB = new atavism.agis.database.ContentDatabase(false);

/*  109 */     String _silenceTimeout = ctDB.loadGameSetting("PLAYER_SILENCE_TIMEOUT");

/*  110 */     if (_silenceTimeout != null) {

/*  111 */       silenceTimeout = Integer.parseInt(_silenceTimeout);

/*      */     }

/*      */     

/*      */

/*  115 */     addProxyExtensionHook("ao.heartbeat", new PlayerHeartbeat(null));

/*      */     

/*  117 */     new Thread(new PlayerTimeout(null), "PlayerTimeout").start();

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*  125 */   CountLogger countLogger = new CountLogger("ProxyMsg", 5000, 2);

/*      */   

/*      */   CountLogger.Counter countMsgPerception;

/*      */   

/*      */   CountLogger.Counter countMsgPerceptionGain;

/*      */   

/*      */   CountLogger.Counter countMsgPerceptionLost;

/*      */   

/*      */   CountLogger.Counter countMsgUpdateWNodeIn;

/*      */   

/*      */   CountLogger.Counter countMsgUpdateWNodeOut;

/*      */   

/*      */   CountLogger.Counter countMsgPropertyIn;

/*      */   

/*      */   CountLogger.Counter countMsgPropertyOut;

/*      */   

/*      */   CountLogger.Counter countMsgTargetedProperty;

/*      */   

/*      */   CountLogger.Counter countMsgWNodeCorrectIn;

/*      */   

/*      */   CountLogger.Counter countMsgWNodeCorrectOut;

/*      */   

/*      */   CountLogger.Counter countMsgMobPathIn;

/*      */   

/*      */   CountLogger.Counter countMsgMobPathOut;

/*      */   

/*      */   public static boolean isOnBlockList(OID subject, OID target)

/*      */   {

/*  153 */     Log.error("SocialClient.isOnBlockList: subject:" + subject + "  target:" + target);

/*  154 */     WorldManagerClient.ExtensionMessage message = new WorldManagerClient.ExtensionMessage(atavism.agis.plugins.SocialClient.MSG_TYPE_IS_ON_BLOCK_LIST, "ao.IS_ON_BLOCK_LIST", subject);

/*  155 */     message.setProperty("targetOid", target);

/*  156 */     return Engine.getAgent().sendRPCReturnBoolean(message).booleanValue();

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public boolean isDevMode()

/*      */   {

/*  165 */     return this.devMode;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void setDevMode(boolean mode)

/*      */   {

/*  173 */     this.devMode = mode;

/*      */   }

/*      */   

/*      */   public List<MessageType> getExtraPlayerMessageTypes() {

/*  177 */     return this.extraPlayerMessageTypes;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void setExtraPlayerMessageTypes(List<MessageType> extraPlayerMessageTypes)

/*      */   {

/*  188 */     this.extraPlayerMessageTypes = extraPlayerMessageTypes;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addExtraPlayerMessageType(MessageType messageType)

/*      */   {

/*  198 */     if (this.extraPlayerMessageTypes == null)

/*  199 */       this.extraPlayerMessageTypes = new LinkedList();

/*  200 */     this.extraPlayerMessageTypes.add(messageType);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addExtraPlayerExtensionMessageType(MessageType messageType)

/*      */   {

/*  210 */     addExtraPlayerMessageType(messageType);

/*  211 */     getHookManager().addHook(messageType, new ExtensionHook());

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addProxyExtensionHook(String subType, ProxyExtensionHook hook)

/*      */   {

/*  225 */     synchronized (this.extensionHooks) {

/*  226 */       List<ProxyExtensionHook> hookList = (List)this.extensionHooks.get(subType);

/*  227 */       if (hookList == null) {

/*  228 */         hookList = new ArrayList();

/*  229 */         this.extensionHooks.put(subType, hookList);

/*      */       }

/*  231 */       hookList.add(hook);

/*      */     }

/*      */   }

/*      */   

/*      */   public Map<String, List<ProxyExtensionHook>> getProxyExtensionHooks(String subType)

/*      */   {

/*  237 */     return this.extensionHooks;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void onActivate()

/*      */   {

/*      */     try

/*      */     {

/*  264 */       atavism.server.network.PacketAggregator.initializeAggregation(Engine.getProperties());

/*      */       

/*      */

/*  267 */       String logProxyHistograms = Engine.properties.getProperty("atavism.log_proxy_histograms");

/*  268 */       if ((logProxyHistograms != null) && (logProxyHistograms.equals("true"))) {

/*  269 */         int interval = 5000;

/*      */         

/*  271 */         String intervalString = Engine.properties.getProperty("atavism.log_proxy_histograms_interval");

/*  272 */         if (intervalString != null) {

/*  273 */           int newInterval = Integer.parseInt(intervalString);

/*  274 */           if (newInterval > 0)

/*  275 */             interval = newInterval;

/*      */         }

/*  277 */         this.proxyQueueHistogram = new atavism.server.util.TimeHistogram("TimeInQ", Integer.valueOf(interval));

/*      */         

/*  279 */         this.proxyCallbackHistogram = new atavism.server.util.TimeHistogram("TimeInCallback", Integer.valueOf(interval));

/*  280 */         this.countLogger.start();

/*      */       }

/*      */       

/*      */

/*  284 */       this.filteredProps = new HashSet();

/*  285 */       this.playerSpecificProps = new HashSet();

/*  286 */       this.cachedPlayerSpecificFilterProps = new HashSet();

/*      */       

/*  288 */       addFilteredProperty("inv.bag");

/*  289 */       addFilteredProperty(":loc");

/*  290 */       addFilteredProperty("masterOid");

/*  291 */       addFilteredProperty("agisobj.basedc");

/*  292 */       addFilteredProperty("aoobj.dc");

/*  293 */       addFilteredProperty("aoobj.followsterrainflag");

/*  294 */       addFilteredProperty("aoobj.perceiver");

/*  295 */       addFilteredProperty("aoobj.scale");

/*  296 */       addFilteredProperty("aoobj.mobflag");

/*  297 */       addFilteredProperty("aoobj.structflag");

/*  298 */       addFilteredProperty("aoobj.userflag");

/*  299 */       addFilteredProperty("aoobj.itemflag");

/*  300 */       addFilteredProperty("aoobj.lightflag");

/*  301 */       addFilteredProperty("namespace");

/*  302 */       addFilteredProperty("regenEffectMap");

/*  303 */       addFilteredProperty(WorldManagerClient.MOB_PATH_PROPERTY);

/*  304 */       addFilteredProperty(WorldManagerClient.TEMPL_SOUND_DATA_LIST);

/*  305 */       addFilteredProperty(WorldManagerClient.TEMPL_TERRAIN_DECAL_DATA);

/*  306 */       addFilteredProperty("instanceStack");

/*  307 */       addFilteredProperty("currentInstanceName");

/*  308 */       addFilteredProperty("ignored_oids");

/*      */       

/*      */

/*  311 */       registerHooks();

/*      */       

/*      */

/*      */

/*  315 */       PluginMessageCallback pluginMessageCallback = new PluginMessageCallback();

/*  316 */       MessageTypeFilter filter = new MessageTypeFilter();

/*  317 */       filter.addType(WorldManagerClient.MSG_TYPE_SYS_CHAT);

/*  318 */       Engine.getAgent().createSubscription(filter, pluginMessageCallback);

/*      */       

/*      */

/*      */

/*  322 */       this.perceptionFilter = new PerceptionFilter();

/*  323 */       LinkedList<MessageType> types = new LinkedList();

/*  324 */       types.add(WorldManagerClient.MSG_TYPE_PERCEPTION_INFO);

/*  325 */       types.add(WorldManagerClient.MSG_TYPE_ANIMATION);

/*  326 */       types.add(WorldManagerClient.MSG_TYPE_DISPLAY_CONTEXT);

/*  327 */       types.add(WorldManagerClient.MSG_TYPE_DETACH);

/*  328 */       types.add(PropertyMessage.MSG_TYPE_PROPERTY);

/*  329 */       types.add(WorldManagerClient.MSG_TYPE_COM);

/*  330 */       types.add(atavism.agis.plugins.SocialClient.MSG_TYPE_BLOCK_LIST);

/*  331 */       types.add(CombatClient.MSG_TYPE_DAMAGE);

/*  332 */       types.add(WorldManagerClient.MSG_TYPE_UPDATEWNODE);

/*  333 */       types.add(WorldManagerClient.MSG_TYPE_MOB_PATH);

/*  334 */       types.add(WorldManagerClient.MSG_TYPE_WNODECORRECT);

/*  335 */       types.add(WorldManagerClient.MSG_TYPE_ORIENT);

/*  336 */       types.add(WorldManagerClient.MSG_TYPE_SOUND);

/*  337 */       types.add(atavism.agis.plugins.AnimationClient.MSG_TYPE_INVOKE_EFFECT);

/*  338 */       types.add(WorldManagerClient.MSG_TYPE_EXTENSION);

/*  339 */       types.add(WorldManagerClient.MSG_TYPE_P2P_EXTENSION);

/*      */       

/*      */

/*  342 */       types.add(InventoryClient.MSG_TYPE_INV_UPDATE);

/*      */       

/*  344 */       types.add(CombatClient.MSG_TYPE_ABILITY_STATUS);

/*  345 */       types.add(CombatClient.MSG_TYPE_ABILITY_UPDATE);

/*  346 */       types.add(WorldManagerClient.MSG_TYPE_FOG);

/*  347 */       types.add(WorldManagerClient.MSG_TYPE_ROAD);

/*  348 */       types.add(WorldManagerClient.MSG_TYPE_NEW_DIRLIGHT);

/*  349 */       types.add(WorldManagerClient.MSG_TYPE_SET_AMBIENT);

/*  350 */       types.add(WorldManagerClient.MSG_TYPE_TARGETED_PROPERTY);

/*  351 */       types.add(WorldManagerClient.MSG_TYPE_FREE_OBJECT);

/*  352 */       types.add(MSG_TYPE_VOICE_PARMS);

/*  353 */       types.add(MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST);

/*  354 */       types.add(MSG_TYPE_GET_MATCHING_PLAYERS);

/*  355 */       types.add(MSG_TYPE_ADD_STATIC_PERCEPTION);

/*  356 */       types.add(MSG_TYPE_REMOVE_STATIC_PERCEPTION);

/*      */       

/*  358 */       if (this.extraPlayerMessageTypes != null)

/*  359 */         types.addAll(this.extraPlayerMessageTypes);

/*  360 */       this.perceptionFilter.setTypes(types);

/*      */       

/*      */

/*      */

/*      */

/*      */

/*  366 */       this.perceptionFilter.setMatchAllSubjects(true);

/*      */       

/*  368 */       atavism.server.messages.PerceptionTrigger perceptionTrigger = new atavism.server.messages.PerceptionTrigger();

/*  369 */       this.perceptionSubId = Engine.getAgent().createSubscription(this.perceptionFilter, this.playerMessageCallback, 0, perceptionTrigger);

/*      */       

/*      */

/*      */

/*  373 */       this.responderFilter = new PerceptionFilter();

/*  374 */       types.clear();

/*  375 */       types.add(InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ);

/*  376 */       types.add(MSG_TYPE_PLAYER_IGNORE_LIST_REQ);

/*  377 */       types.add(MSG_TYPE_GET_PLAYER_LOGIN_STATUS);

/*  378 */       types.add(MSG_TYPE_LOGOUT_PLAYER);

/*  379 */       this.responderFilter.setTypes(types);

/*  380 */       this.responderSubId = Engine.getAgent().createSubscription(this.responderFilter, this.playerMessageCallback, 8);

/*      */       

/*      */

/*      */

/*  384 */       types.clear();

/*  385 */       types.add(atavism.management.Management.MSG_TYPE_GET_PLUGIN_STATUS);

/*  386 */       Engine.getAgent().createSubscription(new MessageTypeFilter(types), pluginMessageCallback, 8);

/*      */       

/*      */

/*  389 */       MessageTypeFilter filter3 = new MessageTypeFilter();

/*      */       

/*  391 */       filter3.addType(MSG_TYPE_ACCOUNT_LOGIN);

/*  392 */       Engine.getAgent().createSubscription(filter3, this);

/*      */       

/*      */

/*      */

/*      */

/*  397 */       this.serverSocket = new atavism.server.network.rdp.RDPServerSocket();

/*      */       

/*  399 */       String log_rdp_counters = Engine.getProperty("atavism.log_rdp_counters");

/*  400 */       if ((log_rdp_counters == null) || (log_rdp_counters.equals("false")))

/*  401 */         atavism.server.network.rdp.RDPServer.setCounterLogging(false);

/*  402 */       atavism.server.network.rdp.RDPServer.startRDPServer();

/*  403 */       this.serverSocket.registerAcceptCallback(this);

/*      */       

/*  405 */       initializeVoiceServerInformation();

/*      */       

/*  407 */       registerExtensionSubtype("voice_parms", MSG_TYPE_VOICE_PARMS);

/*  408 */       registerExtensionSubtype("player_path_req", MSG_TYPE_PLAYER_PATH_REQ);

/*  409 */       registerExtensionSubtype("player_path_req", MSG_TYPE_PLAYER_PATH_REQ);

/*  410 */       registerExtensionSubtype("ao.UPDATE_PLAYER_IGNORE_LIST", MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST);

/*  411 */       registerExtensionSubtype("ao.GET_MATCHING_PLAYERS", MSG_TYPE_GET_MATCHING_PLAYERS);

/*  412 */       registerExtensionSubtype("ao.PLAYER_IGNORE_LIST_REQ", MSG_TYPE_PLAYER_IGNORE_LIST_REQ);

/*      */       

/*  414 */       Log.debug("ProxyPlugin before bindAddress");

/*  415 */       InetSocketAddress bindAddress = getBindAddress();

/*  416 */       Log.debug("ProxyPlugin after bindAddress " + bindAddress.getHostName() + " " + bindAddress.getAddress() + " " + bindAddress.getPort());

/*  417 */       if (Log.loggingDebug) {

/*  418 */         Log.debug("BIND: binding for client tcp and rdp packets on port " + bindAddress.getPort() + " with rdpsocket: " + this.serverSocket.toString());

/*      */       }

/*      */       

/*      */

/*  422 */       Log.debug("ProxyPlugin before server socket");

/*  423 */       this.serverSocket.bind(Integer.valueOf(Integer.parseInt(Engine.getProperty("atavism.proxy.bindport"))), serverSocketReceiveBufferSize);

/*  424 */       Log.debug("BIND: bound server socket");

/*  425 */       this.clientTCPMessageIO = atavism.server.network.ClientTCPMessageIO.setup(bindAddress, this, this);

/*  426 */       Log.debug("BIND: setup clientTCPMessage");

/*  427 */       this.clientTCPMessageIO.start("ClientIO");

/*  428 */       Log.debug("BIND: started clientTCPMessage");

/*      */       

/*      */

/*  431 */       InetSocketAddress externalAddress = getExternalAddress(bindAddress);

/*  432 */       Log.debug("BIND: got external Address " + externalAddress.getHostName() + " " + externalAddress.getAddress() + " " + externalAddress.getPort());

/*      */       

/*  434 */       setPluginInfo("host=" + Engine.getProperty("atavism.proxy.externaladdress") + ",port=" + externalAddress.getPort());

/*  435 */       Log.debug("Registering proxy plugin");

/*  436 */       Engine.registerStatusReportingPlugin(this);

/*  437 */       Log.debug("Proxy: activation done");

/*      */       

/*      */

/*      */

/*  441 */       runCheck();

/*      */     }

/*      */     catch (Exception e) {

/*  444 */       throw new AORuntimeException("activate failed", e);

/*      */     }

/*      */   }

/*      */   

/*      */   private InetSocketAddress getBindAddress() throws java.io.IOException

/*      */   {

/*  450 */     String propStr = Engine.getProperty("atavism.proxy.bindport");

/*  451 */     Log.debug("Proxy: getBindAddress propStr=" + propStr);

/*      */     int port;

/*  453 */     if (propStr != null) {

/*  454 */       int port = Integer.parseInt(propStr.trim());

/*  455 */       Log.debug("Proxy: getBindAddress port=" + port);

/*      */     }

/*      */     else {

/*  458 */       port = Integer.parseInt(Engine.getProperty("atavism.proxyport").trim());

/*      */     }

/*  460 */     Log.debug("Proxy: getBindAddress port=" + port);

/*      */     

/*      */

/*      */

/*  464 */     propStr = Engine.getProperty("atavism.proxy.bindaddress");

/*  465 */     Log.debug("Proxy: getBindAddress propStr=" + propStr + " " + Character.digit(propStr.charAt(0), 16) + " " + Character.digit(propStr.charAt(1), 16) + " " +

/*  466 */       Character.digit(propStr.charAt(2), 16) + " c=");

/*      */     

/*  468 */     int count = 0;

/*  469 */     if (propStr.contains(".")) {

/*  470 */       for (int i = 0; i < propStr.length(); i++) {

/*  471 */         if (propStr.charAt(i) == '.') {

/*  472 */           count++;

/*      */         }

/*      */       }

/*      */     }

/*  476 */     InetAddress address = null;

/*  477 */     InetAddress[] address2 = null;

/*      */     

/*  479 */     if (((count != 3) || (Character.digit(propStr.charAt(0), 10) == -1)) ||

/*      */     

/*      */

/*      */

/*      */

/*  484 */       (propStr != null)) {

/*      */       try {

/*  486 */         address = InetAddress.getByName(propStr.trim());

/*  487 */         address2 = InetAddress.getAllByName(propStr.trim());

/*  488 */         for (InetAddress ai : address2) {

/*  489 */           Log.debug("Proxy: getBindAddress address2=" + ai + " " + ai.getHostName() + " " + ai.getHostAddress());

/*      */         }

/*      */         

/*  492 */         Log.debug("Proxy: getBindAddress address=" + address + " " + address.getHostName() + " " + address.getHostAddress());

/*      */       } catch (java.net.UnknownHostException e) {

/*  494 */         log.error("getBindAddress " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */       }

/*      */     }

/*  497 */     Log.debug("Proxy: getBindAddress address=" + address + " " + address.getHostName() + " " + address.getAddress());

/*      */     

/*  499 */     return new InetSocketAddress(address, port);

/*      */   }

/*      */   

/*      */   private InetSocketAddress getExternalAddress(InetSocketAddress bindAddress) throws java.io.IOException

/*      */   {

/*  504 */     String propStr = Engine.getProperty("atavism.proxy.externalport");

/*  505 */     Log.debug("Proxy: getExternalAddress propStr=" + propStr);

/*      */     int port;

/*  507 */     int port; if (propStr != null) {

/*  508 */       port = Integer.parseInt(propStr.trim());

/*      */     } else {

/*  510 */       port = bindAddress.getPort();

/*      */     }

/*  512 */     Log.debug("Proxy: getExternalAddress port=" + port);

/*      */     

/*      */

/*  515 */     propStr = Engine.getProperty("atavism.proxy.externaladdress");

/*  516 */     Log.debug("Proxy: getExternalAddress propStr=" + propStr);

/*      */     InetAddress address;

/*  518 */     InetAddress address; if (propStr != null) {

/*  519 */       address = InetAddress.getByName(propStr.trim());

/*      */     } else {

/*  521 */       address = bindAddress.getAddress();

/*  522 */       Log.debug("Proxy: getExternalAddress else address=" + address);

/*  523 */       if (address.isAnyLocalAddress())

/*      */       {

/*  525 */         address = InetAddress.getLocalHost();

/*  526 */         Log.debug("Proxy: getExternalAddress get local host address=" + address + " " + address.getHostName() + " " + address.getHostAddress());

/*      */       }

/*      */     }

/*  529 */     Log.debug("Proxy: getExternalAddress address=" + address + " " + address.getHostName() + " " + address.getAddress());

/*      */     

/*  531 */     return new InetSocketAddress(address, port);

/*      */   }

/*      */   

/*  534 */   private String howla() { String characters = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijklmnoprstquwxyz123456789";

/*  535 */     String k = "";

/*  536 */     for (int i = 0; i < 14; i++) {

/*  537 */       java.util.Random random = new java.util.Random();

/*  538 */       k = k + characters.charAt(random.nextInt(characters.length() - 1));

/*      */     }

/*      */     

/*      */

/*  542 */     return k;

/*      */   }

/*      */   

/*      */   private void runCheck() {

/*  546 */     String email = Engine.getProperty("atavism.licence.email");

/*  547 */     String licencekey = Engine.getProperty("atavism.licence.key");

/*      */     

/*  549 */     String url = "https://apanel.atavismonline.com/login/verifyserver.php";

/*      */     

/*      */     try

/*      */     {

/*  553 */       String res = "";

/*  554 */       java.net.URL urlObj = new java.net.URL(url);

/*  555 */       URLConnection lu = urlObj.openConnection();

/*      */       

/*  557 */       String resSor = howla();

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*  566 */       String data = "email=" + URLEncoder.encode(email, "UTF-8") + "&licence=" + URLEncoder.encode(licencekey, "UTF-8") + "&ver=" + URLEncoder.encode("2018.3.1", "UTF-8") + "&addr=" + URLEncoder.encode(Engine.getProperty("atavism.proxy.bindaddress"), "UTF-8") + "&sor=" + URLEncoder.encode(resSor, "UTF-8") + "&c=" + URLEncoder.encode("0", "UTF-8") + "&cp=" + this.playerManager.getPlayerCount();

/*      */       

/*  568 */       lu.setDoOutput(true);

/*  569 */       OutputStreamWriter wr = new OutputStreamWriter(lu.getOutputStream());

/*  570 */       wr.write(data);

/*  571 */       wr.flush();

/*      */       

/*      */

/*  574 */       java.io.BufferedReader rd = new java.io.BufferedReader(new java.io.InputStreamReader(lu.getInputStream()));

/*  575 */       String line = "";

/*  576 */       while ((line = rd.readLine()) != null) {

/*  577 */         res = res + line;

/*      */       }

/*  579 */       wr.flush();

/*  580 */       wr.close();

/*      */       

/*  582 */       res = atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(res));

/*      */       

/*  584 */       String[] output = res.split(":");

/*  585 */       if ((atavism.server.util.EncryptionHelper.passwordMD5Check(output[0], getTemp())) && (resSor.equals(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[2]))))) {

/*  586 */         this.connectionLimit = Integer.parseInt(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[1])));

/*  587 */         recheck reCheck = new recheck(resSor);

/*  588 */         Engine.getExecutor().scheduleAtFixedRate(reCheck, 300L, 300L, java.util.concurrent.TimeUnit.SECONDS);

/*      */       } else {

/*  590 */         System.out.println("\nLicense verification failed");

/*  591 */         Log.error("License verification failed");

/*      */       }

/*  593 */       Log.debug("CONNECTOR: connections set to: " + this.connectionLimit);

/*      */     } catch (Exception e) {

/*  595 */       Log.error("CONNECTOR: failed verifying account with : " + e);

/*      */     }

/*      */   }

/*      */   

/*      */   class recheck implements Runnable

/*      */   {

/*  601 */     protected String sec = "";

/*      */     

/*  603 */     public recheck(String sec) { this.sec = sec; }

/*      */     

/*      */     public void run() {

/*  606 */       Log.debug("CONNECTOR: ");

/*  607 */       String email = Engine.getProperty("atavism.licence.email");

/*  608 */       String licencekey = Engine.getProperty("atavism.licence.key");

/*  609 */       String url = "https://apanel.atavismonline.com/login/verifyserver.php";

/*      */       try

/*      */       {

/*  612 */         String res = "";

/*  613 */         java.net.URL urlObj = new java.net.URL(url);

/*  614 */         URLConnection lu = urlObj.openConnection();

/*      */         

/*      */

/*      */

/*      */

/*      */

/*      */

/*  621 */         String data = "email=" + URLEncoder.encode(email, "UTF-8") + "&licence=" + URLEncoder.encode(licencekey, "UTF-8") + "&ver=" + URLEncoder.encode("2018.3.1", "UTF-8") + "&addr=" + URLEncoder.encode(Engine.getProperty("atavism.proxy.bindaddress"), "UTF-8") + "&sor=" + URLEncoder.encode(this.sec, "UTF-8") + "&c=" + URLEncoder.encode("1", "UTF-8") + "&cp=" + ProxyPlugin.this.playerManager.getPlayerCount();

/*      */         

/*  623 */         lu.setDoOutput(true);

/*  624 */         OutputStreamWriter wr = new OutputStreamWriter(lu.getOutputStream());

/*  625 */         wr.write(data);

/*  626 */         wr.flush();

/*      */         

/*      */

/*  629 */         java.io.BufferedReader rd = new java.io.BufferedReader(new java.io.InputStreamReader(lu.getInputStream()));

/*  630 */         String line = "";

/*  631 */         while ((line = rd.readLine()) != null) {

/*  632 */           res = res + line;

/*      */         }

/*      */         

/*  635 */         wr.flush();

/*  636 */         wr.close();

/*      */         

/*  638 */         res = atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(res));

/*      */         

/*  640 */         String[] output = res.split(":");

/*  641 */         if ((atavism.server.util.EncryptionHelper.passwordMD5Check(output[0], ProxyPlugin.this.getTemp())) && (this.sec.equals(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[2]))))) {

/*  642 */           ProxyPlugin.this.connectionLimit = Integer.parseInt(atavism.agis.util.HelperFunctions.readEncodedString(Base64.decode(output[1])));

/*      */         } else {

/*  644 */           System.out.println("\nLicense verification failed");

/*  645 */           Log.error("License verification failed");

/*  646 */           ProxyPlugin.this.connectionLimit = 0;

/*      */         }

/*  648 */         Log.debug("CONNECTOR: connections set to: " + ProxyPlugin.this.connectionLimit);

/*      */       } catch (Exception e) {

/*  650 */         Log.error("CONNECTOR: failed verifying account with : " + e);

/*      */       }

/*      */     }

/*      */     

/*      */

/*      */

/*      */     private static final long serialVersionUID = 1L;

/*      */   }

/*      */   

/*      */

/*      */   public Map<String, String> getStatusMap()

/*      */   {

/*  662 */     Map<String, String> status = new HashMap();

/*  663 */     status.put("players", Integer.toString(this.playerManager.getPlayerCount()));

/*  664 */     return status;

/*      */   }

/*      */   

/*      */   /* Error */

/*      */   public void registerCommand(String command, CommandParser parser)

/*      */   {

/*      */     // Byte code:

/*      */     //   0: aload_0

/*      */     //   1: getfield 18    atavism/server/plugins/ProxyPlugin:commandMapLock    Ljava/util/concurrent/locks/Lock;

/*      */     //   4: invokeinterface 405 1 0

/*      */     //   9: aload_0

/*      */     //   10: getfield 21    atavism/server/plugins/ProxyPlugin:commandMap    Ljava/util/Map;

/*      */     //   13: aload_1

/*      */     //   14: new 406    atavism/server/plugins/ProxyPlugin$RegisteredCommand

/*      */     //   17: dup

/*      */     //   18: aload_2

/*      */     //   19: aload_0

/*      */     //   20: getfield 24    atavism/server/plugins/ProxyPlugin:defaultCommandAccess    Latavism/server/plugins/ProxyPlugin$CommandAccessCheck;

/*      */     //   23: invokespecial 407    atavism/server/plugins/ProxyPlugin$RegisteredCommand:<init>    (Latavism/server/plugins/ProxyPlugin$CommandParser;Latavism/server/plugins/ProxyPlugin$CommandAccessCheck;)V

/*      */     //   26: invokeinterface 163 3 0

/*      */     //   31: pop

/*      */     //   32: aload_0

/*      */     //   33: getfield 18    atavism/server/plugins/ProxyPlugin:commandMapLock    Ljava/util/concurrent/locks/Lock;

/*      */     //   36: invokeinterface 408 1 0

/*      */     //   41: goto +15 -> 56

/*      */     //   44: astore_3

/*      */     //   45: aload_0

/*      */     //   46: getfield 18    atavism/server/plugins/ProxyPlugin:commandMapLock    Ljava/util/concurrent/locks/Lock;

/*      */     //   49: invokeinterface 408 1 0

/*      */     //   54: aload_3

/*      */     //   55: athrow

/*      */     //   56: return

/*      */     // Line number table:

/*      */     //   Java source line #815    -> byte code offset #0

/*      */     //   Java source line #817    -> byte code offset #9

/*      */     //   Java source line #820    -> byte code offset #32

/*      */     //   Java source line #821    -> byte code offset #41

/*      */     //   Java source line #820    -> byte code offset #44

/*      */     //   Java source line #822    -> byte code offset #56

/*      */     // Local variable table:

/*      */     //   start    length    slot    name    signature

/*      */     //   0    57    0    this    ProxyPlugin

/*      */     //   0    57    1    command    String

/*      */     //   0    57    2    parser    CommandParser

/*      */     //   44    11    3    localObject    Object

/*      */     // Exception table:

/*      */     //   from    to    target    type

/*      */     //   9    32    44    finally

/*      */   }

/*      */   

/*      */   class ReceivedMessage

/*      */     implements Runnable

/*      */   {

/*      */     Message message;

/*      */     int flags;

/*      */     

/*      */     ReceivedMessage(Message message, int flags)

/*      */     {

/*  669 */       this.message = message;

/*  670 */       this.flags = flags;

/*      */     }

/*      */     

/*      */     public void run() {

/*  674 */       ProxyPlugin.this.callEngineOnMessage(this.message, this.flags);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public class PluginMessageCallback

/*      */     implements atavism.msgsys.MessageCallback

/*      */   {

/*      */     public PluginMessageCallback() {}

/*      */     

/*      */

/*      */     public void handleMessage(Message message, int flags)

/*      */     {

/*  688 */       this.executor.execute(new ProxyPlugin.ReceivedMessage(ProxyPlugin.this, message, flags));

/*      */     }

/*      */     

/*  691 */     java.util.concurrent.ExecutorService executor = java.util.concurrent.Executors.newSingleThreadExecutor();

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public class PlayerMessageCallback

/*      */     implements atavism.msgsys.MessageCallback

/*      */   {

/*      */     public PlayerMessageCallback() {}

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void handleMessage(Message message, int flags)

/*      */     {

/*  718 */       if ((message instanceof TargetMessage)) {

/*  719 */         if (message.getMsgType() == WorldManagerClient.MSG_TYPE_TARGETED_PROPERTY) {

/*  720 */           ProxyPlugin.this.countMsgTargetedProperty.add();

/*      */         }

/*      */         

/*  723 */         OID playerOid = ((TargetMessage)message).getTarget();

/*  724 */         Player player = ProxyPlugin.this.playerManager.getPlayer(playerOid);

/*  725 */         if (player == null) {

/*  726 */           Log.debug("TargetMessage: player " + playerOid + " not found");

/*      */           

/*  728 */           if (message.isRPC()) {

/*  729 */             if (message.getMsgType() == InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ) {

/*  730 */               Engine.getAgent().sendBooleanResponse(message,

/*  731 */                 Boolean.valueOf(false));

/*  732 */             } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_PLAYER_IGNORE_LIST_REQ) {

/*  733 */               Engine.getAgent().sendObjectResponse(message, null);

/*  734 */             } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_GET_PLAYER_LOGIN_STATUS) {

/*  735 */               Engine.getAgent().sendObjectResponse(message, null);

/*  736 */             } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_LOGOUT_PLAYER) {

/*  737 */               Engine.getAgent().sendObjectResponse(message, null);

/*      */             } else {

/*  739 */               throw new RuntimeException("Unexpected RPC message " + message + " for player " + player);

/*      */             }

/*      */           }

/*      */         }

/*      */         else

/*      */         {

/*  745 */           message.setEnqueueTime();

/*      */           

/*  747 */           ProxyPlugin.this.messageQQ.insert(player, message);

/*      */         }

/*  749 */         return; }

/*  750 */       if ((message instanceof atavism.msgsys.SubjectMessage))

/*      */       {

/*  752 */         List<Player> perceivers = ProxyPlugin.this.playerManager.getPerceivers(((atavism.msgsys.SubjectMessage)message).getSubject());

/*  753 */         if (perceivers == null) {

/*  754 */           Log.warn("No perceivers for " + message);

/*  755 */           return;

/*      */         }

/*  757 */         if ((message instanceof WorldManagerClient.UpdateWorldNodeMessage)) {

/*  758 */           WorldManagerClient.UpdateWorldNodeMessage wMsg = (WorldManagerClient.UpdateWorldNodeMessage)message;

/*      */           

/*  760 */           DirLocOrientEvent dloEvent = new DirLocOrientEvent(wMsg.getSubject(), wMsg.getWorldNode());

/*  761 */           wMsg.setEventBuf(dloEvent.toBytes());

/*      */         }

/*      */         

/*      */

/*  765 */         if (message.getMsgType() == WorldManagerClient.MSG_TYPE_UPDATEWNODE) {

/*  766 */           ProxyPlugin.this.countMsgUpdateWNodeIn.add();

/*  767 */           ProxyPlugin.this.countMsgUpdateWNodeOut.add(perceivers.size());

/*  768 */         } else if (message.getMsgType() == PropertyMessage.MSG_TYPE_PROPERTY) {

/*  769 */           ProxyPlugin.this.countMsgPropertyIn.add();

/*  770 */           ProxyPlugin.this.countMsgPropertyOut.add(perceivers.size());

/*  771 */         } else if (message.getMsgType() == WorldManagerClient.MSG_TYPE_WNODECORRECT) {

/*  772 */           ProxyPlugin.this.countMsgWNodeCorrectIn.add();

/*  773 */           ProxyPlugin.this.countMsgWNodeCorrectOut.add(perceivers.size());

/*  774 */         } else if (message.getMsgType() == WorldManagerClient.MSG_TYPE_MOB_PATH) {

/*  775 */           ProxyPlugin.this.countMsgMobPathIn.add();

/*  776 */           ProxyPlugin.this.countMsgMobPathOut.add(perceivers.size());

/*      */         }

/*  778 */       } else { if ((message instanceof PerceptionMessage)) {

/*  779 */           PerceptionMessage pMsg = (PerceptionMessage)message;

/*  780 */           ProxyPlugin.this.countMsgPerception.add();

/*  781 */           ProxyPlugin.this.countMsgPerceptionGain.add(pMsg.getGainObjectCount());

/*  782 */           ProxyPlugin.this.countMsgPerceptionLost.add(pMsg.getLostObjectCount());

/*      */           

/*  784 */           OID playerOid = pMsg.getTarget();

/*  785 */           Log.debug("PERCEP: got perception message with player: " + playerOid);

/*  786 */           Player player = ProxyPlugin.this.playerManager.getPlayer(playerOid);

/*  787 */           if (player == null) {

/*  788 */             Log.debug("PerceptionMessage: player " + playerOid + " not found");

/*      */           } else {

/*  790 */             message.setEnqueueTime();

/*  791 */             ProxyPlugin.this.messageQQ.insert(player, message);

/*  792 */             Log.debug("PERCEP: added perception message to messageQQ: ");

/*      */           }

/*  794 */           return;

/*      */         }

/*  796 */         Log.error("PlayerMessageCallback unknown type=" + message.getMsgType()); return;

/*      */       }

/*      */       

/*      */       List<Player> perceivers;

/*  800 */       message.setEnqueueTime();

/*  801 */       ProxyPlugin.this.messageQQ.insert(perceivers, message);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void registerCommand(String command, CommandParser parser, CommandAccessCheck access)

/*      */   {

/*  836 */     this.commandMapLock.lock();

/*      */     try {

/*  838 */       this.commandMap.put(command, new RegisteredCommand(parser, access));

/*      */     } finally {

/*  840 */       this.commandMapLock.unlock();

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public static abstract interface CommandParser

/*      */   {

/*      */     public abstract void parse(CommandEvent paramCommandEvent);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public static abstract interface CommandAccessCheck

/*      */   {

/*      */     public abstract boolean allowed(CommandEvent paramCommandEvent, ProxyPlugin paramProxyPlugin);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   private static class RegisteredCommand

/*      */   {

/*      */     public ProxyPlugin.CommandParser parser;

/*      */     

/*      */     public ProxyPlugin.CommandAccessCheck access;

/*      */     

/*      */

/*      */     public RegisteredCommand(ProxyPlugin.CommandParser p, ProxyPlugin.CommandAccessCheck a)

/*      */     {

/*  869 */       this.parser = p;

/*  870 */       this.access = a;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*  878 */   protected Lock commandMapLock = atavism.server.util.LockFactory.makeLock("CommandMapLock");

/*      */   

/*  880 */   Map<String, RegisteredCommand> commandMap = new HashMap();

/*      */   

/*  882 */   CommandAccessCheck defaultCommandAccess = new DefaultCommandAccess(null);

/*      */   

/*      */   private static class DefaultCommandAccess implements ProxyPlugin.CommandAccessCheck {

/*      */     public boolean allowed(CommandEvent event, ProxyPlugin proxy) {

/*  886 */       return true;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   void registerHooks()

/*      */   {

/*  895 */     log.debug("registering hooks");

/*      */     

/*  897 */     getHookManager().addHook(atavism.agis.plugins.SocialClient.MSG_TYPE_BLOCK_LIST, new BlockListHook());

/*      */     

/*  899 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_DISPLAY_CONTEXT, new DisplayContextHook());

/*  900 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_DETACH, new DetachHook());

/*  901 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_ANIMATION, new AnimationHook());

/*  902 */     getHookManager().addHook(atavism.agis.plugins.AnimationClient.MSG_TYPE_INVOKE_EFFECT, new InvokeEffectHook());

/*  903 */     getHookManager().addHook(PropertyMessage.MSG_TYPE_PROPERTY, new PropertyHook());

/*  904 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_EXTENSION, new ExtensionHook());

/*  905 */     getHookManager().addHook(CombatClient.MSG_TYPE_ABILITY_STATUS, new AbilityStatusHook());

/*  906 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_TARGETED_PROPERTY, new TargetedPropertyHook());

/*  907 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_PERCEPTION_INFO, new PerceptionHook());

/*  908 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_COM, new ComHook());

/*      */     

/*  910 */     getHookManager().addHook(CombatClient.MSG_TYPE_DAMAGE, new DamageHook());

/*  911 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_SYS_CHAT, new SysChatHook());

/*  912 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_UPDATEWNODE, new UpdateWNodeHook());

/*  913 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_MOB_PATH, new UpdateMobPathHook());

/*  914 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_WNODECORRECT, new WNodeCorrectHook());

/*  915 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_ORIENT, new OrientHook());

/*  916 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_SOUND, new SoundHook());

/*  917 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_FOG, new FogHook());

/*  918 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_ROAD, new RoadHook());

/*  919 */     getHookManager().addHook(InventoryClient.MSG_TYPE_INV_UPDATE, new InvUpdateHook());

/*  920 */     getHookManager().addHook(CombatClient.MSG_TYPE_ABILITY_UPDATE, new AbilityUpdateHook());

/*  921 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_NEW_DIRLIGHT, new NewDirLightHook());

/*  922 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_FREE_OBJECT, new FreeObjectHook());

/*  923 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_SET_AMBIENT, new SetAmbientHook());

/*  924 */     getHookManager().addHook(WorldManagerClient.MSG_TYPE_P2P_EXTENSION, new P2PExtensionHook());

/*  925 */     getHookManager().addHook(MSG_TYPE_VOICE_PARMS, new VoiceParmsHook());

/*  926 */     getHookManager().addHook(MSG_TYPE_PLAYER_PATH_REQ, new PlayerPathReqHook());

/*  927 */     getHookManager().addHook(InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ, new InstanceEntryReqHook());

/*  928 */     getHookManager().addHook(atavism.management.Management.MSG_TYPE_GET_PLUGIN_STATUS, new GetPluginStatusHook());

/*  929 */     getHookManager().addHook(MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST, new UpdatePlayerIgnoreListHook());

/*  930 */     getHookManager().addHook(MSG_TYPE_GET_MATCHING_PLAYERS, new GetMatchingPlayersHook());

/*  931 */     getHookManager().addHook(MSG_TYPE_PLAYER_IGNORE_LIST_REQ, new PlayerIgnoreListReqHook());

/*  932 */     getHookManager().addHook(MSG_TYPE_GET_PLAYER_LOGIN_STATUS, new GetPlayerLoginStatusHook(null));

/*  933 */     getHookManager().addHook(MSG_TYPE_LOGOUT_PLAYER, new LogoutPlayerHook(null));

/*  934 */     getHookManager().addHook(MSG_TYPE_ADD_STATIC_PERCEPTION, new AddStaticPerceptionHook(null));

/*  935 */     getHookManager().addHook(MSG_TYPE_REMOVE_STATIC_PERCEPTION, new RemoveStaticPerceptionHook(null));

/*  936 */     getHookManager().addHook(MSG_TYPE_ACCOUNT_LOGIN, new AccountLoginHook(null));

/*      */   }

/*      */   

/*      */   class MatchedMessage { final Long sub;

/*      */     

/*  941 */     MatchedMessage(Long sub, Message message) { this.sub = sub;

/*  942 */       this.message = message;

/*  943 */       this.enqueueTime = System.currentTimeMillis();

/*      */     }

/*      */     

/*      */     public String toString() {

/*  947 */       return "MatchedMessage[subId=" + this.sub + ", enqueueTime=" + this.enqueueTime + ",msg=" + this.message;

/*      */     }

/*      */     

/*      */

/*      */     final Message message;

/*      */     final long enqueueTime;

/*      */   }

/*      */   

/*  955 */   private static final Player loginSerializer = new Player(null, null);

/*      */   

/*      */   void callEngineOnMessage(Message message, int flags) {

/*  958 */     super.handleMessage(message, flags);

/*      */   }

/*      */   

/*      */

/*      */   protected void initializeVoiceServerInformation()

/*      */   {

/*  964 */     voiceServerHost = Engine.properties.getProperty("atavism.voiceserver");

/*  965 */     String s = Engine.properties.getProperty("atavism.voiceport");

/*  966 */     if (s != null) {

/*  967 */       voiceServerPort = Integer.valueOf(Integer.parseInt(s));

/*      */     }

/*  969 */     if (Log.loggingDebug) {

/*  970 */       log.debug("initializeVoiceServerInformation: voiceServerHost " + voiceServerHost + ", voiceServerPort " + voiceServerPort);

/*      */     }

/*      */   }

/*      */   

/*      */   class MessageCallback

/*      */     implements atavism.server.util.SQCallback

/*      */   {

/*      */     protected ProxyPlugin proxyPlugin;

/*      */     

/*      */     public MessageCallback(ProxyPlugin proxyPlugin)

/*      */     {

/*  981 */       this.proxyPlugin = proxyPlugin;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void doWork(Object value, Object key)

/*      */     {

/*  997 */       Message message = (Message)value;

/*  998 */       Player player = (Player)key;

/*      */       

/*      */

/* 1001 */       if (message == null) {

/* 1002 */         Log.dumpStack("DOMESSAGE: Message for oid=" + player.getOid() + " is not a Message: " + value);

/* 1003 */         return;

/*      */       }

/*      */       

/* 1006 */       if ((message instanceof ProxyPlugin.ConnectionResetMessage)) {

/* 1007 */         if (player == ProxyPlugin.loginSerializer) {

/* 1008 */           ProxyPlugin.this.processConnectionResetInternal((ProxyPlugin.ConnectionResetMessage)message);

/*      */         } else {

/* 1010 */           ProxyPlugin.this.messageQQ.insert(ProxyPlugin.loginSerializer, message);

/*      */         }

/* 1012 */         return;

/*      */       }

/*      */       

/*      */

/*      */

/* 1017 */       int status = player.getStatus();

/* 1018 */       if ((status == 3) || (status == 0))

/*      */       {

/* 1020 */         Log.debug(

/* 1021 */           "Ignoring message: id=" + message.getMsgId() + " type=" + message.getMsgType() + " for " + player);

/* 1022 */         if (message.isRPC()) {

/* 1023 */           if (message.getMsgType() == InstanceClient.MSG_TYPE_INSTANCE_ENTRY_REQ) {

/* 1024 */             Engine.getAgent().sendBooleanResponse(message, Boolean.valueOf(false));

/* 1025 */           } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_PLAYER_IGNORE_LIST_REQ) {

/* 1026 */             Engine.getAgent().sendObjectResponse(message, null);

/* 1027 */           } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_GET_PLAYER_LOGIN_STATUS) {

/* 1028 */             Engine.getAgent().sendObjectResponse(message, null);

/* 1029 */           } else if (message.getMsgType() == ProxyPlugin.MSG_TYPE_LOGOUT_PLAYER) {

/* 1030 */             Engine.getAgent().sendObjectResponse(message, null);

/*      */           } else {

/* 1032 */             throw new RuntimeException("Unexpected RPC message " + message + " for player " + player);

/*      */           }

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1045 */         return;

/*      */       }

/*      */       try

/*      */       {

/* 1049 */         long inQueue = 0L;

/* 1050 */         if (Log.loggingDebug) {

/* 1051 */           inQueue = System.nanoTime() - message.getEnqueueTime();

/* 1052 */           Log.debug("DOINGSVRMESSAGE: Message for oid=" + player.getOid() + ",msgId=" + message.getMsgId() + ",in-queue=" + inQueue / 1000L + " usec: " + message

/* 1053 */             .getMsgType());

/*      */         }

/* 1055 */         if ((Log.loggingInfo) && (ProxyPlugin.this.proxyQueueHistogram != null)) {

/* 1056 */           ProxyPlugin.this.proxyQueueHistogram.addTime(inQueue);

/*      */         }

/*      */         

/* 1059 */         List<atavism.server.engine.Hook> hooks = ProxyPlugin.this.getHookManager().getHooks(message

/* 1060 */           .getMsgType());

/* 1061 */         long callbackStart = System.nanoTime();

/*      */         

/* 1063 */         for (atavism.server.engine.Hook hook : hooks) {

/* 1064 */           ((ProxyHook)hook).processMessage(message, 0, player);

/*      */         }

/* 1066 */         long callbackTime = 0L;

/* 1067 */         if ((Log.loggingDebug) || (Log.loggingInfo)) {

/* 1068 */           callbackTime = System.nanoTime() - callbackStart;

/*      */         }

/* 1070 */         if (Log.loggingDebug) {

/* 1071 */           Log.debug(

/* 1072 */             "DONESVRMESSAGE: Message for oid=" + player.getOid() + ",msgId=" + message.getMsgId() + ",in-queue=" + inQueue / 1000L + " usec: ,execute=" + callbackTime / 1000L + " usec: " + message.getMsgType());

/*      */         }

/* 1074 */         if ((Log.loggingInfo) && (ProxyPlugin.this.proxyCallbackHistogram != null)) {

/* 1075 */           ProxyPlugin.this.proxyCallbackHistogram.addTime(callbackTime);

/*      */         }

/*      */       } catch (Exception ex) {

/* 1078 */         Log.exception("SQ MessageCallback", ex);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1088 */   SquareQueue<Player, Message> messageQQ = new SquareQueue("Message");

/*      */   

/* 1090 */   atavism.server.util.SQThreadPool messageThreadPool = new atavism.server.util.SQThreadPool(this.messageQQ, new MessageCallback(this));

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void acceptConnection(ClientConnection con)

/*      */   {

/* 1100 */     Log.info("ProxyPlugin: CONNECTION remote=" + con);

/* 1101 */     con.registerMessageCallback(this);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void processPacket(ClientConnection con, AOByteBuffer buf)

/*      */   {

/*      */     try

/*      */     {

/* 1114 */       if (Log.loggingNet) {

/* 1115 */         if (ClientConnection.getLogMessageContents()) {

/* 1116 */           Log.net("ProxyPlugin.processPacket: con " + con + ", length " + buf.limit() + ", packet " + atavism.server.util.DebugUtils.byteArrayToHexString(buf));

/*      */         } else {

/* 1118 */           Log.net("ProxyPlugin.processPacket: con " + con + ", buf " + buf);

/*      */         }

/*      */       }

/* 1121 */       Event event = Engine.getEventServer().parseBytes(buf, con);

/* 1122 */       if (event == null) {

/* 1123 */         Log.error("Engine: could not parse packet data, remote=" + con);

/* 1124 */         return;

/*      */       }

/*      */       

/* 1127 */       Player player = (Player)con.getAssociation();

/* 1128 */       if (player == null) {

/* 1129 */         player = loginSerializer;

/* 1130 */         if ((event instanceof AuthorizedLoginEvent)) {

/* 1131 */           Log.info("ProxyPlugin: LOGIN_RECV remote=" + con + " playerOid=" + ((AuthorizedLoginEvent)event).getOid());

/*      */         }

/*      */       }

/* 1134 */       this.playerManager.processEvent(player, event, this.eventQQ);

/*      */     }

/*      */     catch (AORuntimeException e) {

/* 1137 */       Log.exception("ProxyPlugin.processPacket caught exception", e);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public class EventCallback

/*      */     implements atavism.server.util.SQCallback

/*      */   {

/*      */     public EventCallback() {}

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void doWork(Object value, Object key)

/*      */     {

/* 1158 */       Event event = (Event)value;

/* 1159 */       if (event == null) {

/* 1160 */         Log.dumpStack("EventCallback.doWork: event object is null, for key " + key);

/* 1161 */         return;

/*      */       }

/*      */       try {

/* 1164 */         ClientConnection con = event.getConnection();

/* 1165 */         Player player = (Player)key;

/*      */         

/*      */

/*      */

/* 1169 */         long startTime = System.currentTimeMillis();

/* 1170 */         long inQueue = startTime - event.getEnqueueTime();

/* 1171 */         Log.info("ProxyPlugin: EventCallback doWork  value" + value + " key=" + key + " in-queue=" + inQueue + " ms player:" + player);

/*      */         

/* 1173 */         if ((player == ProxyPlugin.loginSerializer) && ((event instanceof AuthorizedLoginEvent))) {

/* 1174 */           AuthorizedLoginEvent loginEvent = (AuthorizedLoginEvent)event;

/* 1175 */           OID playerOid = loginEvent.getOid();

/*      */           

/* 1177 */           Log.info("ProxyPlugin: LOGIN_BEGIN remote=" + con + " playerOid=" + playerOid + " in-queue=" + inQueue + " ms");

/*      */           

/* 1179 */           boolean loginOK = ProxyPlugin.this.processLogin(con, loginEvent);

/*      */           

/* 1181 */           Player newPlayer = ProxyPlugin.this.playerManager.getPlayer(playerOid);

/* 1182 */           String playerName = null;

/* 1183 */           if (newPlayer != null)

/* 1184 */             playerName = newPlayer.getName();

/* 1185 */           Log.info(

/* 1186 */             "ProxyPlugin: LOGIN_END remote=" + con + (loginOK ? " SUCCESS " : " FAILURE ") + " playerOid=" + playerOid + " name=" + playerName + " in-queue=" + inQueue + " ms processing=" + (System.currentTimeMillis() - startTime) + " ms nPlayers=" + ProxyPlugin.this.playerManager.getPlayerCount());

/* 1187 */           return;

/*      */         }

/*      */         

/* 1190 */         if (player == ProxyPlugin.loginSerializer) {

/* 1191 */           Log.error("ClientEvent: Illegal event for loginSerializer: " + event.getClass().getName() + ", con=" + con);

/* 1192 */           return;

/*      */         }

/*      */         

/* 1195 */         if (Log.loggingDebug)

/* 1196 */           Log.debug("ClientEvent: player=" + player + ", in-queue=" + inQueue + " ms: " + event.getName());

/* 1197 */         if ((Log.loggingInfo) && (inQueue > 2000L)) {

/* 1198 */           Log.info("LONG IN-QUEUE: " + inQueue + " ms: player=" + player + " " + event.getName());

/*      */         }

/*      */         

/* 1201 */         Lock objLock = ProxyPlugin.this.getObjectLockManager().getLock(player.getOid());

/* 1202 */         objLock.lock();

/*      */         try {

/* 1204 */           if (Log.loggingDebug)

/* 1205 */             Log.debug("ClientEvent: event detail: " + event);

/* 1206 */           if ((event instanceof ComEvent)) {

/* 1207 */             ProxyPlugin.this.processCom(con, (ComEvent)event);

/* 1208 */           } else if ((event instanceof DirLocOrientEvent)) {

/* 1209 */             ProxyPlugin.this.processDirLocOrient(con, (DirLocOrientEvent)event);

/* 1210 */           } else if ((event instanceof CommandEvent)) {

/* 1211 */             ProxyPlugin.this.processCommand(con, (CommandEvent)event);

/* 1212 */           } else if ((event instanceof AutoAttackEvent)) {

/* 1213 */             ProxyPlugin.this.processAutoAttack(con, (AutoAttackEvent)event);

/* 1214 */           } else if ((event instanceof ExtensionMessageEvent)) {

/* 1215 */             ProxyPlugin.this.processExtensionMessageEvent(con, (ExtensionMessageEvent)event);

/*      */           }

/* 1217 */           else if ((event instanceof atavism.agis.events.AbilityStatusEvent)) {

/* 1218 */             ProxyPlugin.this.processAbilityStatusEvent(con, (atavism.agis.events.AbilityStatusEvent)event);

/*      */           }

/* 1220 */           else if ((event instanceof atavism.agis.events.RequestQuestInfo)) {

/* 1221 */             ProxyPlugin.this.processRequestQuestInfo(con, (atavism.agis.events.RequestQuestInfo)event);

/* 1222 */           } else if ((event instanceof QuestResponse)) {

/* 1223 */             ProxyPlugin.this.processQuestResponse(con, (QuestResponse)event);

/* 1224 */           } else if ((event instanceof atavism.agis.events.ConcludeQuest)) {

/* 1225 */             ProxyPlugin.this.processReqConcludeQuest(con, (atavism.agis.events.ConcludeQuest)event);

/* 1226 */           } else if ((event instanceof ActivateItemEvent)) {

/* 1227 */             ProxyPlugin.this.processActivateItem(con, (ActivateItemEvent)event);

/* 1228 */           } else if ((event instanceof atavism.server.events.LogoutEvent)) {

/* 1229 */             ProxyPlugin.this.processLogout(con, (atavism.server.events.LogoutEvent)event);

/* 1230 */           } else if ((event instanceof atavism.server.events.SceneLoadedEvent)) {

/* 1231 */             ProxyPlugin.this.processSceneLoaded(con, (atavism.server.events.SceneLoadedEvent)event);

/*      */           } else {

/* 1233 */             throw new RuntimeException("Unknown event: " + event);

/*      */           }

/* 1235 */           long elapsed = System.currentTimeMillis() - startTime;

/* 1236 */           if (Log.loggingDebug) {

/* 1237 */             Log.debug("ClientEvent: processed event " + event + ", player=" + player + ", processing=" + elapsed + " ms");

/*      */             

/*      */

/* 1240 */             ProxyPlugin.this.clientMsgMeter.add(Long.valueOf(elapsed));

/*      */           }

/* 1242 */           if (elapsed > 2000L) {

/* 1243 */             Log.info(

/* 1244 */               "LONG PROCESS: " + elapsed + " ms: player=" + player + " " + event.getName());

/*      */           }

/*      */         } catch (Exception e) {

/* 1247 */           throw new RuntimeException("ProxyPlugin.EventCallback " + event + " processing error ", e);

/*      */         } finally {

/* 1249 */           objLock.unlock();

/*      */         }

/*      */       } catch (Exception e) {

/* 1252 */         throw new RuntimeException("ProxyPlugin.EventCallback " + event + " ", e);

/*      */       }

/* 1254 */       ProxyPlugin.log.debug("ProxyPlugin.EventCallback " + event + " doWork End");

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/* 1261 */   SquareQueue<Player, Event> eventQQ = new SquareQueue("Event");

/*      */   

/* 1263 */   atavism.server.util.SQThreadPool eventThreadPool = new atavism.server.util.SQThreadPool(this.eventQQ, new EventCallback());

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public Set<OID> getPlayerOids()

/*      */   {

/* 1272 */     List<Player> players = new ArrayList(this.playerManager.getPlayerCount());

/* 1273 */     this.playerManager.getPlayers(players);

/* 1274 */     Set<OID> result = new HashSet(players.size());

/* 1275 */     for (Player player : players) {

/* 1276 */       result.add(player.getOid());

/*      */     }

/* 1278 */     return result;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public List<String> getPlayerNames()

/*      */   {

/* 1287 */     List<Player> players = new ArrayList(this.playerManager.getPlayerCount());

/* 1288 */     Log.debug("ProxyPlugin.getPlayerNames: count is " + this.playerManager.getPlayerCount());

/* 1289 */     this.playerManager.getPlayers(players);

/* 1290 */     List<String> result = new ArrayList(players.size());

/* 1291 */     for (Player player : players) {

/* 1292 */       result.add(player.getName());

/*      */     }

/* 1294 */     return result;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public List<Player> getPlayers()

/*      */   {

/* 1302 */     List<Player> players = new ArrayList(this.playerManager.getPlayerCount());

/* 1303 */     this.playerManager.getPlayers(players);

/* 1304 */     return players;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public Player getPlayer(OID oid)

/*      */   {

/* 1314 */     return this.playerManager.getPlayer(oid);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public void addPlayerMessage(Message message, Player player)

/*      */   {

/* 1321 */     message.setEnqueueTime();

/* 1322 */     this.messageQQ.insert(player, message);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addFilteredProperty(String filteredProperty)

/*      */   {

/* 1333 */     this.filteredProps.add(filteredProperty);

/* 1334 */     this.cachedPlayerSpecificFilterProps.add(filteredProperty);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void addPlayerSpecificProperty(String filteredProperty)

/*      */   {

/* 1346 */     this.playerSpecificProps.add(filteredProperty);

/* 1347 */     this.cachedPlayerSpecificFilterProps.add(filteredProperty);

/*      */   }

/*      */   

/*      */   protected void recreatePlayerSpecificCache() {

/* 1351 */     this.cachedPlayerSpecificFilterProps = new HashSet();

/* 1352 */     this.cachedPlayerSpecificFilterProps.addAll(this.filteredProps);

/* 1353 */     this.cachedPlayerSpecificFilterProps.addAll(this.playerSpecificProps);

/*      */   }

/*      */   

/* 1356 */   atavism.server.util.AOMeter clientMsgMeter = new atavism.server.util.AOMeter("ClientEventProcessorMeter");

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean processLogin(ClientConnection con, AuthorizedLoginEvent loginEvent)

/*      */   {

/* 1371 */     OID playerOid = loginEvent.getOid();

/*      */     

/* 1373 */     String version = loginEvent.getVersion();

/* 1374 */     int nPlayers = this.playerManager.getPlayerCount();

/*      */     

/* 1376 */     String[] clientVersionCapabilities = null;

/* 1377 */     if ((version != null) && (version.length() > 0)) {

/* 1378 */       clientVersionCapabilities = version.split(",");

/*      */     }

/* 1380 */     LinkedList<String> clientCapabilities = new LinkedList();

/* 1381 */     String clientVersion = "";

/* 1382 */     if ((clientVersionCapabilities != null) && (clientVersionCapabilities.length > 0)) {

/* 1383 */       clientVersion = clientVersionCapabilities[0];

/* 1384 */       for (int i = 1; i < clientVersionCapabilities.length; i++) {

/* 1385 */         clientCapabilities.add(clientVersionCapabilities[i].trim());

/*      */       }

/*      */     }

/*      */     

/* 1389 */     int versionCompare = atavism.server.util.ServerVersion.compareVersionStrings(clientVersion, "2018.3.1");

/* 1390 */     if ((versionCompare != 1) && (versionCompare != 0)) {

/* 1391 */       Log.warn("processLogin: unsupported version " + clientVersion + " from player: " + playerOid);

/* 1392 */       AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed: Unsupported client version", this.serverVersion);

/* 1393 */       con.send(loginResponse.toBytes());

/* 1394 */       return false;

/*      */     }

/*      */     

/*      */

/* 1398 */     if ((!isAdmin(playerOid)) || (nPlayers >= this.connectionLimit)) {

/* 1399 */       Log.debug("processLogin: player is not admin");

/* 1400 */       if ((nPlayers >= MaxConcurrentUsers) || (nPlayers >= this.connectionLimit)) {

/* 1401 */         Log.warn("processLogin: too many users, failed for player: " + playerOid);

/* 1402 */         Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, this.capacityError, this.serverVersion);

/* 1403 */         con.send(loginResponse.toBytes());

/* 1404 */         return false;

/*      */       }

/*      */     } else {

/* 1407 */       Log.debug("processLogin: player is admin, bypassing max check");

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 1413 */     atavism.server.util.SecureToken token = atavism.server.util.SecureTokenManager.getInstance().importToken(loginEvent.getWorldToken());

/* 1414 */     boolean validToken = true;

/* 1415 */     if (!token.getValid()) {

/* 1416 */       Log.debug("token is not valid");

/* 1417 */       validToken = false;

/*      */     }

/* 1419 */     OID characterOid = (OID)token.getProperty("character_oid");

/* 1420 */     Log.debug("PlayerOID: " + playerOid);

/* 1421 */     Log.debug("CharacterOID: " + characterOid);

/* 1422 */     if (!playerOid.equals(characterOid)) {

/* 1423 */       Log.debug("playerOid does not match character_oid");

/* 1424 */       validToken = false;

/*      */     }

/* 1426 */     if (!token.getProperty("proxy_server").equals(Engine.getAgent().getName())) {

/* 1427 */       Log.debug("proxy_server does not match engine agent name");

/* 1428 */       validToken = false;

/*      */     }

/* 1430 */     if (!validToken) {

/* 1431 */       Log.error("processLogin: invalid proxy token");

/* 1432 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, this.tokenError, this.serverVersion);

/* 1433 */       con.send(loginResponse.toBytes());

/* 1434 */       return false;

/*      */     }

/*      */     try

/*      */     {

/* 1438 */       TargetMessage getPlayerLoginStatus = new TargetMessage(MSG_TYPE_GET_PLAYER_LOGIN_STATUS, playerOid);

/*      */       

/* 1440 */       PlayerLoginStatus loginStatus = (PlayerLoginStatus)Engine.getAgent().sendRPCReturnObject(getPlayerLoginStatus);

/* 1441 */       if (this.proxyLoginCallback.duplicateLogin(loginStatus, con)) {

/* 1442 */         if (loginStatus != null) {

/* 1443 */           Log.info("processLogin: LOGIN_DUPLICATE remote=" + con + " playerOid=" + playerOid + " name=" + loginStatus.name + " existingCon=" + loginStatus.clientCon + " existingProxy=" + loginStatus.proxyPluginName);

/*      */         }

/*      */         else {

/* 1446 */           Log.info("processLogin: LOGIN_DUPLICATE remote=" + con + " playerOid=" + playerOid + " loginStatus is null");

/*      */         }

/* 1448 */         AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed: Already connected", this.serverVersion);

/* 1449 */         con.send(loginResponse.toBytes());

/* 1450 */         return false;

/*      */       }

/*      */     } catch (atavism.msgsys.NoRecipientsException e) {

/* 1453 */       log.debug("processLogin: OK! player is not logged " + e);

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1469 */     Player player = new Player(playerOid, con);

/* 1470 */     player.setStatus(1);

/* 1471 */     if (!this.playerManager.addPlayer(player))

/*      */     {

/* 1473 */       player = this.playerManager.getPlayer(playerOid);

/* 1474 */       Log.info("processLogin: LOGIN_DUPLICATE remote=" + con + " playerOid=" + playerOid + " existing=" + player.getConnection());

/* 1475 */       AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed: Already connected", this.serverVersion);

/*      */       

/*      */

/* 1478 */       con.send(loginResponse.toBytes());

/* 1479 */       return false;

/*      */     }

/* 1481 */     con.setAssociation(player);

/*      */     

/* 1483 */     player.setVersion(clientVersion);

/* 1484 */     player.setCapabilities(clientCapabilities);

/*      */     

/* 1486 */     String errorMessage = this.proxyLoginCallback.preLoad(player, con);

/* 1487 */     if (errorMessage != null) {

/* 1488 */       this.playerManager.removePlayer(playerOid);

/* 1489 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, errorMessage, this.serverVersion);

/*      */       

/* 1491 */       con.send(loginResponse.toBytes());

/* 1492 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 1498 */     if (Log.loggingDebug) {

/* 1499 */       Log.debug("processLogin: loading object: " + playerOid + ", con=" + con);

/*      */     }

/* 1501 */     if (!loadPlayerObject(player)) {

/* 1502 */       Log.error("processLogin: could not load object " + playerOid);

/* 1503 */       this.playerManager.removePlayer(playerOid);

/* 1504 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, "Login Failed", this.serverVersion);

/* 1505 */       con.send(loginResponse.toBytes());

/* 1506 */       return false;

/*      */     }

/* 1508 */     if (Log.loggingDebug) {

/* 1509 */       Log.debug("processLogin: loaded player object: " + playerOid);

/*      */     }

/*      */     

/* 1512 */     errorMessage = this.proxyLoginCallback.postLoad(player, con);

/* 1513 */     if (errorMessage != null) {

/* 1514 */       this.playerManager.removePlayer(playerOid);

/* 1515 */       Event loginResponse = new AuthorizedLoginResponseEvent(playerOid, false, errorMessage, this.serverVersion);

/* 1516 */       con.send(loginResponse.toBytes());

/* 1517 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 1523 */     AuthorizedLoginResponseEvent loginResponse = new AuthorizedLoginResponseEvent(playerOid, true, "Login Succeeded", this.serverVersion + ", " + this.serverCapabilitiesSentToClient);

/* 1524 */     con.send(loginResponse.toBytes());

/* 1525 */     if (Log.loggingDebug) {

/* 1526 */       Log.debug("Login response sent for playerOid=" + playerOid + " the authorized login response message is : " + loginResponse.getMessage());

/*      */     }

/*      */     

/*      */

/*      */

/* 1531 */     this.playerManager.addStaticPerception(player, playerOid);

/*      */     

/* 1533 */     boolean loginOK = processLoginHelper(con, player);

/* 1534 */     if (!loginOK)

/*      */     {

/*      */

/*      */

/*      */

/*      */

/* 1540 */       if (Log.loggingDebug) {

/* 1541 */         Log.debug("processLogin: loading object: " + playerOid + ", con=" + con + " login failed disconect player");

/*      */       }

/*      */       

/* 1544 */       con.setAssociation(null);

/* 1545 */       if (this.perceptionFilter.removeTarget(playerOid)) {

/* 1546 */         FilterUpdate filterUpdate = new FilterUpdate(1);

/* 1547 */         filterUpdate.removeFieldValue(1, playerOid);

/* 1548 */         Engine.getAgent().applyFilterUpdate(this.perceptionSubId, filterUpdate);

/* 1549 */         this.responderFilter.removeTarget(playerOid);

/* 1550 */         Engine.getAgent().applyFilterUpdate(this.responderSubId, filterUpdate);

/*      */       }

/* 1552 */       this.playerManager.removeStaticPerception(player, playerOid);

/* 1553 */       this.playerManager.removePlayer(playerOid);

/* 1554 */       con.close();

/*      */     } else {

/* 1556 */       this.proxyLoginCallback.postSpawn(player, con);

/*      */       

/* 1558 */       this.playerManager.loginComplete(player, this.eventQQ);

/*      */       

/* 1560 */       atavism.msgsys.SubjectMessage loginSpawned = new atavism.msgsys.SubjectMessage(MSG_TYPE_LOGIN_SPAWNED);

/* 1561 */       loginSpawned.setSubject(playerOid);

/* 1562 */       Engine.getAgent().sendBroadcast(loginSpawned);

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1569 */       processPlayerIgnoreList(player);

/*      */       

/*      */

/*      */

/* 1573 */       OID accountID = (OID)EnginePlugin.getObjectProperty(playerOid, WorldManagerClient.NAMESPACE, "accountId");

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1585 */       this.clientConnections.put(accountID, con);

/*      */     }

/* 1587 */     log.debug("processLogin: loginOK:" + loginOK + " end");

/* 1588 */     return loginOK;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean loadPlayerObject(Player player)

/*      */   {

/* 1598 */     InstanceRestorePoint restorePoint = null;

/* 1599 */     LinkedList restoreStack = null;

/* 1600 */     boolean first = true;

/* 1601 */     OID playerOid = player.getOid();

/*      */     

/*      */

/* 1604 */     List<Namespace> namespaces = new ArrayList();

/* 1605 */     OID oidResult = ObjectManagerClient.loadSubObject(playerOid, namespaces);

/* 1606 */     if (oidResult == null) {

/* 1607 */       return false;

/*      */     }

/*      */     

/* 1610 */     atavism.server.math.Point location = new atavism.server.math.Point();

/* 1611 */     OID instanceOid = Engine.getDatabase().getLocation(playerOid, WorldManagerClient.NAMESPACE, location);

/* 1612 */     if (Log.loggingDebug) {

/* 1613 */       log.debug("loadPlayerObject instanceOid " + instanceOid + " instanceEntryAllowed:" + instanceEntryAllowed(playerOid, instanceOid, location));

/*      */     }

/* 1615 */     if (Log.loggingDebug)

/* 1616 */       log.debug("POP: trying to load player into instance: " + instanceOid);

/* 1617 */     AccountDatabase aDB = new AccountDatabase(false);

/* 1618 */     int guildID = aDB.GetGuildId(playerOid);

/*      */     try {

/*      */       for (;;) {

/* 1621 */         OID result = null;

/* 1622 */         if (instanceEntryAllowed(playerOid, instanceOid, location)) {

/* 1623 */           InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073);

/* 1624 */           if (Log.loggingDebug) {

/* 1625 */             log.debug("loadPlayerObject InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid + " start do ");

/*      */           }

/*      */           

/*      */

/* 1629 */           if ((instanceInfo.oid != null) && ((instanceInfo.populationLimit < 1) || (instanceInfo.playerPopulation < instanceInfo.populationLimit)))

/*      */           {

/*      */

/* 1632 */             result = ObjectManagerClient.loadObject(playerOid);

/* 1633 */             if (Log.loggingDebug) {

/* 1634 */               Log.debug("POP: loading player into instance: " + instanceInfo.oid + " of ID: " + instanceInfo.templateID);

/*      */             }

/*      */           }

/*      */         }

/*      */         

/* 1639 */         if ((restoreStack != null) && (!restorePoint.getFallbackFlag())) {

/* 1640 */           EnginePlugin.setObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack", restoreStack);

/*      */         }

/*      */         

/* 1643 */         if (result != null) {

/* 1644 */           if (restorePoint == null) break;

/* 1645 */           EnginePlugin.setObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "currentInstanceName", Integer.valueOf(restorePoint.getInstanceID()));

/* 1646 */           if (!Log.loggingDebug) break;

/* 1647 */           log.debug("INSTANCE: setting current instance prop: " + restorePoint.getInstanceID()); break;

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/*      */

/* 1654 */         if (first)

/*      */         {

/* 1656 */           Integer instanceID = (Integer)EnginePlugin.getObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "currentInstanceName");

/* 1657 */           if (Log.loggingDebug)

/* 1658 */             log.debug("Failed initial load, retrying with current instanceID=" + instanceID);

/* 1659 */           if (Log.loggingDebug) {

/* 1660 */             log.debug(" loadPlayerObject " + instanceID + "  " + playerOid);

/*      */           }

/* 1662 */           if (instanceID.intValue() > 0)

/*      */           {

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1673 */             instanceOid = this.instanceEntryCallback.selectInstance(player, instanceID.intValue(), playerOid, guildID);

/* 1674 */             if (Log.loggingDebug)

/* 1675 */               log.debug("loadPlayerObject instanceOid:" + instanceOid);

/* 1676 */             if (instanceOid != null)

/*      */             {

/* 1678 */               InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073, false);

/* 1679 */               if (Log.loggingDebug) {

/* 1680 */                 log.debug(" loadPlayerObject InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid);

/*      */               }

/* 1682 */               if (instanceInfo.oid != null) {

/* 1683 */                 if ((instanceInfo.populationLimit > 0) && (instanceInfo.playerPopulation >= instanceInfo.populationLimit)) {

/* 1684 */                   if (Log.loggingDebug)

/* 1685 */                     Log.debug("POP: got population: " + instanceInfo.playerPopulation + " and limit: " + instanceInfo.populationLimit);

/* 1686 */                   instanceOid = handleFullInstance(instanceInfo.templateID, instanceInfo);

/* 1687 */                   instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073);

/* 1688 */                   log.debug(" loadPlayerObject 2 InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid);

/*      */                 }

/*      */                 

/* 1691 */                 if (Log.loggingDebug)

/* 1692 */                   log.debug("Failed initial load, retrying with instanceOid=" + instanceOid + " and instanceName: " + instanceInfo.name);

/* 1693 */                 BasicWorldNode wnode = new BasicWorldNode();

/* 1694 */                 wnode.setInstanceOid(instanceOid);

/* 1695 */                 ObjectManagerClient.fixWorldNode(playerOid, wnode);

/* 1696 */                 first = false;

/* 1697 */                 continue;

/*      */               }

/*      */             }

/*      */           }

/*      */         }

/*      */         

/*      */

/* 1704 */         if ((restorePoint != null) && (restorePoint.getFallbackFlag())) {

/* 1705 */           if (Log.loggingDebug) {

/* 1706 */             log.debug("loadPlayerObject instanceOid " + instanceOid + " restorePoint:" + restorePoint + " restorePoint.getFallbackFlag():" + restorePoint.getFallbackFlag() + " return false");

/*      */           }

/* 1708 */           return false;

/*      */         }

/*      */         

/*      */

/* 1712 */         restoreStack = (LinkedList)EnginePlugin.getObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack");

/*      */         

/* 1714 */         if ((restoreStack == null) || (restoreStack.size() == 0)) {

/* 1715 */           Log.error("Failed finding matching instance, and restore stack is null or empty?" + restoreStack + " return false");

/* 1716 */           return false;

/*      */         }

/*      */         

/*      */

/* 1720 */         int size = restoreStack.size();

/* 1721 */         restorePoint = (InstanceRestorePoint)restoreStack.get(size - 1);

/*      */         

/* 1723 */         instanceOid = restorePoint.getInstanceOid();

/*      */         

/* 1725 */         if (restorePoint.getInstanceID() > 0) {

/* 1726 */           instanceOid = this.instanceEntryCallback.selectInstance(player, restorePoint.getInstanceID());

/* 1727 */           Log.debug("Failed finding matching instance, retrying with restore point instanceID=" + restorePoint.getInstanceID() + " result: " + instanceOid);

/*      */         }

/*      */         

/* 1730 */         if (instanceOid != null) {

/* 1731 */           BasicWorldNode wnode = new BasicWorldNode();

/* 1732 */           wnode.setInstanceOid(instanceOid);

/*      */           

/* 1734 */           wnode.setLoc(restorePoint.getLoc());

/* 1735 */           wnode.setOrientation(restorePoint.getOrientation());

/* 1736 */           wnode.setDir(new atavism.server.math.AOVector(0.0F, 0.0F, 0.0F));

/*      */           

/* 1738 */           boolean rc = ObjectManagerClient.fixWorldNode(playerOid, wnode);

/*      */           

/* 1740 */           if (!rc) {

/* 1741 */             if (Log.loggingDebug) {

/* 1742 */               log.debug("loadPlayerObject instanceOid " + instanceOid + " rc:" + rc + " return false");

/*      */             }

/* 1744 */             return false;

/*      */           }

/* 1746 */           location = restorePoint.getLoc();

/*      */         }

/* 1748 */         first = false;

/*      */         

/* 1750 */         if (!restorePoint.getFallbackFlag()) {

/* 1751 */           restoreStack.remove(size - 1);

/*      */         }

/*      */       }

/*      */     }

/*      */     catch (Exception e) {

/* 1756 */       log.error("loadPlayerObject instanceOid " + instanceOid + " Exception: " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */     }

/*      */     

/* 1759 */     if (Log.loggingDebug) {

/* 1760 */       log.debug("loadPlayerObject instanceOid " + instanceOid + " END return true");

/*      */     }

/* 1762 */     return true;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean processLoginHelper(ClientConnection con, Player player)

/*      */   {

/* 1776 */     OID playerOid = player.getOid();

/*      */     

/*      */

/*      */

/* 1780 */     WorldManagerClient.ObjectInfo objInfo = WorldManagerClient.getObjectInfo(playerOid);

/* 1781 */     if (Log.loggingDebug)

/* 1782 */       log.debug("processLoginHelper objInfo " + objInfo.instanceOid);

/* 1783 */     if (objInfo == null) {

/* 1784 */       Log.error("processLogin: Could not get player ObjectInfo oid=" + playerOid);

/*      */       

/* 1786 */       return false;

/*      */     }

/*      */     

/* 1789 */     if (atavism.server.objects.World.FollowsTerrainOverride != null) {

/* 1790 */       Log.debug("using follows terrain override");

/* 1791 */       objInfo.followsTerrain = atavism.server.objects.World.FollowsTerrainOverride.booleanValue();

/*      */     }

/* 1793 */     if (Log.loggingDebug) {

/* 1794 */       Log.debug("processLogin: got object info: " + objInfo);

/*      */     }

/* 1796 */     player.setName(objInfo.name);

/*      */     

/* 1798 */     InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(objInfo.instanceOid, -131073);

/*      */     

/* 1800 */     if (Log.loggingDebug)

/* 1801 */       log.debug("InstanceInfo " + instanceInfo + " " + instanceInfo.playerOid + " " + instanceInfo.templateID + " " + instanceInfo.groupOid + " " + instanceInfo.guildOid);

/* 1802 */     if (instanceInfo == null) {

/* 1803 */       Log.error("processLogin: unknown instanceOid=" + objInfo.instanceOid);

/*      */       

/* 1805 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/* 1812 */     atavism.server.messages.LoginMessage loginMessage = new atavism.server.messages.LoginMessage(playerOid, objInfo.name);

/* 1813 */     loginMessage.setInstanceOid(objInfo.instanceOid);

/* 1814 */     AsyncRPCCallback asyncRPCCallback = new AsyncRPCCallback(player, "processLogin: got LoginMessage response");

/*      */     

/* 1816 */     int expectedResponses = Engine.getAgent().sendBroadcastRPC(loginMessage, asyncRPCCallback);

/*      */     

/* 1818 */     asyncRPCCallback.waitForResponses(expectedResponses);

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1829 */     Log.debug("processLogin: sending template (scene) name: " + instanceInfo.templateName);

/*      */     

/*      */

/* 1832 */     Event worldFileEvent = new atavism.server.events.WorldFileEvent(instanceInfo.templateName);

/* 1833 */     con.send(worldFileEvent.toBytes());

/* 1834 */     player.sceneLoading(true);

/*      */     

/*      */

/* 1837 */     Log.debug("INFO: process login helper");

/* 1838 */     con.send(objInfo.toBuffer(playerOid));

/*      */     

/*      */

/* 1841 */     DisplayContext dc = WorldManagerClient.getDisplayContext(playerOid);

/* 1842 */     ModelInfoEvent modelInfoEvent = new ModelInfoEvent(playerOid);

/* 1843 */     modelInfoEvent.setDisplayContext(dc);

/* 1844 */     if (Log.loggingDebug) {

/* 1845 */       Log.debug("processLogin: got dc: " + dc);

/*      */     }

/* 1847 */     con.send(modelInfoEvent.toBytes());

/*      */     

/*      */

/* 1850 */     Map<String, DisplayContext> childMap = dc.getChildDCMap();

/* 1851 */     if ((childMap != null) && (!childMap.isEmpty())) {

/* 1852 */       for (String slot : childMap.keySet()) {

/* 1853 */         DisplayContext attachDC = (DisplayContext)childMap.get(slot);

/* 1854 */         if (attachDC == null) {

/* 1855 */           throw new AORuntimeException("attach DC is null for obj: " + playerOid);

/*      */         }

/*      */         

/* 1858 */         OID attacheeOID = attachDC.getObjRef();

/* 1859 */         if (attacheeOID == null) {

/* 1860 */           throw new AORuntimeException("attachee oid is null for obj: " + playerOid);

/*      */         }

/*      */         

/*      */

/* 1864 */         if (Log.loggingDebug) {

/* 1865 */           Log.debug("processLogin: sending attach message to " + playerOid + " attaching to obj " + playerOid + ", object being attached=" + attacheeOID + " to slot " + slot + ", attachmentDC=" + attachDC);

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/* 1871 */         AttachEvent event = new AttachEvent(playerOid, attacheeOID, slot, attachDC);

/*      */         

/* 1873 */         con.send(event.toBytes());

/*      */       }

/* 1875 */       Log.debug("processLogin: done with processing attachments");

/*      */     }

/*      */     

/*      */

/*      */

/* 1880 */     if (this.perceptionFilter.addTarget(playerOid)) {

/* 1881 */       FilterUpdate filterUpdate = new FilterUpdate(1);

/* 1882 */       filterUpdate.addFieldValue(1, playerOid);

/* 1883 */       Engine.getAgent().applyFilterUpdate(this.perceptionSubId, filterUpdate);

/* 1884 */       this.responderFilter.addTarget(playerOid);

/* 1885 */       Engine.getAgent().applyFilterUpdate(this.responderSubId, filterUpdate);

/*      */     }

/*      */     

/*      */

/*      */

/* 1890 */     WorldManagerClient.updateObject(playerOid, playerOid);

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 1972 */     WorldManagerClient.TargetedExtensionMessage spawnBegin = new WorldManagerClient.TargetedExtensionMessage(playerOid, playerOid);

/*      */     

/* 1974 */     spawnBegin.setExtensionType("ao.SCENE_BEGIN");

/* 1975 */     spawnBegin.setProperty("action", "login");

/* 1976 */     spawnBegin.setProperty("name", instanceInfo.name);

/*      */     

/* 1978 */     spawnBegin.setProperty("templateName", instanceInfo.templateName);

/*      */     

/*      */

/* 1981 */     WorldManagerClient.TargetedExtensionMessage spawnEnd = new WorldManagerClient.TargetedExtensionMessage(playerOid, playerOid);

/*      */     

/* 1983 */     spawnEnd.setExtensionType("ao.SCENE_END");

/* 1984 */     spawnEnd.setProperty("action", "login");

/* 1985 */     spawnEnd.setProperty("name", instanceInfo.name);

/*      */     

/* 1987 */     spawnEnd.setProperty("templateName", instanceInfo.templateName);

/*      */     

/*      */

/*      */

/*      */

/*      */

/* 1993 */     Integer perceptionCount = WorldManagerClient.spawn(playerOid, spawnBegin, spawnEnd);

/*      */     

/* 1995 */     if (perceptionCount.intValue() < 0) {

/* 1996 */       Log.error("processLogin: spawn failed error=" + perceptionCount + " playerOid=" + playerOid);

/*      */       

/* 1998 */       if (perceptionCount.intValue() == -2)

/*      */       {

/*      */

/* 2001 */         return false;

/*      */       }

/* 2003 */       return false;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 2015 */     if ((perceptionCount.intValue() == 0) && (player.supportsLoadingState())) {

/* 2016 */       player.setLoadingState(1);

/* 2017 */       con.send(new atavism.server.events.LoadingStateEvent(false).toBytes());

/*      */     }

/*      */     

/* 2020 */     if (Log.loggingDebug) {

/* 2021 */       Log.debug("processLogin: During login, perceptionCount is " + perceptionCount);

/*      */       

/* 2023 */       Log.debug("processLogin: spawned player, master playerOid=" + playerOid);

/*      */     }

/*      */     

/*      */

/*      */

/* 2028 */     if (Log.loggingDebug) {

/* 2029 */       Log.debug("processLogin: sending over instance information for player " + playerOid + ", instance=" + instanceInfo.name + ", instanceOid=" + instanceInfo.oid);

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 2035 */     updateInstancePerception(player.getOid(), null, instanceInfo.oid, instanceInfo.name);

/*      */     

/*      */

/* 2038 */     return true;

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public ProxyLoginCallback getProxyLoginCallback()

/*      */   {

/* 2045 */     return this.proxyLoginCallback;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void setProxyLoginCallback(ProxyLoginCallback callback)

/*      */   {

/* 2053 */     this.proxyLoginCallback = callback;

/*      */   }

/*      */   

/*      */   private static class DefaultProxyLoginCallback

/*      */     implements ProxyLoginCallback

/*      */   {

/*      */     public boolean duplicateLogin(ProxyPlugin.PlayerLoginStatus existingLogin, ClientConnection con)

/*      */     {

/* 2061 */       return existingLogin != null;

/*      */     }

/*      */     

/*      */     public String preLoad(Player player, ClientConnection con) {

/* 2065 */       return null;

/*      */     }

/*      */     

/*      */     public String postLoad(Player player, ClientConnection con) {

/* 2069 */       return null;

/*      */     }

/*      */     

/*      */

/*      */     public void postSpawn(Player player, ClientConnection con) {}

/*      */   }

/*      */   

/*      */

/*      */   private boolean instanceEntryAllowed(OID playerOid, OID instanceOid, atavism.server.math.Point location)

/*      */   {

/* 2079 */     if (instanceOid == null) {

/* 2080 */       return false;

/*      */     }

/* 2082 */     return this.instanceEntryCallback.instanceEntryAllowed(playerOid, instanceOid, location);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public InstanceEntryCallback getInstanceEntryCallback()

/*      */   {

/* 2090 */     return this.instanceEntryCallback;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void setInstanceEntryCallback(InstanceEntryCallback callback)

/*      */   {

/* 2098 */     this.instanceEntryCallback = callback;

/*      */   }

/*      */   

/*      */   private static class DefaultInstanceEntryCallback implements InstanceEntryCallback

/*      */   {

/*      */     public boolean instanceEntryAllowed(OID playerOid, OID instanceOid, atavism.server.math.Point location)

/*      */     {

/* 2105 */       return true;

/*      */     }

/*      */     

/*      */     public OID selectInstance(Player player, int instanceID) {

/* 2109 */       return InstanceClient.getInstanceOid(instanceID, player.getOid(), null, -1, false);

/*      */     }

/*      */     

/*      */     public OID selectInstance(Player player, int instanceID, OID playerOid) {

/* 2113 */       return InstanceClient.getInstanceOid(instanceID, player.getOid(), playerOid, -1, false);

/*      */     }

/*      */     

/* 2116 */     public OID selectInstance(Player player, int instanceID, OID playerOid, int guildId) { return InstanceClient.getInstanceOid(instanceID, player.getOid(), playerOid, guildId, false); }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public void processRequestQuestInfo(ClientConnection con, atavism.agis.events.RequestQuestInfo event)

/*      */   {

/* 2125 */     OID npcOid = event.getQuestNpcOid();

/* 2126 */     Player player = verifyPlayer("processRequestQuestInfo", event, con);

/* 2127 */     if (Log.loggingDebug) {

/* 2128 */       Log.debug("processRequestQuestInfo: player=" + player + ", npc=" + npcOid);

/*      */     }

/* 2130 */     atavism.agis.plugins.QuestClient.requestQuestInfo(npcOid, player.getOid());

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public void processQuestResponse(ClientConnection con, QuestResponse event)

/*      */   {

/* 2137 */     Player player = verifyPlayer("processQuestResponse", event, con);

/* 2138 */     boolean acceptStatus = event.getResponse();

/* 2139 */     OID npcOid = event.getQuestNpcOid();

/* 2140 */     OID questOid = event.getQuestId();

/*      */     

/* 2142 */     if (Log.loggingDebug) {

/* 2143 */       Log.debug("processQuestResponse: player=" + player + ", npcOid=" + npcOid + ", acceptStatus=" + acceptStatus);

/*      */     }

/*      */     

/*      */

/*      */

/* 2148 */     atavism.agis.plugins.QuestClient.QuestResponseMessage msg = new atavism.agis.plugins.QuestClient.QuestResponseMessage(npcOid, player.getOid(), questOid, acceptStatus);

/*      */     

/* 2150 */     Engine.getAgent().sendBroadcast(msg);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   public void processReqConcludeQuest(ClientConnection con, atavism.agis.events.ConcludeQuest event)

/*      */   {

/* 2158 */     Player player = verifyPlayer("processReqConcludeQuest", event, con);

/* 2159 */     OID mobOid = event.getQuestNpcOid();

/* 2160 */     if (Log.loggingDebug) {

/* 2161 */       Log.debug("processReqConclude: player=" + player + ", mobOid=" + mobOid);

/*      */     }

/* 2163 */     atavism.agis.plugins.QuestClient.requestConclude(mobOid, player.getOid());

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void connectionReset(ClientConnection con)

/*      */   {

/* 2175 */     Player player = (Player)con.getAssociation();

/*      */     

/* 2177 */     if (player == null) {

/* 2178 */       Log.info("ProxyPlugin: DISCONNECT remote=" + con);

/* 2179 */       return;

/*      */     }

/* 2181 */     Log.info(

/* 2182 */       "ProxyPlugin: DISCONNECT remote=" + con + " playerOid=" + player.getOid() + " name=" + player.getName());

/*      */     

/* 2184 */     if (this.playerManager.logout(player)) {

/* 2185 */       ConnectionResetMessage message = new ConnectionResetMessage(con, player);

/*      */       

/* 2187 */       message.setEnqueueTime(System.currentTimeMillis());

/* 2188 */       this.messageQQ.insert(player, message); } }

/*      */   

/*      */   class ConnectionResetMessage extends Message { ClientConnection con;

/*      */     Player player;

/*      */     public static final long serialVersionUID = 1L;

/*      */     

/* 2194 */     ConnectionResetMessage(ClientConnection con, Player player) { this.con = con;

/* 2195 */       this.player = player;

/*      */     }

/*      */     

/*      */     public Player getPlayer() {

/* 2199 */       return this.player;

/*      */     }

/*      */     

/*      */     public ClientConnection getConnection() {

/* 2203 */       return this.con;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void processConnectionResetInternal(ConnectionResetMessage message)

/*      */   {

/* 2218 */     long startTime = System.currentTimeMillis();

/* 2219 */     ClientConnection con = message.getConnection();

/* 2220 */     Player player = message.getPlayer();

/* 2221 */     OID playerOid = player.getOid();

/*      */     

/* 2223 */     Log.info("ProxyPlugin: LOGOUT_BEGIN remote=" + con + " playerOid=" + player.getOid() + " name=" + player.getName());

/*      */     

/*      */

/* 2226 */     if (player.getStatus() != 3) {

/* 2227 */       log.error("processConnectionReset: player status is " +

/* 2228 */         Player.statusToString(player.getStatus()) + " should be " +

/* 2229 */         Player.statusToString(3));

/*      */     }

/*      */     

/*      */     try

/*      */     {

/* 2234 */       if (!WorldManagerClient.despawn(playerOid)) {

/* 2235 */         log.warn("processConnectionReset: despawn player failed for " + playerOid);

/*      */       }

/* 2237 */       Log.debug("processConnectionResetInternal Removing perceptionFilter for palyer: " + playerOid);

/* 2238 */       if (this.perceptionFilter.removeTarget(playerOid)) {

/* 2239 */         FilterUpdate filterUpdate = new FilterUpdate(1);

/* 2240 */         filterUpdate.removeFieldValue(1, playerOid);

/* 2241 */         Log.debug("processConnectionResetInternal Removing perceptionFilter applyFilterUpdate for palyer: " + playerOid);

/* 2242 */         Engine.getAgent().applyFilterUpdate(this.perceptionSubId, filterUpdate);

/* 2243 */         Log.debug("processConnectionResetInternal Removing responderFilter for palyer: " + playerOid);

/* 2244 */         this.responderFilter.removeTarget(playerOid);

/* 2245 */         Log.debug("processConnectionResetInternal Removing perceptionFilter applyFilterUpdate for palyer: " + playerOid);

/* 2246 */         Engine.getAgent().applyFilterUpdate(this.responderSubId, filterUpdate);

/*      */       }

/*      */       

/*      */

/*      */

/* 2251 */       atavism.server.messages.LogoutMessage logoutMessage = new atavism.server.messages.LogoutMessage(playerOid, player.getName());

/* 2252 */       Log.debug("processConnectionResetInternal: Send LogoutMessage for player: " + playerOid + "  and wait for response");

/* 2253 */       AsyncRPCCallback asyncRPCCallback = new AsyncRPCCallback(player, "processLogout: got LogoutMessage response");

/* 2254 */       int expectedResponses = Engine.getAgent().sendBroadcastRPCBlocking(logoutMessage, asyncRPCCallback);

/* 2255 */       Log.debug("processConnectionResetInternal: Send LogoutMessage for player: " + playerOid + "  and wait for response expectedResponses=" + expectedResponses);

/*      */       

/* 2257 */       OID accountID = (OID)EnginePlugin.getObjectProperty(playerOid, WorldManagerClient.NAMESPACE, "accountId");

/* 2258 */       Log.debug("Removing connection from client connection map for account: " + accountID);

/* 2259 */       this.clientConnections.remove(accountID);

/*      */       

/*      */

/* 2262 */       if (!ObjectManagerClient.unloadObject(playerOid).booleanValue()) {

/* 2263 */         log.warn("processConnectionReset: unloadObject failed oid=" + playerOid);

/*      */       }

/*      */     } catch (atavism.msgsys.NoRecipientsException nre) {

/* 2266 */       log.exception("ProxyPlugin.processConnectionResetInternal(): NoRecipientsException ", nre);

/*      */     } catch (atavism.msgsys.RPCTimeoutException nre) {

/* 2268 */       log.exception("ProxyPlugin.processConnectionResetInternal(): RPCTimeoutException ", nre);

/*      */     } catch (Exception nre) {

/* 2270 */       log.exception("ProxyPlugin.processConnectionResetInternal(): Exception ", nre);

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 2276 */     this.messageQQ.removeKey(player);

/* 2277 */     this.eventQQ.removeKey(player);

/*      */     

/* 2279 */     this.playerManager.removeStaticPerception(player, playerOid);

/* 2280 */     this.playerManager.removePlayer(playerOid);

/*      */     

/* 2282 */     Log.info("ProxyPlugin: LOGOUT_END remote=" + con + " playerOid=" + player.getOid() + " name=" + player.getName() + " in-queue=" + (startTime - message.getEnqueueTime()) + " processing=" + (

/* 2283 */       System.currentTimeMillis() - startTime) + " nPlayers=" + this.playerManager.getPlayerCount());

/*      */     

/* 2285 */     synchronized (player) {

/* 2286 */       player.clearConnection();

/* 2287 */       player.notifyAll();

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   protected void processDirLocOrient(ClientConnection con, DirLocOrientEvent event)

/*      */   {

/* 2296 */     if (Log.loggingDebug)

/* 2297 */       Log.debug("processDirLocOrient: got dir loc orient event: " + event);

/* 2298 */     Player player = verifyPlayer("processDirLoc", event, con);

/*      */     

/*      */

/* 2301 */     BasicWorldNode wnode = new BasicWorldNode();

/* 2302 */     wnode.setDir(event.getDir());

/* 2303 */     wnode.setLoc(event.getLoc());

/* 2304 */     wnode.setOrientation(event.getQuaternion());

/*      */     

/* 2306 */     WorldManagerClient.updateWorldNode(player.getOid(), wnode);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   protected void processCom(ClientConnection con, ComEvent event)

/*      */   {

/* 2314 */     Player player = verifyPlayer("processCom", event, con);

/*      */     

/* 2316 */     Log.info("ProxyPlugin: CHAT_SENT player=" + player + " channel=" + event

/* 2317 */       .getChannelId() + " msg=[" + event.getMessage() + "]");

/* 2318 */     AccountDatabase aDB = new AccountDatabase(false);

/* 2319 */     log.debug("processCom: CHAT_SENT");

/*      */     

/*      */

/* 2322 */     if (aDB.isOnBlackList(player.getOid(), event.getObjectOid()))

/*      */     {

/* 2324 */       aDB.close();

/* 2325 */       return;

/*      */     }

/* 2327 */     incrementChatCount();

/* 2328 */     WorldManagerClient.sendChatMsg(player.getOid(), player.getName(), event.getChannelId(), event

/* 2329 */       .getMessage());

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void processCommand(ClientConnection con, CommandEvent event)

/*      */   {

/* 2339 */     Player player = verifyPlayer("processCommand", event, con);

/*      */     

/* 2341 */     String cmd = event.getCommand().split(" ")[0];

/* 2342 */     if (Log.loggingDebug) {

/* 2343 */       log.debug("processCommand: cmd=" + cmd + ", fullCmd=" + event

/* 2344 */         .getCommand());

/*      */     }

/*      */     

/*      */

/* 2348 */     this.commandMapLock.lock();

/*      */     try {

/* 2350 */       command = (RegisteredCommand)this.commandMap.get(cmd);

/*      */     } finally { RegisteredCommand command;

/* 2352 */       this.commandMapLock.unlock(); }

/*      */     RegisteredCommand command;

/* 2354 */     if (command == null) {

/* 2355 */       Log.warn(

/* 2356 */         "processCommand: no parser for command: " + event.getCommand());

/* 2357 */       command = (RegisteredCommand)this.commandMap.get("/unknowncmd");

/* 2358 */       if (command != null) {

/* 2359 */         Engine.setCurrentPlugin(this);

/* 2360 */         command.parser.parse(event);

/* 2361 */         Engine.setCurrentPlugin(null);

/*      */       }

/* 2363 */       return;

/*      */     }

/*      */     

/* 2366 */     Engine.setCurrentPlugin(this);

/* 2367 */     if (command.access.allowed(event, this))

/*      */     {

/* 2369 */       command.parser.parse(event);

/*      */     } else

/* 2371 */       Log.warn(

/* 2372 */         "Player " + player + " not allowed to run command '" + event.getCommand() + "'");

/* 2373 */     Engine.setCurrentPlugin(null);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   protected void processAutoAttack(ClientConnection con, AutoAttackEvent event)

/*      */   {

/* 2380 */     CombatClient.autoAttack(event.getAttackerOid(), event.getTargetOid(), event

/* 2381 */       .getAttackStatus());

/*      */   }

/*      */   

/*      */   protected void processActivateItem(ClientConnection con, ActivateItemEvent event)

/*      */   {

/* 2386 */     InventoryClient.activateObject(event.getItemOid(), event

/* 2387 */       .getObjectOid(), event.getTargetOid());

/*      */   }

/*      */   

/*      */   protected void processAbilityStatusEvent(ClientConnection con, atavism.agis.events.AbilityStatusEvent event)

/*      */   {

/* 2392 */     Player player = (Player)con.getAssociation();

/*      */     

/*      */

/* 2395 */     atavism.agis.events.AbilityStatusMessage msg = new atavism.agis.events.AbilityStatusMessage(CombatClient.MSG_TYPE_ABILITY_STATUS, player.getOid(), event.getPropertyMap());

/* 2396 */     Engine.getAgent().sendBroadcast(msg);

/*      */   }

/*      */   

/*      */

/*      */   protected void processLogout(ClientConnection con, atavism.server.events.LogoutEvent event) {}

/*      */   

/*      */

/*      */   protected void processSceneLoaded(ClientConnection con, atavism.server.events.SceneLoadedEvent event)

/*      */   {

/* 2405 */     Player player = (Player)con.getAssociation();

/* 2406 */     player.sceneLoading(false);

/* 2407 */     Log.debug("SCENE: sceneLoading set to false for player: " + player.getOid());

/*      */   }

/*      */   

/*      */   protected void processExtensionMessageEvent(ClientConnection con, ExtensionMessageEvent event)

/*      */   {

/* 2412 */     String key = (String)event.getPropertyMap().get("ext_msg_subtype");

/* 2413 */     OID target = event.getTargetOid();

/* 2414 */     Player player = (Player)con.getAssociation();

/*      */     

/* 2416 */     if (Log.loggingDebug) {

/* 2417 */       Log.debug("processExtensionMessageEvent: " + player + " subType=" + key + " target=" + target);

/*      */     }

/*      */     

/* 2420 */     List<ProxyExtensionHook> proxyHookList = (List)this.extensionHooks.get(key);

/* 2421 */     if (proxyHookList != null) {

/* 2422 */       for (ProxyExtensionHook hook : proxyHookList) {

/* 2423 */         hook.processExtensionEvent(event, player, this);

/*      */       }

/* 2425 */       return;

/*      */     }

/*      */     

/* 2428 */     if (target != null)

/*      */     {

/*      */

/*      */

/* 2432 */       WorldManagerClient.TargetedExtensionMessage msg = new WorldManagerClient.TargetedExtensionMessage(WorldManagerClient.MSG_TYPE_EXTENSION, target, player.getOid(), event.getClientTargeted(), event.getPropertyMap());

/* 2433 */       if (event.getClientTargeted().booleanValue()) {

/* 2434 */         msg.setMsgType(WorldManagerClient.MSG_TYPE_P2P_EXTENSION);

/* 2435 */         if (allowClientToClientMessage(player, target, msg))

/* 2436 */           Engine.getAgent().sendBroadcast(msg);

/*      */       } else {

/* 2438 */         MessageType msgType = getExtensionMessageType(key);

/* 2439 */         if (msgType == null) {

/* 2440 */           Log.error("processExtensionMessageEvent: key '" + key + "' has no corresponding MessageType");

/*      */           

/* 2442 */           return;

/*      */         }

/* 2444 */         msg.setMsgType(msgType);

/* 2445 */         Engine.getAgent().sendBroadcast(msg);

/*      */       }

/*      */     } else {

/* 2448 */       MessageType msgType = getExtensionMessageType(key);

/* 2449 */       if (msgType == null) {

/* 2450 */         Log.error("processExtensionMessageEvent: key '" + key + "' has no corresponding MessageType");

/*      */         

/* 2452 */         return;

/*      */       }

/*      */       

/* 2455 */       WorldManagerClient.ExtensionMessage msg = new WorldManagerClient.ExtensionMessage(msgType, player.getOid(), event.getPropertyMap());

/* 2456 */       Engine.getAgent().sendBroadcast(msg);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   public void registerExtensionSubtype(String subtype, MessageType type)

/*      */   {

/* 2466 */     this.extensionMessageRegistry.put(subtype, type);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public MessageType unregisterExtensionSubtype(String subtype)

/*      */   {

/* 2473 */     return (MessageType)this.extensionMessageRegistry.remove(subtype);

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public MessageType getExtensionMessageType(String subtype)

/*      */   {

/* 2480 */     return (MessageType)this.extensionMessageRegistry.get(subtype);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public boolean allowClientToClientMessage(Player sender, OID targetOid, WorldManagerClient.TargetedExtensionMessage message)

/*      */   {

/* 2501 */     return this.defaultAllowClientToClientMessage;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 2508 */   public boolean defaultAllowClientToClientMessage = false;

/*      */   

/* 2510 */   protected HashMap<String, MessageType> extensionMessageRegistry = new HashMap();

/*      */   protected PerceptionFilter perceptionFilter;

/*      */   protected long perceptionSubId;

/*      */   protected PerceptionFilter responderFilter;

/*      */   protected long responderSubId;

/*      */   

/*      */   abstract class BasicProxyHook implements ProxyHook { BasicProxyHook() {}

/*      */     

/* 2518 */     public boolean processMessage(Message msg, int flags) { return true; }

/*      */     

/*      */

/*      */

/*      */     public abstract void processMessage(Message paramMessage, int paramInt, Player paramPlayer);

/*      */   }

/*      */   

/*      */

/*      */   class DisplayContextHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2529 */     DisplayContextHook() { super(); }

/*      */     

/* 2531 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.DisplayContextMessage dcMsg = (WorldManagerClient.DisplayContextMessage)msg;

/*      */       

/* 2533 */       OID dcObjOid = dcMsg.getSubject();

/* 2534 */       DisplayContext dc = dcMsg.getDisplayContext();

/* 2535 */       if (Log.loggingDebug) {

/* 2536 */         ProxyPlugin.log.debug("handleDC: oid=" + dcObjOid + " dc=" + dc);

/*      */       }

/* 2538 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2541 */       if (dc != null) {

/* 2542 */         ModelInfoEvent event = new ModelInfoEvent(dcObjOid);

/* 2543 */         event.setDisplayContext(dc);

/* 2544 */         event.setForceInstantLoad(dcMsg.getForceInstantLoad());

/* 2545 */         con.send(event.toBytes());

/*      */       }

/*      */       

/*      */

/* 2549 */       Map<String, DisplayContext> childMap = dc.getChildDCMap();

/* 2550 */       if ((childMap != null) && (!childMap.isEmpty())) {

/* 2551 */         for (String slot : childMap.keySet()) {

/* 2552 */           DisplayContext attachDC = (DisplayContext)childMap.get(slot);

/* 2553 */           if (attachDC == null) {

/* 2554 */             throw new AORuntimeException("attach DC is null for obj: " + dcObjOid);

/*      */           }

/*      */           

/* 2557 */           OID attacheeOID = attachDC.getObjRef();

/* 2558 */           if (attacheeOID == null) {

/* 2559 */             throw new AORuntimeException("attachee oid is null for obj: " + dcObjOid);

/*      */           }

/*      */           

/*      */

/* 2563 */           if (Log.loggingDebug) {

/* 2564 */             ProxyPlugin.log.debug("DisplayContextHook: sending attach message to " + player

/* 2565 */               .getOid() + " attaching to obj " + dcObjOid + ", object being attached=" + attacheeOID + " to slot " + slot + ", attachmentDC=" + attachDC);

/*      */           }

/*      */           

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 2574 */           AttachEvent event = new AttachEvent(dcObjOid, attacheeOID, slot, attachDC);

/*      */           

/* 2576 */           con.send(event.toBytes());

/*      */         }

/* 2578 */         ProxyPlugin.log.debug("DisplayContextHook: done with processing attachments");

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class NewDirLightHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2587 */     NewDirLightHook() { super(); }

/*      */     

/* 2589 */     public void processMessage(Message m, int flags, Player player) { WorldManagerClient.NewDirLightMessage msg = (WorldManagerClient.NewDirLightMessage)m;

/* 2590 */       OID playerOid = msg.getTarget();

/* 2591 */       OID lightOid = msg.getSubject();

/* 2592 */       atavism.server.objects.LightData lightData = msg.getLightData();

/*      */       

/* 2594 */       if (!playerOid.equals(player.getOid())) {

/* 2595 */         Log.error("Message target and perceiver mismatch");

/*      */       }

/*      */       

/* 2598 */       ClientConnection con = player.getConnection();

/*      */       

/* 2600 */       if (Log.loggingDebug) {

/* 2601 */         ProxyPlugin.log.debug("NewDirLightHook: notifyOid=" + playerOid + ", lightOid=" + lightOid + ", light=" + lightData);

/*      */       }

/* 2603 */       NewLightEvent lightEvent = new NewLightEvent(playerOid, lightOid, lightData);

/*      */       

/* 2605 */       con.send(lightEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/*      */   class FreeObjectHook extends ProxyPlugin.BasicProxyHook {

/* 2610 */     FreeObjectHook() { super(); }

/*      */     

/* 2612 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.FreeObjectMessage message = (WorldManagerClient.FreeObjectMessage)msg;

/*      */       

/* 2614 */       player.getConnection().send(message.toBuffer());

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class SetAmbientHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2622 */     SetAmbientHook() { super(); }

/*      */     

/* 2624 */     public void processMessage(Message m, int flags, Player player) { WorldManagerClient.SetAmbientLightMessage msg = (WorldManagerClient.SetAmbientLightMessage)m;

/* 2625 */       atavism.server.objects.Color ambientLight = msg.getColor();

/* 2626 */       OID playerOid = msg.getTarget();

/*      */       

/* 2628 */       if (!playerOid.equals(player.getOid())) {

/* 2629 */         Log.error("Message target and perceiver mismatch");

/*      */       }

/*      */       

/* 2632 */       ClientConnection con = player.getConnection();

/*      */       

/* 2634 */       if (Log.loggingDebug) {

/* 2635 */         ProxyPlugin.log.debug("SetAmbientHook: targetOid=" + playerOid + ", ambient=" + ambientLight);

/*      */       }

/*      */       

/* 2638 */       Event ambientLightEvent = new atavism.server.events.AmbientLightEvent(ambientLight);

/* 2639 */       con.send(ambientLightEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/*      */   class DetachHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2646 */     DetachHook() { super(); }

/*      */     

/* 2648 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.DetachMessage dMsg = (WorldManagerClient.DetachMessage)msg;

/*      */       

/* 2650 */       OID dcObjOid = dMsg.getSubject();

/* 2651 */       OID objBeingDetached = dMsg.getObjBeingDetached();

/* 2652 */       String socket = dMsg.getSocketName();

/* 2653 */       if (Log.loggingDebug) {

/* 2654 */         ProxyPlugin.log.debug("DetachHook: dcObjOid=" + dcObjOid + ", objBeingDetached=" + objBeingDetached + ", socket=" + socket);

/*      */       }

/*      */       

/*      */

/*      */

/* 2659 */       ClientConnection con = player.getConnection();

/*      */       

/* 2661 */       atavism.server.events.DetachEvent detachEvent = new atavism.server.events.DetachEvent(dcObjOid, objBeingDetached, socket);

/*      */       

/* 2663 */       con.send(detachEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/*      */   class AnimationHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2670 */     AnimationHook() { super(); }

/*      */     

/*      */     public void processMessage(Message msg, int flags, Player player) {

/* 2673 */       WorldManagerClient.AnimationMessage animMsg = (WorldManagerClient.AnimationMessage)msg;

/*      */       

/*      */

/* 2676 */       OID playerOid = player.getOid();

/* 2677 */       ClientConnection con = player.getConnection();

/*      */       

/* 2679 */       OID objOid = animMsg.getSubject();

/* 2680 */       List<atavism.server.util.AnimationCommand> animList = animMsg.getAnimationList();

/*      */       

/*      */

/* 2683 */       atavism.server.events.NotifyPlayAnimationEvent animEvent = new atavism.server.events.NotifyPlayAnimationEvent(objOid);

/*      */       

/* 2685 */       animEvent.setAnimList(animList);

/*      */       

/*      */

/* 2688 */       con.send(animEvent.toBytes());

/* 2689 */       if (Log.loggingDebug) {

/* 2690 */         ProxyPlugin.log.debug("AnimationHook: send anim msg for playerOid " + playerOid + ", objId=" + objOid + ", animEvent=" + animEvent);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class InvokeEffectHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2699 */     InvokeEffectHook() { super(); }

/*      */     

/* 2701 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.AnimationClient.InvokeEffectMessage effectMsg = (atavism.agis.plugins.AnimationClient.InvokeEffectMessage)msg;

/*      */       

/* 2703 */       OID objOid = effectMsg.getSubject();

/*      */       

/* 2705 */       if (Log.loggingDebug) {

/* 2706 */         ProxyPlugin.log.debug("InvokeEffectHook: got msg=" + effectMsg.toString());

/*      */       }

/*      */       

/* 2709 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2712 */       AOByteBuffer buf = effectMsg.toBuffer(player.getVersion());

/* 2713 */       if (buf != null) {

/* 2714 */         con.send(buf);

/* 2715 */         if (Log.loggingDebug)

/* 2716 */           ProxyPlugin.log.debug("InvokeEffectHook: sent ext msg for notifyOid " + objOid);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   class AbilityStatusHook extends ProxyPlugin.BasicProxyHook {

/* 2722 */     AbilityStatusHook() { super(); }

/*      */     

/* 2724 */     public void processMessage(Message msg, int flags, Player player) { AOByteBuffer buf = null;

/* 2725 */       ClientConnection con = player.getConnection();

/* 2726 */       atavism.agis.events.AbilityStatusMessage asMsg = (atavism.agis.events.AbilityStatusMessage)msg;

/* 2727 */       buf = asMsg.toBuffer();

/* 2728 */       if (buf != null) {

/* 2729 */         con.send(buf);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   class ExtensionHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2737 */     ExtensionHook() { super(); }

/*      */     

/* 2739 */     public void processMessage(Message msg, int flags, Player player) { AOByteBuffer buf = null;

/*      */       

/* 2741 */       ClientConnection con = player.getConnection();

/* 2742 */       OID subject = null;

/* 2743 */       OID target = null;

/* 2744 */       String subType = null;

/*      */       

/* 2746 */       if ((msg instanceof WorldManagerClient.TargetedExtensionMessage)) {

/* 2747 */         WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/*      */         

/* 2749 */         subject = extMsg.getSubject();

/* 2750 */         target = extMsg.getTarget();

/* 2751 */         subType = extMsg.getExtensionType();

/*      */         

/* 2753 */         if (Log.loggingDebug) {

/* 2754 */           Set<String> keySet = extMsg.keySet();

/* 2755 */           for (String key : keySet) {

/* 2756 */             ProxyPlugin.log.debug("ExtensionHook: playerOid=" + player.getOid() + ", oid=" + subject + ", key " + key + ", value=" + extMsg

/*      */             

/* 2758 */               .getProperty(key));

/*      */           }

/*      */         }

/*      */         

/*      */

/* 2763 */         buf = extMsg.toBuffer(player.getVersion());

/*      */       }

/*      */       else {

/* 2766 */         WorldManagerClient.ExtensionMessage extMsg = (WorldManagerClient.ExtensionMessage)msg;

/*      */         

/* 2768 */         subject = extMsg.getSubject();

/* 2769 */         subType = extMsg.getExtensionType();

/*      */         

/* 2771 */         if (Log.loggingDebug) {

/* 2772 */           Set<String> keySet = extMsg.keySet();

/* 2773 */           for (String key : keySet) {

/* 2774 */             ProxyPlugin.log.debug("ExtensionHook: playerOid=" + player.getOid() + ", oid=" + subject + ", key " + key + ", value=" + extMsg

/*      */             

/* 2776 */               .getProperty(key));

/*      */           }

/*      */         }

/*      */         

/*      */

/* 2781 */         buf = extMsg.toBuffer(player.getVersion());

/*      */       }

/*      */       

/* 2784 */       if (buf != null) {

/* 2785 */         con.send(buf);

/* 2786 */         if (Log.loggingDebug) {

/* 2787 */           ProxyPlugin.log.debug("ExtensionHook: sent subType " + subType + " for playerOid=" + player

/* 2788 */             .getOid() + ", target=" + target + ", subject=" + subject);

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   class P2PExtensionHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2797 */     P2PExtensionHook() { super(); }

/*      */     

/* 2799 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/*      */       

/* 2801 */       OID objOid = extMsg.getSubject();

/*      */       

/* 2803 */       Set<String> keySet = extMsg.keySet();

/* 2804 */       for (String key : keySet) {

/* 2805 */         if (Log.loggingDebug) {

/* 2806 */           ProxyPlugin.log.debug("P2PExtensionHook: playerOid=" + player.getOid() + ", oid = " + objOid + ", got key " + key + ", value=" + extMsg

/*      */           

/* 2808 */             .getProperty(key));

/*      */         }

/*      */       }

/*      */       

/* 2812 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2815 */       AOByteBuffer buf = extMsg.toBuffer(player.getVersion());

/* 2816 */       if (buf != null) {

/* 2817 */         con.send(buf);

/* 2818 */         if (Log.loggingDebug) {

/* 2819 */           ProxyPlugin.log.debug("P2PExtensionHook: sent ext msg for notifyOid " + objOid);

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class PropertyHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2829 */     PropertyHook() { super(); }

/*      */     

/* 2831 */     public boolean processMessage(Message msg, int flags) { return true; }

/*      */     

/*      */     public void processMessage(Message msg, int flags, Player player)

/*      */     {

/* 2835 */       PropertyMessage propMsg = (PropertyMessage)msg;

/*      */       

/* 2837 */       OID subjectOid = propMsg.getSubject();

/*      */       

/* 2839 */       if (Log.loggingDebug) {

/* 2840 */         Set<String> keySet = propMsg.keySet();

/* 2841 */         for (String key : keySet) {

/* 2842 */           ProxyPlugin.log.debug("handlePropertyMsg: player=" + player + ", oid=" + subjectOid + ", got key " + key + ", value=" + propMsg

/*      */           

/* 2844 */             .getProperty(key));

/*      */         }

/*      */       }

/*      */       

/* 2848 */       ClientConnection con = player.getConnection();

/*      */       

/* 2850 */       AOByteBuffer buf = null;

/* 2851 */       if ((ProxyPlugin.this.playerSpecificProps.size() > 0) && (subjectOid != player.getOid())) {

/* 2852 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.cachedPlayerSpecificFilterProps);

/*      */       }

/*      */       else {

/* 2855 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.filteredProps);

/*      */       }

/* 2857 */       if (buf != null) {

/* 2858 */         con.send(buf);

/* 2859 */         if (Log.loggingDebug) {

/* 2860 */           ProxyPlugin.log.debug("sent prop msg for player " + player + ", subjectId=" + subjectOid);

/*      */         }

/* 2862 */       } else if (Log.loggingDebug) {

/* 2863 */         ProxyPlugin.log.debug("filtered out prop msg for player " + player + ", subjectId=" + subjectOid + " because all props were filtered");

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   class TargetedPropertyHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 2873 */     TargetedPropertyHook() { super(); }

/*      */     

/* 2875 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedPropertyMessage propMsg = (WorldManagerClient.TargetedPropertyMessage)msg;

/*      */       

/* 2877 */       OID targetOid = propMsg.getTarget();

/* 2878 */       OID subjectOid = propMsg.getSubject();

/*      */       

/* 2880 */       if (Log.loggingDebug) {

/* 2881 */         Set<String> keySet = propMsg.keySet();

/* 2882 */         for (String key : keySet) {

/* 2883 */           ProxyPlugin.log.debug("handleTargetedPropertyMsg: playerOid=" + player

/* 2884 */             .getOid() + ", targetOid=" + targetOid + ", oid = " + subjectOid + ", got key " + key + ", value=" + propMsg

/*      */             

/* 2886 */             .getProperty(key));

/*      */         }

/*      */       }

/*      */       

/*      */

/* 2891 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 2894 */       AOByteBuffer buf = null;

/* 2895 */       if ((ProxyPlugin.this.playerSpecificProps.size() > 0) && (subjectOid != player.getOid())) {

/* 2896 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.cachedPlayerSpecificFilterProps);

/*      */       }

/*      */       else

/* 2899 */         buf = propMsg.toBuffer(player.getVersion(), ProxyPlugin.this.filteredProps);

/* 2900 */       if (buf != null) {

/* 2901 */         con.send(buf);

/* 2902 */         if (Log.loggingDebug) {

/* 2903 */           ProxyPlugin.log.debug("sent targeted prop msg for targetOid " + targetOid + ", subjectOid=" + subjectOid);

/*      */         }

/* 2905 */       } else if (Log.loggingDebug) {

/* 2906 */         ProxyPlugin.log.debug("filtered out targeted prop msg for targetOid " + targetOid + ", subjectOid=" + subjectOid + " because all props were filtered");

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean specialCaseNewProcessing(PerceptionMessage.ObjectNote objectNote, Player player)

/*      */   {

/* 2927 */     long start = System.currentTimeMillis();

/*      */     

/* 2929 */     ClientConnection con = player.getConnection();

/*      */     

/* 2931 */     OID objOid = objectNote.getSubject();

/* 2932 */     ObjectType objType = objectNote.getObjectType();

/*      */     

/*      */

/*      */

/* 2936 */     if (objType == atavism.server.objects.ObjectTypes.light) {

/* 2937 */       Log.debug("specialCaseNewProcessing: got a light object");

/*      */       

/* 2939 */       atavism.server.objects.LightData lightData = (atavism.server.objects.LightData)EnginePlugin.getObjectProperty(objOid, Namespace.WORLD_MANAGER, atavism.server.objects.Light.LightDataPropertyKey);

/*      */       

/* 2941 */       if (Log.loggingDebug)

/* 2942 */         Log.debug("specialCaseNewProcessing: light data=" + lightData);

/* 2943 */       NewLightEvent lightEvent = new NewLightEvent(player.getOid(), objOid, lightData);

/*      */       

/* 2945 */       con.send(lightEvent.toBytes());

/* 2946 */       return true;

/*      */     }

/*      */     

/* 2949 */     if (objType.equals(WorldManagerClient.TEMPL_OBJECT_TYPE_TERRAIN_DECAL)) {

/* 2950 */       Log.debug("specialCaseNewProcessing: got a terrain decal object");

/*      */       

/* 2952 */       atavism.server.objects.TerrainDecalData decalData = (atavism.server.objects.TerrainDecalData)EnginePlugin.getObjectProperty(objOid, Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_TERRAIN_DECAL_DATA);

/*      */       

/* 2954 */       if (Log.loggingDebug) {

/* 2955 */         Log.debug("specialCaseNewProcessing: terrain decal data=" + decalData);

/*      */       }

/* 2957 */       atavism.server.events.NewTerrainDecalEvent decalEvent = new atavism.server.events.NewTerrainDecalEvent(objOid, decalData);

/*      */       

/* 2959 */       con.send(decalEvent.toBytes());

/* 2960 */       return true;

/*      */     }

/*      */     

/* 2963 */     if (objType.equals(WorldManagerClient.TEMPL_OBJECT_TYPE_POINT_SOUND)) {

/* 2964 */       Log.debug("specialCaseNewProcessing: got a point sound object");

/*      */       

/* 2966 */       List<atavism.server.objects.SoundData> soundData = (List)EnginePlugin.getObjectProperty(objOid, Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_SOUND_DATA_LIST);

/*      */       

/* 2968 */       if (Log.loggingDebug) {

/* 2969 */         Log.debug("specialCaseNewProcessing: sound data=" + soundData);

/*      */       }

/* 2971 */       WorldManagerClient.SoundMessage soundMsg = new WorldManagerClient.SoundMessage(objOid);

/* 2972 */       soundMsg.setSoundData(soundData);

/* 2973 */       con.send(soundMsg.toBuffer());

/* 2974 */       return true;

/*      */     }

/*      */     

/*      */

/* 2978 */     WorldManagerClient.PerceptionInfo perceptionInfo = (WorldManagerClient.PerceptionInfo)objectNote.getObjectInfo();

/*      */     

/*      */

/* 2981 */     if (perceptionInfo.objectInfo == null)

/*      */     {

/* 2983 */       return true;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/* 2989 */     WorldManagerClient.MobPathMessage pathMsg = (WorldManagerClient.MobPathMessage)perceptionInfo.objectInfo.getProperty(WorldManagerClient.MOB_PATH_PROPERTY);

/*      */     

/* 2991 */     con.send(perceptionInfo.objectInfo.toBuffer(player.getOid()));

/*      */     

/*      */

/* 2994 */     if (perceptionInfo.displayContext != null) {

/* 2995 */       ModelInfoEvent modelInfoEvent = new ModelInfoEvent(objOid);

/* 2996 */       modelInfoEvent.setDisplayContext(perceptionInfo.displayContext);

/* 2997 */       con.send(modelInfoEvent.toBytes());

/*      */     }

/* 2999 */     else if (Log.loggingDebug) {

/* 3000 */       Log.debug("No display context for " + objOid + " " + perceptionInfo.objectInfo);

/*      */     }

/*      */     

/*      */

/* 3004 */     if (pathMsg != null)

/*      */     {

/* 3006 */       if (pathMsg.pathExpired()) {

/* 3007 */         if (Log.loggingDebug) {

/* 3008 */           Log.debug(

/* 3009 */             "specialCaseNewProcessing: for mob " + objOid + ", last mob path expired " + pathMsg.toString());

/*      */         }

/*      */       }

/*      */       else {

/* 3013 */         if (Log.loggingDebug)

/* 3014 */           Log.debug(

/* 3015 */             "specialCaseNewProcessing: for mob " + objOid + ", sending last mob path " + pathMsg.toString());

/* 3016 */         AOByteBuffer pathBuf = pathMsg.toBuffer();

/* 3017 */         con.send(pathBuf);

/*      */       }

/*      */     }

/*      */     

/*      */

/* 3022 */     Map<String, DisplayContext> childMap = null;

/* 3023 */     if (perceptionInfo.displayContext != null)

/* 3024 */       childMap = perceptionInfo.displayContext.getChildDCMap();

/* 3025 */     if ((childMap != null) && (!childMap.isEmpty())) {

/* 3026 */       for (String slot : childMap.keySet()) {

/* 3027 */         DisplayContext attachDC = (DisplayContext)childMap.get(slot);

/* 3028 */         if (attachDC == null) {

/* 3029 */           throw new AORuntimeException("attach DC is null for obj: " + objOid);

/*      */         }

/*      */         

/* 3032 */         OID attacheeOID = attachDC.getObjRef();

/* 3033 */         if (attacheeOID == null) {

/* 3034 */           throw new AORuntimeException("attachee oid is null for obj: " + objOid);

/*      */         }

/*      */         

/*      */

/* 3038 */         if (Log.loggingDebug) {

/* 3039 */           Log.debug(

/* 3040 */             "specialCaseNewProcessing: sending attach message to " + player.getOid() + " attaching to obj " + objOid + ", object being attached=" + attacheeOID + " to slot " + slot + ", attachmentDC=" + attachDC);

/*      */         }

/*      */         

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3049 */         AttachEvent event = new AttachEvent(objOid, attacheeOID, slot, attachDC);

/*      */         

/* 3051 */         con.send(event.toBytes());

/*      */       }

/* 3053 */       if (Log.loggingDebug) {

/* 3054 */         Log.debug("specialCaseNewProcessing: done with processing attachments");

/*      */       }

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3070 */     long finish = System.currentTimeMillis();

/* 3071 */     if (Log.loggingDebug) {

/* 3072 */       Log.debug(

/* 3073 */         "specialCaseNewProcessing: finished.\tplayerOid=" + player.getOid() + ", oid=" + objOid + " in " + (finish - start) + " ms");

/*      */     }

/* 3075 */     return false;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected boolean specialCaseFreeProcessing(PerceptionMessage.ObjectNote objectNote, Player player)

/*      */   {

/* 3091 */     if (player.getOid().equals(objectNote.getSubject())) {

/* 3092 */       Log.debug("ignoring free object message to self");

/* 3093 */       return true;

/*      */     }

/*      */     

/* 3096 */     ClientConnection con = player.getConnection();

/* 3097 */     if (!con.isOpen()) {

/* 3098 */       con = null;

/*      */     }

/* 3100 */     OID objOid = objectNote.getSubject();

/*      */     

/* 3102 */     if (objectNote.getObjectType() == atavism.server.objects.ObjectTypes.road) {

/* 3103 */       if (Log.loggingDebug)

/* 3104 */         Log.debug(

/* 3105 */           "specialCaseFreeProcessing: playerOid=" + player.getOid() + ", roadSegmentOid=" + objOid);

/* 3106 */       handleFreeRoad(con, objOid);

/* 3107 */       return true;

/*      */     }

/* 3109 */     if (objectNote.getObjectType().equals(WorldManagerClient.TEMPL_OBJECT_TYPE_TERRAIN_DECAL))

/*      */     {

/* 3111 */       if (Log.loggingDebug)

/* 3112 */         Log.debug(

/* 3113 */           "specialCaseFreeProcessing: playerOid=" + player.getOid() + ", decalOid=" + objOid);

/* 3114 */       atavism.server.events.FreeTerrainDecalEvent decalEvent = new atavism.server.events.FreeTerrainDecalEvent(objOid);

/* 3115 */       if (con != null)

/* 3116 */         con.send(decalEvent.toBytes());

/* 3117 */       return true;

/*      */     }

/*      */     

/*      */

/* 3121 */     if (Log.loggingDebug) {

/* 3122 */       Log.debug("specialCaseFreeProcessing: playerOid=" + player.getOid() + ", objOid=" + objOid);

/*      */     }

/*      */     

/*      */

/* 3126 */     NotifyFreeObjectEvent freeEvent = new NotifyFreeObjectEvent(player.getOid(), objOid);

/*      */     

/* 3128 */     if (con != null) {

/* 3129 */       con.send(freeEvent.toBytes());

/*      */     }

/* 3131 */     return false;

/*      */   }

/*      */   

/*      */

/*      */

/*      */   protected void handleFreeRoad(ClientConnection con, OID objOid)

/*      */   {

/* 3138 */     WorldManagerClient.FreeRoadMessage freeRoadMsg = new WorldManagerClient.FreeRoadMessage(objOid);

/*      */     

/* 3140 */     AOByteBuffer buf = freeRoadMsg.toBuffer();

/* 3141 */     if (con != null) {

/* 3142 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */   class PerceptionHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3150 */     PerceptionHook() { super(); }

/*      */     

/* 3152 */     public void processMessage(Message msg, int flags, Player player) { PerceptionMessage perceptionMessage = (PerceptionMessage)msg;

/*      */       

/*      */

/* 3155 */       List<PerceptionMessage.ObjectNote> gain = perceptionMessage.getGainObjects();

/*      */       

/* 3157 */       List<PerceptionMessage.ObjectNote> lost = perceptionMessage.getLostObjects();

/*      */       

/* 3159 */       if (Log.loggingDebug) {

/* 3160 */         Log.debug(

/*      */         

/* 3162 */           "PerceptionHook.processMessage: start " + (gain == null ? 0 : gain.size()) + " gain and " + (lost == null ? 0 : lost.size()) + " lost");

/*      */       }

/* 3164 */       if (player.getOid().equals(atavism.server.objects.World.DEBUG_OID)) {

/* 3165 */         Log.info(

/*      */         

/* 3167 */           "PerceptionHook: oid=" + atavism.server.objects.World.DEBUG_OID + " start " + (gain == null ? 0 : gain.size()) + " gain and " + (lost == null ? 0 : lost.size()) + " lost");

/*      */       }

/* 3169 */       ClientConnection con = player.getConnection();

/*      */       List<OID> newSubjects;

/* 3171 */       synchronized (ProxyPlugin.this.playerManager) {

/* 3172 */         newSubjects = new LinkedList();

/* 3173 */         List<OID> deleteSubjects = new LinkedList();

/* 3174 */         if (lost != null) {

/* 3175 */           ProxyPlugin.this.playerManager.removeWorldPerception(player, lost, deleteSubjects);

/*      */         }

/* 3177 */         if (gain != null)

/* 3178 */           ProxyPlugin.this.playerManager.addWorldPerception(player, gain, newSubjects);

/* 3179 */         if ((deleteSubjects.size() > 0) || (newSubjects.size() > 0))

/*      */         {

/* 3181 */           FilterUpdate perceptionUpdate = new FilterUpdate(deleteSubjects.size() + newSubjects.size());

/*      */           

/*      */

/*      */

/*      */

/* 3186 */           for (OID oid : newSubjects) {

/* 3187 */             perceptionUpdate.addFieldValue(2, oid);

/*      */           }

/*      */           

/*      */

/* 3191 */           if (player.getOid().equals(atavism.server.objects.World.DEBUG_OID)) {

/* 3192 */             Log.info(

/* 3193 */               "subject changes: " + newSubjects.size() + " gained " + deleteSubjects.size() + " lost");

/*      */           }

/*      */           

/*      */

/*      */

/* 3198 */           Engine.getAgent().applyFilterUpdate(ProxyPlugin.this.perceptionSubId, perceptionUpdate, 0, perceptionMessage);

/*      */         }

/*      */       }

/*      */       

/*      */

/*      */

/* 3204 */       boolean loadingState = false;

/* 3205 */       if ((player.supportsLoadingState()) && (

/* 3206 */         (player.getLoadingState() == 0) || ((gain != null) &&

/* 3207 */         (gain.size() > 20)) || ((lost != null) &&

/* 3208 */         (lost.size() > 20))))

/*      */       {

/*      */

/* 3211 */         con.send(new atavism.server.events.LoadingStateEvent(true).toBytes());

/* 3212 */         loadingState = true;

/*      */       }

/*      */       

/* 3215 */       if (lost != null) {

/* 3216 */         for (PerceptionMessage.ObjectNote objectNote : lost) {

/* 3217 */           ProxyPlugin.this.specialCaseFreeProcessing(objectNote, player);

/*      */         }

/*      */       }

/*      */       

/* 3221 */       if (gain != null) {

/* 3222 */         for (PerceptionMessage.ObjectNote objectNote : gain) {

/*      */           try {

/* 3224 */             ProxyPlugin.this.specialCaseNewProcessing(objectNote, player);

/* 3225 */             WorldManagerClient.updateObject(player.getOid(), objectNote

/* 3226 */               .getSubject());

/*      */           } catch (Exception e) {

/* 3228 */             Log.exception(

/*      */             

/* 3230 */               "specialCaseNewProcessing: player=" + player + " oid=" + objectNote.getSubject(), e);

/*      */           }

/*      */         }

/*      */       }

/*      */       

/* 3235 */       if (loadingState) {

/* 3236 */         player.setLoadingState(1);

/* 3237 */         con.send(new atavism.server.events.LoadingStateEvent(false).toBytes());

/*      */       }

/*      */     } }

/*      */   

/*      */   public static class AddStaticPerceptionMessage extends TargetMessage { private String name;

/*      */     private ObjectType type;

/*      */     private boolean objectInfoProvided;

/*      */     

/*      */     public AddStaticPerceptionMessage() {}

/*      */     

/* 3247 */     public AddStaticPerceptionMessage(MessageType type) { super(); }

/*      */     

/*      */     public String getName()

/*      */     {

/* 3251 */       return this.name;

/*      */     }

/*      */     

/*      */     public void setName(String name) {

/* 3255 */       this.name = name;

/*      */     }

/*      */     

/*      */     public ObjectType getType() {

/* 3259 */       return this.type;

/*      */     }

/*      */     

/*      */     public void setType(ObjectType type) {

/* 3263 */       this.type = type;

/*      */     }

/*      */     

/*      */     public boolean hasObjectInfo() {

/* 3267 */       return this.objectInfoProvided;

/*      */     }

/*      */     

/*      */     public void setHasObjectInfo(boolean flag) {

/* 3271 */       this.objectInfoProvided = flag;

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public static void addStaticPerception(OID playerOid, OID oid)

/*      */   {

/* 3282 */     addStaticPerception(playerOid, oid, null, null, false);

/*      */   }

/*      */   

/*      */   public static void addStaticPerception(OID oid, OID oid2, String name, ObjectType type)

/*      */   {

/* 3287 */     addStaticPerception(oid, oid2, name, type, true);

/*      */   }

/*      */   

/*      */   private static void addStaticPerception(OID playerOid, OID oid, String name, ObjectType type, boolean hasObjectInfo)

/*      */   {

/* 3292 */     AddStaticPerceptionMessage message = new AddStaticPerceptionMessage(MSG_TYPE_ADD_STATIC_PERCEPTION);

/*      */     

/* 3294 */     message.setTarget(playerOid);

/* 3295 */     message.setSubject(oid);

/* 3296 */     message.setName(name);

/* 3297 */     message.setType(type);

/* 3298 */     message.setHasObjectInfo(hasObjectInfo);

/* 3299 */     Engine.getAgent().sendBroadcast(message);

/*      */   }

/*      */   

/*      */   public static void removeStaticPerception(OID playerOid, OID oid) {

/* 3303 */     TargetMessage message = new TargetMessage(MSG_TYPE_REMOVE_STATIC_PERCEPTION);

/*      */     

/* 3305 */     message.setTarget(playerOid);

/* 3306 */     message.setSubject(oid);

/* 3307 */     Engine.getAgent().sendBroadcast(message);

/*      */   }

/*      */   

/* 3310 */   private class AddStaticPerceptionHook extends ProxyPlugin.BasicProxyHook { private AddStaticPerceptionHook() { super(); }

/*      */     

/* 3312 */     public void processMessage(Message msg, int flags, Player player) { ProxyPlugin.AddStaticPerceptionMessage message = (ProxyPlugin.AddStaticPerceptionMessage)msg;

/* 3313 */       if (Log.loggingDebug) {

/* 3314 */         Log.debug(

/* 3315 */           "AddStaticPerceptionHook: player=" + player.getOid() + ", subject=" + message.getSubject());

/*      */       }

/*      */       

/* 3318 */       if (!message.hasObjectInfo())

/*      */       {

/* 3320 */         ObjectManagerClient.ObjectStatus objectStatus = ObjectManagerClient.getObjectStatus(message.getSubject());

/* 3321 */         if ((objectStatus == null) || (objectStatus.namespaces == null)) {

/* 3322 */           Log.error(

/* 3323 */             "AddStaticPerceptionHook: ignoring unknown subject=" + message.getSubject() + " added to " + player);

/*      */           

/*      */

/* 3326 */           return;

/*      */         }

/* 3328 */         message.setName(objectStatus.name);

/* 3329 */         message.setType(objectStatus.type);

/*      */       }

/*      */       

/* 3332 */       boolean perceptionGain = ProxyPlugin.this.playerManager.addStaticPerception(player, message

/* 3333 */         .getSubject());

/*      */       

/* 3335 */       if (perceptionGain) {

/* 3336 */         FilterUpdate perceptionUpdate = new FilterUpdate(1);

/* 3337 */         perceptionUpdate.addFieldValue(2, message

/* 3338 */           .getSubject());

/* 3339 */         Engine.getAgent().applyFilterUpdate(ProxyPlugin.this.perceptionSubId, perceptionUpdate, 0);

/*      */         

/*      */

/*      */

/* 3343 */         WorldManagerClient.ObjectInfo info = new WorldManagerClient.ObjectInfo();

/* 3344 */         info.oid = message.getSubject();

/* 3345 */         info.name = message.getName();

/* 3346 */         info.objType = message.getType();

/* 3347 */         info.dir = new atavism.server.math.AOVector(0.0F, 0.0F, 0.0F);

/* 3348 */         Log.debug("INFO: add static perception hook");

/* 3349 */         player.getConnection().send(info.toBuffer(player.getOid()));

/*      */         

/*      */

/* 3352 */         WorldManagerClient.updateObject(player.getOid(), message

/* 3353 */           .getSubject());

/*      */       }

/*      */     }

/*      */   }

/*      */   

/* 3358 */   private class RemoveStaticPerceptionHook extends ProxyPlugin.BasicProxyHook { private RemoveStaticPerceptionHook() { super(); }

/*      */     

/* 3360 */     public void processMessage(Message msg, int flags, Player player) { TargetMessage message = (TargetMessage)msg;

/* 3361 */       boolean proxyPerceptionLoss = ProxyPlugin.this.playerManager.removeStaticPerception(player, message

/* 3362 */         .getSubject());

/* 3363 */       Log.debug("ProxyPlugin.RemoveStaticPerceptionHook(): proxyPerceptionLoss = " + proxyPerceptionLoss + ", playerOid=" + player

/*      */       

/*      */

/* 3366 */         .getOid() + ", oid=" + message.getSubject());

/* 3367 */       if (proxyPerceptionLoss) {

/* 3368 */         FilterUpdate proxyPerceptionUpdate = new FilterUpdate(1);

/* 3369 */         proxyPerceptionUpdate.removeFieldValue(2, message

/* 3370 */           .getSubject());

/* 3371 */         Engine.getAgent().applyFilterUpdate(ProxyPlugin.this.perceptionSubId, proxyPerceptionUpdate, 0);

/*      */       }

/*      */       

/*      */

/* 3375 */       NotifyFreeObjectEvent freeEvent = new NotifyFreeObjectEvent(player.getOid(), message.getSubject());

/* 3376 */       player.getConnection().send(freeEvent.toBytes());

/*      */     }

/*      */   }

/*      */   

/* 3380 */   class VoiceParmsHook extends ProxyPlugin.BasicProxyHook { VoiceParmsHook() { super(); }

/*      */     

/*      */     public void processMessage(Message msg, int flags, Player player)

/*      */     {

/* 3384 */       WorldManagerClient.TargetedExtensionMessage extMsg = new WorldManagerClient.TargetedExtensionMessage("voice_parms_response", player.getOid());

/* 3385 */       extMsg.setProperty("host", ProxyPlugin.voiceServerHost);

/* 3386 */       extMsg.setProperty("port", ProxyPlugin.voiceServerPort);

/*      */       

/*      */

/*      */

/* 3390 */       atavism.server.util.SecureTokenSpec tokenSpec = new atavism.server.util.SecureTokenSpec((byte)2, Engine.getAgent().getName(), System.currentTimeMillis() + 30000L);

/* 3391 */       tokenSpec.setProperty("player_oid", player.getOid());

/* 3392 */       byte[] authToken = atavism.server.util.SecureTokenManager.getInstance().generateToken(tokenSpec);

/*      */       

/* 3394 */       extMsg.setProperty("auth_token", Base64.encodeBytes(authToken));

/*      */       

/*      */

/* 3397 */       ClientConnection con = player.getConnection();

/*      */       

/*      */

/* 3400 */       AOByteBuffer buf = extMsg.toBuffer(player.getVersion());

/* 3401 */       if (buf != null) {

/* 3402 */         con.send(buf);

/* 3403 */         if (Log.loggingDebug) {

/* 3404 */           ProxyPlugin.log.debug("VoiceParmsHook: sent voice_parm_response ext msg for player " + player

/* 3405 */             .getOid());

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void processPlayerIgnoreList(Player player)

/*      */   {

/* 3419 */     if (player.getStatus() == 3) {

/* 3420 */       Log.error("ProxyPlugin.processPlayerIgnoreList: Aborting... player.getStatus() is STATUS_LOGOUT");

/* 3421 */       return;

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3429 */     sendPlayerIgnoreList(player);

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected void sendPlayerIgnoreList(Player player)

/*      */   {

/* 3440 */     String missing = " Missing ";

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public void updateIgnoredOids(Player player, List<OID> nowIgnored, List<OID> noLongerIgnored) {}

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   class UpdatePlayerIgnoreListHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3468 */     UpdatePlayerIgnoreListHook() { super(); }

/*      */     

/* 3470 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/*      */       

/* 3472 */       LinkedList<OID> nowIgnored = (LinkedList)extMsg.getProperty("now_ignored");

/*      */       

/* 3474 */       LinkedList<OID> noLongerIgnored = (LinkedList)extMsg.getProperty("no_longer_ignored");

/* 3475 */       ProxyPlugin.this.updateIgnoredOids(player, nowIgnored, noLongerIgnored);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   class GetMatchingPlayersHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3517 */     GetMatchingPlayersHook() { super(); }

/*      */     

/* 3519 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.TargetedExtensionMessage extMsg = (WorldManagerClient.TargetedExtensionMessage)msg;

/* 3520 */       String playerName = (String)extMsg.getProperty("player_name");

/* 3521 */       Boolean exactMatch = (Boolean)extMsg.getProperty("exact_match");

/* 3522 */       boolean match = exactMatch == null ? true : exactMatch.booleanValue();

/*      */       

/* 3524 */       List<Object> matchLists = Engine.getDatabase().getOidsAndNamesMatchingName(playerName, match);

/*      */       

/* 3526 */       WorldManagerClient.TargetedExtensionMessage response = new WorldManagerClient.TargetedExtensionMessage("player_ignore_list", player.getOid());

/* 3527 */       response.setSubject(player.getOid());

/* 3528 */       List<OID> oids = (List)matchLists.get(0);

/* 3529 */       List<String> names = (List)matchLists.get(1);

/* 3530 */       response.setProperty("ignored_oids", (java.io.Serializable)oids);

/* 3531 */       response.setProperty("ignored_player_names", (java.io.Serializable)names);

/* 3532 */       if (Log.loggingDebug)

/* 3533 */         ProxyPlugin.log.debug("ProxyPlugin.GetMatchingPlayersHook: For player " + player

/* 3534 */           .getOid() + ", found " + (oids == null ? 0 : oids

/* 3535 */           .size()) + " players: " +

/* 3536 */           Database.makeOidCollectionString(oids) + " " + (match ? "exactly matching" : "starting with") + " name '" + playerName + "':" +

/*      */           

/*      */

/* 3539 */           Database.makeNameCollectionString(names));

/* 3540 */       player.getConnection().send(response.toBuffer(player.getVersion()));

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public List<Object> matchingPlayers(Player player, String playerName, Boolean exactMatch)

/*      */   {

/* 3552 */     boolean match = exactMatch == null ? true : exactMatch.booleanValue();

/*      */     

/* 3554 */     List<Object> matchLists = Engine.getDatabase().getOidsAndNamesMatchingName(playerName, match);

/* 3555 */     List<OID> oids = (List)matchLists.get(0);

/* 3556 */     List<String> names = (List)matchLists.get(1);

/* 3557 */     if (Log.loggingDebug)

/* 3558 */       log.debug("ProxyPlugin.matchingPlayers: For player " + player

/* 3559 */         .getOid() + ", found " + (oids == null ? 0 : oids

/* 3560 */         .size()) + " players: " +

/* 3561 */         Database.makeOidCollectionString(oids) + " " + (match ? "exactly matching" : "starting with") + " name '" + playerName + "':" +

/*      */         

/*      */

/* 3564 */         Database.makeNameCollectionString(names));

/* 3565 */     return matchLists;

/*      */   }

/*      */   

/* 3568 */   class PlayerIgnoreListReqHook extends ProxyPlugin.BasicProxyHook { PlayerIgnoreListReqHook() { super(); }

/*      */     

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */     public void processMessage(Message msg, int flags, Player player) {}

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   class PlayerPathReqHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3585 */     PlayerPathReqHook() { super(); }

/*      */     

/* 3587 */     public void processMessage(Message msg, int flags, Player player) { OID playerOid = player.getOid();

/* 3588 */       BasicWorldNode wnode = WorldManagerClient.getWorldNode(playerOid);

/* 3589 */       WorldManagerClient.ExtensionMessage extMsg = (WorldManagerClient.ExtensionMessage)msg;

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 3600 */       WorldManagerClient.PlayerPathWMReqMessage reqMsg = new WorldManagerClient.PlayerPathWMReqMessage(playerOid, wnode.getInstanceOid(), (String)extMsg.getProperty("room_id"), (atavism.server.math.AOVector)extMsg.getProperty("start"), ((Float)extMsg.getProperty("speed")).floatValue(), (atavism.server.math.Quaternion)extMsg.getProperty("start_orient"), (atavism.server.math.AOVector)extMsg.getProperty("dest"), (atavism.server.math.Quaternion)extMsg.getProperty("dest_orient"), (List)extMsg.getProperty("boundary"), (List)extMsg.getProperty("obstacles"), ((Float)extMsg.getProperty("avatar_width")).floatValue());

/* 3601 */       Engine.getAgent().sendBroadcast(reqMsg);

/*      */     }

/*      */   }

/*      */   

/* 3605 */   class BlockListHook extends ProxyPlugin.BasicProxyHook { BlockListHook() { super(); }

/*      */     

/* 3607 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.SocialClient.BlockListMessage dmgMsg = (atavism.agis.plugins.SocialClient.BlockListMessage)msg;

/* 3608 */       ProxyPlugin.log.error("BlockListHook Start");

/* 3609 */       player.setIgnoredOids(dmgMsg.getBlockList());

/* 3610 */       ProxyPlugin.log.error("BlockListHook End");

/*      */     }

/*      */   }

/*      */   

/*      */   class ComHook extends ProxyPlugin.BasicProxyHook {

/* 3615 */     ComHook() { super(); }

/*      */     

/* 3617 */     public void processMessage(Message msg, int flags, Player player) { AOByteBuffer buf = null;

/*      */       

/* 3619 */       if ((msg instanceof WorldManagerClient.ComMessage)) {

/* 3620 */         WorldManagerClient.ComMessage comMsg = (WorldManagerClient.ComMessage)msg;

/* 3621 */         AccountDatabase aDB = new AccountDatabase(false);

/*      */         

/*      */

/* 3624 */         OID oid = comMsg.getSubject();

/* 3625 */         Log.debug("ComHook.processMessage: ComMessage player:" + player + " plyOid:" + player.getOid() + " getSubject:" + oid + " comMsg:" + comMsg);

/*      */         

/* 3627 */         if (atavism.agis.plugins.SocialClient.isOnBlockList(player.getOid(), oid))

/*      */         {

/*      */

/* 3630 */           if (Log.loggingDebug) {

/* 3631 */             Log.debug(

/*      */             

/*      */

/* 3634 */               "ComHook.processMessage: Ignoring chat from player " + oid + " to player " + player.getOid() + " because originator is in the player's ignored list");

/*      */           }

/*      */           

/* 3637 */           return;

/*      */         }

/*      */         

/*      */

/* 3641 */         buf = comMsg.toBuffer();

/* 3642 */         Log.info("ProxyPlugin: CHAT_RECV player=" + player + " from=" + comMsg

/* 3643 */           .getSubject() + " private=false msg=[" + comMsg

/* 3644 */           .getString() + "]");

/* 3645 */       } else if ((msg instanceof WorldManagerClient.TargetedComMessage)) {

/* 3646 */         WorldManagerClient.TargetedComMessage comMsg = (WorldManagerClient.TargetedComMessage)msg;

/* 3647 */         AccountDatabase aDB = new AccountDatabase(false);

/* 3648 */         OID oid = comMsg.getSubject();

/* 3649 */         Log.debug("ComHook.processMessage: TargetedComMessage player:" + player + " plyOid:" + player.getOid() + " getSubject:" + oid + " comMsg:" + comMsg);

/*      */         

/*      */

/* 3652 */         if (atavism.agis.plugins.SocialClient.isOnBlockList(player.getOid(), oid))

/*      */         {

/*      */

/* 3655 */           if (Log.loggingDebug) {

/* 3656 */             Log.debug(

/*      */             

/*      */

/* 3659 */               "ComHook.processMessage: Ignoring chat from player " + oid + " to player " + player.getOid() + " because originator is in the player's ignored list");

/*      */           }

/*      */           

/* 3662 */           return;

/*      */         }

/*      */         

/* 3665 */         buf = comMsg.toBuffer();

/* 3666 */         Log.info("ProxyPlugin: CHAT_RECV player=" + player + " from=" + comMsg

/* 3667 */           .getSubject() + " private=true msg=[" + comMsg

/* 3668 */           .getString() + "]");

/*      */       }

/*      */       else {

/* 3671 */         Log.debug("ComHook.processMessage: else player:" + player + " plyOid:" + player.getOid() + " msg " + msg);

/*      */         

/*      */

/* 3674 */         return;

/*      */       }

/* 3676 */       ClientConnection con = player.getConnection();

/* 3677 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/* 3681 */   class DamageHook extends ProxyPlugin.BasicProxyHook { DamageHook() { super(); }

/*      */     

/* 3683 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.CombatClient.DamageMessage dmgMsg = (atavism.agis.plugins.CombatClient.DamageMessage)msg;

/*      */       

/* 3685 */       OID attackerOid = dmgMsg.getAttackerOid();

/* 3686 */       OID targetOid = dmgMsg.getTargetOid();

/*      */       

/*      */

/* 3689 */       AOByteBuffer buf = dmgMsg.toBuffer();

/*      */       

/* 3691 */       ClientConnection con = player.getConnection();

/* 3692 */       if (Log.loggingDebug)

/* 3693 */         ProxyPlugin.log.debug("DamageHook: attackerOid= " + attackerOid + ", attacks targetOid=" + targetOid + " for " + dmgMsg

/*      */         

/* 3695 */           .getDmg() + " damage");

/* 3696 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/*      */   class SysChatHook implements atavism.server.engine.Hook { SysChatHook() {}

/*      */     

/* 3702 */     public boolean processMessage(Message msg, int flags) { WorldManagerClient.SysChatMessage sysMsg = (WorldManagerClient.SysChatMessage)msg;

/*      */       

/* 3704 */       AOByteBuffer buf = sysMsg.toBuffer();

/*      */       

/* 3706 */       if (Log.loggingDebug) {

/* 3707 */         ProxyPlugin.log.debug("syschathook:\t " + sysMsg.getString());

/*      */       }

/* 3709 */       java.util.Collection<Player> players = new ArrayList(ProxyPlugin.this.playerManager.getPlayerCount());

/* 3710 */       ProxyPlugin.this.playerManager.getPlayers(players);

/* 3711 */       for (Player pp : players) {

/* 3712 */         pp.getConnection().send(buf);

/*      */       }

/* 3714 */       return true;

/*      */     }

/*      */   }

/*      */   

/* 3718 */   class UpdateWNodeHook extends ProxyPlugin.BasicProxyHook { UpdateWNodeHook() { super(); }

/*      */     

/* 3720 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.UpdateWorldNodeMessage wMsg = (WorldManagerClient.UpdateWorldNodeMessage)msg;

/* 3721 */       OID subjectOid = wMsg.getSubject();

/* 3722 */       OID playerOid = player.getOid();

/* 3723 */       if (Log.loggingDebug) {

/* 3724 */         Log.debug("UpdateWNodeHook.processMessage: subjectOid=" + subjectOid + ", playerOid=" + playerOid + " msg=" + msg);

/*      */       }

/*      */       

/* 3727 */       if (playerOid.equals(subjectOid))

/*      */       {

/* 3729 */         if (Log.loggingDebug) {

/* 3730 */           Log.debug("UpdateWNodeHook.processMessage: subjectOid=" + subjectOid + ", ignoring msg since playerOid matches subjectOid");

/*      */         }

/*      */         

/* 3733 */         return;

/*      */       }

/*      */       

/* 3736 */       player.getConnection().send(wMsg.getEventBuf());

/*      */     }

/*      */   }

/*      */   

/* 3740 */   class UpdateMobPathHook extends ProxyPlugin.BasicProxyHook { UpdateMobPathHook() { super(); }

/*      */     

/* 3742 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.MobPathMessage pathMsg = (WorldManagerClient.MobPathMessage)msg;

/* 3743 */       OID subjectOid = pathMsg.getSubject();

/* 3744 */       if (Log.loggingDebug) {

/* 3745 */         ProxyPlugin.log.debug("UpdateMobPathHook.processMessage: subjectOid=" + subjectOid + ", msg=" + msg);

/*      */       }

/* 3747 */       AOByteBuffer buf = pathMsg.toBuffer();

/* 3748 */       ClientConnection con = player.getConnection();

/* 3749 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/* 3753 */   class WNodeCorrectHook extends ProxyPlugin.BasicProxyHook { WNodeCorrectHook() { super(); }

/*      */     

/* 3755 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.WorldNodeCorrectMessage wMsg = (WorldManagerClient.WorldNodeCorrectMessage)msg;

/*      */       

/* 3757 */       OID oid = wMsg.getSubject();

/*      */       

/* 3759 */       if (Log.loggingDebug) {

/* 3760 */         ProxyPlugin.log.debug("WNodeCorrectHook.processMessage: oid=" + oid + ", msg=" + msg);

/*      */       }

/*      */       

/*      */

/*      */

/*      */

/* 3766 */       AOByteBuffer buf = wMsg.toBuffer();

/* 3767 */       ClientConnection con = player.getConnection();

/* 3768 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/* 3772 */   class OrientHook extends ProxyPlugin.BasicProxyHook { OrientHook() { super(); }

/*      */     

/* 3774 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.OrientMessage oMsg = (WorldManagerClient.OrientMessage)msg;

/*      */       

/*      */

/* 3777 */       AOByteBuffer buf = oMsg.toBuffer();

/*      */       

/* 3779 */       ClientConnection con = player.getConnection();

/* 3780 */       con.send(buf);

/*      */     }

/*      */   }

/*      */   

/*      */   class SoundHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3787 */     SoundHook() { super(); }

/*      */     

/* 3789 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.SoundMessage sMsg = (WorldManagerClient.SoundMessage)msg;

/*      */       

/*      */

/* 3792 */       OID target = sMsg.getTarget();

/* 3793 */       if ((target != null) && (!target.equals(player.getOid()))) {

/* 3794 */         return;

/*      */       }

/* 3796 */       ClientConnection con = player.getConnection();

/* 3797 */       con.send(sMsg.toBuffer());

/*      */     }

/*      */   }

/*      */   

/* 3801 */   class InvUpdateHook extends ProxyPlugin.BasicProxyHook { InvUpdateHook() { super(); }

/*      */     

/* 3803 */     public void processMessage(Message msg, int flags, Player player) { InventoryClient.InvUpdateMessage uMsg = (InventoryClient.InvUpdateMessage)msg;

/*      */       

/*      */

/* 3806 */       if (!player.getOid().equals(uMsg.getSubject()))

/* 3807 */         return;

/* 3808 */       ClientConnection con = player.getConnection();

/* 3809 */       if (Log.loggingDebug) {

/* 3810 */         ProxyPlugin.log.debug("InvUpdateHook: sending update to player " + player

/* 3811 */           .getOid() + " msgOid=" + uMsg.getSubject());

/*      */       }

/* 3813 */       con.send(uMsg.toBuffer());

/*      */     }

/*      */   }

/*      */   

/* 3817 */   class FogHook extends ProxyPlugin.BasicProxyHook { FogHook() { super(); }

/*      */     

/* 3819 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.FogMessage fogMsg = (WorldManagerClient.FogMessage)msg;

/* 3820 */       atavism.server.objects.FogRegionConfig fogConfig = fogMsg.getFogConfig();

/* 3821 */       OID targetOid = fogMsg.getTarget();

/* 3822 */       ClientConnection con = player.getConnection();

/*      */       

/* 3824 */       WorldManagerClient.FogMessage fogMessage = new WorldManagerClient.FogMessage(null, fogConfig);

/* 3825 */       con.send(fogMessage.toBuffer());

/* 3826 */       if (Log.loggingDebug) {

/* 3827 */         ProxyPlugin.log.debug("FogHook: sending new fog to targetOid " + targetOid + fogConfig);

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */   class RoadHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3839 */     RoadHook() { super(); }

/*      */     

/* 3841 */     public void processMessage(Message msg, int flags, Player player) { WorldManagerClient.RoadMessage roadMsg = (WorldManagerClient.RoadMessage)msg;

/* 3842 */       Set<atavism.server.objects.Road> roads = roadMsg.getRoads();

/* 3843 */       if (Log.loggingDebug)

/* 3844 */         ProxyPlugin.log.debug("RoadHook: got " + roads.size() + " roads");

/* 3845 */       OID targetOid = roadMsg.getTarget();

/* 3846 */       ClientConnection con = player.getConnection();

/* 3847 */       List<AOByteBuffer> bufList = roadMsg.toBuffer();

/* 3848 */       for (AOByteBuffer buf : bufList) {

/* 3849 */         con.send(buf);

/*      */       }

/* 3851 */       if (Log.loggingDebug)

/* 3852 */         ProxyPlugin.log.debug("RoadHook: sent new roads to targetOid " + targetOid);

/*      */     }

/*      */   }

/*      */   

/* 3856 */   class AbilityUpdateHook extends ProxyPlugin.BasicProxyHook { AbilityUpdateHook() { super(); }

/*      */     

/* 3858 */     public void processMessage(Message msg, int flags, Player player) { atavism.agis.plugins.CombatClient.AbilityUpdateMessage pMsg = (atavism.agis.plugins.CombatClient.AbilityUpdateMessage)msg;

/* 3859 */       if (Log.loggingDebug) {

/* 3860 */         ProxyPlugin.log.debug("AbilityUpdateHook: got AbilityUpdate message: " + msg);

/*      */       }

/*      */       

/* 3863 */       ClientConnection con = player.getConnection();

/* 3864 */       con.send(pMsg.toBuffer());

/*      */     }

/*      */   }

/*      */   

/*      */   class GetPluginStatusHook implements atavism.server.engine.Hook { GetPluginStatusHook() {}

/*      */     

/* 3870 */     public boolean processMessage(Message msg, int flags) { LinkedHashMap<String, java.io.Serializable> status = new LinkedHashMap();

/* 3871 */       status.put("plugin", ProxyPlugin.this.getName());

/* 3872 */       status.put("user", Integer.valueOf(ProxyPlugin.this.playerManager.getPlayerCount()));

/* 3873 */       status.put("login", Integer.valueOf(ProxyPlugin.this.playerManager.getLoginCount()));

/* 3874 */       status.put("login_sec", Integer.valueOf(ProxyPlugin.this.playerManager.getLoginSeconds()));

/* 3875 */       status.put("instance_entry", Integer.valueOf(ProxyPlugin.this.instanceEntryCount));

/* 3876 */       status.put("chat", Integer.valueOf(ProxyPlugin.this.chatSentCount));

/* 3877 */       status.put("private_chat", Integer.valueOf(ProxyPlugin.this.privateChatSentCount));

/* 3878 */       Engine.getAgent().sendObjectResponse(msg, status);

/* 3879 */       return true; } }

/*      */   

/*      */   public static class PlayerLoginStatus { public OID oid;

/*      */     public int status;

/*      */     public String name;

/*      */     public String clientCon;

/*      */     public String proxyPluginName;

/*      */     private static final long serialVersionUID = 1L;

/*      */     

/* 3888 */     public String toString() { return "[PlayerLoginStatus: oid=" + this.oid + ", status=" + this.status + ", name=" + this.name + ", proxyPluginName=" + this.proxyPluginName + "]"; }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   private class GetPlayerLoginStatusHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 3906 */     private GetPlayerLoginStatusHook() { super(); }

/*      */     

/* 3908 */     public void processMessage(Message msg, int flags, Player player) { Log.debug("GetPlayerLoginStatusHook: player=" + player);

/* 3909 */       ProxyPlugin.PlayerLoginStatus loginStatus = new ProxyPlugin.PlayerLoginStatus();

/* 3910 */       loginStatus.oid = player.getOid();

/* 3911 */       loginStatus.status = player.getStatus();

/* 3912 */       loginStatus.name = player.getName();

/* 3913 */       loginStatus.clientCon = player.getConnection().toString();

/* 3914 */       loginStatus.proxyPluginName = ProxyPlugin.this.getName();

/* 3915 */       Log.debug("GetPlayerLoginStatusHook: response=" + loginStatus);

/* 3916 */       Engine.getAgent().sendObjectResponse(msg, loginStatus);

/*      */     }

/*      */   }

/*      */   

/* 3920 */   private class LogoutPlayerHook extends ProxyPlugin.BasicProxyHook { private LogoutPlayerHook() { super(); }

/*      */     

/*      */

/* 3923 */     public void processMessage(Message message, int flags, Player player) { new Thread(new ProxyPlugin.LogoutPlayerRPCThread(ProxyPlugin.this, message, player), "LogoutPlayer" + player.getOid()).start(); }

/*      */   }

/*      */   

/*      */   private class LogoutPlayerRPCThread implements Runnable { private Player player;

/*      */     private Message message;

/*      */     

/* 3929 */     public LogoutPlayerRPCThread(Message message, Player player) { this.player = player;

/* 3930 */       this.message = message;

/*      */     }

/*      */     

/*      */     public void run() {

/* 3934 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.run(): start");

/*      */       try {

/* 3936 */         Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.run(): try { logoutPlayer(); }");

/* 3937 */         logoutPlayer();

/*      */       } catch (Exception e) {

/* 3939 */         Log.exception("LogoutPlayer", e);

/* 3940 */         Engine.getAgent().sendObjectResponse(this.message, null);

/*      */       }

/* 3942 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.run(): done");

/*      */     }

/*      */     

/*      */     public void logoutPlayer() {

/* 3946 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.logoutPlayer(): start");

/* 3947 */       ProxyPlugin.PlayerLoginStatus loginStatus = new ProxyPlugin.PlayerLoginStatus();

/* 3948 */       loginStatus.oid = this.player.getOid();

/* 3949 */       loginStatus.status = this.player.getStatus();

/* 3950 */       loginStatus.name = this.player.getName();

/* 3951 */       loginStatus.clientCon = this.player.getConnection().toString();

/* 3952 */       loginStatus.proxyPluginName = ProxyPlugin.this.getName();

/*      */       

/*      */

/*      */

/* 3956 */       WorldManagerClient.ComMessage comMessage = new WorldManagerClient.ComMessage(this.player.getOid(), "", 0, "Your player logged in from a different location.");

/*      */       

/* 3958 */       this.player.getConnection().sendInternal(comMessage.toBuffer());

/*      */       try {

/* 3960 */         Thread.sleep(20L);

/*      */       }

/*      */       catch (InterruptedException localInterruptedException) {}

/* 3963 */       this.player.getConnection().close();

/*      */       

/* 3965 */       synchronized (this.player) {

/* 3966 */         while (this.player.getConnection() != null) {

/*      */           try {

/* 3968 */             this.player.wait();

/*      */           }

/*      */           catch (InterruptedException localInterruptedException1) {}

/*      */         }

/*      */       }

/* 3973 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.logoutPlayer(): Engine.getAgent().sendObjectResponse() message=" + this.message + ", loginStatus=" + loginStatus);

/*      */       

/* 3975 */       Engine.getAgent().sendObjectResponse(this.message, loginStatus);

/* 3976 */       Log.debug("[CYC] ProxyPlugin.LogoutPlayerRPCThread.logoutPlayer(): done");

/*      */     }

/*      */   }

/*      */   

/*      */   private class AccountLoginHook implements atavism.server.engine.Hook

/*      */   {

/*      */     private AccountLoginHook() {}

/*      */     

/*      */     public boolean processMessage(Message msg, int flags)

/*      */     {

/* 3986 */       Log.debug("AccountLoginHook hit");

/* 3987 */       atavism.msgsys.GenericMessage tMsg = (atavism.msgsys.GenericMessage)msg;

/* 3988 */       OID accountId = (OID)tMsg.getProperty("accountId");

/* 3989 */       Log.debug("AccountLoginHook accountId=" + accountId + "; map=" + ProxyPlugin.this.clientConnections);

/* 3990 */       if (ProxyPlugin.this.clientConnections.containsKey(accountId)) {

/* 3991 */         Log.debug("Closing client connection");

/* 3992 */         ((ClientConnection)ProxyPlugin.this.clientConnections.get(accountId)).close();

/* 3993 */         ProxyPlugin.this.clientConnections.remove(accountId);

/*      */       }

/* 3995 */       return true;

/*      */     }

/*      */   }

/*      */   

/*      */   static class InstanceEntryState {

/* 4000 */     int step = 1;

/*      */     InstanceClient.InstanceInfo instanceInfo;

/*      */     LinkedList restoreStack;

/*      */     BasicWorldNode previousLoc;

/*      */   }

/*      */   

/*      */   class InstanceEntryReqHook

/*      */     extends ProxyPlugin.BasicProxyHook

/*      */   {

/* 4009 */     InstanceEntryReqHook() { super(); }

/*      */     

/* 4011 */     public void processMessage(Message msg, int flags, Player player) { InstanceClient.InstanceEntryReqMessage entryMessage = (InstanceClient.InstanceEntryReqMessage)msg;

/* 4012 */       ProxyPlugin.log.debug("InstanceEntryReqHook ");

/*      */       

/* 4014 */       ProxyPlugin.InstanceEntryState state = (ProxyPlugin.InstanceEntryState)entryMessage.getProcessingState();

/* 4015 */       if (state == null) {

/* 4016 */         state = new ProxyPlugin.InstanceEntryState();

/* 4017 */         entryMessage.setProcessingState(state);

/*      */       }

/*      */       

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4027 */       if (state.step == 1) {

/* 4028 */         entryStep1(entryMessage, state, player);

/* 4029 */       } else if (state.step == 2) {

/* 4030 */         entryStep2(entryMessage, state, player);

/*      */       }

/*      */     }

/*      */     

/*      */     protected void entryStep1(InstanceClient.InstanceEntryReqMessage entryMessage, ProxyPlugin.InstanceEntryState state, Player player)

/*      */     {

/* 4036 */       ProxyPlugin.log.debug("entryStep1 ");

/* 4037 */       BasicWorldNode destination = entryMessage.getWorldNode();

/* 4038 */       int entryFlags = entryMessage.getFlags();

/*      */       

/* 4040 */       String flagStr = "";

/* 4041 */       if ((entryFlags & 0x1) != 0)

/* 4042 */         flagStr = flagStr + "push,";

/* 4043 */       if ((entryFlags & 0x2) != 0) {

/* 4044 */         flagStr = flagStr + "pop,";

/*      */       }

/* 4046 */       Log.info("ProxyPlugin: INSTANCE_BEGIN player=" + player + " destination=" + destination + " flags=" + flagStr);

/*      */       

/*      */

/* 4049 */       if (((entryFlags & 0x1) != 0) && ((entryFlags & 0x2) != 0))

/*      */       {

/* 4051 */         Log.debug(

/* 4052 */           "InstanceEntryReqHook: push and pop flags cannot be combined oid=" + player.getOid());

/* 4053 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4055 */         return;

/*      */       }

/*      */       

/* 4058 */       if (((entryFlags & 0x1) != 0) &&

/* 4059 */         (destination == null)) {

/* 4060 */         Log.debug(

/* 4061 */           "InstanceEntryReqHook: push without destination oid=" + player.getOid());

/* 4062 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4064 */         return;

/*      */       }

/*      */       

/* 4067 */       if (((entryFlags & 0x2) != 0) &&

/* 4068 */         (destination != null)) {

/* 4069 */         Log.debug(

/* 4070 */           "InstanceEntryReqHook: pop with destination oid=" + player.getOid());

/* 4071 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4073 */         return;

/*      */       }

/*      */       

/*      */

/* 4077 */       if (player.getStatus() != 2) {

/* 4078 */         Log.debug("InstanceEntryReqHook: invalid player status " + player);

/*      */         

/* 4080 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4082 */         return;

/*      */       }

/*      */       

/* 4085 */       if ((entryFlags & 0x2) != 0)

/*      */       {

/*      */

/* 4088 */         LinkedList restoreStack = (LinkedList)EnginePlugin.getObjectProperty(player.getOid(), Namespace.OBJECT_MANAGER, "instanceStack");

/*      */         

/* 4090 */         if ((restoreStack == null) || (restoreStack.size() == 0)) {

/* 4091 */           Log.debug("InstanceEntryReqHook: player has no stack to pop " + player);

/*      */           

/* 4093 */           Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */           

/* 4095 */           return;

/*      */         }

/* 4097 */         state.restoreStack = restoreStack;

/*      */         

/* 4099 */         InstanceRestorePoint restorePoint = (InstanceRestorePoint)restoreStack.get(restoreStack.size() - 1);

/* 4100 */         if (restoreStack.size() == 1) {

/* 4101 */           if (restorePoint.getFallbackFlag()) {

/* 4102 */             Log.warn("InstanceEntryReqHook: popping to fallback restore point " + player);

/*      */           }

/*      */           else {

/* 4105 */             Log.warn("InstanceEntryReqHook: popping last instance restore point " + player);

/*      */           }

/*      */         }

/* 4108 */         destination = new BasicWorldNode();

/* 4109 */         OID instanceOid = restorePoint.getInstanceOid();

/* 4110 */         if (restorePoint.getInstanceID() > 0) {

/* 4111 */           instanceOid = ProxyPlugin.this.instanceEntryCallback.selectInstance(player, restorePoint

/* 4112 */             .getInstanceID());

/*      */         }

/* 4114 */         if (instanceOid != null) {

/* 4115 */           destination.setInstanceOid(instanceOid);

/* 4116 */           destination.setLoc(restorePoint.getLoc());

/* 4117 */           destination.setOrientation(restorePoint.getOrientation());

/* 4118 */           destination.setDir(new atavism.server.math.AOVector(0.0F, 0.0F, 0.0F));

/*      */         }

/* 4120 */         entryMessage.setWorldNode(destination);

/*      */       }

/*      */       

/* 4123 */       if (!ProxyPlugin.this.instanceEntryAllowed(player.getOid(), destination

/* 4124 */         .getInstanceOid(), destination.getLoc())) {

/* 4125 */         Log.info("ProxyPlugin: INSTANCE_REJECT player=" + player + " current=" + state.previousLoc + " destination=" + destination);

/*      */         

/*      */

/* 4128 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4130 */         return;

/*      */       }

/*      */       

/* 4133 */       state.instanceInfo = InstanceClient.getInstanceInfo(destination

/* 4134 */         .getInstanceOid(), -131073);

/*      */       

/* 4136 */       if (state.instanceInfo.oid == null) {

/* 4137 */         Log.error(

/* 4138 */           "InstanceEntryReqHook: unknown instanceOid=" + destination.getInstanceOid());

/* 4139 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4141 */         return;

/*      */       }

/*      */       

/* 4144 */       Log.debug("POP: got population: " + state.instanceInfo.playerPopulation + " and limit: " + state.instanceInfo.populationLimit);

/* 4145 */       if ((state.instanceInfo.populationLimit > 0) && (state.instanceInfo.playerPopulation >= state.instanceInfo.populationLimit)) {

/* 4146 */         OID instanceOid = ProxyPlugin.handleFullInstance(state.instanceInfo.templateID, state.instanceInfo);

/* 4147 */         destination.setInstanceOid(instanceOid);

/* 4148 */         state.instanceInfo = InstanceClient.getInstanceInfo(destination

/* 4149 */           .getInstanceOid(), -131073);

/*      */       }

/*      */       

/* 4152 */       if (Log.loggingDebug) {

/* 4153 */         Log.debug("InstanceEntryReqHook: instance terrain config: " + state.instanceInfo.terrainConfig);

/*      */       }

/*      */       

/*      */

/* 4157 */       WorldManagerClient.TargetedExtensionMessage instanceBegin = new WorldManagerClient.TargetedExtensionMessage(player.getOid(), player.getOid());

/* 4158 */       instanceBegin.setExtensionType("ao.SCENE_BEGIN");

/* 4159 */       instanceBegin.setProperty("action", "instance");

/* 4160 */       instanceBegin.setProperty("name", state.instanceInfo.name);

/*      */       

/* 4162 */       instanceBegin.setProperty("templateName", state.instanceInfo.templateName);

/*      */       

/*      */

/*      */

/*      */

/* 4167 */       boolean rc = WorldManagerClient.despawn(player.getOid(), instanceBegin, null);

/*      */       

/* 4169 */       if (!rc) {

/* 4170 */         Log.error("InstanceEntryReqHook: despawn failed " + player);

/* 4171 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4173 */         return;

/*      */       }

/*      */       

/*      */

/* 4177 */       state.previousLoc = WorldManagerClient.getWorldNode(player.getOid());

/*      */       

/* 4179 */       Log.info("ProxyPlugin: INSTANCE_STEP1 player=" + player + " current=" + state.previousLoc + " destination=" + destination + " destName=" + state.instanceInfo.name);

/*      */       

/*      */

/*      */

/*      */

/*      */

/* 4185 */       ArrayList<Namespace> unloadWM = new ArrayList(1);

/* 4186 */       unloadWM.add(WorldManagerClient.NAMESPACE);

/* 4187 */       rc = ObjectManagerClient.unloadSubObject(player.getOid(), unloadWM).booleanValue();

/* 4188 */       if (!rc) {

/* 4189 */         Log.error("InstanceEntryReqHook: unload wm sub-object failed " + player);

/*      */         

/* 4191 */         Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */         

/* 4193 */         return;

/*      */       }

/* 4195 */       state.step = 2;

/* 4196 */       ProxyPlugin.this.messageQQ.insert(player, entryMessage);

/*      */     }

/*      */     

/*      */     protected void entryStep2(InstanceClient.InstanceEntryReqMessage entryMessage, ProxyPlugin.InstanceEntryState state, Player player)

/*      */     {

/* 4201 */       ProxyPlugin.log.debug(" entryStep1 ");

/*      */       

/* 4203 */       int entryFlags = entryMessage.getFlags();

/* 4204 */       ClientConnection con = player.getConnection();

/* 4205 */       BasicWorldNode destination = entryMessage.getWorldNode();

/* 4206 */       BasicWorldNode previousLoc = state.previousLoc;

/*      */       

/* 4208 */       BasicWorldNode restoreLoc = null;

/* 4209 */       if ((entryFlags & 0x1) != 0) {

/* 4210 */         restoreLoc = entryMessage.getRestoreNode();

/* 4211 */         if (restoreLoc == null)

/* 4212 */           restoreLoc = previousLoc;

/*      */       }

/*      */       InstanceClient.InstanceInfo instanceInfo;

/*      */       for (;;) {

/* 4216 */         boolean rc = ObjectManagerClient.fixWorldNode(player.getOid(), destination);

/*      */         

/* 4218 */         if (!rc) {

/* 4219 */           Log.debug("InstanceEntryReqHook: fixWorldNode failed " + player + " node=" + destination);

/*      */           

/* 4221 */           Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */           

/* 4223 */           return;

/*      */         }

/*      */         

/* 4226 */         instanceInfo = InstanceClient.getInstanceInfo(destination

/* 4227 */           .getInstanceOid(), 8);

/*      */         

/* 4229 */         EnginePlugin.setObjectProperty(player.getOid(), Namespace.OBJECT_MANAGER, "currentInstanceName",

/*      */         

/*      */

/* 4232 */           Integer.valueOf(instanceInfo.templateID));

/* 4233 */         Log.debug("INSTANCE: storing current instance prop: " + instanceInfo.templateID);

/*      */         

/*      */

/*      */

/*      */

/* 4238 */         Log.debug("instanceReq: sending template (scene) name: " + state.instanceInfo.templateName);

/*      */         

/*      */

/* 4241 */         Event worldFileEvent = new atavism.server.events.WorldFileEvent(state.instanceInfo.templateName, destination.getLoc());

/* 4242 */         con.send(worldFileEvent.toBytes());

/* 4243 */         player.sceneLoading(true);

/*      */         

/*      */

/*      */

/*      */

/*      */

/* 4249 */         WorldManagerClient.WorldNodeCorrectMessage correctMsg = new WorldManagerClient.WorldNodeCorrectMessage(player.getOid(), destination);

/* 4250 */         con.send(correctMsg.toBuffer());

/*      */         

/* 4252 */         if ((entryFlags & 0x1) != 0) {

/* 4253 */           ProxyPlugin.this.pushInstanceRestorePoint(player, restoreLoc);

/*      */         }

/*      */         

/* 4256 */         WorldManagerClient.TargetedExtensionMessage instanceEnd = new WorldManagerClient.TargetedExtensionMessage(player.getOid(), player.getOid());

/* 4257 */         instanceEnd.setExtensionType("ao.SCENE_END");

/* 4258 */         instanceEnd.setProperty("action", "instance");

/* 4259 */         instanceEnd.setProperty("name", state.instanceInfo.name);

/*      */         

/* 4261 */         instanceEnd.setProperty("templateName", state.instanceInfo.templateName);

/*      */         

/*      */

/*      */

/* 4265 */         ArrayList<Namespace> loadWM = new ArrayList(1);

/* 4266 */         loadWM.add(WorldManagerClient.NAMESPACE);

/* 4267 */         OID oid = ObjectManagerClient.loadSubObject(player.getOid(), loadWM);

/*      */         

/* 4269 */         if (oid == null) {

/* 4270 */           Log.error("InstanceEntryReqHook: load wm sub-object failed " + player);

/*      */           

/* 4272 */           if ((previousLoc != null) && (destination != previousLoc)) {

/* 4273 */             Log.error("InstanceEntryReqHook: attempting to restore previous location " + player + " previous=" + previousLoc);

/*      */             

/* 4275 */             destination = previousLoc;

/* 4276 */             entryFlags &= 0xFFFFFFFD;

/* 4277 */             continue;

/*      */           }

/*      */         }

/*      */         

/* 4281 */         Integer result = WorldManagerClient.spawn(player.getOid(), null, instanceEnd);

/*      */         

/* 4283 */         if (result.intValue() >= 0) break label578;

/* 4284 */         Log.error("InstanceEntryReqHook: spawn failed " + player);

/* 4285 */         if ((result.intValue() != -2) || (previousLoc == null) || (destination == previousLoc))

/*      */           break;

/* 4287 */         Log.error("InstanceEntryReqHook: attempting to restore previous location " + player + " previous=" + previousLoc);

/*      */         

/* 4289 */         destination = previousLoc;

/* 4290 */         entryFlags &= 0xFFFFFFFD;

/*      */       }

/*      */       

/* 4293 */       Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.FALSE);

/*      */       

/* 4295 */       return;

/*      */       

/*      */

/*      */

/*      */

/*      */       label578:

/*      */       

/*      */

/*      */

/* 4304 */       WorldManagerClient.correctWorldNode(player.getOid(), destination);

/*      */       

/*      */

/* 4307 */       ProxyPlugin.this.updateInstancePerception(player.getOid(), previousLoc

/* 4308 */         .getInstanceOid(), destination.getInstanceOid(), instanceInfo.name);

/*      */       

/*      */

/*      */

/*      */

/*      */

/* 4314 */       Log.info("ProxyPlugin: INSTANCE_END player=" + player + " destination=" + destination);

/*      */       

/*      */

/*      */

/* 4318 */       if ((entryFlags & 0x2) != 0) {

/* 4319 */         LinkedList restoreStack = state.restoreStack;

/*      */         

/* 4321 */         InstanceRestorePoint top = (InstanceRestorePoint)restoreStack.get(restoreStack.size() - 1);

/* 4322 */         if (!top.getFallbackFlag()) {

/* 4323 */           restoreStack.remove(restoreStack.size() - 1);

/* 4324 */           EnginePlugin.setObjectProperty(player.getOid(), Namespace.OBJECT_MANAGER, "instanceStack", restoreStack);

/*      */         }

/*      */       }

/*      */       

/*      */

/*      */

/*      */

/* 4331 */       ProxyPlugin.access$1208(ProxyPlugin.this);

/* 4332 */       Engine.getAgent().sendBooleanResponse(entryMessage, Boolean.TRUE);

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   public static OID handleFullInstance(int instanceTemplateID, InstanceClient.InstanceInfo instanceInfo)

/*      */   {

/* 4344 */     Log.debug("POP: instance full with template: " + instanceTemplateID);

/*      */     

/* 4346 */     int instanceNum = 1;

/* 4347 */     String instanceName = "";

/*      */     OID instanceOid;

/*      */     for (;;)

/*      */     {

/* 4351 */       instanceName = instanceTemplateID + "_" + instanceNum;

/* 4352 */       instanceOid = InstanceClient.getInstanceOid(instanceName);

/* 4353 */       if (instanceOid != null) {

/* 4354 */         instanceInfo = InstanceClient.getInstanceInfo(instanceOid, -131073);

/* 4355 */         if (instanceInfo.populationLimit < 1) break; if (instanceInfo.playerPopulation < instanceInfo.populationLimit) {

/*      */           break;

/*      */         }

/*      */       } else {

/* 4359 */         atavism.server.objects.Template overrideTemplate = new atavism.server.objects.Template();

/* 4360 */         overrideTemplate.put(Namespace.INSTANCE, "name", instanceName);

/* 4361 */         instanceOid = InstanceClient.createInstance(instanceTemplateID, overrideTemplate);

/* 4362 */         if (instanceOid != null) {

/*      */           break;

/*      */         }

/*      */       }

/* 4366 */       instanceNum++;

/*      */     }

/*      */     

/* 4369 */     return instanceOid;

/*      */   }

/*      */   

/*      */   private void updateInstancePerception(OID playerOid, OID prevInstanceOid, OID destInstanceOid, String destInstanceName)

/*      */   {

/* 4374 */     if (prevInstanceOid != null)

/*      */     {

/* 4376 */       removeStaticPerception(playerOid, prevInstanceOid);

/*      */     }

/*      */     

/*      */

/* 4380 */     addStaticPerception(playerOid, destInstanceOid, destInstanceName, atavism.server.objects.ObjectTypes.instance);

/*      */   }

/*      */   

/*      */   protected void pushInstanceRestorePoint(Player player, BasicWorldNode loc)

/*      */   {

/* 4385 */     OID playerOid = player.getOid();

/* 4386 */     log.debug("pushInstanceRestorePoint " + playerOid);

/* 4387 */     InstanceRestorePoint restorePoint = new InstanceRestorePoint();

/* 4388 */     restorePoint.setInstanceOid(loc.getInstanceOid());

/* 4389 */     restorePoint.setLoc(loc.getLoc());

/* 4390 */     restorePoint.setOrientation(loc.getOrientation());

/*      */     

/* 4392 */     InstanceClient.InstanceInfo instanceInfo = InstanceClient.getInstanceInfo(loc

/* 4393 */       .getInstanceOid(), 8);

/* 4394 */     restorePoint.setInstanceID(instanceInfo.templateID);

/*      */     

/*      */

/* 4397 */     LinkedList<Object> restoreStack = (LinkedList)EnginePlugin.getObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack");

/*      */     

/* 4399 */     if (restoreStack == null) {

/* 4400 */       restoreStack = new LinkedList();

/*      */     }

/*      */     

/* 4403 */     restoreStack.add(restorePoint);

/*      */     

/* 4405 */     EnginePlugin.setObjectProperty(playerOid, Namespace.OBJECT_MANAGER, "instanceStack", restoreStack);

/*      */   }

/*      */   

/*      */

/*      */   protected void sendOceanData(OceanData oceanData, Player player)

/*      */   {

/* 4411 */     WorldManagerClient.TargetedExtensionMessage oceanMsg = new ClientParameter.ClientParameterMessage(player.getOid());

/* 4412 */     oceanMsg.setProperty("Ocean.DisplayOcean", oceanData.displayOcean

/* 4413 */       .toString());

/* 4414 */     if (oceanData.useParams != null) {

/* 4415 */       oceanMsg.setProperty("Ocean.UseParams", oceanData.useParams

/* 4416 */         .toString());

/*      */     }

/* 4418 */     if (oceanData.waveHeight != null) {

/* 4419 */       oceanMsg.setProperty("Ocean.WaveHeight", oceanData.waveHeight

/* 4420 */         .toString());

/*      */     }

/* 4422 */     if (oceanData.seaLevel != null) {

/* 4423 */       oceanMsg.setProperty("Ocean.SeaLevel", oceanData.seaLevel

/* 4424 */         .toString());

/*      */     }

/* 4426 */     if (oceanData.bumpScale != null) {

/* 4427 */       oceanMsg.setProperty("Ocean.BumpScale", oceanData.bumpScale

/* 4428 */         .toString());

/*      */     }

/* 4430 */     if (oceanData.bumpSpeedX != null) {

/* 4431 */       oceanMsg.setProperty("Ocean.BumpSpeedX", oceanData.bumpSpeedX

/* 4432 */         .toString());

/*      */     }

/* 4434 */     if (oceanData.bumpSpeedZ != null) {

/* 4435 */       oceanMsg.setProperty("Ocean.BumpSpeedZ", oceanData.bumpSpeedZ

/* 4436 */         .toString());

/*      */     }

/* 4438 */     if (oceanData.textureScaleX != null) {

/* 4439 */       oceanMsg.setProperty("Ocean.TextureScaleX", oceanData.textureScaleX

/* 4440 */         .toString());

/*      */     }

/* 4442 */     if (oceanData.textureScaleZ != null) {

/* 4443 */       oceanMsg.setProperty("Ocean.TextureScaleZ", oceanData.textureScaleZ

/* 4444 */         .toString());

/*      */     }

/* 4446 */     if (oceanData.deepColor != null) {

/* 4447 */       oceanMsg.setProperty("Ocean.DeepColor", oceanData.deepColor

/* 4448 */         .toString());

/*      */     }

/* 4450 */     if (oceanData.shallowColor != null) {

/* 4451 */       oceanMsg.setProperty("Ocean.ShallowColor", oceanData.shallowColor

/* 4452 */         .toString());

/*      */     }

/* 4454 */     player.getConnection().send(oceanMsg.toBuffer(player.getVersion()));

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */   protected Player verifyPlayer(String context, Event event, ClientConnection con)

/*      */   {

/* 4462 */     Player player = (Player)con.getAssociation();

/* 4463 */     if (!player.getOid().equals(event.getObjectOid())) {

/* 4464 */       throw new AORuntimeException(context + ": con doesn't match player " + player + " against eventOid " + event.getObjectOid());

/*      */     }

/* 4466 */     return player;

/*      */   }

/*      */   

/*      */   private class PlayerTimeout implements Runnable {

/*      */     private PlayerTimeout() {}

/*      */     

/*      */     public void run() {

/* 4473 */       for (;;) { try { Log.debug("PlayerTimeout thread running..");

/* 4474 */           timeoutPlayers();

/*      */         } catch (Exception e) {

/* 4476 */           Log.exception("PlayerTimeout", e);

/*      */         }

/*      */         try {

/* 4479 */           Thread.sleep(10000L);

/*      */         }

/*      */         catch (InterruptedException localInterruptedException) {}

/*      */       }

/*      */     }

/*      */     

/*      */     private void timeoutPlayers() {

/* 4486 */       List<Player> timedoutPlayers = ProxyPlugin.this.playerManager.getTimedoutPlayers(ProxyPlugin.idleTimeout * 1000, ProxyPlugin.silenceTimeout * 1000, ProxyPlugin.silenceLoadingTimeout * 1000);

/*      */       

/* 4488 */       for (Player player : timedoutPlayers) {

/* 4489 */         if (!ProxyPlugin.this.isAdmin(player.getOid())) {

/* 4490 */           Log.info(

/* 4491 */             "ProxyPlugin: IDLE_TIMEOUT remote=" + player.getConnection() + " player=" + player);

/* 4492 */           player.getConnection().close();

/*      */         }

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   private static class PlayerHeartbeat

/*      */     implements ProxyExtensionHook

/*      */   {

/*      */     public void processExtensionEvent(ExtensionMessageEvent event, Player player, ProxyPlugin proxy)

/*      */     {

/* 4503 */       Map<String, java.io.Serializable> props = new HashMap();

/* 4504 */       props.put("ext_msg_subtype", "ao.heartbeat");

/*      */       

/*      */

/* 4507 */       WorldManagerClient.TargetedExtensionMessage msg = new WorldManagerClient.TargetedExtensionMessage(WorldManagerClient.MSG_TYPE_EXTENSION, player.getOid(), player.getOid(), Boolean.valueOf(false), props);

/* 4508 */       Engine.getAgent().sendBroadcast(msg);

/*      */     } }

/*      */   

/*      */   static class AsyncRPCCallback implements atavism.msgsys.ResponseCallback { Player player;

/*      */     String debugPrefix;

/*      */     

/* 4514 */     AsyncRPCCallback(Player player, String debugPrefix) { this.player = player;

/* 4515 */       this.debugPrefix = debugPrefix;

/*      */     }

/*      */     

/*      */     public synchronized void handleResponse(atavism.msgsys.ResponseMessage response) {

/* 4519 */       this.responders -= 1;

/* 4520 */       Log.debug(this.debugPrefix + ", fromAgent=" + response.getSenderName() + " playerOid=" + this.player.getOid() + " responders=" + this.responders);

/* 4521 */       if (this.responders < 1)

/* 4522 */         notify();

/*      */     }

/*      */     

/*      */     public synchronized void waitForResponses(int expectedResponses) {

/* 4526 */       Log.debug(this.debugPrefix + ", playerOid=" + this.player.getOid() + " responders=" + this.responders + " expectedResponses=" + expectedResponses);

/* 4527 */       this.responders += expectedResponses;

/* 4528 */       Log.debug(this.debugPrefix + ", playerOid=" + this.player.getOid() + " responders=" + this.responders + " expectedResponses=" + expectedResponses + " after");

/* 4529 */       while (this.responders > 0) {

/*      */         try {

/* 4531 */           wait();

/*      */         } catch (InterruptedException e) {

/* 4533 */           ProxyPlugin.log.error("waitForResponses wait InterruptedException: " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */         } catch (Exception e) {

/* 4535 */           ProxyPlugin.log.error("waitForResponses wait InterruptedException: " + e.getMessage() + " " + e.getLocalizedMessage());

/*      */         }

/*      */       }

/*      */     }

/*      */     

/*      */

/*      */

/*      */

/*      */

/* 4544 */     int responders = 0;

/*      */   }

/*      */   

/*      */   public void incrementChatCount() {

/* 4548 */     this.chatSentCount += 1;

/*      */   }

/*      */   

/*      */   public void incrementPrivateChatCount() {

/* 4552 */     this.privateChatSentCount += 1;

/*      */   }

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4563 */   protected atavism.server.network.rdp.RDPServerSocket serverSocket = null;

/*      */   

/*      */   protected int clientPort;

/*      */   

/* 4567 */   protected static final Logger log = new Logger("ProxyPlugin");

/*      */   

/* 4569 */   PlayerMessageCallback playerMessageCallback = new PlayerMessageCallback();

/*      */   

/* 4571 */   protected PlayerManager playerManager = new PlayerManager();

/*      */   

/* 4573 */   protected atavism.server.util.TimeHistogram proxyQueueHistogram = null;

/*      */   

/* 4575 */   protected atavism.server.util.TimeHistogram proxyCallbackHistogram = null;

/*      */   

/* 4577 */   protected List<MessageType> extraPlayerMessageTypes = null;

/*      */   

/* 4579 */   private ProxyLoginCallback proxyLoginCallback = new DefaultProxyLoginCallback(null);

/*      */   

/* 4581 */   private InstanceEntryCallback instanceEntryCallback = new DefaultInstanceEntryCallback(null);

/*      */   

/* 4583 */   private int instanceEntryCount = 0;

/*      */   

/* 4585 */   private int chatSentCount = 0;

/*      */   

/* 4587 */   private int privateChatSentCount = 0;

/*      */   

/*      */

/* 4590 */   public static final MessageType MSG_TYPE_VOICE_PARMS = MessageType.intern("ao.VOICE_PARMS");

/*      */   

/*      */

/* 4593 */   public static final MessageType MSG_TYPE_PLAYER_PATH_REQ = MessageType.intern("ao.PLAYER_PATH_REQ");

/*      */   

/*      */

/* 4596 */   public static final MessageType MSG_TYPE_UPDATE_PLAYER_IGNORE_LIST = MessageType.intern("ao.UPDATE_PLAYER_IGNORE_LIST");

/*      */   

/*      */

/* 4599 */   public static final MessageType MSG_TYPE_GET_MATCHING_PLAYERS = MessageType.intern("ao.GET_MATCHING_PLAYERS");

/*      */   

/*      */

/* 4602 */   public static final MessageType MSG_TYPE_PLAYER_IGNORE_LIST = MessageType.intern("ao.PLAYER_IGNORE_LIST");

/*      */   

/*      */

/* 4605 */   public static final MessageType MSG_TYPE_PLAYER_IGNORE_LIST_REQ = MessageType.intern("ao.PLAYER_IGNORE_LIST_REQ");

/*      */   

/*      */

/* 4608 */   public static final MessageType MSG_TYPE_RELAY_UPDATE_PLAYER_IGNORE_LIST = MessageType.intern("ao.RELAY_UPDATE_PLAYER_IGNORE_LIST");

/*      */   

/*      */

/* 4611 */   public static final MessageType MSG_TYPE_GET_PLAYER_LOGIN_STATUS = MessageType.intern("ao.GET_PLAYER_LOGIN_STATUS");

/*      */   

/*      */

/* 4614 */   public static final MessageType MSG_TYPE_LOGOUT_PLAYER = MessageType.intern("ao.LOGOUT_PLAYER");

/*      */   

/*      */

/* 4617 */   public static final MessageType MSG_TYPE_ADD_STATIC_PERCEPTION = MessageType.intern("ao.ADD_STATIC_PERCEPTION");

/*      */   

/*      */

/* 4620 */   public static final MessageType MSG_TYPE_REMOVE_STATIC_PERCEPTION = MessageType.intern("ao.REMOVE_STATIC_PERCEPTION");

/*      */   

/*      */

/* 4623 */   public static final MessageType MSG_TYPE_LOGIN_SPAWNED = MessageType.intern("ao.LOGIN_SPAWNED");

/*      */   

/*      */

/* 4626 */   public static final MessageType MSG_TYPE_ACCOUNT_LOGIN = MessageType.intern("ao.ACCOUNT_LOGIN");

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4633 */   protected static String voiceServerHost = "";

/*      */   

/* 4635 */   protected static Integer voiceServerPort = null;

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4643 */   public String serverCapabilitiesSentToClient = "DirLocOrient";

/*      */   

/*      */

/*      */

/*      */

/* 4648 */   static int serverSocketReceiveBufferSize = 131072;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4654 */   public static int MaxConcurrentUsers = 1000;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4660 */   public static int idleTimeout = 900;

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */

/* 4668 */   public static int silenceTimeout = 30;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4674 */   public static int silenceLoadingTimeout = 900;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4680 */   public static int maxMessagesBeforeConnectionReset = 15000;

/*      */   

/*      */

/*      */

/*      */

/*      */

/* 4686 */   public static int maxByteCountBeforeConnectionReset = 2000000;

/*      */   

/*      */

/*      */

/*      */

/* 4691 */   public String capacityError = "Login Failed: Servers at capacity, please try again later.";

/*      */   

/*      */

/*      */

/*      */

/* 4696 */   public String tokenError = "Login Failed: Secure token invalid.";

/*      */   

/*      */

/*      */

/*      */

/* 4701 */   private atavism.server.network.ClientTCPMessageIO clientTCPMessageIO = null;

/*      */   

/*      */   /* Error */

/*      */   public void addAdmin(OID oid)

/*      */   {

/*      */     // Byte code:

/*      */     //   0: getstatic 287    atavism/server/util/Log:loggingDebug    Z

/*      */     //   3: ifeq +29 -> 32

/*      */     //   6: getstatic 331    atavism/server/plugins/ProxyPlugin:log    Latavism/server/util/Logger;

/*      */     //   9: new 82    java/lang/StringBuilder

/*      */     //   12: dup

/*      */     //   13: invokespecial 83    java/lang/StringBuilder:<init>    ()V

/*      */     //   16: ldc_w 1046

/*      */     //   19: invokevirtual 85    java/lang/StringBuilder:append    (Ljava/lang/String;)Ljava/lang/StringBuilder;

/*      */     //   22: aload_1

/*      */     //   23: invokevirtual 140    java/lang/StringBuilder:append    (Ljava/lang/Object;)Ljava/lang/StringBuilder;

/*      */     //   26: invokevirtual 87    java/lang/StringBuilder:toString    ()Ljava/lang/String;

/*      */     //   29: invokevirtual 410    atavism/server/util/Logger:debug    (Ljava/lang/String;)V

/*      */     //   32: aload_0

/*      */     //   33: getfield 1047    atavism/server/plugins/ProxyPlugin:lock    Ljava/util/concurrent/locks/Lock;

/*      */     //   36: invokeinterface 405 1 0

/*      */     //   41: aload_0

/*      */     //   42: getfield 69    atavism/server/plugins/ProxyPlugin:adminSet    Ljava/util/Set;

/*      */     //   45: aload_1

/*      */     //   46: invokeinterface 524 2 0

/*      */     //   51: pop

/*      */     //   52: aload_0

/*      */     //   53: getfield 1047    atavism/server/plugins/ProxyPlugin:lock    Ljava/util/concurrent/locks/Lock;

/*      */     //   56: invokeinterface 408 1 0

/*      */     //   61: goto +15 -> 76

/*      */     //   64: astore_2

/*      */     //   65: aload_0

/*      */     //   66: getfield 1047    atavism/server/plugins/ProxyPlugin:lock    Ljava/util/concurrent/locks/Lock;

/*      */     //   69: invokeinterface 408 1 0

/*      */     //   74: aload_2

/*      */     //   75: athrow

/*      */     //   76: return

/*      */     // Line number table:

/*      */     //   Java source line #4708    -> byte code offset #0

/*      */     //   Java source line #4709    -> byte code offset #6

/*      */     //   Java source line #4710    -> byte code offset #32

/*      */     //   Java source line #4712    -> byte code offset #41

/*      */     //   Java source line #4714    -> byte code offset #52

/*      */     //   Java source line #4715    -> byte code offset #61

/*      */     //   Java source line #4714    -> byte code offset #64

/*      */     //   Java source line #4716    -> byte code offset #76

/*      */     // Local variable table:

/*      */     //   start    length    slot    name    signature

/*      */     //   0    77    0    this    ProxyPlugin

/*      */     //   0    77    1    oid    OID

/*      */     //   64    11    2    localObject    Object

/*      */     // Exception table:

/*      */     //   from    to    target    type

/*      */     //   41    52    64    finally

/*      */   }

/*      */   

/*      */   public Set<OID> getAdmins()

/*      */   {

/* 4722 */     this.lock.lock();

/*      */     try {

/* 4724 */       return new HashSet(this.adminSet);

/*      */     } finally {

/* 4726 */       this.lock.unlock();

/*      */     }

/*      */   }

/*      */   

/*      */

/*      */

/*      */   public boolean isAdmin(OID playerOid)

/*      */   {

/* 4734 */     this.lock.lock();

/*      */     try { boolean bool;

/* 4736 */       if (playerOid == null) {

/* 4737 */         return false;

/*      */       }

/* 4739 */       return this.adminSet.contains(playerOid);

/*      */     } finally {

/* 4741 */       this.lock.unlock();

/*      */     }

/*      */   }

/*      */   

/*      */

/* 4746 */   Set<OID> adminSet = new HashSet();

/*      */   

/* 4748 */   HashMap<OID, ClientConnection> clientConnections = new HashMap();

/*      */   

/*      */

/* 4751 */   Set<String> filteredProps = null;

/*      */   

/*      */

/*      */

/* 4755 */   Set<String> playerSpecificProps = null;

/*      */   

/*      */

/*      */

/* 4759 */   Set<String> cachedPlayerSpecificFilterProps = null;

/*      */   

/*      */

/* 4762 */   String serverVersion = null;

/*      */   

/* 4764 */   protected Map<String, List<ProxyExtensionHook>> extensionHooks = new HashMap();

/*      */   

/* 4766 */   private int connectionLimit = 0;

/*      */   

/* 4768 */   boolean devMode = true;

/*      */   

/*      */

/*      */

/*      */

/*      */

/*      */

/*      */   protected Object createMBeanInstance()

/*      */   {

/* 4777 */     return new ProxyJMX();

/*      */   }

/*      */   

/*      */   public static abstract interface ProxyJMXMBean

/*      */   {

/*      */     public abstract int getMaxConcurrentUsers();

/*      */     

/*      */     public abstract void setMaxConcurrentUsers(int paramInt);

/*      */     

/*      */     public abstract int getIdleTimeout();

/*      */     

/*      */     public abstract void setIdleTimeout(int paramInt);

/*      */     

/*      */     public abstract int getSilenceTimeout();

/*      */     

/*      */     public abstract void setSilenceTimeout(int paramInt);

/*      */     

/*      */     public abstract int getCurrentUsers();

/*      */     

/*      */     public abstract int getPeakUsers();

/*      */     

/*      */     public abstract int getLoginCount();

/*      */     

/*      */     public abstract int getLogoutCount();

/*      */     

/*      */     public abstract int getClientPort();

/*      */     

/*      */     public abstract int getMaxMessagesBeforeConnectionReset();

/*      */     

/*      */     public abstract void setMaxMessagesBeforeConnectionReset(int paramInt);

/*      */     

/*      */     public abstract int getMaxByteCountBeforeConnectionReset();

/*      */     

/*      */     public abstract void setMaxByteCountBeforeConnectionReset(int paramInt);

/*      */     

/*      */     public abstract String getCapacityErrorMessage();

/*      */     

/*      */     public abstract void setCapacityErrorMessage(String paramString);

/*      */   }

/*      */   

/*      */   protected class ProxyJMX implements ProxyPlugin.ProxyJMXMBean {

/*      */     protected ProxyJMX() {}

/*      */     

/*      */     public int getMaxConcurrentUsers() {

/* 4821 */       return ProxyPlugin.MaxConcurrentUsers;

/*      */     }

/*      */     

/*      */     public void setMaxConcurrentUsers(int users) {

/* 4825 */       if (users >= 0)

/* 4826 */         ProxyPlugin.MaxConcurrentUsers = users;

/*      */     }

/*      */     

/*      */     public int getIdleTimeout() {

/* 4830 */       return ProxyPlugin.idleTimeout;

/*      */     }

/*      */     

/*      */     public void setIdleTimeout(int timeout) {

/* 4834 */       if (timeout > 0)

/* 4835 */         ProxyPlugin.idleTimeout = timeout;

/*      */     }

/*      */     

/*      */     public int getSilenceTimeout() {

/* 4839 */       return ProxyPlugin.silenceTimeout;

/*      */     }

/*      */     

/*      */     public void setSilenceTimeout(int timeout) {

/* 4843 */       if (timeout > 0)

/* 4844 */         ProxyPlugin.silenceTimeout = timeout;

/*      */     }

/*      */     

/*      */     public int getCurrentUsers() {

/* 4848 */       return ProxyPlugin.this.playerManager.getPlayerCount();

/*      */     }

/*      */     

/*      */     public int getPeakUsers() {

/* 4852 */       return ProxyPlugin.this.playerManager.getPeakPlayerCount();

/*      */     }

/*      */     

/*      */     public int getLoginCount() {

/* 4856 */       return ProxyPlugin.this.playerManager.getLoginCount();

/*      */     }

/*      */     

/*      */     public int getLogoutCount() {

/* 4860 */       return ProxyPlugin.this.playerManager.getLogoutCount();

/*      */     }

/*      */     

/*      */     public int getClientPort() {

/* 4864 */       return ProxyPlugin.this.clientPort;

/*      */     }

/*      */     

/*      */     public int getMaxMessagesBeforeConnectionReset() {

/* 4868 */       return ProxyPlugin.maxMessagesBeforeConnectionReset;

/*      */     }

/*      */     

/*      */     public void setMaxMessagesBeforeConnectionReset(int count) {

/* 4872 */       if (count > 0)

/* 4873 */         ProxyPlugin.maxMessagesBeforeConnectionReset = count;

/*      */     }

/*      */     

/*      */     public int getMaxByteCountBeforeConnectionReset() {

/* 4877 */       return ProxyPlugin.maxByteCountBeforeConnectionReset;

/*      */     }

/*      */     

/*      */     public void setMaxByteCountBeforeConnectionReset(int bytes) {

/* 4881 */       if (bytes > 0)

/* 4882 */         ProxyPlugin.maxByteCountBeforeConnectionReset = bytes;

/*      */     }

/*      */     

/*      */     public String getCapacityErrorMessage() {

/* 4886 */       return ProxyPlugin.this.capacityError;

/*      */     }

/*      */     

/*      */     public void setCapacityErrorMessage(String errorMessage) {

/* 4890 */       if (errorMessage != null) {

/* 4891 */         ProxyPlugin.this.capacityError = errorMessage;

/*      */       }

/*      */     }

/*      */   }

/*      */   

/*      */   private String getTemp()

/*      */   {

/* 4898 */     return "53d9e7ed9b24ad39cb3b5b514cf061b8";

/*      */   }

/*      */   

/*      */   class PeriodicGC implements Runnable {

/*      */     PeriodicGC() {}

/*      */     

/*      */     public void run() {

/* 4905 */       int count = 1;

/*      */       for (;;) {

/*      */         try {

/* 4908 */           Thread.sleep(60000L);

/*      */         }

/*      */         catch (InterruptedException localInterruptedException) {}

/* 4911 */         System.out.println("Proxy running GC " + count);

/* 4912 */         System.gc();

/* 4913 */         count++;

/*      */       }

/*      */     }

/*      */   }

/*      */ }





/* Location:              C:\atavism.jar!\atavism\server\plugins\ProxyPlugin.class

 * Java compiler version: 8 (52.0)

 * JD-Core Version:       0.7.1

 */
Код:

Тут стоит ограничения помогите снять (уже пытаюсь как кто через php обход сделать но пока толку 0(

Может кто то может помочь сделать php проверку
 

Гуглишь любой байткод редактор. И там где проверка правишь байткод ( скажем на обход через прыжок этой проверки ).
 
  • Мне нравится
Реакции: kick
Последнее редактирование модератором:
Closed.
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху Снизу