package mapped;

import java.io.IOException;
import java.net.Socket;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSWorldMapData_0;

@ObfuscatedName("ii")
public class WorldMapData_0 extends AbstractWorldMapData implements RSWorldMapData_0 {
   @ObfuscatedName("gl")
   @ObfuscatedSignature(
      descriptor = "Loh;"
   )
   static Archive field2426;

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Luj;B)V",
      garbageValue = "-89"
   )
   void method4468(Buffer var1) {
      int var2 = var1.readUnsignedByte_base();
      if(var2 != WorldMapID.field2608.value) {
         throw new IllegalStateException("");
      } else {
         super.minPlane = var1.readUnsignedByte_base();
         super.planes = var1.readUnsignedByte_base();
         super.regionXLow = var1.readUnsignedShort_base();
         super.regionYLow = var1.readUnsignedShort_base();
         super.regionX = var1.readUnsignedShort_base();
         super.regionY = var1.readUnsignedShort_base();
         super.groupId = var1.readNullableLargeSmart_base();
         super.fileId = var1.readNullableLargeSmart_base();
      }
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(Luj;B)V",
      garbageValue = "7"
   )
   void vmethod4896(Buffer var1) {
      super.planes = Math.min(super.planes, 4);
      super.floorUnderlayIds = new short[1][64][64];
      super.floorOverlayIds = new short[super.planes][64][64];
      super.field2560 = new byte[super.planes][64][64];
      super.field2571 = new byte[super.planes][64][64];
      super.decorations = new WorldMapDecoration[super.planes][64][64][];
      int var2 = var1.readUnsignedByte_base();
      if(var2 != class250.field2605.value) {
         throw new IllegalStateException("");
      } else {
         int var3 = var1.readUnsignedByte_base();
         int var4 = var1.readUnsignedByte_base();
         if(var3 == super.regionX && var4 == super.regionY) {
            for(int var5 = 0; var5 < 64; ++var5) {
               for(int var6 = 0; var6 < 64; ++var6) {
                  this.method4907(var5, var6, var1);
               }
            }

         } else {
            throw new IllegalStateException("");
         }
      }
   }

   public boolean equals(Object var1) {
      if(!(var1 instanceof WorldMapData_0)) {
         return false;
      } else {
         WorldMapData_0 var2 = (WorldMapData_0)var1;
         return var2.regionX == super.regionX && super.regionY == var2.regionY;
      }
   }

   public int hashCode() {
      return super.regionX | super.regionY << 8;
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Ljava/net/Socket;III)Lro;",
      garbageValue = "-919788218"
   )
   public static AbstractSocket method4467(Socket var0, int var1, int var2) throws IOException {
      return new BufferedNetSocket(var0, var1, var2);
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/CharSequence;I)Ljava/lang/String;",
      garbageValue = "265827581"
   )
   public static String method4483_base(CharSequence var0) {
      int var1 = var0.length();
      StringBuilder var2 = new StringBuilder(var1);

      for(int var3 = 0; var3 < var1; ++var3) {
         char var4 = var0.charAt(var3);
         if((var4 < 'a' || var4 > 'z') && (var4 < 'A' || var4 > 'Z') && (var4 < '0' || var4 > '9') && var4 != '.' && var4 != '-' && var4 != '*' && var4 != '_') {
            if(var4 == ' ') {
               var2.append('+');
            } else {
               byte var5 = class137.charToByteCp1252_base(var4);
               var2.append('%');
               int var6 = var5 >> 4 & 15;
               if(var6 >= 10) {
                  var2.append((char)(var6 + 55));
               } else {
                  var2.append((char)(var6 + 48));
               }

               var6 = var5 & 15;
               if(var6 >= 10) {
                  var2.append((char)(var6 + 55));
               } else {
                  var2.append((char)(var6 + 48));
               }
            }
         } else {
            var2.append(var4);
         }
      }

      return var2.toString();
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(II)I",
      garbageValue = "1663325079"
   )
   public static int Widget_unpackTargetMask_base(int var0) {
      return var0 >> 11 & 63;
   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(I)Lcr;",
      garbageValue = "850899958"
   )
   static World method4482() {
      return World.World_listCount < World.World_count?class361.World_worlds[++World.World_listCount - 1]:null;
   }
}
