Skip to content

Commit

Permalink
Support upgrading of old style keys to new keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Cu3PO42 committed Oct 8, 2015
1 parent 0540f32 commit 24caef5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions app/elements/key-breaker/key-breaker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../../../bower_components/polymer-ts/polymer-ts.ts"/>
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
Expand Down Expand Up @@ -51,7 +50,8 @@ var fs = require("fs");
};
KeyBreaker.prototype.saveBreak = function () {
if (this.breakResult.success) {
this.ipcClient.send("file-dialog-save", { options: { defaultPath: this.breakResult.path, filters: [{ name: "Key file", extensions: ["bin"] }] } });
if (this.breakResult.path !== "")
this.ipcClient.send("file-dialog-save", { options: { defaultPath: this.breakResult.path, filters: [{ name: "Key file", extensions: ["bin"] }] } });
}
else {
this.ipcClient.send("break-key-cancel");
Expand Down Expand Up @@ -122,21 +122,21 @@ var fs = require("fs");
observe("file1"),
__metadata('design:type', Function),
__metadata('design:paramtypes', [Object, Object]),
__metadata('design:returntype', Object)
__metadata('design:returntype', void 0)
], KeyBreaker.prototype, "file1Changed", Object.getOwnPropertyDescriptor(KeyBreaker.prototype, "file1Changed")));
Object.defineProperty(KeyBreaker.prototype, "file2Changed",
__decorate([
observe("file2"),
__metadata('design:type', Function),
__metadata('design:paramtypes', [Object, Object]),
__metadata('design:returntype', Object)
__metadata('design:returntype', void 0)
], KeyBreaker.prototype, "file2Changed", Object.getOwnPropertyDescriptor(KeyBreaker.prototype, "file2Changed")));
Object.defineProperty(KeyBreaker.prototype, "folderChanged",
__decorate([
observe("folder"),
__metadata('design:type', Function),
__metadata('design:paramtypes', [Object, Object]),
__metadata('design:returntype', Object)
__metadata('design:returntype', void 0)
], KeyBreaker.prototype, "folderChanged", Object.getOwnPropertyDescriptor(KeyBreaker.prototype, "folderChanged")));
KeyBreaker = __decorate([
component("key-breaker"),
Expand Down
3 changes: 2 additions & 1 deletion app/elements/key-breaker/key-breaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class KeyBreaker extends polymer.Base {

saveBreak() {
if (this.breakResult.success) {
this.ipcClient.send("file-dialog-save", <{options: GitHubElectron.Dialog.OpenDialogOptions}>{options: {defaultPath: this.breakResult.path, filters: [{name: "Key file", extensions: ["bin"]}]}});
if (this.breakResult.path !== "")
this.ipcClient.send("file-dialog-save", <{options: GitHubElectron.Dialog.OpenDialogOptions}>{options: {defaultPath: this.breakResult.path, filters: [{name: "Key file", extensions: ["bin"]}]}});
} else {
this.ipcClient.send("break-key-cancel");
}
Expand Down
27 changes: 12 additions & 15 deletions server/dumper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/// <reference path="../typings/node/node.d.ts"/>
/// <reference path="../typings/github-electron/github-electron.d.ts" />
/// <reference path="../typings/async/async.d.ts" />
/// <reference path="../typings/lodash/lodash.d.ts" />
/// <reference path="../typings/path-extra/path-extra.d.ts" />
var ipcServer = require("electron-ipc-tunnel/server");
var fs = require("fs");
var KeySAV = require("keysavcore");
Expand Down Expand Up @@ -52,7 +47,7 @@ module.exports = function () {
res.push(tmp);
}
}
reply("dump-save-dumped", res);
reply("dump-save-dumped", { pokemon: res, isNewKey: reader.get_IsNewKey() });
});
});
});
Expand Down Expand Up @@ -94,15 +89,17 @@ module.exports = function () {
else {
breakInProgress = 2;
files = _.map(files, function (f) { return f.subarray(f.length % 0x100000); });
savBreakRes = KeySAV.Core.SaveBreaker.Break(files[0], files[1]);
if (savBreakRes.success) {
var resPkx = new KeySAV.Core.Structures.PKX.ctor$1(savBreakRes.resPkx, 0, 0, false);
var savePath = path.join(dataDirectory, util.format("SAV Key - %s - (%s.%s) - TSV %s.bin", resPkx.ot, padNumber(resPkx.tid), padNumber(resPkx.sid), ("0000" + resPkx.tsv).slice(-4)));
}
else {
savePath = "";
}
reply("break-key-result", { success: savBreakRes.success, path: savePath, result: savBreakRes.result });
KeySAV.Core.SaveBreaker.Break(files[0], files[1], store.getSaveKey.bind(store), function (savBreakRes) {
var savePath;
if (savBreakRes.success && savBreakRes.resPkx !== null) {
var resPkx = new KeySAV.Core.Structures.PKX.ctor$1(savBreakRes.resPkx, 0, 0, false);
savePath = savBreakRes.resPkx !== null ? path.join(dataDirectory, util.format("SAV Key - %s - (%s.%s) - TSV %s.bin", resPkx.ot, padNumber(resPkx.tid), padNumber(resPkx.sid), ("0000" + resPkx.tsv).slice(-4))) : "";
}
else {
savePath = "";
}
reply("break-key-result", { success: savBreakRes.success, path: savePath, result: savBreakRes.result });
});
}
});
});
Expand Down
20 changes: 11 additions & 9 deletions server/dumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export = function() {
res.push(tmp);
}
}
reply("dump-save-dumped", res);
reply("dump-save-dumped", {pokemon: res, isNewKey: reader.get_IsNewKey()});
});
});
});
Expand Down Expand Up @@ -105,14 +105,16 @@ export = function() {
} else {
breakInProgress = 2;
files = _.map(files, (f) => f.subarray(f.length % 0x100000));
savBreakRes = KeySAV.Core.SaveBreaker.Break(files[0], files[1]);
if (savBreakRes.success) {
var resPkx = new KeySAV.Core.Structures.PKX.ctor$1(savBreakRes.resPkx, 0, 0, false);
var savePath = path.join(dataDirectory, util.format("SAV Key - %s - (%s.%s) - TSV %s.bin", resPkx.ot, padNumber(resPkx.tid), padNumber(resPkx.sid), ("0000"+resPkx.tsv).slice(-4)));
} else {
savePath = "";
}
reply("break-key-result", {success: savBreakRes.success, path: savePath, result: savBreakRes.result})
KeySAV.Core.SaveBreaker.Break(files[0], files[1], store.getSaveKey.bind(store), function(savBreakRes) {
var savePath;
if (savBreakRes.success && savBreakRes.resPkx !== null) {
var resPkx = new KeySAV.Core.Structures.PKX.ctor$1(savBreakRes.resPkx, 0, 0, false);
savePath = savBreakRes.resPkx !== null ? path.join(dataDirectory, util.format("SAV Key - %s - (%s.%s) - TSV %s.bin", resPkx.ot, padNumber(resPkx.tid), padNumber(resPkx.sid), ("0000"+resPkx.tsv).slice(-4))) : "";
} else {
savePath = "";
}
reply("break-key-result", {success: savBreakRes.success, path: savePath, result: savBreakRes.result})
});
}
});
});
Expand Down

0 comments on commit 24caef5

Please sign in to comment.