Browse Source

compatibility with shaker + fix for early smt/packets from server

SaltyMonkey 6 years ago
parent
commit
e415542e8d
2 changed files with 18 additions and 1 deletions
  1. 5 0
      lib/unitFps.js
  2. 13 1
      lib/unitState.js

+ 5 - 0
lib/unitFps.js

@@ -90,6 +90,8 @@ class unitFps {
 		const isEntityBlocked = (gameId) => (blockedPlayers.has(gameId) || blockedNpcs.has(gameId) || blockedSummons.has(gameId) || blockedServants.has(gameId));
 
 		const changeShakeState = () => {
+			if (data.externalShakeControl) return;
+
 			mod.clientInterface.configureCameraShake(!data.activeMode.blockShakeEffects);
 		};
 
@@ -467,6 +469,7 @@ class unitFps {
 		};
 
 		const smtHandler = (event) => {
+			if (!data.inGame) return;
 			if (isSmtBlockable(event)) return false;
 		};
 
@@ -475,10 +478,12 @@ class unitFps {
 		};
 
 		const blockUselessPacketsHandler = () => {
+			if (!data.inGame) return;
 			if (data.activeMode.blockUselessPackets) return false;
 		};
 
 		const throttlePacketsHandler = (name, code, payload) => {
+			if (!data.inGame) return;
 			// eslint-disable-next-line no-magic-numbers
 			let needBlock = (data.activeMode.throttleSomePackets && throttlePacketsData[name] && (throttlePacketsData[name].equals(payload)));
 			throttlePacketsData[name] = payload;

+ 13 - 1
lib/unitState.js

@@ -45,6 +45,8 @@ class unitState extends EventEmitter {
 			"activeMode": undefined,
 			"prevMode": undefined,
 			"lockedMode": false,
+			"inGame": false,
+			"externalShakeControl": false,
 			"availableClasses": new Set(),
 			"userTemplateToClassMap": {},
 			"lockedPacketsData": [],
@@ -98,6 +100,11 @@ class unitState extends EventEmitter {
 		this.__mod.hook("S_LOGIN", RAW_HOOK_MODE.EVENT, HOOK_SETTINGS.FIRST, () => {
 			this.lockedMode = false;
 
+			if(this.__mod.manager.isLoaded("shaker")) {
+				this.__mod.warning("Camera shake effects will not be applied as the Shaker mod is installed. Please use \"/toolbox shaker\" to configure camera shaking behavior");
+				this.externalShakeControl = true;
+			}
+
 			this.preset = this.__mod.settings.classBasedPresets
 				? (this.presets[this.__mod.game.me.class] || this.presets["common"])
 				: this.presets["common"];
@@ -106,7 +113,8 @@ class unitState extends EventEmitter {
 			this.activeMode = this.preset.modes[this.preset.directives["default"]];
 
 			if (this.__mod.settings.interactive) this.__log.send(`Default mode: "${this.preset.directives["default"]}".`);
-			
+		
+			this.inGame = true;
 			this._eventTriggerPartial();
 		});
 
@@ -170,6 +178,10 @@ class unitState extends EventEmitter {
 
 			this._eventTrigger();
 		});
+
+		this.__mod.hook("S_RETURN_TO_LOBBY", RAW_HOOK_MODE.EVENT, () => {
+			this.inGame = false;
+		});
 	}
 
 	_eventTrigger() {