Skip to content

Commit

Permalink
Merge branch 'release/0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco committed Apr 27, 2016
2 parents fa01ae6 + be9d5f7 commit a3d8d9b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ deploy:
secure: FoiDMNJi5TpJEN1lcxaQ4o8P+p3KRv5W41A1Z7mvxmREsgEgZNzHGsEKssBJdchZOexFtQmQW5/KQBr2StgcYYThfyDs5et0G1xVUitRp5/WtJ40LZmvsA895aYOI5ZpyIeGKG1Xaa059kC5bAqgZNyhOaVRT+ulsNroYcgEM6qNU54D7K6bAy5WQKqIqVU6V8FdQxTp+6XHrvJBayY2vBROzSUch02dsI5+2PpWG+RHH6lT/WnDlmtaQwBO1UTNHn+WfJELbXcovY8SkmBuIjNnqkmAWhgcrOMJ1NGELV4L10kNyisx14M+kEsagIg7Le4qDp0nYuz1yKu8qjTfUdF4SCSvSDaCTTcC9IDRgCxpX9FrIgesDbzENQKggzXs/KHUgp1RBvuFQAOTrBX8/ThZ12pLnxDaVnfRgi1xjJzwKOHthu8ZorrcK9KVRZBdSsHqqrLJ6TUa+bjDUJQZn1NHkxFigpv718ki8ynL31qOxeeCjU6anJx+tGxVUWdfHR1SVvGrtaQ3ekXVV1IOVqAkLc8MdueLvZvDOwxniN/rW/HZQdbKEE+VZLT0vA8AJWs00tuJb/S0EJtFJ5lclNCsKToJmUKE3PW6I6EDH8ym4wzOorVBr4yW8Q3BUb5OJQipXs+V5ZfDdmf74INYpEKp9Lu1qA3T/YwmpJfnRFQ=
skip_cleanup: true
file:
- "release/v0.37.7/aof-replay-client-0.2.3-darwin-x64.zip"
- "release/v0.37.7/aof-replay-client-0.2.3-win32-ia32.zip"
- "release/v0.37.7/aof-replay-client-0.2.3-win32-x64.zip"
- "release/v0.37.7/aof-replay-client-0.2.4-darwin-x64.zip"
- "release/v0.37.7/aof-replay-client-0.2.4-win32-ia32.zip"
- "release/v0.37.7/aof-replay-client-0.2.4-win32-x64.zip"
on:
tags: true
all_branches: true
Expand Down
49 changes: 24 additions & 25 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let request = require("request");
let ipc = require("electron").ipcMain;
let dialog = require("electron").dialog;
let BrowserWindow = require("electron").BrowserWindow;
let _ = require("underscore");
let _ = require("lodash");
let mkdirp = require("mkdirp");
let fs = require("fs");
let winston = require("winston");

Expand Down Expand Up @@ -91,14 +92,16 @@ let staticData = {
"spectatorRegion": "JP1"
}]
};
let appDataPath = app.getPath("userData") + "/";
let replayPath = app.getPath("documents") + "/Analyze or Feed/Replays/";

// Create folder for log files
if (!fs.existsSync(app.getPath("userCache") + "/logs/")){
fs.mkdirSync(app.getPath("userCache") + "/logs/");
}
mkdirp.sync(appDataPath + "logs/");
mkdirp.sync(appDataPath + "cache/");
mkdirp.sync(replayPath);

// Add loggers
let logFile = app.getPath("userCache") + "/logs/" + (new Date()).getTime() + ".log";
let logFile = appDataPath + "logs/" + (new Date()).getTime() + ".log";
let logger = new winston.Logger({ transports: [] });
logger.add(winston.transports.Console, {
"level": "debug"
Expand All @@ -108,11 +111,6 @@ logger.add(winston.transports.File, {
"level": "debug"
});

if (!fs.existsSync("cache"))
fs.mkdir("cache");
if (!fs.existsSync("replays"))
fs.mkdir("replays");

// Add global error handlers
process.on("uncaughtException", function (error) {
logger.error("App Uncaught exception: " + error);
Expand All @@ -123,7 +121,7 @@ process.on("error", function (error) {

// Log operating system
logger.info("We are running on " + process.platform);
logger.info("Application data path: " + app.getPath("userCache"));
logger.info("Application data path: " + appDataPath);

// Load our modules
let aofParser = require(__dirname + "/modules/aof-parser.js")(logger);
Expand All @@ -141,7 +139,7 @@ app.on("window-all-closed", function() {
// User settings
function loadUserSettings(callback) {
logger.info("Loading user settings");
fs.readFile(app.getPath("userCache") + "/settings", function(err, data) {
fs.readFile(appDataPath + "settings", function(err, data) {
if (!err) {
settings = JSON.parse(data);
}
Expand All @@ -152,7 +150,7 @@ function loadUserSettings(callback) {
function saveUserSettings() {
logger.info("Saving user settings");
settings.lolClientPath = lolClient.leaguePath();
fs.writeFileSync(app.getPath("userCache") + "/settings", JSON.stringify(settings, null, 2));
fs.writeFileSync(appDataPath + "settings", JSON.stringify(settings, null, 2));
}

// Check for updates
Expand Down Expand Up @@ -185,7 +183,7 @@ function checkForUpdates(callback) {
// Get static data from api
function getStaticData(callback) {
logger.info("Loading static data");
fs.readFile(app.getPath("userCache") + "/static", function(err, data) {
fs.readFile(appDataPath + "static", function(err, data) {
if (!err) {
logger.info("Reading static data from local cache");
staticData = JSON.parse(data);
Expand All @@ -199,7 +197,7 @@ function getStaticData(callback) {
}
staticData.regions = body.regions;
staticData.leagues = body.leagues;
fs.writeFileSync(app.getPath("userCache") + "/static", JSON.stringify(staticData));
fs.writeFileSync(appDataPath + "static", JSON.stringify(staticData));

ddragonVersion = body.newestVersion.riotVersion + "/";

Expand Down Expand Up @@ -228,28 +226,28 @@ function getStaticData(callback) {

// Extend the metadata of a replay with additional information
function extendReplayMetadata(meta) {
meta.region = _.find(staticData.regions, function(region) { return region.id == meta.regionId }).shortName;
meta.region = _.find(staticData.regions, { "id": meta.regionId }).shortName;

for (let i = 0; i < meta.players.length; i++) {
var p = meta.players[i];

if (staticData.champions) {
let champion = _.find(staticData.champions, function(champion) { return champion.key == p.championId });
let champion = _.find(staticData.champions, { "key": p.championId.toString() });
p.champion = { name: champion.name, image: champion.image.full };
}

if (staticData.leagues) {
let league = _.find(staticData.leagues, function(league) { return league.id == p.leagueId });
let league = _.find(staticData.leagues, { "id": p.leagueId });
p.league = { name: league.name, image: league.name.toLowerCase() + ".png" };
}

if (staticData.summonerSpells) {
let d = _.find(staticData.summonerSpells, function(spell) { return spell.key == p.dId });
let d = _.find(staticData.summonerSpells, { "key": p.dId.toString() });
p.d = { name: d.name, image: d.image.full };
}

if (staticData.summonerSpells) {
let f = _.find(staticData.summonerSpells, function(spell) { return spell.key == p.fId });
let f = _.find(staticData.summonerSpells, { "key": p.fId.toString() });
p.f = { name: f.name, image: f.image.full };
}
}
Expand Down Expand Up @@ -309,8 +307,9 @@ ipc.on("openReplay", function(event, args) {
let files = [];
if (!args) {
files = dialog.showOpenDialog(mainWindow, {
filters: [{ name: 'Replay File', extensions: ['aof'] }],
properties: [ "openFile" ]
filters: [{ name: 'AoF Replay File', extensions: ['aof'] }],
properties: [ "openFile" ],
defaultPath: replayPath
});
} else {
files.push(args);
Expand Down Expand Up @@ -434,7 +433,7 @@ let checkForLeague = function() {
}

game.state = 1;
game.region = _.find(staticData.regions, function(region) { return region.id == game.regionId; });
game.region = _.find(staticData.regions, { "id": game.regionId });
game.metaErrors = 0;
game.key = game.regionId + "-" + game.gameId;
game.oldKeyframeId = game.newestKeyframeId = 0;
Expand Down Expand Up @@ -621,7 +620,7 @@ let updateGame = function(game) {
};

// Downloads a keyframe/chunk for a recording game
let dir = "cache/";
let dir = appDataPath + "cache/";
let options = { timeout: 10000, json: true };
let downloadObject = function(game, typeId, objectId, tries) {
let start = process.hrtime();
Expand Down Expand Up @@ -796,7 +795,7 @@ let finishGame = function(game) {
c += chunk;
});

fs.writeFileSync("replays/" + game.region.shortName + "-" + game.gameId + ".aof", buff);
fs.writeFileSync(replayPath + game.region.shortName + "-" + game.gameId + ".aof", buff);
logger.info("Done");

leagueRecording = false;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/aof-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

let fs = require("fs");
let request = require("request");
let _ = require("underscore");
let _ = require("lodash");
let logger;

let baseUrl = "https://api.aof.gg/v2/";
Expand Down
4 changes: 2 additions & 2 deletions src/modules/lol-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let fs = require("fs");
let winreg = require("winreg");
let spawn = require("child_process").spawn;
let _ = require("underscore");
let _ = require("lodash");
let domain = require("domain");
let logger;

Expand Down Expand Up @@ -159,7 +159,7 @@ function find(hintPath, callback) {
for (let i = 0; i < regexLocations.length; i++) {
for (let j = 0; j < regexLocations[i].keys.length; j++) {
findRegKey(regexLocations[i].hive, regexLocations[i].keys[j], function(path) {
if (path && !_.contains(possiblePaths, path)) {
if (path && possiblePaths.indexOf(path) === -1) {
possiblePaths.push(path);
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/replay-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function(extLogger) {
logger.info("Requesting: " + request.url);

if (request.url.indexOf("/observer-mode/rest/consumer/version") > -1) {
response.end("1.82.89");
response.end("1.82.102");
} else if (request.url.indexOf("/observer-mode/rest/consumer/getGameMetaData/") > -1) {
response.end("{\"gameKey\":{\"gameId\":0,\"platformId\":\"aof\"},\"gameServerAddress\":\"\",\"port\":0,\"" +
"encryptionKey\":\"\",\"chunkTimeInterval\":30000,\"startTime\":\"???\",\"gameEnded\":true,\"lastChunkId\":1,\"lastKeyFrameId\":1,\"endStartupChunkId\":1,\"" +
Expand Down
5 changes: 3 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aof-replay-client",
"version": "0.2.3",
"version": "0.2.4",
"main": "./index.js",
"scripts": {
"start": "cd .. && npm start",
Expand All @@ -11,8 +11,9 @@
"devDependencies": {
"bower": "^1.6.5",
"express": "^4.13.3",
"lodash": "^4.11.1",
"mkdirp": "^0.5.1",
"request": "^2.65.0",
"underscore": "^1.8.3",
"winreg": "0.0.12",
"winston": "^2.1.0"
}
Expand Down

0 comments on commit a3d8d9b

Please sign in to comment.