From f2578715981d2839686d7d8abb99be879f92f9f9 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Tue, 27 Jun 2023 18:56:39 -0500 Subject: [PATCH] no more other player viewing ghost, also odd bug where players can change bodies but cant replicate it anymore --- client/src/index.ts | 10 ++++++---- server/src/handler.rs | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/src/index.ts b/client/src/index.ts index 72b4e3e0778e8a9bd07398fd5586fcfcd0193303..5ff9a935a1d696b099c9e48422dd6fc0e9eb6523 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -34,6 +34,7 @@ export interface GlobalData { mouse_x: number, mouse_y: number, tree: Map, + clicked: number | null, } export interface Keys { @@ -67,6 +68,7 @@ export const global: GlobalData = { mouse_x: 0, mouse_y: 0, tree: new Map(), + clicked: null, } async function client_main(server: string, username: string, texture_quality: string) { @@ -153,7 +155,7 @@ async function client_main(server: string, username: string, texture_quality: st worldposX: worldX, worldposY: worldY, }).finish(); - global.modules[i].flags |= 2; + global.clicked = global.modules[i].id; global.client?.socket.send(encode(MessageC2SModuleGrabBegin_packetInfo.type, msg)) } } @@ -193,8 +195,8 @@ async function client_main(server: string, username: string, texture_quality: st }).finish(); for (let i = 0; i < global.modules.length; i++) { - if((global.modules[i].flags & 2) != 0) { - global.modules[i].flags &= ~2; + if(global.clicked === global.modules[i].id) { + global.clicked = null; let msg = MessageC2SModuleGrabEnd.encode({ moduleId: global.modules[i].id, worldposX: worldX, @@ -354,7 +356,7 @@ async function client_main(server: string, username: string, texture_quality: st global.context.restore(); - if ((module.flags & 2) != 0) { + if (global.clicked == module.id) { global.context.save(); global.context.translate(global.mouse_x - window.innerWidth/2, global.mouse_y - window.innerHeight/2); diff --git a/server/src/handler.rs b/server/src/handler.rs index 8f31d36faeee39b138e594a6b6f225aca9266db3..ed46466179c07f5b02929f6965a72797e31cf999 100644 --- a/server/src/handler.rs +++ b/server/src/handler.rs @@ -446,7 +446,6 @@ pub async fn handle_client( } MessageC2S::ModuleGrabBegin(p) => { if let Entity::Module(module) = entities.write().await.entities.get_mut(&p.module_id).unwrap() { - module.flags |= 2; //debug!("[{}] grab begin: {:?}, flags: {}", remote_addr, p, module.flags); } } @@ -456,9 +455,8 @@ pub async fn handle_client( let mut did_attach = false; let mut attached_id = None; if let Entity::Module(p_module) = entities.entities.get_mut(&p.module_id).unwrap() { - p_module.flags &= !2; module = Some(p_module.clone()); - //debug!("[{}] grab end: {:?}", remote_addr, p); + debug!("[{}] grab end: {:?}", remote_addr, p); } let mut data_handle = data.write().await; let player_id = entities.get_player_id(remote_addr).unwrap();