ソースを参照

fixed old io.set invocations to point to async versions

tags/v0.3.2
Big Bad Waffle 5年前
コミット
5657c64aa6
4個のファイルの変更51行の追加46行の削除
  1. +32
    -28
      src/server/components/extensions/socialCommands.js
  2. +6
    -5
      src/server/fixes/fixes.js
  3. +7
    -8
      src/server/index.js
  4. +6
    -5
      src/server/world/customMap.js

+ 32
- 28
src/server/components/extensions/socialCommands.js ファイルの表示

@@ -98,7 +98,7 @@ module.exports = {
},

//actions
join: function (value) {
join: async function (value) {
if (typeof (value) !== 'string')
return;

@@ -143,10 +143,11 @@ module.exports = {
channels.push(value);

let charname = obj.auth.charname;
io.set({
ent: charname,
field: 'customChannels',
value: JSON.stringify(channels)
await io.setAsync({
key: charname,
table: 'customChannels',
value: channels,
serialize: true
});

obj.socket.emit('events', {
@@ -165,7 +166,7 @@ module.exports = {
});
},

leave: function (value) {
leave: async function (value) {
if (typeof (value) !== 'string')
return;

@@ -189,10 +190,11 @@ module.exports = {
channels.spliceWhere(c => (c === value));

let charname = obj.auth.charname;
io.set({
ent: charname,
field: 'customChannels',
value: JSON.stringify(channels)
await io.setAsync({
key: charname,
table: 'customChannels',
value: channels,
serialize: true
});

obj.socket.emit('event', {
@@ -270,11 +272,11 @@ module.exports = {
});
},

mute: function (target, reason) {
mute: async function (target, reason = null) {
if (typeof (target) === 'object') {
let keys = Object.keys(target);
target = keys[0];
reason = keys[1];
reason = keys[1] || null;
}

if (target === this.obj.name)
@@ -309,23 +311,24 @@ module.exports = {
}]
});

io.set({
ent: new Date(),
field: 'modLog',
value: JSON.stringify({
await io.setAsync({
key: new Date(),
table: 'modLog',
value: {
source: this.obj.name,
command: 'mute',
target: target,
reason: reason
})
},
serialize: true
});
},

unmute: function (target, reason) {
unmute: async function (target, reason = null) {
if (typeof (target) === 'object') {
let keys = Object.keys(target);
target = keys[0];
reason = keys[1];
reason = keys[1] || null;
}

if (target === this.obj.name)
@@ -360,15 +363,16 @@ module.exports = {
}]
});

io.set({
ent: new Date(),
field: 'modLog',
value: JSON.stringify({
await io.setAsync({
key: new Date(),
table: 'modLog',
value: {
source: this.obj.name,
command: 'unmute',
target: target,
reason: reason
})
},
serialize: true
});
},

@@ -562,14 +566,14 @@ module.exports = {
}, 1, this.obj);
},

setPassword: function (config) {
setPassword: async function (config) {
let keys = Object.keys(config);
let username = keys[0];
let hashedPassword = keys[1];

io.set({
ent: username,
field: 'login',
await io.setAsync({
key: username,
table: 'login',
value: hashedPassword
});
},


+ 6
- 5
src/server/fixes/fixes.js ファイルの表示

@@ -114,15 +114,16 @@ module.exports = {
});
},

fixSkins: function (username, skins) {
fixSkins: async function (username, skins) {
let length = skins.length;
skins = skins.filter(s => !!configSkins.getBlueprint(s));

if (length !== skins.length) {
io.set({
ent: username,
field: 'skins',
value: JSON.stringify(skins)
await io.setAsync({
key: username,
table: 'skins',
value: skins,
serialize: true
});
}
}


+ 7
- 8
src/server/index.js ファイルの表示

@@ -59,21 +59,20 @@ let startup = {
sheets.init();
},

onError: function (e) {
onError: async function (e) {
if (e.toString().indexOf('ERR_IPC_CHANNEL_CLOSED') > -1)
return;

_.log('Error Logged: ' + e.toString());
_.log(e.stack);

io.set({
ent: new Date(),
field: 'error',
value: e.toString() + ' | ' + e.stack.toString(),
callback: function () {
process.exit();
}
await io.setAsync({
key: new Date(),
table: 'error',
value: e.toString() + ' | ' + e.stack.toString()
});

process.exit();
}
};



+ 6
- 5
src/server/world/customMap.js ファイルの表示

@@ -21,11 +21,12 @@ module.exports = {
this.build(callback);
},

save: function () {
io.set({
ent: this.ent,
field: 'customMap',
value: JSON.stringify(this.tiles)
save: async function () {
await io.setAsync({
key: this.ent,
table: 'customMap',
value: this.tiles,
serialize: true
});
},



読み込み中…
キャンセル
保存