Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace Ferri.APU
{
class AutoPacketUpdate
{
public static string GetFinalCode(string strSource)
{
string strBegin = "[";
string strEnd = "]";
bool includeBegin = false;
bool includeEnd = false;
string[] result = { string.Empty, string.Empty };
int iIndexOfBegin = strSource.IndexOf(strBegin);
if (iIndexOfBegin != -1)
{
// include the Begin string if desired
if (includeBegin)
iIndexOfBegin -= strBegin.Length;
strSource = strSource.Substring(iIndexOfBegin + strBegin.Length);
int iEnd = strSource.IndexOf(strEnd);
if (iEnd != -1)
{
// include the End string if desired
if (includeEnd)
iEnd += strEnd.Length;
result[0] = strSource.Substring(0, iEnd);
// advance beyond this segment
if (iEnd + strEnd.Length < strSource.Length)
result[1] = strSource.Substring(iEnd + strEnd.Length);
}
}
else
// stay where we are
result[1] = strSource;
return result[0];
}
public static string addHabboConnectionMessageEventGetCode(string strSource)
{
string strBegin = ".addHabboConnectionMessageEvent(new ";
string strEnd = "(this.";
bool includeBegin = false;
bool includeEnd = false;
string[] result = { string.Empty, string.Empty };
int iIndexOfBegin = strSource.IndexOf(strBegin);
if (iIndexOfBegin != -1)
{
// include the Begin string if desired
if (includeBegin)
iIndexOfBegin -= strBegin.Length;
strSource = strSource.Substring(iIndexOfBegin + strBegin.Length);
int iEnd = strSource.IndexOf(strEnd);
if (iEnd != -1)
{
// include the End string if desired
if (includeEnd)
iEnd += strEnd.Length;
result[0] = strSource.Substring(0, iEnd);
// advance beyond this segment
if (iEnd + strEnd.Length < strSource.Length)
result[1] = strSource.Substring(iEnd + strEnd.Length);
}
}
else
// stay where we are
result[1] = strSource;
return result[0];
}
public static string ImportGetCode(string code)
{
string[] xx = code.Split('.');
return xx[1];
}
public static string ConvertToPacketId(string OldPacketCode, string file)
{
string[] Classes = Regex.Split(file, "//------------------------------------------------------------");
foreach (string SepareCodes in Classes)
{
if(SepareCodes.Contains("public class HabboMessages implements"))
{
string[] Lines = Regex.Split(file, "\n");
int i = 0;
foreach (string Line in Lines)
{
if (Line.Contains(OldPacketCode))
{
if (!Line.Contains("import"))
{
string[] LastStep = Regex.Split(Line, " = ");
return GetFinalCode(LastStep[0]);
}
}
i++;
}
}
}
return "";
}
public static string AddCode(string code, string packetid, string PacketCode, string Comment = "")
{
PacketCode = PacketCode.Replace("_-", "");
PacketCode = PacketCode.Replace(";", "");
return ("internal const short " + code + " = " + packetid + "; // " + PacketCode + "\n\r");
}
public static string ReleaseFilter(string Line)
{
Line = Line.Replace(" ", "");
Line = Line.Replace("vark", "");
Line = Line.Replace(":", "");
Line = Line.Replace("String=", "");
Line = Line.Replace(";", "");
Line = Line.Replace("\"", "");
return Line;
}
public static void Start()
{
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Gray;
Console.WriteLine("###############################################################################");
Console.WriteLine("### Maded by Droppy & Josh ###");
Console.WriteLine("###############################################################################");
Console.ResetColor();
Console.WriteLine();
var F5 = new StreamReader("swf/scriptss.txt");
string All = F5.ReadToEnd();
string[] Classes = Regex.Split(All, "//------------------------------------------------------------");
foreach (string SepareCodes in Classes)
{
if (SepareCodes.Contains("RELEASE63-"))
{
string[] Classes2 = Regex.Split(SepareCodes, "\n");
int line = 0;
foreach (string Line in Classes2)
{
if (line == 11)
{
Console.Write("Release Atual: ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(ReleaseFilter(Line));
Console.ResetColor();
}
line++;
}
}
}
Console.WriteLine();
Console.WriteLine("//==> Be welcome.");
Console.WriteLine();
string Put = "By Droppy \n\r\n\r";
int Count = 0;
foreach (string SepareCodes in Classes)
{
if (SepareCodes.Contains("public class HabboCommunicationDemo extends"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 27)
{
Put = Put + AddCode("SendToken", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
if (LineCount == 28)
{
Put = Put + AddCode("SendPublicKey", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
if (SepareCodes.Contains("public class HabboInventory extends"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 45)
{
Put = Put + AddCode("SendInterface", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
if (SepareCodes.Contains("public class HabboMessenger extends"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 32)
{
Put = Put + AddCode("SendMinimailCount", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
if (SepareCodes.Contains("public function IncomingMessages(_arg1:HabboNavigator){"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 21)
{
Put = Put + AddCode("SendHomeRoom", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
if (LineCount == 28)
{
Put = Put + AddCode("SendFavourites", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
if (SepareCodes.Contains("public class VideoOfferManager implements"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 5)
{
Put = Put + AddCode("SendFuserights", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
if (SepareCodes.Contains("public class FriendList {"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 6)
{
Put = Put + AddCode("SendFriends", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
if (SepareCodes.Contains("public class AvatarImageWidget implements _-1jT {"))
{
string[] nClasses = Regex.Split(SepareCodes, "\n");
int LineCount = 0;
foreach (string Line in nClasses)
{
if (LineCount == 6)
{
Put = Put + AddCode("SendUserInformation", ConvertToPacketId(ImportGetCode(Line), All), ImportGetCode(Line));
}
LineCount++;
}
Count = Count + 1;
}
}
string[] lines = {Put};
System.IO.File.WriteAllLines("Packet.ini", lines);
Console.ForegroundColor = ConsoleColor.Green;
//Console.WriteLine(Count + " packet(s) saved(s) in Packet.ini!");
Console.WriteLine(lines[0]);
Console.ResetColor();
Console.WriteLine("");
Console.WriteLine("Press Any Key to Close.");
}
}
class Program
{
static void Main(string[] args)
{
try
{
AutoPacketUpdate.Start();
Console.ReadKey();
}
catch
{
Environment.Exit(1);
}
}
}
}