From 1b61eecd09c6689c7c41670335166de6285954e4 Mon Sep 17 00:00:00 2001 From: azw Date: Wed, 1 Nov 2023 15:02:54 +0000 Subject: [PATCH] 1 --- server/notifyserver/proto/cs_proto.proto | 7 ------- server/notifyserver/tools/pbtools/app.js | 24 +++++++++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/server/notifyserver/proto/cs_proto.proto b/server/notifyserver/proto/cs_proto.proto index 80afdb7..ac999ba 100755 --- a/server/notifyserver/proto/cs_proto.proto +++ b/server/notifyserver/proto/cs_proto.proto @@ -1333,13 +1333,6 @@ message CMExecCommand optional string cmd = 1; //指令 } -//丢弃道具 -message CMDropItem -{ - optional int32 item_id = 1; //道具id - optional int32 weapon_idx = 2; //武器索引 0-4 -} - //发送表情 message CMEmote { diff --git a/server/notifyserver/tools/pbtools/app.js b/server/notifyserver/tools/pbtools/app.js index b5340be..2ab2444 100644 --- a/server/notifyserver/tools/pbtools/app.js +++ b/server/notifyserver/tools/pbtools/app.js @@ -69,13 +69,15 @@ class PBTools { `use std::rc::{Rc, Weak}; use std::cell::RefCell; use crate::cs::cs_proto as cs; +use crate::cs::cs_msgid as cs_msgid; struct Handler { msg_id: i32, handler_id: i32, } -static HANDLERS: Vec = Vec::new(); +static mut HANDLERS: Vec> = Vec::new(); +//static HANDLERS: [Option; 2000]; /* func GetNetMsgHandler(msgId uint16) Option { @@ -122,24 +124,32 @@ pub trait MsgHandler {`; `; data += ` pub fn registe_handlers() { + unsafe { + HANDLERS.reserve(2000); + for i in 0..1999 { + HANDLERS.push(None); + } `; this.csProtoPb.nested.cs.nestedArray.forEach( (item) => { if (item.name[0] == 'C' && item.name[1] == 'M') { - /* data += ` - HANDLERS[int(CMMessageIdE__${item.name})] = &CsNetMsgHandler{ - MsgId: int(CMMessageIdE__${item.name}), + HANDLERS[cs_msgid::CMMessageId_e::_${item.name} as usize] = Some( +Handler { + msg_id: cs_msgid::CMMessageId_e::_${item.name} as i32, + handler_id: 0, +/* Cb: func (hdr *f5.MsgHdr, handler MsgHandler) { handler.${item.name}(hdr, hdr.Msg.(*${item.name})) }, - }; -`;*/ +*/ +}); +`; } }); data += ` -}`; +}}`; fs.writeFileSync('./src/cs/cs_auto_gen.rs', data); }