()
| 21 | } |
| 22 | |
| 23 | public void run() |
| 24 | { |
| 25 | InputStream in = null; |
| 26 | FileOutputStream out = null; |
| 27 | try |
| 28 | { |
| 29 | SaveDatabase saveDatabase = new SaveDatabase(this.file); |
| 30 | saveDatabase.load(); |
| 31 | this.progressDialog.updateProgress(25); |
| 32 | String saveName = saveDatabase.getName(); |
| 33 | Main.savePrefix = saveName + Main.fileSeparator; |
| 34 | |
| 35 | int sep = saveName.indexOf(' '); |
| 36 | if ((sep != 6) || (!Character.isDigit(saveName.charAt(0)))) { |
| 37 | throw new DBException("Save name is not formatted correctly"); |
| 38 | } |
| 39 | String fileName = "save_" + saveName.substring(0, 6) + ".smm"; |
| 40 | SaveEntry saveEntry = saveDatabase.getEntry(fileName); |
| 41 | if (saveEntry == null) { |
| 42 | throw new DBException("Save does not contain " + fileName); |
| 43 | } |
| 44 | in = saveEntry.getInputStream(); |
| 45 | Database database = new Database(); |
| 46 | database.load(in); |
| 47 | in.close(); |
| 48 | in = null; |
| 49 | this.progressDialog.updateProgress(35); |
| 50 | |
| 51 | DBList list = (DBList)database.getTopLevelStruct().getValue(); |
| 52 | String startingMod = list.getString("StartingMod"); |
| 53 | if (startingMod.length() == 0) { |
| 54 | throw new DBException("StartingMod not found in SMM database"); |
| 55 | } |
| 56 | DBElement element = list.getElement("QuestBase_list"); |
| 57 | if ((element == null) || (element.getType() != 15)) { |
| 58 | throw new DBException("QuestBaseList not found in SMM database"); |
| 59 | } |
| 60 | DBList questList = (DBList)element.getValue(); |
| 61 | if (questList.getElementCount() == 0) { |
| 62 | throw new DBException("No quest list found in SMM database"); |
| 63 | } |
| 64 | DBList fieldList = (DBList)questList.getElement(0).getValue(); |
| 65 | String questDBName = fieldList.getString("QuestBase"); |
| 66 | if (questDBName.length() == 0) { |
| 67 | throw new DBException("No quest database name found in SMM database"); |
| 68 | } |
| 69 | |
| 70 | Main.modName = startingMod + ".sav"; |
| 71 | saveEntry = saveDatabase.getEntry(Main.modName); |
| 72 | if (saveEntry == null) { |
| 73 | throw new DBException("Save does not contain " + Main.modName); |
| 74 | } |
| 75 | in = saveEntry.getInputStream(); |
| 76 | if (Main.modFile.exists()) { |
| 77 | Main.modFile.delete(); |
| 78 | } |
| 79 | |
| 80 | byte[] buffer = new byte[4096]; |
nothing calls this directly
no test coverage detected