Skip to content

Commit

Permalink
Deobfuscate SoundClip code
Browse files Browse the repository at this point in the history
No functional changes intended. Code changes except for renaming things:
- remove hardcoded static strings
- remove unnecessary escapes from debug log strings
  • Loading branch information
StenAL committed Apr 28, 2023
1 parent 16aaac1 commit c9836b0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 78 deletions.
56 changes: 0 additions & 56 deletions client/src/main/java/com/aapeli/client/Class86.java

This file was deleted.

51 changes: 51 additions & 0 deletions client/src/main/java/com/aapeli/client/SoundClip.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.aapeli.client;

import java.applet.Applet;
import java.applet.AudioClip;
import java.net.URL;

class SoundClip {

private Applet applet;
private URL dir;
private String file;
private boolean debug;
private AudioClip audioClip;
private boolean defined;


protected SoundClip(Applet applet, URL dir, String file, boolean debug) {
this.applet = applet;
this.dir = dir;
this.file = file;
this.debug = debug;
this.audioClip = null;
this.defined = false;
}

protected boolean isDefined() {
return this.defined;
}

protected void defineClip() {
if (!this.defined) {
if (this.debug) {
System.out.println("SoundClip.defineClip(): 'dir'=\"" + this.dir + "\", 'file'=\"" + this.file + "\"");
}

//todo this.audioClip = this.applet.getAudioClip(this.dir, this.file);
URL url = dir;
try {
url = new URL(dir, file);
} catch (Exception ex) {
System.out.println("SoundClip.defineClip(): failed to load sound clip");
}
audioClip = Applet.newAudioClip(url);
this.defined = true;
}
}

protected AudioClip getAudioClip() {
return this.audioClip;
}
}
44 changes: 22 additions & 22 deletions client/src/main/java/com/aapeli/client/SoundManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ public void run() {
var3 = false;
Enumeration var1 = this.aHashtable1489.elements();

Class86 var2;
SoundClip soundClip;
while (var1.hasMoreElements()) {
var2 = (Class86) ((Class86) var1.nextElement());
if (!var2.method1682()) {
var2.method1683();
soundClip = (SoundClip) var1.nextElement();
if (!soundClip.isDefined()) {
soundClip.defineClip();
var3 = true;
}
}

var1 = this.aHashtable1490.elements();

while (var1.hasMoreElements()) {
var2 = (Class86) ((Class86) var1.nextElement());
if (!var2.method1682()) {
var2.method1683();
soundClip = (SoundClip) var1.nextElement();
if (!soundClip.isDefined()) {
soundClip.defineClip();
var3 = true;
}
}
Expand Down Expand Up @@ -104,8 +104,8 @@ public void defineSound(String var1, String var2) {
this.anAApplet1492.printSUD("SoundManager: Defining sound \"" + var2 + "\"");
}

Class86 var3 = new Class86(this.anApplet1485, this.anURL1486, var2, this.aBoolean1488);
this.aHashtable1490.put(var1, var3);
SoundClip soundClip = new SoundClip(this.anApplet1485, this.anURL1486, var2, this.aBoolean1488);
this.aHashtable1490.put(var1, soundClip);
if (this.aBoolean1487) {
this.method1690();
}
Expand Down Expand Up @@ -234,7 +234,7 @@ private void method1688() {
}

private void method1689(int var1, URL var2, String var3) {
this.aHashtable1489.put(new Integer(var1), new Class86(this.anApplet1485, var2, var3 + ".au", this.aBoolean1488));
this.aHashtable1489.put(new Integer(var1), new SoundClip(this.anApplet1485, var2, var3 + ".au", this.aBoolean1488));
}

private synchronized void method1690() {
Expand All @@ -247,11 +247,11 @@ private synchronized void method1690() {
}

private void method1691(int var1) {
Class86 var2 = (Class86) ((Class86) this.aHashtable1489.get(new Integer(var1)));
if (var2 != null) {
AudioClip var3 = var2.method1684();
if (var3 != null) {
var3.play();
SoundClip soundClip = (SoundClip) this.aHashtable1489.get(new Integer(var1));
if (soundClip != null) {
AudioClip audioClip = soundClip.getAudioClip();
if (audioClip != null) {
audioClip.play();
}
}
}
Expand All @@ -262,16 +262,16 @@ private void method1692(String var1, int var2) {
System.out.println("SoundManager." + aStringArray1484[var2] + "(\"" + var1 + "\")");
}

Class86 var3 = (Class86) ((Class86) this.aHashtable1490.get(var1));
if (var3 != null) {
AudioClip var4 = var3.method1684();
if (var4 != null) {
SoundClip soundClip = (SoundClip) this.aHashtable1490.get(var1);
if (soundClip != null) {
AudioClip audioClip = soundClip.getAudioClip();
if (audioClip != null) {
if (var2 == 0) {
var4.stop();
audioClip.stop();
} else if (var2 == 1) {
var4.play();
audioClip.play();
} else if (var2 == 2) {
var4.loop();
audioClip.loop();
}
} else if (this.aBoolean1488) {
System.out.println("SoundManager." + aStringArray1484[var2] + "(\"" + var1 + "\"): AudioClip not ready!");
Expand Down

0 comments on commit c9836b0

Please sign in to comment.