@@ -113,6 +113,20 @@ module.exports = { | |||||
callback(); | callback(); | ||||
}, | }, | ||||
//This function is called from the 'forceSave' command. Because of this, the first argument is the action data | |||||
// instead of (callback, saveStash) | |||||
doSaveManual: async function (msg) { | |||||
await this.doSave(null, true); | |||||
process.send({ | |||||
module: 'atlas', | |||||
method: 'resolveCallback', | |||||
msg: { | |||||
id: msg.callbackId | |||||
} | |||||
}); | |||||
}, | |||||
doSaveStash: async function () { | doSaveStash: async function () { | ||||
const { username, obj: { stash } } = this; | const { username, obj: { stash } } = this; | ||||
@@ -600,8 +600,14 @@ module.exports = { | |||||
}); | }); | ||||
}, | }, | ||||
saveAll: function () { | |||||
connections.forceSaveAll(); | |||||
saveAll: async function () { | |||||
const { obj: { social } } = this; | |||||
social.sendMessage('Initiating Save', 'color-blueA'); | |||||
await connections.forceSaveAll(); | |||||
social.sendMessage('Save Complete', 'color-blueA'); | |||||
}, | }, | ||||
rezone: function (msg) { | rezone: function (msg) { | ||||
@@ -162,16 +162,26 @@ module.exports = { | |||||
return result; | return result; | ||||
}, | }, | ||||
forceSaveAll: function () { | |||||
this.players | |||||
forceSaveAll: async function () { | |||||
const promises = this.players | |||||
.filter(p => p.zoneName !== undefined) | .filter(p => p.zoneName !== undefined) | ||||
.forEach(p => { | |||||
atlas.performAction(p, { | |||||
cpn: 'auth', | |||||
method: 'doSave', | |||||
data: {} | |||||
.map(p => { | |||||
const promise = new Promise(res => { | |||||
const msg = { | |||||
cpn: 'auth', | |||||
method: 'doSaveManual', | |||||
data: { | |||||
callbackId: atlas.registerCallback(res) | |||||
} | |||||
}; | |||||
atlas.performAction(p, msg); | |||||
}); | }); | ||||
return promise; | |||||
}); | }); | ||||
await Promise.all(promises); | |||||
}, | }, | ||||
modifyPlayerCount: function (delta) { | modifyPlayerCount: function (delta) { | ||||