Skip to content

Commit

Permalink
Fix native fps to prevent divide by 0 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmsv-mx123 authored Sep 27, 2023
1 parent e7c66cc commit 7d0a395
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Client/JClassPatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,11 @@ else if (invoke.name.equals("addKeyListener"))
nextNode, new FieldInsnNode(Opcodes.GETFIELD, "e", "Ib", "I"));
methodNode.instructions.insertBefore(nextNode, new IntInsnNode(Opcodes.SIPUSH, 256));
methodNode.instructions.insertBefore(nextNode, new InsnNode(Opcodes.IMUL));
// added to prevent seeks div by 0
methodNode.instructions.insertBefore(nextNode, new InsnNode(Opcodes.ICONST_1));
methodNode.instructions.insertBefore(
nextNode,
new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Math", "max", "(II)I", false));
methodNode.instructions.insertBefore(nextNode, new InsnNode(Opcodes.IDIV));
methodNode.instructions.insertBefore(
nextNode, new FieldInsnNode(Opcodes.PUTSTATIC, "Game/Client", "fps", "I"));
Expand Down
5 changes: 4 additions & 1 deletion src/Game/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -2477,7 +2477,10 @@ public static void drawNativeTextHook(Object surfaceInstance) {
try {
Reflection.drawString.invoke(
surfaceInstance,
"Fps: " + Client.fps,
"Fps: "
+ (Client.username_login.equals(XPBar.excludeUsername)
? Renderer.fps
: Client.fps),
Renderer.width - 62 - offset,
Renderer.height - 19,
0xffff00,
Expand Down

0 comments on commit 7d0a395

Please sign in to comment.