using System; using System.Collections.Generic; using System.Windows; using System.Windows.Forms; using System.Text; using System.Runtime.InteropServices; using System.IO; using zyxAdapter; using MrWu.Debug; using Game.Data; namespace nativeCom{ public partial class dcEvent_zyx:dcEvent_zyx0{ unsafe public override int doMsg_rukou(string dowhat/*^分割*/, string datas/*结构体地址 ^分割*/,ref tr_rltpchar t)//返回string/*^分割*/ { return 1; } unsafe public override string doMsg(string dowhat/*^分割*/, string datas/*结构体地址 ^分割*/)//返回string/*^分割*/ { //MrWu.Debug.Debug.Log("dowhat:" + dowhat); try{ string result="null"; string[] dts =null; if(datas!=null){ dts= datas.Split('^'); } string[] dostr=dowhat.Split('^'); string[] cmds=dostr[0].Split('*'); switch(cmds[0]){ // case "showcsharpdllform": // if (cmds[1]=="1") Formzyx.fmzyx. Show();else Formzyx.fmzyx. Hide(); // break; case "yasuo": ABlock ablockTmp= new ABlock(); myCom_zyx.Instance.getDataOfStruct(int.Parse(dts[0]), ref ablockTmp,(int*)&ablockTmp); ABlock ablockTmp1= new ABlock(); myCom_zyx.Instance.getDataOfStruct(int.Parse(dts[1]), ref ablockTmp1,(int*)&ablockTmp1); // log("xxxx "+ablockTmp.len+" "+ablockTmp1.len); if (cmds[1][0]=='1') result= myCom_zyx.Instance.Compress(ref ablockTmp,ref ablockTmp1).ToString();else result=myCom_zyx.Instance.deCompress(ref ablockTmp,ref ablockTmp1).ToString(); //log("xxxx xxx "+ablockTmp.len+" "+ablockTmp1.len); break; case "gameClose": return "closeOk";//必须 case "dopack"://收包 //log("命令。。。 "+cmds[1]); switch(cmds[1]){ case "dologic"://每次数据变化 tr_pack_dapai pk1=(tr_pack_dapai) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(tr_pack_dapai)); mjchild.instance.sendPackFunc(ref pk1,int.Parse(dts[1])); break; case "allpack_chupai"://出牌 //全包 tr_pack_dapai pk=(tr_pack_dapai) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(tr_pack_dapai)); result=mjchild.instance.chupai(ref pk).ToString(); break; case "fanWorld": pk=(tr_pack_dapai) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(tr_pack_dapai)); Tr_Paixing tp= (Tr_Paixing) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[1])),typeof(Tr_Paixing)); int gzNum=int.Parse(cmds[2]); int wjpos=int.Parse(cmds[3]); result= mjchild.instance. calFan_world(ref pk,ref tp,gzNum,wjpos).ToString(); break; case "cal_hupai"://计算胡牌再修正 //log("-----------------"); //pai*' + inttostr(wjpos) + '*' + inttostr(C_lg.getfangpao_new) + '*' + inttostr(LingPai)], [ p, @wjpos, @t, @dapaiToDll]); pk=(tr_pack_dapai) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[3])),typeof(tr_pack_dapai)); Tr_faninfo tf= (Tr_faninfo) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(Tr_faninfo)); int hpr=*(int*)int.Parse(dts[1]); int step=*(int*)int.Parse(dts[5]); //log("计算胡番----"); mjchild.instance. cal_hupai(ref pk,ref tf,hpr,int.Parse(cmds[3]),int.Parse(cmds[4]),int.Parse(dts[4]),step); // ABlock ab= new ABlock(); // myCom_zyx.Instance.getDataOfStruct(, ref ab,(int*)&ab); funs.instance.memToNative_bytes_(funs.instance.StructToBytes(tf),int.Parse(dts[2])); break; case "calfan_hupai"://计算胡番 //log("xxxxxxxxxxxxxxxxxxxx"); pk=(tr_pack_dapai) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[5])),typeof(tr_pack_dapai)); tp= (Tr_Paixing) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(Tr_Paixing)); tf= (Tr_faninfo) Marshal.PtrToStructure(new IntPtr(int.Parse(dts[2])),typeof(Tr_faninfo)); hpr=*(int*)int.Parse(dts[3]); mjchild.instance. calFan_hupai(ref pk,ref tp,new IntPtr(int.Parse(dts[1])),ref tf,hpr,int.Parse(cmds[3]),int.Parse(cmds[4]),int.Parse(dts[6])); result= (tf.fan[95+hpr]).ToString(); // if (result==""||result==" ") // log("sdfsf"); // ABlock ab= new ABlock(); // myCom_zyx.Instance.getDataOfStruct(, ref ab,(int*)&ab); funs.instance.memToNative_bytes_(funs.instance.StructToBytes(tf),int.Parse(dts[4])); break; case "initdll": mjchild nc=new mjchild(); mjchild.instance=nc; //Debug.Log("111"); tcls_mem_dll_main cs_main=(tcls_mem_dll_main)Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(tcls_mem_dll_main)); log("宿主参数 "+cs_main.a); tcls_mem_dll cs_dll=new tcls_mem_dll(); //Debug.Log("222"); tcls_mem_dll.init(ref cs_dll); //Debug.Log("333"); ABlock ab= new ABlock(); myCom_zyx.Instance.getDataOfStruct(int.Parse(dts[1]), ref ab,(int*)&ab); //Debug.Log("444"); result=mjchild.instance.initDll(ref cs_main,ref cs_dll ,ref ab,int.Parse( dts[2])).ToString(); //Debug.Log("555"); //nativeCom.Formzyx.fmzyx.Show(); break; case "initdll_agame"://主要是规则 if(cmds[2] == "1") break; tcls_mem_dll_main_agame cs_main_agame=(tcls_mem_dll_main_agame)Marshal.PtrToStructure(new IntPtr(int.Parse(dts[0])),typeof(tcls_mem_dll_main_agame)); log("宿主参数_agame "+cs_main_agame.a); tcls_mem_dll_agame cs_dll_agame=(tcls_mem_dll_agame)Marshal.PtrToStructure(new IntPtr(int.Parse(dts[1])),typeof(tcls_mem_dll_agame)); if(cs_dll_agame.gzcs_big == null) break; log("----------initdll_agame-------"); cs_dll_agame.gz= (Tr_MJGZ)funs.instance.clone(cs_main_agame.gz);// (Tr_MJGZ)baseFuntion. Clone( cs_main_agame.gz); log("----------init-------"); ab= new ABlock(); myCom_zyx.Instance.getDataOfStruct(int.Parse(dts[2]), ref ab,(int*)&ab); //Debug.Log("abc"); result=mjchild.instance.initDll_agame(ref cs_main_agame,ref cs_dll_agame , ref ab,int.Parse(dts[3])).ToString(); //Debug.Log("ccc"); break; } break; } return result; }catch(Exception e){ string _path = "d:\\123.txt"; if(!File.Exists(_path)){ File.Create(_path); } FileStream fs = new FileStream(_path,FileMode.Append); log(e.ToString()); string _logs = e.ToString() +"\r\n" +System.DateTime.Now.ToString() + "\r\n"; byte[] bts = System.Text.Encoding.GetEncoding("GB2312").GetBytes(_logs.ToCharArray()); fs.Write(bts,0,bts.Length); fs.Dispose(); fs.Close(); return null; } } } }