Browse Source

slight cleanup, removed asserts - tested successfully

SaltyMonkey 6 years ago
parent
commit
70301d7a98
6 changed files with 9 additions and 36 deletions
  1. 2 2
      fpsManager.js
  2. 4 4
      lib/management/cmd.js
  3. 1 10
      lib/unitFps.js
  4. 1 4
      lib/unitProto.js
  5. 1 16
      lib/unitState.js
  6. 0 0
      lib/unitUI.js

+ 2 - 2
fpsManager.js

@@ -14,7 +14,7 @@
 * @property {import('./lib/unitState')} data
 * @property {import('./lib/unitState')} data
 * @property {import('./lib/unitTracker')} tracker
 * @property {import('./lib/unitTracker')} tracker
 * @property {import('./lib/unitFps')} fps
 * @property {import('./lib/unitFps')} fps
-* @property {import('./lib/unitCommands')} cmd
+* @property {import('./lib/management/cmd')} cmd
 * @property {*} mod
 * @property {*} mod
 */
 */
 
 
@@ -29,7 +29,7 @@ const units = [
 	["data", require("./lib/unitState")],
 	["data", require("./lib/unitState")],
 	["tracker", require("./lib/unitTracker")],
 	["tracker", require("./lib/unitTracker")],
 	["fps", require("./lib/unitFps")],
 	["fps", require("./lib/unitFps")],
-	["cmd", require("./lib/unitCommands")]
+	["cmd", require("./lib/management/cmd")]
 ];
 ];
 
 
 class FpsManager {
 class FpsManager {

+ 4 - 4
lib/unitCommands.js → lib/management/cmd.js

@@ -7,16 +7,16 @@
 */
 */
 
 
 /**
 /**
- * @typedef {import("../fpsManager.js").deps} deps
+ * @typedef {import("../../fpsManager.js").deps} deps
 */
 */
 const rfdc = require("rfdc")({ "proto": true });
 const rfdc = require("rfdc")({ "proto": true });
 const stringSimilarity = require("string-similarity");
 const stringSimilarity = require("string-similarity");
 
 
-class unitControl {
+class Commands {
 	/**
 	/**
 	 *Creates an instance of Control.
 	 *Creates an instance of Control.
 	 * @param {deps} deps
 	 * @param {deps} deps
-	 * @memberof unitControl
+	 * @memberof Commands
 	*/
 	*/
 	constructor(deps) {
 	constructor(deps) {
 		let prefixes = ["fm", "fps"];
 		let prefixes = ["fm", "fps"];
@@ -84,4 +84,4 @@ class unitControl {
 			deps.mod.command.add(prefixes, commands, this);
 			deps.mod.command.add(prefixes, commands, this);
 	}
 	}
 }
 }
-module.exports = unitControl;
+module.exports = Commands;

+ 1 - 10
lib/unitFps.js

@@ -9,7 +9,7 @@
 /**
 /**
  * @typedef {import("../fpsManager.js").deps} deps
  * @typedef {import("../fpsManager.js").deps} deps
 */
 */
-const assert = require("assert").strict;
+
 const utils = require("./helpers/utils");
 const utils = require("./helpers/utils");
 const { ENTITY_HOOK_TYPE, RAW_HOOK_MODE, HOOK_SETTINGS, DESPAWN_TYPES, EVENTS, HPCHANGE, MPCHANGE } = require("./helpers/enums");
 const { ENTITY_HOOK_TYPE, RAW_HOOK_MODE, HOOK_SETTINGS, DESPAWN_TYPES, EVENTS, HPCHANGE, MPCHANGE } = require("./helpers/enums");
 
 
@@ -20,7 +20,6 @@ class unitFps {
 	* @memberof unitFps
 	* @memberof unitFps
 	*/
 	*/
 	constructor(deps) {
 	constructor(deps) {
-		assert.ok(Object.keys(deps), "unitState: empty deps");
 		const data = deps.data;
 		const data = deps.data;
 		const mod = deps.mod;
 		const mod = deps.mod;
 		const tracker = deps.tracker;
 		const tracker = deps.tracker;
@@ -431,8 +430,6 @@ class unitFps {
 				}
 				}
 			}
 			}
 			for (const [key, value] of tracker.spawnedDrop.entries()) {
 			for (const [key, value] of tracker.spawnedDrop.entries()) {
-				assert.ok(Object.keys(value).length > 3, "reconfigure event: wrong object drop");
-
 				let needBlock = isDropBlockable(value);
 				let needBlock = isDropBlockable(value);
 				if (needBlock && !blockedDrop.has(key)) {
 				if (needBlock && !blockedDrop.has(key)) {
 					mod.send(...proto.getData("S_DESPAWN_DROPITEM"), { "gameId": value.gameId });
 					mod.send(...proto.getData("S_DESPAWN_DROPITEM"), { "gameId": value.gameId });
@@ -445,8 +442,6 @@ class unitFps {
 			}
 			}
 
 
 			for (const [key, value] of tracker.spawnedPlayers.entries()) {
 			for (const [key, value] of tracker.spawnedPlayers.entries()) {
-				assert.ok(Object.keys(value).length > 3, "reconfigure event: wrong object players");
-
 				let needBlock = isPlayerBlockable(value);
 				let needBlock = isPlayerBlockable(value);
 				if (needBlock && !blockedPlayers.has(key)) {
 				if (needBlock && !blockedPlayers.has(key)) {
 					mod.send(...proto.getData("S_DESPAWN_USER"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW });
 					mod.send(...proto.getData("S_DESPAWN_USER"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW });
@@ -459,8 +454,6 @@ class unitFps {
 			}
 			}
 
 
 			for (const [key, value] of tracker.spawnedServants.entries()) {
 			for (const [key, value] of tracker.spawnedServants.entries()) {
-				assert.ok(Object.keys(value).length > 3, "reconfigure event: wrong object servants");
-
 				let needBlock = isServantBlockable(value);
 				let needBlock = isServantBlockable(value);
 				if (needBlock && !blockedServants.has(key)) {
 				if (needBlock && !blockedServants.has(key)) {
 					mod.send(...proto.getData("S_REQUEST_DESPAWN_SERVANT"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW });
 					mod.send(...proto.getData("S_REQUEST_DESPAWN_SERVANT"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW });
@@ -473,7 +466,6 @@ class unitFps {
 			}
 			}
 
 
 			for (const [key, value] of tracker.spawnedSummons.entries()) {
 			for (const [key, value] of tracker.spawnedSummons.entries()) {
-				assert.ok(Object.keys(value).length > 3, "reconfigure event: wrong object summons");
 				let needBlock = isSummonsBlockable(value);
 				let needBlock = isSummonsBlockable(value);
 				if (needBlock && !blockedSummons.has(key)) {
 				if (needBlock && !blockedSummons.has(key)) {
 					mod.send(...proto.getData("S_DESPAWN_NPC"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW, "loc": value.loc });
 					mod.send(...proto.getData("S_DESPAWN_NPC"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW, "loc": value.loc });
@@ -486,7 +478,6 @@ class unitFps {
 			}
 			}
 
 
 			for (const [key, value] of tracker.spawnedNPCS.entries()) {
 			for (const [key, value] of tracker.spawnedNPCS.entries()) {
-				assert.ok(Object.keys(value).length > 3, "reconfigure event: wrong object NPCS");
 				let needBlock = isSummonsBlockable(value);
 				let needBlock = isSummonsBlockable(value);
 				if (needBlock && !blockedNpcs.has(key)) {
 				if (needBlock && !blockedNpcs.has(key)) {
 					mod.send(...proto.getData("S_DESPAWN_NPC"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW, "loc": value.loc });
 					mod.send(...proto.getData("S_DESPAWN_NPC"), { "gameId": value.gameId, "type": DESPAWN_TYPES.OUTOFVIEW, "loc": value.loc });

+ 1 - 4
lib/unitProto.js

@@ -1,7 +1,7 @@
 "use strict";
 "use strict";
 
 
 const proto = require("../data/protoData.json");
 const proto = require("../data/protoData.json");
-const assert = require("assert").strict;
+
 /*
 /*
 * Unit for Fps Manager. Managing definitions versions for game protocol
 * Unit for Fps Manager. Managing definitions versions for game protocol
 * Author: SaltyMonkey
 * Author: SaltyMonkey
@@ -22,9 +22,6 @@ class unitProto {
 		this.__mod = deps.mod;
 		this.__mod = deps.mod;
 
 
 		console.log("DEBUG: unitProto -> constructor");
 		console.log("DEBUG: unitProto -> constructor");
-		
-		assert.ok(Object.keys(deps), "unitProto: empty deps");
-		assert.ok(Object.keys(proto), "unitProto empty");
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 16
lib/unitState.js

@@ -9,7 +9,7 @@
 /**
 /**
  * @typedef {import("../fpsManager.js").deps} deps
  * @typedef {import("../fpsManager.js").deps} deps
 */
 */
-const assert = require("assert").strict;
+
 //using es5 compatible mode because json not supports es6 types and es6 version is slow ->(require("fast-deep-equal/es6");)
 //using es5 compatible mode because json not supports es6 types and es6 version is slow ->(require("fast-deep-equal/es6");)
 const equal = require("fast-deep-equal");
 const equal = require("fast-deep-equal");
 const EventEmitter = require("events").EventEmitter;
 const EventEmitter = require("events").EventEmitter;
@@ -34,9 +34,6 @@ class unitState extends EventEmitter {
 	 */
 	 */
 	constructor(deps) {
 	constructor(deps) {
 		super();
 		super();
-
-		assert.ok(Object.keys(deps), "unitState: empty deps");
-
 		console.log("DEBUG: unitState -> constructor");
 		console.log("DEBUG: unitState -> constructor");
 
 
 		this.__mod = deps.mod;
 		this.__mod = deps.mod;
@@ -70,18 +67,11 @@ class unitState extends EventEmitter {
 				this.onScreenEffectsBuffs.add(abnormality.id);
 				this.onScreenEffectsBuffs.add(abnormality.id);
 		});
 		});
 
 
-		assert.ok(Array.from(this.huntingRewardsBuffs).length > 0, "unitState: empty huntingRewardsBuffs");
-		assert.ok(Array.from(this.shapeChangersBuffs).length > 0, "unitState: empty shapeChangersBuffs");
-		assert.ok(Array.from(this.onScreenEffectsBuffs).length > 0, "unitState: empty onScreenEffectsBuffs");
-
 		deps.mod.game.data.users.forEach(template => {
 		deps.mod.game.data.users.forEach(template => {
 			this.availableClasses.push(template.class);
 			this.availableClasses.push(template.class);
 			this.userTemplateToClassMap[template] = template.class;
 			this.userTemplateToClassMap[template] = template.class;
 		});
 		});
 
 
-		assert.ok(this.availableClasses.length > 0, "unitState: empty availableClasses");
-		assert.ok(Object.keys(this.userTemplateToClassMap).length > 0, "unitState: empty userTemplateToClassMap");
-		
 		this.Init();
 		this.Init();
 	}
 	}
 
 
@@ -92,12 +82,8 @@ class unitState extends EventEmitter {
 			this.presets[x] = utils.loadJson(utils.getFullPath(__dirname, `../settings/presets/${x}.json`));
 			this.presets[x] = utils.loadJson(utils.getFullPath(__dirname, `../settings/presets/${x}.json`));
 		});
 		});
 
 
-		assert.ok(Object.keys(this.presets).length >= 1, "unitState: empty presets");
-
 		let staticData = utils.loadJson(utils.getFullPath(__dirname, "../data/staticData.json"));
 		let staticData = utils.loadJson(utils.getFullPath(__dirname, "../data/staticData.json"));
 
 
-		assert.ok(Object.keys(staticData).length > 0, "unitState: empty staticData");
-
 		this.lockedPacketsData = staticData.blockedProto;
 		this.lockedPacketsData = staticData.blockedProto;
 		this.throttlePacketsData = staticData.throttledProto;
 		this.throttlePacketsData = staticData.throttledProto;
 		this.smtData = new Set(...staticData.blockedSmt);
 		this.smtData = new Set(...staticData.blockedSmt);
@@ -110,7 +96,6 @@ class unitState extends EventEmitter {
 			if (!this.preset) { throw new Error("Preset can't be loaded! Critical error. "); }
 			if (!this.preset) { throw new Error("Preset can't be loaded! Critical error. "); }
 
 
 			this.activeMode = this.preset.modes[this.preset.directives["default"]];
 			this.activeMode = this.preset.modes[this.preset.directives["default"]];
-			assert.ok(Object.keys(this.activeMode).length > 0, "unitState: empty activeMode");
 		});
 		});
 
 
 		this.__mod.hook(...this.__proto.getData("S_LOAD_TOPO"), HOOK_SETTINGS.FIRST, (event) => {
 		this.__mod.hook(...this.__proto.getData("S_LOAD_TOPO"), HOOK_SETTINGS.FIRST, (event) => {

+ 0 - 0
lib/unitUI.js