コード例 #1
0
ファイル: Worker.java プロジェクト: d0k/ednaunpack
  public void run() {
    try {
      for (Slice.FileData data = slice.readNextFile(); data != null; data = slice.readNextFile()) {
        FileList.FileLocation file = data.file;

        ByteArrayInputStream in = new ByteArrayInputStream(data.data);
        decoder.SetDecoderProperties(data.props);

        String fileName = destpath + "/" + file.fileName;
        File f = new File(fileName);
        f.getParentFile().mkdirs();

        // check if we need to undo the tranformation on x86 executables
        if ((file.fileName.contains(".exe")
            || file.fileName.contains(".dll"))) { // TODO there is an attribute for this
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          decoder.Code(in, out, file.originalSize);
          byte[] decompressedData = out.toByteArray();
          Util.transformCallInstructions(decompressedData);
          BufferedOutputStream outfile = new BufferedOutputStream(new FileOutputStream(f));
          outfile.write(decompressedData);
          outfile.close();
        } else {
          BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(f));
          decoder.Code(in, out, file.originalSize);
          out.close();
        }
        f.setLastModified(file.mtime.getTime());
        ui.increaseProgress();
      }
    } catch (Exception e) {
      ui.showError(e.getLocalizedMessage());
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: Engine.java プロジェクト: Eway/whereigo
  /** thread's run() method that does all the work in the right order */
  public void run() {
    try {
      if (log != null)
        log.println(
            "-------------------\ncartridge "
                + gwcfile.name
                + " started (openWIG r"
                + VERSION
                + ")\n-------------------");
      prepareState();

      if (doRestore) restoreGame();
      else newGame();

      loglevel = LOG_PROP;

      ui.debugMsg("Starting game...\n");
      ui.start();

      player.refreshLocation();
      cartridge.callEvent(doRestore ? "OnRestore" : "OnStart", null);
      ui.refresh();
      eventRunner.unpause();

      mainloop();
    } catch (IOException e) {
      ui.showError("Could not load cartridge: " + e.getMessage());
    } catch (Throwable t) {
      stacktrace(t);
    } finally {
      ui.end();
    }
  }
コード例 #3
0
ファイル: Engine.java プロジェクト: Eway/whereigo
 public void run() {
   // perform the actual sync
   try {
     ui.blockForSaving();
     savegame.store(state.getEnvironment());
   } catch (IOException e) {
     log("STOR: save failed: " + e.toString(), LOG_WARN);
     ui.showError("Sync failed.\n" + e.getMessage());
   } finally {
     ui.unblock();
   }
 }
コード例 #4
0
ファイル: Engine.java プロジェクト: Eway/whereigo
 /** utility function to dump stack trace and show a semi-meaningful error */
 public static void stacktrace(Throwable e) {
   e.printStackTrace();
   String msg;
   if (state != null) {
     System.out.println(state.currentThread.stackTrace);
     msg = e.toString() + "\n\nstack trace: " + state.currentThread.stackTrace;
   } else {
     msg = e.toString();
   }
   log(msg, LOG_ERROR);
   ui.showError(
       "you hit a bug! please report at openwig.googlecode.com and i'll fix it for you!\n" + msg);
 }