~starkingdoms/starkingdoms

f2578715981d2839686d7d8abb99be879f92f9f9 — ghostlyzsh 2 years ago dc9acc1
no more other player viewing ghost, also odd bug where players can change bodies but cant replicate it anymore
2 files changed, 7 insertions(+), 7 deletions(-)

M client/src/index.ts
M server/src/handler.rs
M client/src/index.ts => client/src/index.ts +6 -4
@@ 34,6 34,7 @@ export interface GlobalData {
    mouse_x: number,
    mouse_y: number,
    tree: Map<number, AttachedModule>,
    clicked: number | null,
}

export interface Keys {


@@ 67,6 68,7 @@ export const global: GlobalData = {
    mouse_x: 0,
    mouse_y: 0,
    tree: new Map<number, AttachedModule>(),
    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);

M server/src/handler.rs => server/src/handler.rs +1 -3
@@ 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();