potential bugfix

This commit is contained in:
sirjonasxx 2018-11-06 21:21:24 +01:00
parent 02f2384374
commit a6d2636d0d

View File

@ -488,21 +488,26 @@ public class HPacket implements StringifyAble {
if (amount == 0) { if (amount == 0) {
return this; return this;
} }
int i = 6;
while (i < packetInBytes.length - 1 - oldS.length()) { int max = packetInBytes.length;
int i = packetInBytes.length - 2 - oldS.length();
while (i >= 6) {
if (canReadString(i)) { if (canReadString(i)) {
String s = readString(i); String s = readString(i);
if (s.contains(oldS)) { if (s.contains(oldS) && i + 2 + s.length() <= max) {
String replacement = s.replaceAll(oldS, newS); String replacement = s.replaceAll(oldS, newS);
replaceString(i, replacement); replaceString(i, replacement);
i += 1 + replacement.length(); i -= (1 + oldS.length());
amount -= 1; amount -= 1;
if (amount == 0) { if (amount == 0) {
return this; return this;
} }
max = i;
} }
} }
i++; i--;
} }
return this; return this;
} }
@ -907,9 +912,17 @@ public class HPacket implements StringifyAble {
} }
public static void main(String[] args) { public static void main(String[] args) {
HPacket packet = new HPacket("{l}{u:1442}{i:5}{i:4}{i:80015}{s:goiazdq}{s:samen spelen is tof}{b:false}{i:4}{s:spelletjes spelen}"); // HPacket packet = new HPacket("{l}{u:1442}{i:5}{i:4}{i:80015}{s:goiazdq}{s:samen spelen is tof}{b:false}{i:4}{s:spelletjes spelen}");
//
// System.out.println(packet.replaceAllSubstrings("spelen", "ownen").replaceAllIntegers(4, 45664868).toExpression());
System.out.println(packet.replaceAllSubstrings("spelen", "ownen").replaceAllIntegers(4, 45664868).toExpression());
HPacket packet2 = new HPacket("[0][0][10]([14]1[0][0][0][1][0][0][0][155][0][0][0][0][0][0][0][20][0][3]j¸[0][27]Sibyl System - Company News[0][0][0]8b09104s23014s04104s250148dc581e8240be4d7ceaaf11eacdd9bc0[0][0][16]f[0][0][0]ÿ[0][1][91]æ[0][0][0][17][0][1][91]æ[0]ΧO[0][6]Zhepyr[0][0][10]à[0][3]Õ¹[0][12]Bedrijfsblad[0][0][0]8b12114t48234s04234s2511416196f44746ef4f19213efb77da53d95[0][0][1][18][0][0][0]¾[0][0][11]c[0][0][0][12][0][0][11]c[1].D[11][0][10]AlphaRosea[0][2][143]b[0][3][138],[0][18]Imperial Newsflash[0][0][0]>b25114s41044s21044s25044s171109dcddee64fc01679e8792223ff4d9aaa[0][0][2]q[0][0][0]«[0][0]&7[0][0][0]&[0][0]&7[1]*[125]¸[0][6]Xorasy[0][0]&w[0][3]o[139][0][17][91]s[93] Ruilkamer [91]s[93][0][0][0]2b21054t14064s440376457dc68b5359c1d21b3bf6bec2a1b89[0][0]@[21][0][0][0][154][0][0]§Î[0][0][2][7][0][0]§Î[1]-Û¢[0][6]Furnix[0][0][2][31][0][2][141]«[0][28]Defensie Voorlichtingsdienst[0][0][0]>b01064s12117s43114t40014s55111c4408dc36ad72edd8798afd29b00f523[0][0][1][148][0][0][0]l[0][0][7][150][0][0][0][11][0][0][7][150][1]%t[132][0][7]jkaddai[0][0]¿[15][0][3]à^[0][25][91]PA[93] Recruitment Helpdesk[0][0][0]>b08134s02014s19114s95066s850685f0d5a0fa9d247da3b52f707434abee7[0][0][0][7][0][0][0]^[0][0][0]k[0][0][0]k[0][0][0]k[1][22]\u00ADä[0][12]supermooieik[0][0]`Î[0][3]µ[125][0][25][91]A&R[93] Afk / Weggeef [91]A&R[93][0][0][0]8b01114s21014s16174s3604791309a5ddb6265ba42f806c14577e7e4[0][0][0][5][0][0][0]H[0][0][0]&[0][0][0]&[0][0][0]&[0]î[6]Õ[0][5]Ziemy[0][0][30]¡[0][3]#k[0][16]Give-Away - Fans[0][0][0]8b09044s34021s34044s340175320e7b023fe1cf24ac5d63221d1cffd[0][0][0][158][0][0][0];[0][0][14]¿[0][0][0][145][0][0][14]¿[1][24]%[2][0][7]-Rhedyn[0][2][143]#[0][3]á;[0][26]USA: Friends & Supporters.[0][0][0]>b10044s36044s44044t28104s39011005466e044e3ee85d5d3f19b487a471e[0][0][0][4][0][0][0]3[0][0][0][17][0][0][0][17][0][0][0][17][1].[138]·[0][12]Pingponglord[0][5]§[152][0][3]áé[0][16]United Newspaper[0][0][0]>b25114s11174s27014s18114t39114542b32ec5cf1b7b46c1492a842c8db84[0][0][0][6][0][0][0],[0][0][0][8][0][0][0][2][0][0][0][8][1][19]w[18][0][11]horselady54[0][9]®P[0][2]ߨ[0][27]Â¥Maanâ[128][153]s WEGGEEF SPEL! Â¥[0][0][0]>b25114s19094t22130t22112s90098c7264b555fc9e31ebe09245d6dfd55bf[0][0][0]![0][0][0]%[0][0][3]6[0][0][3]6[0][0][3]6[0]x¯U[0][10]!MaAntJah![0][2][144]l[0][3]µ\\[0][24]Vief's AFK Game FastPass[0][0][0]>b17064s03134s01010s26104s990641aae3ad5e5b42ed0f4834f5e81286a6e[0][0][0][8][0][0][0]#[0][0][0]a[0][0][0]G[0][0][0]a[1][28]~ý[0][11]Zinzi.Jewel[0][0]ES[0][2]y¥[0][23]Ministerie van Defensie[0][0][0]>b01064s12117s33114s55111t121146e65aff06b414dcdd0cb1ee875196b06[0][0][0][18][0][0][0]#[0][0][0]9[0][0][0]9[0][0][0]9[1]$á[27][0][11]rienie3011.[4]ø\"e[0][3]â_[0][17]µ AFK GAME µ FP[0][0][0]>b21124s23114s24104s93058s83050d2d4b464249d608190ef2ea72f185ecf[0][0][0][2][0][0][0]\"[0][0][0][31][0][0][0][31][0][0][0][31][1]*[154]_[0][9]:Knoppers[0][4]W¥[0][3]×þ[0][7][91]ST[93] FP[0][0][0]>b01024t57136t57138t57132t571306d625674d548ca13deafce5494690ee7[0][0][0][9][0][0][0][30][0][0][0]L[0][0][0]L[0][0][0]L[1]-[31]ì[0][5]Sam_6[0][3][24]ü[0][3]Y[10][0][31]Â¥Super rare weggeef spelÂ¥ fan[0][0][0]8b22134t47134s44134s161148f04a326436a7effa87df4ae0b9347d1[0][0][0][10][0][0][0][30][0][0][0]X[0][0][0][8][0][0][0]X[1]*g[132][0][11]Magnificant[0][4]F[8][0][3]á[20][0][22]Â¥ FP - AFK Weggeef Â¥[0][0][0]8b27134s29091s44114s110170838dbeadf0710910d9ecb526fb4ce63[0][0][0][6][0][0][0][28][0][0][0]%[0][0][0]%[0][0][0]%[0][6]æ[8][0][5]ricks[0][3]Ý©[0][3]Á[158][0][17]Â¥Bingo WeggeefÂ¥[0][0][0]>b01114s23114s24014s11097s13094a7b12ac9ec084a539a94c876400d01c5[0][0][0][9][0][0][0][26][0][0][1][0][0][0][1][0][0][0][1][0][1][16]Ág[0][11]Marianella-[0][2]æS[0][3][157]¥[0][27]Sollicitatie - Storage Wars[0][0][0]>b05164s23114s21164s43114s2411492ea1401b86bf2876d1d27963e96ba39[0][0][0]Ø[0][0][0][26][0][0][6]P[0][0][6]P[0][0][6]P[1][16]Ág[0][11]Marianella-[0][2]Åò[0][2]ÀY[0][16]--Googlen's fans[0][0][0]8b05134s03083s12097s591142b94aa70f93fb872022c01de7cf33f5e[0][0][0]'[0][0][0][20][0][0][0]Ò[0][0][0]Ò[0][0][0]Ò[1][0]µI[0][9]--Googlen[0][1][128]É");
System.out.println(packet2.isCorrupted());
packet2.replaceAllSubstrings("Sibyl", "Habbo Inside");
System.out.println(packet2);
System.out.println(packet2.isCorrupted());
} }
} }