Browse Source

Merged master for v0.10.4

tags/v0.10.4
Shaun 1 year ago
parent
commit
ad00e23abb
56 changed files with 349 additions and 861 deletions
  1. +2
    -2
      .gitlab-ci.yml
  2. +2
    -0
      README.md
  3. +50
    -61
      src/client/js/components/components.js
  4. +0
    -35
      src/client/js/components/sound.js
  5. +5
    -1
      src/client/js/main.js
  6. +2
    -1
      src/client/js/rendering/particles.js
  7. +23
    -8
      src/client/js/rendering/renderer.js
  8. +35
    -0
      src/client/js/sound/sound.js
  9. +4
    -3
      src/client/package.json
  10. +2
    -2
      src/client/ui/templates/login/template.html
  11. +1
    -1
      src/server/.eslintrc
  12. +3
    -0
      src/server/clientComponents/.eslintrc
  13. +0
    -0
      src/server/clientComponents/animation.js
  14. +0
    -0
      src/server/clientComponents/attackAnimation.js
  15. +0
    -0
      src/server/clientComponents/bumpAnimation.js
  16. +0
    -0
      src/server/clientComponents/chatter.js
  17. +0
    -0
      src/server/clientComponents/chest.js
  18. +0
    -0
      src/server/clientComponents/dialogue.js
  19. +0
    -0
      src/server/clientComponents/effects.js
  20. +0
    -0
      src/server/clientComponents/events.js
  21. +0
    -0
      src/server/clientComponents/explosion.js
  22. +0
    -0
      src/server/clientComponents/fadeInOut.js
  23. +0
    -0
      src/server/clientComponents/flash.js
  24. +0
    -0
      src/server/clientComponents/gatherer.js
  25. +0
    -0
      src/server/clientComponents/inventory.js
  26. +0
    -0
      src/server/clientComponents/keyboardMover.js
  27. +0
    -0
      src/server/clientComponents/light.js
  28. +0
    -0
      src/server/clientComponents/lightPatch.js
  29. +0
    -0
      src/server/clientComponents/lightningEffect.js
  30. +0
    -0
      src/server/clientComponents/mouseMover.js
  31. +0
    -0
      src/server/clientComponents/moveAnimation.js
  32. +0
    -0
      src/server/clientComponents/particles.js
  33. +0
    -0
      src/server/clientComponents/passives.js
  34. +0
    -0
      src/server/clientComponents/pather.js
  35. +0
    -0
      src/server/clientComponents/player.js
  36. +0
    -0
      src/server/clientComponents/projectile.js
  37. +0
    -0
      src/server/clientComponents/quests.js
  38. +0
    -0
      src/server/clientComponents/reputation.js
  39. +0
    -0
      src/server/clientComponents/resourceNode.js
  40. +0
    -0
      src/server/clientComponents/serverActions.js
  41. +0
    -0
      src/server/clientComponents/social.js
  42. +50
    -0
      src/server/clientComponents/sound.js
  43. +0
    -0
      src/server/clientComponents/spellbook.js
  44. +0
    -0
      src/server/clientComponents/stash.js
  45. +0
    -0
      src/server/clientComponents/stats.js
  46. +0
    -0
      src/server/clientComponents/touchMover.js
  47. +0
    -0
      src/server/clientComponents/trade.js
  48. +0
    -0
      src/server/clientComponents/whirlwind.js
  49. +5
    -0
      src/server/components/door.js
  50. +14
    -0
      src/server/config/clientConfig.js
  51. +1
    -1
      src/server/config/serverConfig.js
  52. +122
    -729
      src/server/package-lock.json
  53. +5
    -6
      src/server/package.json
  54. +2
    -0
      src/server/server/onConnection.js
  55. +9
    -5
      src/server/server/requestHandlers.js
  56. +12
    -6
      src/server/world/map.js

+ 2
- 2
.gitlab-ci.yml View File

@@ -17,7 +17,7 @@ audit:
lint-server:
stage: test
script:
- npm install eslint eslint-plugin-prettier prettier babel-eslint
- npm install eslint@7.32.0 eslint-plugin-prettier prettier babel-eslint eslint-plugin-requirejs
- cd src/server
- ../../node_modules/.bin/eslint .
only:
@@ -27,7 +27,7 @@ lint-server:
lint-client:
stage: test
script:
- npm install eslint eslint-plugin-prettier prettier babel-eslint eslint-plugin-requirejs
- npm install eslint@7.32.0 eslint-plugin-prettier prettier babel-eslint eslint-plugin-requirejs
- cd src/client
- ../../node_modules/.bin/eslint .
only:


+ 2
- 0
README.md View File

@@ -10,6 +10,8 @@ Built with NodeJS, JS, HTML and CSS.

### Installation and Usage

**IMPORTANT**: The sqlite3 package has been removed for the time being due to multiple `npm audit` issues arrising. While installing this module will not cause you any security issues (due to the nature of the vulnerabilities and how Isleward actually uses the module), we have removed it to make the build process simpler for us. As a result of this, after performing an `npm install` in the `server` folder, please also run `npm i sqlite3`.

* [Windows](https://gitlab.com/Isleward/isleward/wikis/installation-and-usage-(windows))
* [Linux](https://gitlab.com/Isleward/isleward/wikis/installation-and-usage-(linux))
* [MacOS](https://gitlab.com/Isleward/isleward/wikis/installation-and-usage-(macos))


+ 50
- 61
src/client/js/components/components.js View File

@@ -1,50 +1,15 @@
let components = [
'keyboardMover',
'mouseMover',
'touchMover',
'player',
'pather',
'attackAnimation',
'lightningEffect',
'moveAnimation',
'bumpAnimation',
'animation',
'light',
'lightPatch',
'projectile',
'particles',
'explosion',
'spellbook',
'inventory',
'stats',
'chest',
'effects',
'quests',
'events',
'resourceNode',
'gatherer',
'stash',
'flash',
'chatter',
'dialogue',
'trade',
'reputation',
'serverActions',
'social',
'passives',
'sound',
'whirlwind',
'fadeInOut'
].map(function (c) {
return 'js/components/' + c;
});

define([
...components,
'../system/events'
], function () {
const events = arguments[arguments.length - 1];
'js/system/events',
'js/system/globals'
], function (
events,
globals
) {
//Store templates here after loading them
const templates = [];
const extenders = [];

//Bound Methods
const hookEvent = function (e, cb) {
if (!this.eventList[e])
this.eventList[e] = [];
@@ -59,30 +24,54 @@ define([
});
};

let templates = {};
//Helpers
const loadComponent = cpn => {
return new Promise(res => {
require([cpn.path], tpl => {
if (cpn.type)
templates.push(tpl);
if (cpn.extends)
extenders.push(tpl);
res();
});
});
};

[].forEach.call(arguments, function (t, i) {
//Don't do this for the events module
if (i === arguments[2].length - 1)
return;
//Init Methods
const loadComponents = paths => {
return Promise.all(
paths.map(p => loadComponent(p))
);
};
const buildComponents = () => {
templates.forEach(t => {
const extensions = extenders.filter(e => e.extends === t.type);

t.eventList = {};
t.hookEvent = hookEvent;
t.unhookEvents = unhookEvents;
extensions.forEach(e => $.extend(true, t, e));

templates[t.type] = t;
});
t.eventList = {};
t.hookEvent = hookEvent;
t.unhookEvents = unhookEvents;
});
};

//Export
return {
init: async function () {
const paths = globals.clientConfig.clientComponents;

await loadComponents(paths);

buildComponents();
},

getTemplate: function (type) {
if (type === 'lightpatch')
type = 'lightPatch';

let template = templates[type] || {
type: type
};

return template;
return templates.find(t => t.type === type) || { type: type };
}
};
});

+ 0
- 35
src/client/js/components/sound.js View File

@@ -1,35 +0,0 @@
define([
'js/sound/sound'
], function (
soundManager
) {
return {
type: 'sound',

sound: null,
volume: 0,

init: function () {
const {
sound, volume, music, defaultMusic,
obj: { zoneId, x, y, width, height, area }
} = this;

const config = {
scope: zoneId,
file: sound,
volume,
x,
y,
w: width,
h: height,
area,
music,
defaultMusic,
loop: true
};

soundManager.addSound(config);
}
};
});

+ 5
- 1
src/client/js/main.js View File

@@ -10,6 +10,7 @@ define([
'js/resources',
'js/sound/sound',
'js/system/globals',
'js/components/components',
'ui/templates/online/online',
'ui/templates/tooltips/tooltips'
], function (
@@ -23,7 +24,8 @@ define([
events,
resources,
sound,
globals
globals,
components
) {
let fnQueueTick = null;
const getQueueTick = updateMethod => {
@@ -69,6 +71,8 @@ define([
globals.clientConfig = config;

await resources.init();
await components.init();
events.emit('onResourcesLoaded');

this.start();


+ 2
- 1
src/client/js/rendering/particles.js View File

@@ -28,9 +28,10 @@ define([

let options = $.extend(true, {}, particleDefaults, config);

let emitter = new PIXI.particles.Emitter(this.r.layers.particles, ['images/particles.png'], options);
let emitter = new PIXI.particles.Emitter(this.stage, ['images/particles.png'], options);
emitter.obj = obj;
emitter.emit = true;
emitter.particleEngine = this;

this.emitters.push(emitter);



+ 23
- 8
src/client/js/rendering/renderer.js View File

@@ -21,11 +21,15 @@ define([
globals,
renderLoginBackground
) {
let mRandom = Math.random.bind(Math);
const mRandom = Math.random.bind(Math);

const particleLayers = ['particlesUnder', 'particles'];
const particleEngines = {};

return {
stage: null,
layers: {
particlesUnder: null,
objects: null,
mobs: null,
characters: null,
@@ -115,10 +119,15 @@ define([
this.textures[t].scaleMode = PIXI.SCALE_MODES.NEAREST;
});

particles.init({
r: this,
renderer: this.renderer,
stage: this.layers.particles
particleLayers.forEach(p => {
const engine = $.extend({}, particles);
engine.init({
r: this,
renderer: this.renderer,
stage: this.layers[p]
});

particleEngines[p] = engine;
});

this.buildSpritesTexture();
@@ -769,11 +778,16 @@ define([
},

buildEmitter: function (config) {
return particles.buildEmitter(config);
const { layerName = 'particles' } = config;
const particleEngine = particleEngines[layerName];

return particleEngine.buildEmitter(config);
},

destroyEmitter: function (emitter) {
particles.destroyEmitter(emitter);
const particleEngine = emitter.particleEngine;

particleEngine.destroyEmitter(emitter);
},

setSprite: function (obj) {
@@ -887,7 +901,8 @@ define([
return;

effects.render();
particles.update();

particleLayers.forEach(p => particleEngines[p].update());

this.renderer.render(this.stage);
}


+ 35
- 0
src/client/js/sound/sound.js View File

@@ -32,6 +32,7 @@ define([
init: function () {
events.on('onToggleAudio', this.onToggleAudio.bind(this));
events.on('onPlaySound', this.playSound.bind(this));
events.on('onPlaySoundAtPosition', this.onPlaySoundAtPosition.bind(this));
events.on('onManipulateVolume', this.onManipulateVolume.bind(this));

const { clientConfig: { sounds: loadSounds } } = globals;
@@ -67,6 +68,24 @@ define([
}
},

onPlaySoundAtPosition: function ({ position: { x, y }, file, volume }) {
const { player: { x: playerX, y: playerY } } = window;
const dx = Math.abs(x - playerX);
const dy = Math.abs(y - playerY);
const distance = Math.max(dx, dy);

const useVolume = volume * (1 - (Math.pow(distance, 2) / Math.pow(minDistance, 2)));

//eslint-disable-next-line no-undef, no-unused-vars
const sound = new Howl({
src: [file],
volume: useVolume,
loop: false,
autoplay: true,
html5: false
});
},

playSound: function (soundName) {
const soundEntry = this.sounds.find(s => s.name === soundName);
if (!soundEntry)
@@ -211,6 +230,13 @@ define([
addSound: function (
{ name: soundName, scope, file, volume = 1, x, y, w, h, area, music, defaultMusic, autoLoad, loop }
) {
if (this.sounds.some(s => s.file === file)) {
if (window.player?.x !== undefined)
this.update(window.player.x, window.player.y);

return;
}

if (!area && w) {
area = [
[x, y],
@@ -243,6 +269,11 @@ define([
};

this.sounds.push(soundEntry);

if (window.player?.x !== undefined)
this.update(window.player.x, window.player.y);

return soundEntry;
},

loadSound: function (file, loop = false, autoplay = false, volume = 1) {
@@ -290,6 +321,10 @@ define([

const { player: { x, y } } = window;
this.update(x, y);
},

destroySoundEntry: function (soundEntry) {
this.sounds.spliceWhere(s => s === soundEntry);
}
};
});

+ 4
- 3
src/client/package.json View File

@@ -1,11 +1,12 @@
{
"name": "isleward_client",
"version": "0.10.2",
"version": "0.10.4",
"description": "isleward",
"dependencies": {},
"dependencies": {
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^7.32.0",
"babel-eslint": "^10.1.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-requirejs": "^4.0.1"
}


+ 2
- 2
src/client/ui/templates/login/template.html View File

@@ -11,11 +11,11 @@
</div>
<div class="message"></div>
</div>
<div class="news" location="https://gitlab.com/Isleward/play.isleward.com/-/wikis/v0.10.2-Release-Notes">[ Latest Release Notes ]</div>
<div class="news" location="https://gitlab.com/Isleward/play.isleward.com/-/wikis/v0.10.4-Release-Notes">[ Latest Release Notes ]</div>
<div class="extra">
<div class="el btn btnPatreon monetization" location="https://patreon.com/bigbadwaffle">Pledge on Patreon</div>
<div class="el btn btnPaypal monetization" location="https://www.paypal.com/donate?hosted_button_id=NEQAV3NG9PWXA">Donate on Paypal</div>
<div class="el btn btnWiki" location="http://wiki.isleward.com/Main_Page">Access the Wiki</div>
</div>
<div class="version" location="https://gitlab.com/Isleward/play.isleward.com/-/wikis/v0.10.2-Release-Notes">v0.10.2</div>
<div class="version" location="https://gitlab.com/Isleward/play.isleward.com/-/wikis/v0.10.4-Release-Notes">v0.10.4</div>
</div>

+ 1
- 1
src/server/.eslintrc View File

@@ -1,4 +1,4 @@
{
{
"root": true,

"parser": "babel-eslint",


+ 3
- 0
src/server/clientComponents/.eslintrc View File

@@ -0,0 +1,3 @@
{
"extends": "../../client/.eslintrc"
}

src/client/js/components/animation.js → src/server/clientComponents/animation.js View File


src/client/js/components/attackAnimation.js → src/server/clientComponents/attackAnimation.js View File


src/client/js/components/bumpAnimation.js → src/server/clientComponents/bumpAnimation.js View File


src/client/js/components/chatter.js → src/server/clientComponents/chatter.js View File


src/client/js/components/chest.js → src/server/clientComponents/chest.js View File


src/client/js/components/dialogue.js → src/server/clientComponents/dialogue.js View File


src/client/js/components/effects.js → src/server/clientComponents/effects.js View File


src/client/js/components/events.js → src/server/clientComponents/events.js View File


src/client/js/components/explosion.js → src/server/clientComponents/explosion.js View File


src/client/js/components/fadeInOut.js → src/server/clientComponents/fadeInOut.js View File


src/client/js/components/flash.js → src/server/clientComponents/flash.js View File


src/client/js/components/gatherer.js → src/server/clientComponents/gatherer.js View File


src/client/js/components/inventory.js → src/server/clientComponents/inventory.js View File


src/client/js/components/keyboardMover.js → src/server/clientComponents/keyboardMover.js View File


src/client/js/components/light.js → src/server/clientComponents/light.js View File


src/client/js/components/lightPatch.js → src/server/clientComponents/lightPatch.js View File


src/client/js/components/lightningEffect.js → src/server/clientComponents/lightningEffect.js View File


src/client/js/components/mouseMover.js → src/server/clientComponents/mouseMover.js View File


src/client/js/components/moveAnimation.js → src/server/clientComponents/moveAnimation.js View File


src/client/js/components/particles.js → src/server/clientComponents/particles.js View File


src/client/js/components/passives.js → src/server/clientComponents/passives.js View File


src/client/js/components/pather.js → src/server/clientComponents/pather.js View File


src/client/js/components/player.js → src/server/clientComponents/player.js View File


src/client/js/components/projectile.js → src/server/clientComponents/projectile.js View File


src/client/js/components/quests.js → src/server/clientComponents/quests.js View File


src/client/js/components/reputation.js → src/server/clientComponents/reputation.js View File


src/client/js/components/resourceNode.js → src/server/clientComponents/resourceNode.js View File


src/client/js/components/serverActions.js → src/server/clientComponents/serverActions.js View File


src/client/js/components/social.js → src/server/clientComponents/social.js View File


+ 50
- 0
src/server/clientComponents/sound.js View File

@@ -0,0 +1,50 @@
define([
'js/sound/sound'
], function (
soundManager
) {
return {
type: 'sound',

sound: null,
volume: 0,

soundEntry: null,

init: function () {
const {
sound, volume, music, defaultMusic, loop = true,
obj: { zoneId, x, y, width, height, area }
} = this;

const config = {
scope: zoneId,
file: sound,
volume,
x,
y,
w: width,
h: height,
area,
music,
defaultMusic,
loop
};

this.soundEntry = soundManager.addSound(config);
},

extend: function (bpt) {
Object.assign(this, bpt);

Object.assign(this.soundEntry, bpt);
},

destroy: function () {
if (this.soundEntry?.sound)
this.soundEntry?.sound.stop();

soundManager.destroySoundEntry(this.soundEntry);
}
};
});

src/client/js/components/spellbook.js → src/server/clientComponents/spellbook.js View File


src/client/js/components/stash.js → src/server/clientComponents/stash.js View File


src/client/js/components/stats.js → src/server/clientComponents/stats.js View File


src/client/js/components/touchMover.js → src/server/clientComponents/touchMover.js View File


src/client/js/components/trade.js → src/server/clientComponents/trade.js View File


src/client/js/components/whirlwind.js → src/server/clientComponents/whirlwind.js View File


+ 5
- 0
src/server/components/door.js View File

@@ -20,6 +20,11 @@ module.exports = {
this.destroyKey = blueprint.destroyKey;
this.autoClose = blueprint.autoClose;

if (blueprint.openSprite)
this.openSprite = blueprint.openSprite;
if (blueprint.closedSprite)
this.closedSprite = blueprint.closedSprite;

if (this.closed) {
this.obj.instance.physics.setCollision(this.obj.x, this.obj.y, true);
this.obj.instance.objects.notifyCollisionChange(this.obj.x, this.obj.y, true);


+ 14
- 0
src/server/config/clientConfig.js View File

@@ -1,6 +1,7 @@
const imageSize = require('image-size');

const events = require('../misc/events');
const fileLister = require('../misc/fileLister');
const tos = require('./tos');

const config = {
@@ -197,6 +198,7 @@ const config = {
player: [],
npc: []
},
clientComponents: [],
sounds: {
ui: []
},
@@ -207,6 +209,18 @@ module.exports = {
config,

init: async function () {
fileLister.getFolder('./clientComponents').forEach(f => {
if (!f.endsWith('.js')) return;

const type = f.split('.')[0];
const path = 'server/clientComponents/' + f;

config.clientComponents.push({
type,
path
});
});

events.emit('onBeforeGetClientConfig', config);

//Deprecated


+ 1
- 1
src/server/config/serverConfig.js View File

@@ -1,5 +1,5 @@
module.exports = {
version: '0.10.2',
version: '0.10.4',
port: 4000,
startupMessage: 'Server: ready',
defaultZone: 'fjolarok',


+ 122
- 729
src/server/package-lock.json
File diff suppressed because it is too large
View File


+ 5
- 6
src/server/package.json View File

@@ -1,23 +1,22 @@
{
"name": "isleward_server",
"version": "0.10.2",
"version": "0.10.4",
"description": "isleward",
"dependencies": {
"axios": "^0.21.1",
"axios": "^0.22.0",
"bcrypt-nodejs": "0.0.3",
"compression": "^1.7.4",
"express": "^4.17.1",
"express-minify": "^1.0.0",
"image-size": "^1.0.0",
"rethinkdbdash": "^2.3.31",
"socket.io": "^4.1.3",
"socket.io": "^4.2.0",
"universal-analytics": "^0.4.23"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint": "^7.32.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-requirejs": "^4.0.1",
"sqlite3": "^4.2.0"
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-requirejs": "^4.0.1"
}
}

+ 2
- 0
src/server/server/onConnection.js View File

@@ -21,6 +21,7 @@ const onRequest = (socket, msg, callback) => {
return;

delete msg.threadModule;
delete msg.module;

cons.route(socket, msg);
} else if (msg.threadModule) {
@@ -28,6 +29,7 @@ const onRequest = (socket, msg, callback) => {
return;

delete msg.cpn;
delete msg.module;

cons.route(socket, msg);
} else {


+ 9
- 5
src/server/server/requestHandlers.js View File

@@ -11,13 +11,17 @@ const appFile = (req, res) => {
let file = req.params[0];
file = file.replace('/' + root + '/', '');
const validRequest = (
root !== 'server' ||
(
file.includes('mods/') &&
validModPatterns.some(v => file.includes(v))
)
(
root === 'server' &&
file.startsWith('clientComponents/')
) ||
(
file.includes('mods/') &&
validModPatterns.some(v => file.includes(v))
)
);
if (!validRequest)


+ 12
- 6
src/server/world/map.js View File

@@ -259,12 +259,18 @@ module.exports = {
const layers = [...mapFile.layers.filter(l => l.objects), ...mapFile.layers.filter(l => !l.objects)];

//Rooms need to be ahead of exits
layers.rooms = (layers.rooms || [])
.sort(function (a, b) {
if ((a.exit) && (!b.exit))
return 1;
return 0;
});
const layerRooms = layers.find(l => l.name === 'rooms') || {};
layerRooms.objects.sort((a, b) => {
const isExitA = a?.properties?.some(p => p.name === 'exit');
const isExitB = b?.properties?.some(p => p.name === 'exit');

if (isExitA && !isExitB)
return 1;
else if (!isExitA && isExitB)
return -1;

return 0;
});

for (let i = 0; i < layers.length; i++) {
let layer = layers[i];


Loading…
Cancel
Save