import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
public class main {
// mochadoom
static String defaultCfg = "\nalwaysrun true\nchatmacro0 \"No\"\nchatmacro1 \"I'm ready to kick butt!\"\nchatmacro2 \"I'm OK.\"\nchatmacro3 \"I'm not looking too good!\"\nchatmacro4 \"Help!\"\nchatmacro5 \"You suck!\"\nchatmacro6 \"Next time, scumbag...\"\nchatmacro7 \"Come here!\"\nchatmacro8 \"I'll take care of it.\"\nchatmacro9 \"Yes\"\ndetaillevel 0\nfullscreen true\njoyb_fire 0\njoyb_speed 2\njoyb_strafe 1\njoyb_use 3\nkey_down 115\nkey_fire 157\nkey_left 172\nkey_right 174\nkey_speed 182\nkey_strafe 184\nkey_strafeleft 97\nkey_straferight 100\nkey_up 119\nkey_use 32\nmb_used 2\nmouse_sensitivity 5\nmouseb_fire 0\nmouseb_forward 2\nmouseb_strafe 1\nmusic_volume 8\nscreenblocks 10\nsfx_volume 8\nshow_messages true\nsnd_channels 3\nuse_joystick false\nuse_mouse true\nusegamma 0\n";
public static void main(String[] args) throws Exception {
renameConsole("Mocha DOOM 2!");
File iwad = loadLibrary("#1005020");
File iwad2 = prepareProgramFile("doom2.wad");
copyFile(iwad, iwad2);
File iwad3 = new File(iwad2.getName());
if (!iwad3.exists())
throw fail("We are not in the right directory! " + f2s(iwad3.getAbsoluteFile().getParentFile()) + " (should be " + f2s(programDir()) + ")");
File cfgFile = prepareProgramFile("default.cfg");
if (!cfgFile.exists())
saveTextFile(cfgFile, defaultCfg.trim());
String[] argz = {"-iwad", f2s(iwad2)};
printStructure(argz);
i.Main.main(argz);
}
public static void copyFile(File src, File dest) { try {
mkdirsForFile(dest);
FileInputStream inputStream = new FileInputStream(src.getPath());
FileOutputStream outputStream = new FileOutputStream(dest.getPath());
try {
copyStream(inputStream, outputStream);
inputStream.close();
} finally {
outputStream.close();
}
} catch (Throwable __e) { throw __e instanceof RuntimeException ? (RuntimeException) __e : new RuntimeException(__e); }}
static RuntimeException fail() {
throw new RuntimeException("fail");
}
static RuntimeException fail(Object msg) {
throw new RuntimeException(String.valueOf(msg));
}
static RuntimeException fail(String msg) {
throw new RuntimeException(unnull(msg));
}
// disabled for now to shorten some programs
/*static RuntimeException fail(S msg, O... args) {
throw new RuntimeException(format(msg, args));
}*/
static File loadLibrary(String snippetID) {
return loadBinarySnippet(snippetID);
}
static File prepareProgramFile(String name) {
return mkdirsForFile(getProgramFile(name));
}
static File prepareProgramFile(String progID, String name) {
return mkdirsForFile(getProgramFile(progID, name));
}
static String f2s(File f) {
return f == null ? null : f.getAbsolutePath();
}
/** writes safely (to temp file, then rename) */
public static void saveTextFile(String fileName, String contents) throws IOException {
File file = new File(fileName);
File parentFile = file.getParentFile();
if (parentFile != null)
parentFile.mkdirs();
String tempFileName = fileName + "_temp";
File tempFile = new File(tempFileName);
if (contents != null) {
if (tempFile.exists()) try {
String saveName = tempFileName + ".saved." + now();
copyFile(tempFile, new File(saveName));
} catch (Throwable e) { printStackTrace(e); }
FileOutputStream fileOutputStream = new FileOutputStream(tempFile.getPath());
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
PrintWriter printWriter = new PrintWriter(outputStreamWriter);
printWriter.print(contents);
printWriter.close();
}
if (file.exists() && !file.delete())
throw new IOException("Can't delete " + fileName);
if (contents != null)
if (!tempFile.renameTo(file))
throw new IOException("Can't rename " + tempFile + " to " + file);
}
public static void saveTextFile(File fileName, String contents) {
try {
saveTextFile(fileName.getPath(), contents);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
static void renameConsole(String title) {
setConsoleTitle(title);
}
static File programDir_mine; // set this to relocate program's data
static File programDir() {
return programDir(getProgramID());
}
static File programDir(String snippetID) {
if (programDir_mine != null && sameSnippetID(snippetID, programID()))
return programDir_mine;
return new File(javaxDataDir(), formatSnippetID(snippetID));
}
static void printStructure(String prefix, Object o) {
print(prefix + structure(o));
}
static void printStructure(Object o) {
print(structure(o));
}
static File getProgramFile(String progID, String fileName) {
if (new File(fileName).isAbsolute())
return new File(fileName);
return new File(getProgramDir(progID), fileName);
}
static File getProgramFile(String fileName) {
return getProgramFile(getProgramID(), fileName);
}
public static File mkdirsForFile(File file) {
File dir = file.getParentFile();
if (dir != null) // is null if file is in current dir
dir.mkdirs();
return file;
}
static void printStackTrace(Throwable e) {
// we go to system.out now - system.err is nonsense
print(getStackTrace(e));
}
static void printStackTrace() {
printStackTrace(new Throwable());
}
static File javaxDataDir_dir; // can be set to work on different base dir
static File javaxDataDir() {
return javaxDataDir_dir != null ? javaxDataDir_dir : new File(userHome(), "JavaX-Data");
}
static String programID;
static String getProgramID() {
return nempty(programID) ? formatSnippetID(programID) : "?";
}
// TODO: ask JavaX instead
static String getProgramID(Class c) {
String id = (String) getOpt(c, "programID");
if (nempty(id))
return formatSnippetID(id);
return "?";
}
static String getProgramID(Object o) {
return getProgramID(getMainClass(o));
}
static String unnull(String s) {
return s == null ? "" : s;
}
static List unnull(List l) {
return l == null ? emptyList() : l;
}
static Iterable unnull(Iterable i) {
return i == null ? emptyList() : i;
}
static Object[] unnull(Object[] a) {
return a == null ? new Object[0] : a;
}
static String structure(Object o) {
HashSet refd = new HashSet();
return structure_2(structure_1(o, new structure_Data(refd)), refd);
}
// leave to false, unless unstructure() breaks
static boolean structure_allowShortening = false;
static int structure_shareStringsLongerThan = 20;
static class structure_Data {
int stringSizeLimit;
IdentityHashMap