Avoid NpcViewMod packet crash.
This commit is contained in:
@@ -403,6 +403,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
int rightHeight = 0;
|
int rightHeight = 0;
|
||||||
final StringBuilder leftSb = new StringBuilder();
|
final StringBuilder leftSb = new StringBuilder();
|
||||||
final StringBuilder rightSb = new StringBuilder();
|
final StringBuilder rightSb = new StringBuilder();
|
||||||
|
String limitReachedMsg = "";
|
||||||
for (int i = start; i < end; i++)
|
for (int i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
@@ -526,15 +527,22 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftHeight >= (rightHeight + height))
|
if ((rightSb.length() + leftSb.length()) < 13000) // limit of 32766
|
||||||
{
|
{
|
||||||
rightSb.append(sb);
|
if (leftHeight >= (rightHeight + height))
|
||||||
rightHeight += height;
|
{
|
||||||
|
rightSb.append(sb);
|
||||||
|
rightHeight += height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leftSb.append(sb);
|
||||||
|
leftHeight += height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leftSb.append(sb);
|
limitReachedMsg = "<br><center>Too many drops! Could not display them all!</center>";
|
||||||
leftHeight += height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +564,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
html = html.replaceAll("%name%", npc.getName());
|
html = html.replaceAll("%name%", npc.getName());
|
||||||
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
||||||
html = html.replaceAll("%pages%", pagesSb.toString());
|
html = html.replaceAll("%pages%", pagesSb.toString());
|
||||||
html = html.replaceAll("%items%", bodySb.toString());
|
html = html.replaceAll("%items%", bodySb.toString() + limitReachedMsg);
|
||||||
Util.sendCBHtml(activeChar, html);
|
Util.sendCBHtml(activeChar, html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -403,6 +403,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
int rightHeight = 0;
|
int rightHeight = 0;
|
||||||
final StringBuilder leftSb = new StringBuilder();
|
final StringBuilder leftSb = new StringBuilder();
|
||||||
final StringBuilder rightSb = new StringBuilder();
|
final StringBuilder rightSb = new StringBuilder();
|
||||||
|
String limitReachedMsg = "";
|
||||||
for (int i = start; i < end; i++)
|
for (int i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
@@ -526,15 +527,22 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftHeight >= (rightHeight + height))
|
if ((rightSb.length() + leftSb.length()) < 13000) // limit of 32766
|
||||||
{
|
{
|
||||||
rightSb.append(sb);
|
if (leftHeight >= (rightHeight + height))
|
||||||
rightHeight += height;
|
{
|
||||||
|
rightSb.append(sb);
|
||||||
|
rightHeight += height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leftSb.append(sb);
|
||||||
|
leftHeight += height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leftSb.append(sb);
|
limitReachedMsg = "<br><center>Too many drops! Could not display them all!</center>";
|
||||||
leftHeight += height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +564,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
html = html.replaceAll("%name%", npc.getName());
|
html = html.replaceAll("%name%", npc.getName());
|
||||||
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
||||||
html = html.replaceAll("%pages%", pagesSb.toString());
|
html = html.replaceAll("%pages%", pagesSb.toString());
|
||||||
html = html.replaceAll("%items%", bodySb.toString());
|
html = html.replaceAll("%items%", bodySb.toString() + limitReachedMsg);
|
||||||
Util.sendCBHtml(activeChar, html);
|
Util.sendCBHtml(activeChar, html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -403,6 +403,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
int rightHeight = 0;
|
int rightHeight = 0;
|
||||||
final StringBuilder leftSb = new StringBuilder();
|
final StringBuilder leftSb = new StringBuilder();
|
||||||
final StringBuilder rightSb = new StringBuilder();
|
final StringBuilder rightSb = new StringBuilder();
|
||||||
|
String limitReachedMsg = "";
|
||||||
for (int i = start; i < end; i++)
|
for (int i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
@@ -526,15 +527,22 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftHeight >= (rightHeight + height))
|
if ((rightSb.length() + leftSb.length()) < 13000) // limit of 32766
|
||||||
{
|
{
|
||||||
rightSb.append(sb);
|
if (leftHeight >= (rightHeight + height))
|
||||||
rightHeight += height;
|
{
|
||||||
|
rightSb.append(sb);
|
||||||
|
rightHeight += height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leftSb.append(sb);
|
||||||
|
leftHeight += height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leftSb.append(sb);
|
limitReachedMsg = "<br><center>Too many drops! Could not display them all!</center>";
|
||||||
leftHeight += height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +564,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
html = html.replaceAll("%name%", npc.getName());
|
html = html.replaceAll("%name%", npc.getName());
|
||||||
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
||||||
html = html.replaceAll("%pages%", pagesSb.toString());
|
html = html.replaceAll("%pages%", pagesSb.toString());
|
||||||
html = html.replaceAll("%items%", bodySb.toString());
|
html = html.replaceAll("%items%", bodySb.toString() + limitReachedMsg);
|
||||||
Util.sendCBHtml(activeChar, html);
|
Util.sendCBHtml(activeChar, html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -403,6 +403,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
int rightHeight = 0;
|
int rightHeight = 0;
|
||||||
final StringBuilder leftSb = new StringBuilder();
|
final StringBuilder leftSb = new StringBuilder();
|
||||||
final StringBuilder rightSb = new StringBuilder();
|
final StringBuilder rightSb = new StringBuilder();
|
||||||
|
String limitReachedMsg = "";
|
||||||
for (int i = start; i < end; i++)
|
for (int i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
@@ -526,15 +527,22 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftHeight >= (rightHeight + height))
|
if ((rightSb.length() + leftSb.length()) < 13000) // limit of 32766
|
||||||
{
|
{
|
||||||
rightSb.append(sb);
|
if (leftHeight >= (rightHeight + height))
|
||||||
rightHeight += height;
|
{
|
||||||
|
rightSb.append(sb);
|
||||||
|
rightHeight += height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leftSb.append(sb);
|
||||||
|
leftHeight += height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leftSb.append(sb);
|
limitReachedMsg = "<br><center>Too many drops! Could not display them all!</center>";
|
||||||
leftHeight += height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +564,7 @@ public class NpcViewMod implements IBypassHandler
|
|||||||
html = html.replaceAll("%name%", npc.getName());
|
html = html.replaceAll("%name%", npc.getName());
|
||||||
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
html = html.replaceAll("%dropListButtons%", getDropListButtons(npc));
|
||||||
html = html.replaceAll("%pages%", pagesSb.toString());
|
html = html.replaceAll("%pages%", pagesSb.toString());
|
||||||
html = html.replaceAll("%items%", bodySb.toString());
|
html = html.replaceAll("%items%", bodySb.toString() + limitReachedMsg);
|
||||||
Util.sendCBHtml(activeChar, html);
|
Util.sendCBHtml(activeChar, html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user