Beispiel #1
0
  /** 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();
    }
  }
Beispiel #2
0
 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();
   }
 }
Beispiel #3
0
 /** 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);
 }