Browse Source

bug #1934: Fixed saveAll command crashing

tags/v0.11.0^2
Shaun 2 years ago
parent
commit
2da0208563
3 changed files with 39 additions and 9 deletions
  1. +14
    -0
      src/server/components/auth.js
  2. +8
    -2
      src/server/components/extensions/socialCommands.js
  3. +17
    -7
      src/server/security/connections.js

+ 14
- 0
src/server/components/auth.js View File

@@ -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;




+ 8
- 2
src/server/components/extensions/socialCommands.js View File

@@ -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) {


+ 17
- 7
src/server/security/connections.js View File

@@ -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) {


Loading…
Cancel
Save