This commit is contained in:
azw 2023-11-01 13:45:14 +00:00
parent e698f97dbe
commit 91ea484067
3 changed files with 16 additions and 14 deletions

View File

@ -1,7 +1,7 @@
fn main() {
protobuf_codegen_pure::Codegen::new()
.out_dir("src")
.inputs(&["proto/mt.proto",
.out_dir("src/cs")
.inputs(&[//"proto/mt.proto",
"proto/cs_msgid.proto",
"proto/cs_proto.proto"])
.include("proto")

View File

@ -11,24 +11,21 @@ use r9_macro_derive::SharedFromSelf;
use r9_macro_derive::Singleton;
pub mod app;
pub mod mt;
pub mod cs_msgid;
pub mod cs_proto;
//pub mod cs_auto_gen;
pub mod cs;
//pub mod mtb;
pub trait MsgHandler {
/*
fn cm_join(_: &f9::MsgHdr, _: Rc::<RefCell::<cs_proto::CMJoin>>) {
}
fn cm_move(_: &f9::MsgHdr, _: Rc::<RefCell::<cs_proto::CMMove>>) {
fn cm_move(&self, _: &f9::MsgHdr, _: Rc::<RefCell::<cs_proto::CMMove>>) {
}
fn cm_emote(_: &f9::MsgHdr, _: Rc::<RefCell::<cs_proto::CMEmote>>) {
}
*/
}
#[derive(SharedFromSelf)]
@ -48,11 +45,12 @@ impl MsgHandler for PlayerNetHandler {
impl PlayerNetHandler {
/*
pub fn cm_move(hdr: &f9::MsgHdr,
msg: Rc::<RefCell::<cs_proto::CMMove>>) {
println!("seq:{}", msg.borrow().get_seq());
}
*/
}
#[derive(SharedFromSelf)]
@ -88,12 +86,13 @@ impl Player {
return self.nick_name.clone();
}
/*
pub fn cm_move(self_p :&Rc::<RefCell<Player>>,
hdr: &f9::MsgHdr,
msg: Rc::<RefCell::<cs_proto::CMMove>>) {
println!("seq:{}", msg.borrow().get_seq());
}
*/
}
impl PlayerMgr {
@ -145,6 +144,7 @@ fn main() {
println!("account_id:{} name:{}",
hum.as_ref().unwrap().borrow().get_account_id(),
hum.as_ref().unwrap().borrow().get_nick_name());
/*
let msg = Rc::new(RefCell::new(cs_proto::CMMove::new()));
msg.borrow_mut().set_seq(100);
let msg_hdr = f9::MsgHdr {
@ -157,7 +157,7 @@ fn main() {
&hum.unwrap(),
&msg_hdr,
msg
)
)*/
}
App::instance().borrow_mut().init(
crate::app::app::UserApp::instance()

View File

@ -68,6 +68,7 @@ class PBTools {
let data =
`use std::rc::{Rc, Weak};
use std::cell::RefCell;
use crate::cs::cs_proto as cs;
//static mut handlers [2000]Option<CsNetMsgHandler>
@ -104,7 +105,7 @@ pub trait MsgHandler {`;
item.name[1] == 'M') {
data += `
${item.name}(&self, _: &f9.MsgHdr, _: Rc::<RefCell::${item.name}>>) {
fn ${item.name}(&self, _: &f9::MsgHdr, _: Rc::<RefCell::<cs::${item.name}>>) {
panic!("not implement");
}`;
}
@ -112,6 +113,7 @@ pub trait MsgHandler {`;
data += `
}
`;
/*
data += `
func init() {
`;
@ -135,7 +137,7 @@ func init() {
}
});
data += `
}`;
}`;*/
fs.writeFileSync('./src/cs/cs_auto_gen.rs', data);
}