Explorar el Código

small fix to rethink mail feature and big fix to rethink append

tags/v0.3.2
Big Bad Waffle hace 5 años
padre
commit
af6bbd2969
Se han modificado 5 ficheros con 26 adiciones y 18 borrados
  1. +8
    -6
      helpers/sqlite-to-rethink/index.js
  2. +4
    -7
      src/server/components/inventory.js
  3. +1
    -1
      src/server/mail/mailRethinkDb.js
  4. +1
    -0
      src/server/security/connections.js
  5. +12
    -4
      src/server/security/ioRethink.js

+ 8
- 6
helpers/sqlite-to-rethink/index.js Ver fichero

@@ -5,7 +5,7 @@ let util = require('util');
const config = {
file: './storage.db',

dbName: 'dev',
dbName: 'ptr',

dropTables: true,

@@ -48,7 +48,6 @@ let converter = {
port: 28015
});

await this.connection.use(this.useDb);
await this.setupRethink();

await this.convertTables();
@@ -57,14 +56,17 @@ let converter = {
setupRethink: async function () {
try {
await r.dbCreate(config.dbName).run(this.connection);
} catch (e) {
} catch (e) {}

}
await this.connection.use(config.dbName);

for (const table of config.tables) {
try {
if (config.dropTables)
await r.tableDrop(table).run(this.connection);
if (config.dropTables) {
try {
await r.tableDrop(table).run(this.connection);
} catch (e) {}
}
await r.tableCreate(table).run(this.connection);
} catch (e) {
if (!e.msg.includes('already exists'))


+ 4
- 7
src/server/components/inventory.js Ver fichero

@@ -505,7 +505,7 @@ module.exports = {
}, this);
},

mailItem: function (msg) {
mailItem: async function (msg) {
let item = this.findItem(msg.itemId);
if ((!item) || (item.noDrop) || (item.quest)) {
this.resolveCallback(msg);
@@ -514,14 +514,11 @@ module.exports = {

delete item.pos;

io.get({
ent: msg.recipient,
field: 'character',
callback: this.onCheckCharExists.bind(this, msg, item)
let res = await io.getAsync({
key: msg.recipient,
table: 'character'
});
},

onCheckCharExists: async function (msg, item, res) {
if (!res) {
this.resolveCallback(msg, 'Recipient does not exist');
return;


+ 1
- 1
src/server/mail/mailRethinkDb.js Ver fichero

@@ -76,7 +76,7 @@ module.exports = {
table: 'mail'
});

if (!items)
if (!items || !(items instanceof Array))
return;

let player = this.instance.objects.objects.find(o => (o.name === playerName));


+ 1
- 0
src/server/security/connections.js Ver fichero

@@ -124,6 +124,7 @@ module.exports = {

//A hack to allow us to actually call methods again (like retrieve the player list)
player.dead = false;
player.permadead = false;

this.modifyPlayerCount(-1);
},


+ 12
- 4
src/server/security/ioRethink.js Ver fichero

@@ -18,7 +18,7 @@ const tables = [

module.exports = {
connection: null,
useDb: 'dev',
useDb: 'ptr',

init: async function (cbReady) {
const dbConfig = {
@@ -36,7 +36,7 @@ module.exports = {

create: async function () {
try {
await r.dbCreate('dev').run(this.connection);
await r.dbCreate(this.useDb).run(this.connection);
} catch (e) {

}
@@ -128,8 +128,16 @@ module.exports = {
}) {
await r.table(table)
.get(key)
.update({
[field]: r.row('value').append(...value)
.update(row => {
return r.branch(
row('value').typeOf().eq('ARRAY'),
{
[field]: row('value').append(...value)
},
{
[field]: value
}
);
})
.run(this.connection);
},


Cargando…
Cancelar
Guardar