From 9fd29a64a9ac2b02a48cd8770ae8b5710dd8cd0f Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 20 Mar 2019 22:23:26 -0500 Subject: [PATCH] refactor: register traits before client/server entry --- server/game.js | 14 ++++++-------- webpack.client.config.js | 2 +- webpack.server.config.js | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/server/game.js b/server/game.js index 1295165..fb7fb85 100644 --- a/server/game.js +++ b/server/game.js @@ -22,14 +22,12 @@ const entityList = new EntityList(); const stateSynchronizer = new StateSynchronizer({ entityList, }); -setImmediate(() => { - for (let i = 0; i < 20; ++i) { - const x = Math.floor(Math.random() * 1000) + 100; - const y = Math.floor(Math.random() * 500) + 100; - const flowerBarrel = createFlowerBarrelEntity([x, y]); - entityList.addEntity(flowerBarrel); - } -}); +for (let i = 0; i < 20; ++i) { + const x = Math.floor(Math.random() * 1000) + 100; + const y = Math.floor(Math.random() * 500) + 100; + const flowerBarrel = createFlowerBarrelEntity([x, y]); + entityList.addEntity(flowerBarrel); +} // Connection listener. function createConnectionListener(avocadoServer) { return (socket) => { diff --git a/webpack.client.config.js b/webpack.client.config.js index 4b59e20..a8a15c0 100644 --- a/webpack.client.config.js +++ b/webpack.client.config.js @@ -7,8 +7,8 @@ const config = require('./webpack.common.config'); config.entry = { client: [ '@babel/polyfill', - path.join(__dirname, 'client', 'index.js'), path.join(__dirname, 'register-traits.js'), + path.join(__dirname, 'client', 'index.js'), ], }; config.devServer = { diff --git a/webpack.server.config.js b/webpack.server.config.js index 8e34e85..6e61101 100644 --- a/webpack.server.config.js +++ b/webpack.server.config.js @@ -9,8 +9,8 @@ config.entry = { server: [ 'source-map-support/register', '@babel/polyfill', - path.join(__dirname, 'server', 'index.js'), path.join(__dirname, 'register-traits.js'), + path.join(__dirname, 'server', 'index.js'), ], }; config.externals = [