This commit is contained in:
azw 2023-11-01 15:02:54 +00:00
parent 4f322d3cbd
commit 1b61eecd09
2 changed files with 17 additions and 14 deletions

View File

@ -1333,13 +1333,6 @@ message CMExecCommand
optional string cmd = 1; // optional string cmd = 1; //
} }
//
message CMDropItem
{
optional int32 item_id = 1; //id
optional int32 weapon_idx = 2; // 0-4
}
// //
message CMEmote message CMEmote
{ {

View File

@ -69,13 +69,15 @@ class PBTools {
`use std::rc::{Rc, Weak}; `use std::rc::{Rc, Weak};
use std::cell::RefCell; use std::cell::RefCell;
use crate::cs::cs_proto as cs; use crate::cs::cs_proto as cs;
use crate::cs::cs_msgid as cs_msgid;
struct Handler { struct Handler {
msg_id: i32, msg_id: i32,
handler_id: i32, handler_id: i32,
} }
static HANDLERS: Vec<Handler> = Vec::new(); static mut HANDLERS: Vec<Option<Handler>> = Vec::new();
//static HANDLERS: [Option<Handler>; 2000];
/* /*
func GetNetMsgHandler(msgId uint16) Option<CsNetMsgHandler> { func GetNetMsgHandler(msgId uint16) Option<CsNetMsgHandler> {
@ -122,24 +124,32 @@ pub trait MsgHandler {`;
`; `;
data += ` data += `
pub fn registe_handlers() { pub fn registe_handlers() {
unsafe {
HANDLERS.reserve(2000);
for i in 0..1999 {
HANDLERS.push(None);
}
`; `;
this.csProtoPb.nested.cs.nestedArray.forEach( this.csProtoPb.nested.cs.nestedArray.forEach(
(item) => { (item) => {
if (item.name[0] == 'C' && if (item.name[0] == 'C' &&
item.name[1] == 'M') { item.name[1] == 'M') {
/*
data += ` data += `
HANDLERS[int(CMMessageIdE__${item.name})] = &CsNetMsgHandler{ HANDLERS[cs_msgid::CMMessageId_e::_${item.name} as usize] = Some(
MsgId: int(CMMessageIdE__${item.name}), Handler {
msg_id: cs_msgid::CMMessageId_e::_${item.name} as i32,
handler_id: 0,
/*
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) { Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.${item.name}(hdr, hdr.Msg.(*${item.name})) handler.${item.name}(hdr, hdr.Msg.(*${item.name}))
}, },
}; */
`;*/ });
`;
} }
}); });
data += ` data += `
}`; }}`;
fs.writeFileSync('./src/cs/cs_auto_gen.rs', data); fs.writeFileSync('./src/cs/cs_auto_gen.rs', data);
} }