@@ -101,8 +101,8 @@ module.exports = { | |||||
}); | }); | ||||
//If we don't do this, the atlas will try to remove it from the thread | //If we don't do this, the atlas will try to remove it from the thread | ||||
player.zoneName = null; | |||||
player.name = null; | |||||
delete player.zoneName; | |||||
delete player.name; | |||||
//A hack to allow us to actually call methods again (like retrieve the player list) | //A hack to allow us to actually call methods again (like retrieve the player list) | ||||
player.dead = false; | player.dead = false; | ||||
@@ -127,7 +127,7 @@ module.exports = { | |||||
return keysCorrect; | return keysCorrect; | ||||
}, | }, | ||||
isMsgValid: function (msg) { | |||||
isMsgValid: function (msg, source) { | |||||
let signature; | let signature; | ||||
if (msg.module) { | if (msg.module) { | ||||
@@ -152,8 +152,12 @@ module.exports = { | |||||
const result = this.signatureCorrect(msg, signature); | const result = this.signatureCorrect(msg, signature); | ||||
if (!result || msg.cpn !== 'player' || msg.method !== 'performAction') | |||||
if (!result || msg.cpn !== 'player' || msg.method !== 'performAction') { | |||||
if (result && signature.allowWhenIngame === false && source.name !== undefined) | |||||
return false; | |||||
return result; | return result; | ||||
} | |||||
const signatureThreadMsg = signatures.threadCpnMethods[msg.data.cpn]?.[msg.data.method]; | const signatureThreadMsg = signatures.threadCpnMethods[msg.data.cpn]?.[msg.data.method]; | ||||
@@ -49,6 +49,7 @@ const routerConfig = { | |||||
auth: { | auth: { | ||||
login: { | login: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [ | data: [ | ||||
{ | { | ||||
key: 'username', | key: 'username', | ||||
@@ -62,6 +63,7 @@ const routerConfig = { | |||||
}, | }, | ||||
register: { | register: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [ | data: [ | ||||
{ | { | ||||
key: 'username', | key: 'username', | ||||
@@ -75,6 +77,7 @@ const routerConfig = { | |||||
}, | }, | ||||
deleteCharacter: { | deleteCharacter: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [ | data: [ | ||||
{ | { | ||||
key: 'name', | key: 'name', | ||||
@@ -88,6 +91,7 @@ const routerConfig = { | |||||
}, | }, | ||||
createCharacter: { | createCharacter: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [ | data: [ | ||||
{ | { | ||||
key: 'name', | key: 'name', | ||||
@@ -109,10 +113,12 @@ const routerConfig = { | |||||
}, | }, | ||||
getCharacterList: { | getCharacterList: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [] | data: [] | ||||
}, | }, | ||||
getCharacter: { | getCharacter: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [ | data: [ | ||||
{ | { | ||||
key: 'name', | key: 'name', | ||||
@@ -122,6 +128,7 @@ const routerConfig = { | |||||
}, | }, | ||||
play: { | play: { | ||||
callback: true, | callback: true, | ||||
allowWhenIngame: false, | |||||
data: [ | data: [ | ||||
{ | { | ||||
key: 'name', | key: 'name', | ||||
@@ -16,7 +16,9 @@ const onRequest = (socket, msg, callback) => { | |||||
if (!msg.data) | if (!msg.data) | ||||
msg.data = {}; | msg.data = {}; | ||||
if (!router.isMsgValid(msg)) | |||||
const source = cons.players.find(p => p.socket.id === socket.id); | |||||
if (!router.isMsgValid(msg, source)) | |||||
return; | return; | ||||
if (msg.cpn) | if (msg.cpn) | ||||
@@ -24,8 +26,6 @@ const onRequest = (socket, msg, callback) => { | |||||
else if (msg.threadModule) | else if (msg.threadModule) | ||||
cons.route(socket, msg); | cons.route(socket, msg); | ||||
else { | else { | ||||
const source = cons.players.find(p => p.socket.id === socket.id); | |||||
msg.socket = socket; | msg.socket = socket; | ||||
if (source) | if (source) | ||||