Moparscape - RSPS Community

RuneScape 2 Development => RS Client Hacking => Topic started by: Ambokile on July 28, 2014, 08:53:07 AM

Title: Almost completely refactored Player Update protocol (317)
Post by: Ambokile on July 28, 2014, 08:53:07 AM
Here's a player updating protocol that I've refactored. Some of it has been from other sources although I'm not sure of their authors. A lot of it is my work.

There are a few bits missing in the 0x100 (graphics) and 0x8 (animation) procedures which I simply can't find any meaning for. If you have any idea, please let me know.

Code: Java
  1.     privatevoid updatePlayerupdateType(Stream stream, int updateType, Player player, int playerId)
  2.     {
  3.         if((updateType & 0x400)!=0)
  4.         {
  5.             player.startX= stream.getUnsignedByteS();
  6.             player.startY= stream.getUnsignedByteS();
  7.             player.endX= stream.getUnsignedByteS();
  8.             player.endY= stream.getUnsignedByteS();
  9.             player.speedToStart= stream.getUnsignedShortA()+ loopCycle;
  10.             player.speedToEnd= stream.getUnsignedLEShortA()+ loopCycle;
  11.             player.direction= stream.getUnsignedByteS();
  12.             player.resetPath();
  13.         }
  14.         if((updateType & 0x100)!=0)
  15.         {
  16.             player.graphicId= stream.getUnsignedShort();
  17.             int delay = stream.getInt();
  18.             player.graphicHeight= delay >>16;
  19.             player.graphicEndCycle= loopCycle +(delay & 0xffff);
  20.             player.currentAnimation=0;
  21.             player.anInt1522=0;
  22.             if(player.graphicEndCycle> loopCycle)
  23.                 player.currentAnimation=-1;
  24.             if(player.graphicId==65535)
  25.                 player.graphicId=-1;
  26.         }
  27.         if((updateType &8)!=0)
  28.         {
  29.             int animationId = stream.getUnsignedShort();
  30.             if(animationId ==65535)
  31.                 animationId =-1;
  32.             int animationDelay = stream.getUnsignedByteC();
  33.             if(animationId == player.animation&& animationId !=-1)
  34.             {
  35.                 int i3 = Animation.anims[animationId].anInt365;
  36.                 if(i3 ==1)
  37.                 {
  38.                     player.anInt1527=0;
  39.                     player.anInt1528=0;
  40.                     player.animationDelay= animationDelay;
  41.                     player.anInt1530=0;
  42.                 }
  43.                 if(i3 ==2)
  44.                     player.anInt1530=0;
  45.             }else
  46.             if(animationId ==-1|| player.animation==-1|| Animation.anims[animationId].anInt359>= Animation.anims[player.animation].anInt359)
  47.             {
  48.                 player.animation= animationId;
  49.                 player.anInt1527=0;
  50.                 player.anInt1528=0;
  51.                 player.animationDelay= animationDelay;
  52.                 player.anInt1530=0;
  53.                 player.anInt1542= player.pathLength;
  54.             }
  55.         }
  56.         if((updateType &4)!=0)
  57.         {
  58.             player.textSpoken= stream.getString();
  59.             if(player.textSpoken.charAt(0)=='~')
  60.             {
  61.                 player.textSpoken= player.textSpoken.substring(1);
  62.                 pushMessage(player.textSpoken, 2, player.name);
  63.             }else
  64.             if(player == localPlayer)
  65.                 pushMessage(player.textSpoken, 2, player.name);
  66.             player.chatColour=0;
  67.             player.chatEffect=0;
  68.             player.textCycle=150;
  69.         }
  70.         if((updateType & 0x80)!=0)
  71.         {
  72.             int colourAndEffect = stream.getUnsignedShort();
  73.             int rights = stream.getUnsignedByte();
  74.             int messageLength = stream.getUnsignedByteC();
  75.             int originalOffset = stream.currentOffset;
  76.             if(player.name!=null&& player.visible)
  77.             {
  78.                 long nameAsLong = TextClass.longForName(player.name);
  79.                 boolean ignored =false;
  80.                 if(rights <=1)
  81.                 {
  82.                     for(int p =0; p < ignoreCount; p++)
  83.                     {
  84.                         if(ignoreListAsLongs[p]!= nameAsLong)
  85.                             continue;
  86.                         ignored =true;
  87.                         break;
  88.                     }
  89.  
  90.                 }
  91.                 if(!ignored && inTutorial ==0)
  92.                     try
  93.                     {
  94.                         textStream.currentOffset=0;
  95.                         stream.getBytes(messageLength, 0, textStream.buffer);
  96.                         textStream.currentOffset=0;
  97.                         String text = TextInput.readFromStream(messageLength, textStream);
  98.                         text = Censor.doCensor(text);
  99.                         player.textSpoken= text;
  100.                         player.chatColour= colourAndEffect >>8;
  101.                             player.rights= rights;
  102.  
  103.                         //entityMessage(player);
  104.        
  105.                         player.chatEffect= colourAndEffect & 0xff;
  106.                         player.textCycle=150;
  107.                         if(rights ==2|| rights ==3)
  108.                             pushMessage(text, 1, "@[email protected]"+ player.name);
  109.                         else
  110.                         if(rights ==1)
  111.                             pushMessage(text, 1, "@[email protected]"+ player.name);
  112.                         else
  113.                             pushMessage(text, 2, player.name);
  114.                     }
  115.                     catch(Exception exception)
  116.                     {
  117.                         signlink.reporterror("cde2");
  118.                     }
  119.             }
  120.             stream.currentOffset= originalOffset + messageLength;
  121.         }
  122.         if((updateType &1)!=0)
  123.         {
  124.             player.interactingEntity= stream.getUnsignedShort();
  125.             if(player.interactingEntity==65535)
  126.                 player.interactingEntity=-1;
  127.         }
  128.         if((updateType & 0x10)!=0)
  129.         {
  130.             int appearanceBufferSize = stream.getUnsignedByteC();
  131.             byte _appearanceBuffer[]=newbyte[appearanceBufferSize];
  132.             Stream appearanceBuffer =new Stream(_appearanceBuffer);
  133.             stream.readBytes(appearanceBufferSize, 0, _appearanceBuffer);
  134.             playerBuffer[playerId]= appearanceBuffer;
  135.             player.updatePlayer(appearanceBuffer);
  136.         }
  137.         if((updateType &2)!=0)
  138.         {
  139.             player.faceTowardX= stream.getUnsignedShortA();
  140.             player.faceTowardY= stream.getUnsignedShort();
  141.         }
  142.         if((updateType & 0x20)!=0)
  143.         {
  144.             int hitDamage = stream.getUnsignedByte();
  145.             int hitType = stream.getUnsignedByteA();
  146.             player.updateHitData(hitType, hitDamage, loopCycle);
  147.             player.loopCycleStatus= loopCycle +300;
  148.             player.currentHealth= stream.getUnsignedByteC();
  149.             player.maxHealth= stream.getUnsignedByte();
  150.         }
  151.         if((updateType & 0x200)!=0)
  152.         {
  153.             int hitDamage = stream.getUnsignedByte();
  154.             int hitType = stream.getUnsignedByteS();
  155.             player.updateHitData(hitType, hitDamage, loopCycle);
  156.             player.loopCycleStatus= loopCycle +300;
  157.             player.currentHealth= stream.getUnsignedByte();
  158.             player.maxHealth= stream.getUnsignedByteC();
  159.         }
  160.     }