(cherry picked from commit c8a500c9fe
)
tags/v0.13.0.8^0
@@ -425,6 +425,7 @@ module.exports = { | |||
msg.callback(); | |||
}, | |||
/* eslint-disable-next-line max-lines-per-function */ | |||
createCharacter: async function (msg) { | |||
let data = msg.data; | |||
let name = data.name; | |||
@@ -458,8 +459,14 @@ module.exports = { | |||
return; | |||
} | |||
console.log('Starting new character create for', name); | |||
const t1 = +new Date(); | |||
const releaseCreateLock = await getCreateLock(); | |||
const t2 = +new Date(); | |||
console.log('Took', t2 - t1, 'ms to get a create lock'); | |||
let exists = await io.getAsync({ | |||
key: name, | |||
ignoreCase: true, | |||
@@ -467,6 +474,9 @@ module.exports = { | |||
noDefault: true | |||
}); | |||
const t3 = +new Date(); | |||
console.log('Took', t3 - t2, 'ms to check if the character exists'); | |||
if (exists) { | |||
releaseCreateLock(); | |||
msg.callback(messages.login.charExists); | |||
@@ -488,7 +498,13 @@ module.exports = { | |||
let simple = this.obj.getSimple(true); | |||
const t4 = +new Date(); | |||
console.log('Took', t4 - t3, 'ms to build the simpleObj'); | |||
await this.verifySkin(simple); | |||
const t5 = +new Date(); | |||
console.log('Took', t5 - t4, 'ms to verify the skin'); | |||
let prophecies = (data.prophecies || []).filter(p => p); | |||
@@ -507,6 +523,9 @@ module.exports = { | |||
eventEmitter.emit('beforeSaveCharacter', eBeforeSaveCharacter); | |||
const t6 = +new Date(); | |||
console.log('Took', t6 - t5, 'ms to run beforeSaveCharacter'); | |||
await io.setAsync({ | |||
key: name, | |||
table: 'character', | |||
@@ -516,6 +535,9 @@ module.exports = { | |||
this.characters[name] = simple; | |||
this.characterList.push(name); | |||
const t7 = +new Date(); | |||
console.log('Took', t7 - t6, 'ms to save the character'); | |||
await io.setAsync({ | |||
key: this.username, | |||
@@ -524,6 +546,9 @@ module.exports = { | |||
serialize: true | |||
}); | |||
const t8 = +new Date(); | |||
console.log('Took', t8 - t7, 'ms to save the character list'); | |||
releaseCreateLock(); | |||
this.initTracker(); | |||
@@ -137,7 +137,16 @@ module.exports = { | |||
}) | |||
.run(); | |||
} catch (e) { | |||
this.logError(e, table, id); | |||
this.logError({ | |||
sourceModule: 'ioRethink', | |||
sourceMethod: 'setAsync', | |||
error: e, | |||
info: { | |||
table, | |||
key: id, | |||
value: JSON.stringify(value) | |||
} | |||
}); | |||
} | |||
}, | |||
@@ -151,7 +160,15 @@ module.exports = { | |||
.insert(value, { conflict }) | |||
.run(); | |||
} catch (e) { | |||
this.logError(e, table, JSON.stringify(value)); | |||
this.logError({ | |||
sourceModule: 'ioRethink', | |||
sourceMethod: 'setFlat', | |||
error: e, | |||
info: { | |||
table, | |||
value: JSON.stringify(value) | |||
} | |||
}); | |||
} | |||
}, | |||
@@ -193,7 +210,17 @@ module.exports = { | |||
}) | |||
.run(); | |||
} catch (e) { | |||
this.logError(e, table, key); | |||
this.logError({ | |||
sourceModule: 'ioRethink', | |||
sourceMethod: 'append', | |||
error: e, | |||
info: { | |||
table, | |||
key, | |||
field, | |||
value: JSON.stringify(value) | |||
} | |||
}); | |||
} | |||
}, | |||
@@ -208,19 +235,26 @@ module.exports = { | |||
return !!res; | |||
}, | |||
logError: async function (error, table, key) { | |||
logError: async function ({ sourceModule, sourceMethod, error, info }) { | |||
try { | |||
const errorValue = `${error.toString()} | ${error.stack.toString()} | ${table} | ${key}`; | |||
await this.setAsync({ | |||
key: new Date(), | |||
table: 'error', | |||
value: errorValue | |||
value: { | |||
date: new Date(), | |||
sourceModule, | |||
sourceMethod, | |||
error: error.toString(), | |||
stack: error.stack.toString(), | |||
info | |||
} | |||
}); | |||
} catch (e) {} | |||
process.send({ | |||
event: 'onCrashed' | |||
}); | |||
if (process.send) { | |||
process.send({ | |||
event: 'onCrashed' | |||
}); | |||
} else | |||
process.exit(); | |||
} | |||
}; |
@@ -253,15 +253,8 @@ module.exports = { | |||
if (!storeEntry) { | |||
const playerObj = objects.find(o => o.id === toId); | |||
if (!playerObj || playerObj.zoneName !== sourceZone) { | |||
io.setAsync({ | |||
key: new Date(), | |||
table: 'error', | |||
value: `ignoring ${e}` | |||
}); | |||
if (!playerObj || playerObj.zoneName !== sourceZone) | |||
continue; | |||
} | |||
store[toId] = { | |||
obj: playerObj, | |||
@@ -213,6 +213,21 @@ const getThread = async ({ zoneName, zoneId }) => { | |||
thread = getThreadFromName(map.name); | |||
} | |||
if (!thread) { | |||
io.logError({ | |||
sourceModule: 'threadManager', | |||
sourceMethod: 'getThread', | |||
error: 'No thread found', | |||
info: { | |||
requestedZoneName: zoneName, | |||
requestedZoneId: zoneId, | |||
useMapName: map.name | |||
} | |||
}); | |||
process.exit(); | |||
} | |||
if (!thread.isReady) | |||
await thread.promise; | |||