feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) + game logic (GameFix/GameDAL/ServerData) + network layer (NetWorkMessage) + data layer (ObjectModel) + utilities (MrWu/Core/Config/CloudAPI/dll) + adapters (zyxAdapter/base) .NET 8.0 C# solution, 16 projects, 958 source files
This commit is contained in:
137
base/Form1.Designer.cs
generated
Normal file
137
base/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2017/3/11
|
||||
* 时间: 14:09
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
namespace nativeCom
|
||||
{
|
||||
partial class Formzyx
|
||||
{
|
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.TextBox textBox4;
|
||||
private System.Windows.Forms.TextBox textBox3;
|
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the form.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing) {
|
||||
if (components != null) {
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.textBox3 = new System.Windows.Forms.TextBox();
|
||||
this.textBox4 = new System.Windows.Forms.TextBox();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.textBox4);
|
||||
this.tabPage1.Controls.Add(this.textBox3);
|
||||
this.tabPage1.Controls.Add(this.button1);
|
||||
this.tabPage1.Controls.Add(this.button2);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.tabPage1.Size = new System.Drawing.Size(1177, 523);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Log";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(141, 14);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(100, 29);
|
||||
this.button1.TabIndex = 11;
|
||||
this.button1.Text = "show form2";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.Button1Click);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(13, 8);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(100, 29);
|
||||
this.button2.TabIndex = 2;
|
||||
this.button2.Text = "test";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.Button2Click);
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Location = new System.Drawing.Point(16, 15);
|
||||
this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(1185, 552);
|
||||
this.tabControl1.TabIndex = 10;
|
||||
//
|
||||
// textBox3
|
||||
//
|
||||
this.textBox3.Location = new System.Drawing.Point(13, 44);
|
||||
this.textBox3.Multiline = true;
|
||||
this.textBox3.Name = "textBox3";
|
||||
this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBox3.Size = new System.Drawing.Size(990, 208);
|
||||
this.textBox3.TabIndex = 13;
|
||||
//
|
||||
// textBox4
|
||||
//
|
||||
this.textBox4.Location = new System.Drawing.Point(13, 272);
|
||||
this.textBox4.Multiline = true;
|
||||
this.textBox4.Name = "textBox4";
|
||||
this.textBox4.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBox4.Size = new System.Drawing.Size(990, 136);
|
||||
this.textBox4.TabIndex = 14;
|
||||
//
|
||||
// Formzyx
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1408, 616);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.Name = "Formzyx";
|
||||
this.Text = "Form1";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1FormClosing);
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormzyxFormClosed);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage1.PerformLayout();
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
142
base/Form1.cs
Normal file
142
base/Form1.cs
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2017/3/11
|
||||
* 时间: 14:09
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using zyxDll;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace nativeCom
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Description of Form1.
|
||||
/// </summary>
|
||||
public partial class Formzyx : Form
|
||||
{
|
||||
|
||||
[DllImport("HjhaServer_dll.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
|
||||
public static extern int testfun(ref tr_test t );
|
||||
|
||||
static Formzyx _fmzyx=null;
|
||||
public static Formzyx fmzyx{get{if(_fmzyx==null){_fmzyx=new Formzyx();}return _fmzyx;}}
|
||||
|
||||
|
||||
|
||||
public Formzyx()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
static int logCount = 0;
|
||||
|
||||
public static void log(string str,bool isError=false){
|
||||
if (isError){ error(str); return;}
|
||||
if (logCount>1000){
|
||||
fmzyx.textBox3.Clear();
|
||||
logCount = 0;
|
||||
}
|
||||
fmzyx.textBox3.AppendText(str + "\r\n");
|
||||
logCount ++;
|
||||
|
||||
}
|
||||
static int logCount_error = 0;
|
||||
public static void error(string str){
|
||||
if (logCount_error>1000){
|
||||
fmzyx.textBox4.Clear();
|
||||
logCount_error = 0;
|
||||
}
|
||||
fmzyx.textBox4.AppendText(str + "\r\n");
|
||||
logCount_error ++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsafe void Button1Click(object sender, EventArgs e)
|
||||
{
|
||||
Form fm=baseinfo.instance.dll.fmsub;
|
||||
if (fm==null)return;
|
||||
if (!fm.Visible)
|
||||
fm.Show();else fm.Hide();
|
||||
|
||||
}
|
||||
unsafe void Button2Click(object sender, EventArgs e)
|
||||
{
|
||||
return;
|
||||
tr_test t=new tr_test();t.b=651;
|
||||
ABlock b=new ABlock();
|
||||
|
||||
|
||||
tr_rltpchar sdfsdf=new tr_rltpchar();
|
||||
|
||||
string rlt=null;
|
||||
|
||||
int kjk=baseinfo.instance.exe.gamefun("-1",
|
||||
//"9*3000*"+
|
||||
"kljjklj89"
|
||||
//+"*"+Marshal.SizeOf(t).ToString()
|
||||
, ref sdfsdf,ref b,ref b);
|
||||
sdfsdf.str=null;
|
||||
return;
|
||||
// string ss=null;
|
||||
// ABlock b=new ABlock();
|
||||
// dcEvent_zyx.Instance.gamefuns("0","",ref ss,ref b,ref b);
|
||||
// string s=nativeCom.cls_nativeCom.Instance. getUnmanagedString(ref b);
|
||||
//
|
||||
// log(s);
|
||||
// b.pt=null;
|
||||
// log(ss);
|
||||
//
|
||||
|
||||
|
||||
testfun(ref t);
|
||||
log(t.b.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Form1FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (baseinfo.instance.exe.gamestate>2)return;
|
||||
|
||||
e.Cancel=true;
|
||||
}
|
||||
|
||||
|
||||
void FormzyxFormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
Form fm=baseinfo.instance.dll.fmsub;
|
||||
if (fm==null)return;
|
||||
if(baseinfo.instance.exe.gamestate>2)
|
||||
fm.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
namespace zyxDll
|
||||
{
|
||||
public class FormSub0 : Form{
|
||||
public virtual void init(){}
|
||||
}
|
||||
}
|
||||
120
base/Form1.resx
Normal file
120
base/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
50
base/Form2_base.cs
Normal file
50
base/Form2_base.cs
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2018-03-12
|
||||
* 时间: 15:43
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using zyxDll;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace zyxDll
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Description of Form2.
|
||||
/// </summary>
|
||||
public partial class Form2 : FormSub0
|
||||
{
|
||||
|
||||
protected static Form2 _fmSub=null;
|
||||
public static Form2 fmSub {get{if(_fmSub==null){
|
||||
_fmSub=new Form2();
|
||||
|
||||
}return _fmSub;}}
|
||||
|
||||
|
||||
void Form2FormClosed_(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
void Form2FormClosing_(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (baseinfo.instance.exe.gamestate>2)return;
|
||||
|
||||
e.Cancel=true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
145
base/baseFunction.cs
Normal file
145
base/baseFunction.cs
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2017-08-17
|
||||
* 时间: 14:36
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
|
||||
namespace nativeCom
|
||||
{
|
||||
public interface huMnemonic{
|
||||
void Clear();
|
||||
}
|
||||
|
||||
public static class baseFuntion{
|
||||
|
||||
/// <summary>
|
||||
/// 清空一个int数组
|
||||
/// </summary>
|
||||
/// <param name="array"></param>
|
||||
public static void ClearIntArray(ref int[] array){
|
||||
int len = array.Length;
|
||||
for(int i=0;i<len;i++){
|
||||
array[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 把array1中的值完全拷贝到array2中
|
||||
/// </summary>
|
||||
/// <param name="array1">array1</param>
|
||||
/// <param name="array2">array2</param>
|
||||
/// <param name="idx">从那个开始拷贝</param>
|
||||
public static void CopyArray(ref int[] array1,ref int[] array2,int idx){
|
||||
int length = array1.Length;
|
||||
Array.Copy(array1,0,array2,idx,length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="path"></param>
|
||||
public static void Serizeable(Object obj,string path){
|
||||
// try{
|
||||
FileStream stream = new FileStream(path,FileMode.OpenOrCreate);
|
||||
BinaryFormatter binary = new BinaryFormatter();
|
||||
binary.Serialize(stream,obj);
|
||||
stream.Close();
|
||||
stream.Dispose();
|
||||
// }catch(Exception e){
|
||||
// Form1.log("序列化失败:" + e.ToString());
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static Object DeSerizeable(string path){
|
||||
if(!File.Exists(path))
|
||||
return null;
|
||||
// try{
|
||||
FileStream stream = new FileStream(path,FileMode.Open);
|
||||
BinaryFormatter binary = new BinaryFormatter();
|
||||
Object obj = binary.Deserialize(stream);
|
||||
stream.Close();
|
||||
stream.Dispose();
|
||||
return obj;
|
||||
// }catch(Exception e){
|
||||
// Form1.log("反序列化失败:" + e.ToString());
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化到内存流
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static MemoryStream Serizeable(Object obj){
|
||||
MemoryStream ms = null;
|
||||
// try{
|
||||
ms = new MemoryStream();
|
||||
BinaryFormatter binary = new BinaryFormatter();
|
||||
binary.Serialize(ms,obj);
|
||||
// }catch(Exception e){
|
||||
// Form1.log("序列化到内存失败:" + e.ToString());
|
||||
// }
|
||||
return ms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化内存流
|
||||
/// </summary>
|
||||
/// <param name="ms"></param>
|
||||
/// <returns></returns>
|
||||
public static Object DeSerizeable(MemoryStream ms){
|
||||
ms.Position = 0;
|
||||
Object obj;
|
||||
// try{
|
||||
BinaryFormatter binary = new BinaryFormatter();
|
||||
obj = binary.Deserialize(ms);
|
||||
// }catch(Exception e){
|
||||
// Form1.log("内存反序列化失败:" + e.ToString());
|
||||
// return null;
|
||||
// }
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 克隆
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static Object Clone(Object obj){
|
||||
|
||||
MemoryStream ms = Serizeable(obj);
|
||||
|
||||
Object tmp = DeSerizeable(ms);
|
||||
ms.Close();
|
||||
ms.Dispose();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符数装数字
|
||||
/// </summary>
|
||||
/// <param name="ch">0-9</param>
|
||||
/// <returns></returns>
|
||||
public static sbyte charToInt(this char ch){
|
||||
return (sbyte)(ch-48);
|
||||
}
|
||||
}
|
||||
}
|
||||
294
base/event0.cs
Normal file
294
base/event0.cs
Normal file
@ -0,0 +1,294 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2018-03-12
|
||||
* 时间: 16:24
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using zyxAdapter;
|
||||
using MrWu.Debug;
|
||||
|
||||
|
||||
namespace nativeCom {
|
||||
|
||||
|
||||
public class dcEvent_zyx0 {
|
||||
|
||||
public virtual void init() {
|
||||
log("zyxevent init...");
|
||||
// dg_zyxfun dg=new dg_zyxfun( doMsg_fun);
|
||||
|
||||
}
|
||||
public void log(string str, bool isError = false) {
|
||||
if (isError)
|
||||
MrWu.Debug.Debug.Error(str);
|
||||
else
|
||||
MrWu.Debug.Debug.Log(str);
|
||||
|
||||
}
|
||||
|
||||
public virtual myGameClassBase newobj(ref tr_rltpchar t) { return null; }
|
||||
|
||||
/// <summary>
|
||||
/// c# dll过程入口
|
||||
/// </summary>
|
||||
/// <param name="dowhat"></param>
|
||||
/// <param name="datas"></param>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
unsafe public virtual int doMsg_rukou(string dowhat/*^分割*/, string datas/*结构体地址 ^分割*/, ref tr_rltpchar t) {
|
||||
// Thread.Sleep(10000);
|
||||
// return 1;
|
||||
myGameClassBase mc = null;
|
||||
string[] ss = datas.Split('*');//
|
||||
//ss[0] myclass
|
||||
switch (ss[1]) {
|
||||
case "dotimer":
|
||||
case "init_deskmem":
|
||||
break;
|
||||
default: log(dowhat + " " + datas); break;
|
||||
}
|
||||
|
||||
|
||||
bool initedmem = true;
|
||||
switch (ss[1]) {
|
||||
case "init_deskmem":
|
||||
if (ss[2] == "0")
|
||||
initedmem = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (initedmem)
|
||||
mc = myGameObj.getObj(ss[0]) as myGameClassBase;
|
||||
else {
|
||||
mc = newobj(ref t);
|
||||
|
||||
}
|
||||
Igamedo ido = mc as Igamedo;
|
||||
if (ido != null) {
|
||||
|
||||
if (!initedmem)
|
||||
ido.i_do_initMem(false);
|
||||
|
||||
switch (ss[1]) {
|
||||
case "init_deskmem":
|
||||
if (ss[2] == "1") {
|
||||
ido.i_do_initMem(true);
|
||||
mc.releaseAddr();//!!!!必须
|
||||
} else {
|
||||
|
||||
}
|
||||
// mc.do_initmem(true);
|
||||
break;
|
||||
case "startwar":
|
||||
ido.i_do_startWar();
|
||||
break;
|
||||
case "reconnect"://ss[2] 谁id重连
|
||||
ido.i_do_reconect();
|
||||
break;
|
||||
case "dopack":
|
||||
|
||||
|
||||
|
||||
int len = int.Parse(ss[3]);
|
||||
byte[] data = new byte[len];
|
||||
IntPtr ptr = new IntPtr(int.Parse(ss[2]));
|
||||
|
||||
|
||||
Marshal.Copy(ptr, data, 0, len);
|
||||
|
||||
int evt;
|
||||
object obj = cls_nativeCom.Instance.DeSerizeable_obj_withEvt(data, out evt);
|
||||
|
||||
ido.i_do_pack(obj, evt);
|
||||
|
||||
//test发包回去
|
||||
|
||||
//mc.sendpack(obj,84524);
|
||||
|
||||
data = null;
|
||||
break;
|
||||
case "dotimer":
|
||||
|
||||
ido.i_do_timer();
|
||||
break;
|
||||
case "doOthers":
|
||||
switch (ss[2]) {
|
||||
case "setdata_dapai":
|
||||
len = int.Parse(ss[6]);
|
||||
|
||||
ptr = new IntPtr(int.Parse(ss[5]));
|
||||
|
||||
|
||||
// data=new byte[len];
|
||||
// Marshal.Copy(ptr,data,0,len);
|
||||
// ido.i_getData(data);
|
||||
//
|
||||
// break;
|
||||
string str = Marshal.PtrToStringAnsi(ptr);
|
||||
ido.i_getData(str);
|
||||
// IntPtr init = Marshal.StringToHGlobalAnsi(textBox1.Text);
|
||||
//
|
||||
//textBox2.Text = Marshal.PtrToStringAnsi(outit);
|
||||
//
|
||||
//Marshal.FreeHGlobal(outit);
|
||||
break;
|
||||
case "getdata_dapai":
|
||||
ido.i_setData(ref t);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}//返回string/*^分割*/
|
||||
/// <summary>
|
||||
/// 吴龙剑麻将函数(delphi dll调用)
|
||||
/// </summary>
|
||||
/// <param name="dowhat"></param>
|
||||
/// <param name="datas"></param>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
unsafe public int doMsg_fun(string dowhat/*^分割*/, string datas/*结构体地址 ^分割*/, ref tr_rltpchar t)//返回string/*^分割*/
|
||||
{
|
||||
switch (dowhat) {
|
||||
case "Log":
|
||||
MrWu.Debug.Debug.Log("exe log: " + datas, false);
|
||||
break;
|
||||
case "errorLog":
|
||||
|
||||
MrWu.Debug.Debug.Error("exe wrong: " + datas, true);
|
||||
break;
|
||||
case "zyxfun":
|
||||
string[] ss = datas.Split('~');
|
||||
t.str = "slkfj234";
|
||||
t.str = doMsg(ss[0], ss[1]);
|
||||
if (t.str == null || t.str == "" || t.str == " ")
|
||||
log("wrong sdf", true);
|
||||
break;
|
||||
default:
|
||||
log("wrong ...sdfsd", true);
|
||||
break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsafe public string doMsg_other(string dowhat/*^分割*/, string datas/*结构体地址 ^分割*/)//返回string/*^分割*/
|
||||
{
|
||||
|
||||
|
||||
|
||||
string result = "";
|
||||
string[] dts = null;
|
||||
if (datas != null) dts = datas.Split('^');
|
||||
string[] dostr = dowhat.Split('^');
|
||||
|
||||
string[] cmds = dostr[0].Split('*');
|
||||
// if (cls_nativeCom.showlog && cmds[0]!="dotimer")
|
||||
// log("domsg = "+dowhat+" "+datas);
|
||||
switch (cmds[0]) {
|
||||
case "changeText":
|
||||
MrWu.Debug.Debug.Log("changeText:" + cmds[1]);
|
||||
break;
|
||||
case "terminate":
|
||||
MrWu.Debug.Debug.Error("切换游戏状态");
|
||||
// baseinfo.instance.exe.gamestate = 4;
|
||||
//log("termainte self...");
|
||||
// this.timer1.Enabled=true;
|
||||
break;
|
||||
case "serstate":
|
||||
MrWu.Debug.Debug.Error("切换游戏状态:");
|
||||
//baseinfo.instance.exe.gamestate = int.Parse(cmds[1]);
|
||||
break;
|
||||
case "showcsharpdllform":
|
||||
MrWu.Debug.Debug.Log("显示dll窗口!");
|
||||
/*
|
||||
Form fmdll = baseinfo.instance.dll.fm;
|
||||
if (fmdll == null) break;
|
||||
if (cmds[1] == "1") {
|
||||
|
||||
fmdll.Show();
|
||||
} else {
|
||||
if (baseinfo.instance.exe.gamestate == 3) {
|
||||
|
||||
fmdll.Close();
|
||||
} else {
|
||||
if (baseinfo.instance.dll.fmsub != null)
|
||||
baseinfo.instance.dll.fmsub.Hide();
|
||||
fmdll.Hide();
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
break;
|
||||
|
||||
case "yasuo":
|
||||
ABlock ablockTmp = new ABlock();
|
||||
cls_nativeCom.Instance.getDataOfStruct<ABlock>(int.Parse(dts[0]), ref ablockTmp, (int*)&ablockTmp);
|
||||
ABlock ablockTmp1 = new ABlock();
|
||||
cls_nativeCom.Instance.getDataOfStruct<ABlock>(int.Parse(dts[1]), ref ablockTmp1, (int*)&ablockTmp1);
|
||||
// log("xxxx "+ablockTmp.len+" "+ablockTmp1.len);
|
||||
if (cmds[1][0] == '1') result = cls_nativeCom.Instance.Compress(ref ablockTmp, ref ablockTmp1).ToString();
|
||||
else
|
||||
result = cls_nativeCom.Instance.deCompress(ref ablockTmp, ref ablockTmp1).ToString();
|
||||
//log("xxxx xxx "+ablockTmp.len+" "+ablockTmp1.len);
|
||||
break;
|
||||
case "gameClose":
|
||||
return "closeOk";//必须
|
||||
case "dopack_ser"://收包
|
||||
|
||||
int regid_ = int.Parse(dostr[1]);
|
||||
int blx_ = int.Parse(dostr[2]);//包类型--编号
|
||||
int addr_mainpack = int.Parse(dts[0]);//包内容
|
||||
break;
|
||||
// case "dopack"://收包
|
||||
//
|
||||
// int blx=int.Parse(dostr[2]);//包类型--编号
|
||||
// int dataAddr=int.Parse(dostr[3]);//数据地址
|
||||
// int dataSize=int.Parse(dostr[4]);//数据大小
|
||||
// int regid=int.Parse(dostr[5]);//谁发的包
|
||||
// int addr_player=int.Parse(dostr[6]);//谁的地址
|
||||
//
|
||||
//
|
||||
//
|
||||
// switch (blx){//40000~99999给c#新启用
|
||||
// case 50000://test
|
||||
// string str1=myCom.Instance. getUnmanagedString(dataAddr,dataSize);
|
||||
// log(blx+" "+str1);
|
||||
// break;
|
||||
// case 50001:
|
||||
// stu_test st = new stu_test();
|
||||
// myCom.Instance.getDataOfStruct(dataAddr, ref st,(int*)&st);
|
||||
// log(blx+" "+st.b+"");
|
||||
// break;
|
||||
//// case 50002:
|
||||
//// mytestCls1 cls=(mytestCls1)myCom.Instance.getDataOfClass(dataAddr,dataSize);
|
||||
//// log(blx+" "+cls.b+"");
|
||||
//// break;
|
||||
//
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
static int errorIdx;
|
||||
unsafe public virtual string doMsg(string dowhat/*^分割*/, string datas/*结构体地址 ^分割*/)//返回string/*^分割*/
|
||||
{ return "defautSTR"; }
|
||||
}
|
||||
}
|
||||
87
base/funs.cs
Normal file
87
base/funs.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using nativeCom;
|
||||
|
||||
public class funs{
|
||||
static funs _ins;
|
||||
public static funs instance{get{if(_ins==null)_ins=new funs();return _ins;}set{_ins=value;}}
|
||||
|
||||
public byte[] StructToBytes(object structObj)
|
||||
{
|
||||
int size = Marshal.SizeOf(structObj);
|
||||
IntPtr buffer = Marshal.AllocHGlobal(size);
|
||||
try
|
||||
{
|
||||
Marshal.StructureToPtr(structObj, buffer, false);
|
||||
byte[] bytes = new byte[size];
|
||||
Marshal.Copy(buffer, bytes, 0, size);
|
||||
return bytes;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe public object clone(object obj){
|
||||
|
||||
byte[] bt=StructToBytes(obj);
|
||||
fixed(byte* pb=bt ){
|
||||
IntPtr itp=new IntPtr(pb);
|
||||
|
||||
return Marshal.PtrToStructure(itp, obj.GetType());
|
||||
}
|
||||
|
||||
}
|
||||
ABlock a1=new ABlock();
|
||||
ABlock a2=new ABlock();
|
||||
/// <summary>
|
||||
/// 把bt总的数值 写入到ab指针中 偏移ofs个值
|
||||
/// </summary>
|
||||
/// <param name="bt"></param>
|
||||
/// <param name="ab"></param>
|
||||
/// <param name="ofs"></param>
|
||||
|
||||
unsafe public void memToNative_bytes(byte[] bt,ref ABlock ab,int ofs){
|
||||
fixed(byte* pb=bt ){
|
||||
IntPtr pt= new IntPtr( (int)ab.pt+ofs);
|
||||
|
||||
NativeDllMethod.nativefun("1",((int)pb ).ToString()+'*'+pt.ToString()+'*'+bt.Length.ToString(),ref a1,ref a2);
|
||||
//
|
||||
// myCom_zyx.Instance.move2Process((int*)pb,new IntPtr( (int)ab.pt+ofs),bt.Length);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsafe public void memToNative_bytes_(byte[] bt,int addr_){
|
||||
ABlock ab= new ABlock();
|
||||
int* ttt=(int*)&ab;
|
||||
myCom_zyx.Instance.getDataOfStruct<ABlock>(addr_, ref ab,ttt);
|
||||
memToNative_bytes(bt,ref ab,0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取服务器所在的路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string getSeverPath(){
|
||||
return Application.StartupPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取服务规则路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string getGzPath(){ //待换
|
||||
return getSeverPath() + "/mjgz.xml";
|
||||
}
|
||||
}
|
||||
141
base/mj.cs
Normal file
141
base/mj.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.IO;
|
||||
using nativeCom;
|
||||
|
||||
//吴龙剑先完成这个单元 !!!
|
||||
public class mj:mjbase{
|
||||
|
||||
|
||||
bool isTmp=true;
|
||||
public bool fun_menqing(int hpr){//查引用 看范例
|
||||
mainDo("门清",new int[]{hpr},null);
|
||||
return getvalue_int(0)>0;
|
||||
}
|
||||
public int fun_lingpai(){
|
||||
mainDo("零牌",null,null);
|
||||
return getvalue_int(0);
|
||||
}
|
||||
public int fun_lingpaiSty(){
|
||||
mainDo("零牌类型",null,null);
|
||||
return getvalue_int(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加临时番
|
||||
/// </summary>
|
||||
/// <param name="fans"></param>
|
||||
public void fun_addTempFan(int[] fans){
|
||||
mainDo("临时番",fans,null);
|
||||
}
|
||||
/// <summary>
|
||||
/// 上把庄家
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int fun_lastZj(){
|
||||
mainDo("上把庄家",null,null);
|
||||
return getvalue_int(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取庄家ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int fun_zjUserID(){
|
||||
mainDo("庄家",null,null);
|
||||
return getvalue_int(0);
|
||||
}
|
||||
|
||||
public void fun_addTempFan_qianlouzi(int[] fans,bool canju,bool writetmp){
|
||||
sbyte[] bts=new sbyte[2];
|
||||
if(canju) bts[0]=1;else bts[0]=0;
|
||||
if(writetmp) bts[1]=1;else bts[1]=0;
|
||||
mainDo("钱娄子",fans,bts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
-----麻将----
|
||||
55: begin //增加杠 谁 牌 类型(0..2 <-10则等于-n-10 -1则等于杠上精 放杠人[0..1有效])
|
||||
C_lg.addgang_qian(pb[0][0], pb[0][1], pb[0][2], pb[0][3]);
|
||||
end;
|
||||
56: begin //删除杠 谁 牌 新分数【-1一定删 否则和老分数比较、大于老的才删】
|
||||
C_lg.delgang_qian(pb[0][0], pb[0][1], pb[0][2]);
|
||||
end;
|
||||
57: begin //牌是否杠
|
||||
p[4][0] := 0;
|
||||
if c_lg.paiisgang(pb[0][0], pb[0][1]) then
|
||||
p[4][0] := 1;
|
||||
end;
|
||||
*
|
||||
**/
|
||||
|
||||
/// <summary>
|
||||
/// 默认值sty = -1 fan = -1
|
||||
/// </summary>
|
||||
/// <param name="who"></param>
|
||||
/// <param name="pai"></param>
|
||||
/// <param name="sty"></param>
|
||||
/// <param name="fan"></param>
|
||||
public void fun_jiagang(int who,int pai,int sty,int fan){
|
||||
sbyte[] bts=new sbyte[4];
|
||||
bts[0]=(sbyte) who;
|
||||
bts[1]=(sbyte) pai;
|
||||
bts[2]=(sbyte) sty;
|
||||
bts[3]=(sbyte) fan;
|
||||
//log("加杠:" + who + "," + pai + "," + sty + "," + fan);
|
||||
mainDo("增加杠",null,bts);
|
||||
}
|
||||
public void fun_delgang(int who,int pai,int fengValue){
|
||||
sbyte[] bts=new sbyte[3];
|
||||
bts[0]=(sbyte) who;bts[1]=(sbyte) pai;
|
||||
bts[2] =(sbyte)fengValue;
|
||||
mainDo("删除杠",null,bts);
|
||||
}
|
||||
public int fun_paiIsGang(int who,int pai){
|
||||
sbyte[] bts=new sbyte[2];
|
||||
bts[0]=(sbyte) who;
|
||||
bts[1]=(sbyte) pai;
|
||||
mainDo("牌是否杠",null,bts);
|
||||
return getvalue_int(0);
|
||||
}
|
||||
|
||||
public byte[] fun_lajipai(sbyte[] pais,int who,int penglvl){//查引用 看范例
|
||||
mainDo("垃圾牌",new int[]{who,penglvl},pais);
|
||||
byte[] r= getvalue_byteArr(1,getvalue_byte(0));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
//视觉上,左面的剩余牌张 0..PlayerCount-1表示双方不透视 PlayerCountMax表示全透视(想赢钱的鬼)
|
||||
public int fun_paiCnt_lose(int pai,int apos){
|
||||
mainDo("剩余牌",new int[]{pai,apos},null);
|
||||
return getvalue_int(0);
|
||||
}
|
||||
|
||||
//---------------------从这里开始 把所有需求,直接按逻辑罗列。。。 ----------------------
|
||||
public int[] fun_test(int a,int b){
|
||||
if(isTmp)return new int[]{3,4,5,2};
|
||||
mainDo("吴龙剑描述",new int[]{a,b},null);
|
||||
return new int[]{ getvalue_int(0),getvalue_int(1),getvalue_int(2),getvalue_int(3)};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取放炮人
|
||||
/// </summary>
|
||||
/// <param name="pack"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int getFangPaoMan(int fangpaonew){
|
||||
if(fangpaonew >= 10)
|
||||
return fangpaonew - 10;
|
||||
return fangpaonew;
|
||||
}
|
||||
}
|
||||
253
base/mjComEvent.cs
Normal file
253
base/mjComEvent.cs
Normal file
@ -0,0 +1,253 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using zyxAdapter;
|
||||
|
||||
namespace nativeCom {
|
||||
|
||||
|
||||
public partial class dcEvent_zyx : dcEvent_zyx0 {
|
||||
static dcEvent_zyx _instance;
|
||||
public static dcEvent_zyx Instance {
|
||||
get {
|
||||
if (_instance == null) {
|
||||
_instance = new dcEvent_zyx();
|
||||
|
||||
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
public dcEvent_zyx() {
|
||||
_instance = this;
|
||||
//_instance.init();
|
||||
}
|
||||
|
||||
public override void init() {
|
||||
base.init();
|
||||
|
||||
//Form2.fmSub.init();
|
||||
//baseinfo.instance.dll.fun=doMsg_fun;
|
||||
//baseinfo.instance.dll.rukou=doMsg_rukou;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调用gamefun -- 调试用的
|
||||
/// </summary>
|
||||
/// <param name="dowhat"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <param name="rlt"></param>
|
||||
/// <param name="dataEx"></param>
|
||||
/// <param name="result"></param>
|
||||
public int TestGameFun(string dowhat, string param, ref tr_rltpchar rlt, ref nativeCom.ABlock dataEx, ref nativeCom.ABlock result) {
|
||||
//MrWu.Debug.Debug.Error("GameFun:" + dowhat + "," + param);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface Igamedo {
|
||||
|
||||
void i_do_pack(object obj, int evt);
|
||||
void i_do_initMem(bool isfree);
|
||||
void i_do_startWar();
|
||||
void i_do_timer();
|
||||
void i_do_reconect();
|
||||
void i_setData(ref tr_rltpchar t);
|
||||
// void i_getData(byte[] bts);
|
||||
void i_getData(string str);
|
||||
}
|
||||
public class myGameClassBase : myGameObj {
|
||||
public static string teststrs;
|
||||
tr_rltpchar rlt = new tr_rltpchar();
|
||||
ABlock ab = new ABlock();
|
||||
Igamedo igamedo { get { return this as Igamedo; } }
|
||||
public myGameClassBase(ref tr_rltpchar t) {
|
||||
t.str = getAddr.ToString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//----------------数据--------------
|
||||
/// <summary>
|
||||
///座位总数 拿这个循环 中途可能有人先结算
|
||||
/// </summary>
|
||||
public int seatCnts;
|
||||
/// <summary>
|
||||
/// 开战中否
|
||||
/// </summary>
|
||||
public bool isFighting { get; set; }//自己控制,不需要问底层
|
||||
// {
|
||||
// return baseinfo.instance.exe.gamefun("-1","6*-1*-1*5", ref rlt,ref ab,ref ab)==1;
|
||||
// }
|
||||
// }
|
||||
|
||||
//-------------------过程或属性---------------------
|
||||
/// </summary>
|
||||
/// <param name="获取某座位的玩家ID"></param>
|
||||
/// <returns></returns>
|
||||
public int getUserId(int seat) {
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "2*" + seat, ref rlt, ref ab, ref ab);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结算
|
||||
/// </summary>
|
||||
/// <param name="seat"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="sifangFinal 私房有效 0增量 1最终"></param>
|
||||
public void setFan(int seat, int value, int sifangFinal = 0) {
|
||||
|
||||
int id = getUserId(seat); setFan_id(id, value, sifangFinal);
|
||||
// int lx=2;
|
||||
//
|
||||
// if (isSifang)
|
||||
// lx=8+sifangFinal;
|
||||
//
|
||||
// baseinfo.instance.exe.gamefun("-1","11*"+id.ToString()+"*"+lx.ToString()+"*"+value.ToString(), ref rlt,ref ab,ref ab);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结算
|
||||
/// </summary>
|
||||
/// <param name="seat"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="sifangFinal 私房有效 0增量 1最终"></param>
|
||||
public void setFan_id(int id, int value, int sifangFinal = 0) {
|
||||
// int id=getUserId(seat);
|
||||
int lx = 2;
|
||||
|
||||
if (isSifang)
|
||||
lx = 8 + sifangFinal;
|
||||
|
||||
|
||||
dcEvent_zyx.Instance.TestGameFun("-1", "11*" + id.ToString() + "*" + lx.ToString() + "*" + value.ToString(), ref rlt, ref ab, ref ab);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//提前结算--》可以离开桌子了
|
||||
public void tiqianJieSuan(int seat) {
|
||||
int id = getUserId(seat);
|
||||
tiqianJieSuan_id(id);
|
||||
dcEvent_zyx.Instance.TestGameFun("-1", "11*" + id.ToString() + "*10*0", ref rlt, ref ab, ref ab);
|
||||
}
|
||||
//提前结算--》可以离开桌子了
|
||||
public void tiqianJieSuan_id(int id) {
|
||||
// int id=getUserId(seat);
|
||||
dcEvent_zyx.Instance.TestGameFun("-1", "11*" + id.ToString() + "*10*0", ref rlt, ref ab, ref ab);
|
||||
}
|
||||
public void tiqianXiaZhuo_id(int id) {
|
||||
// int id=getUserId(seat);
|
||||
dcEvent_zyx.Instance.TestGameFun("-1", "11*" + id.ToString() + "*11*0", ref rlt, ref ab, ref ab);
|
||||
}
|
||||
public int warOver() {
|
||||
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "10", ref rlt, ref ab, ref ab);
|
||||
}
|
||||
public bool isGui_id(int id) {
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "4*" + id.ToString() + "*5", ref rlt, ref ab, ref ab) == 1;
|
||||
}
|
||||
public bool isTiqianJiesuan_id(int id) {
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "4*" + id.ToString() + "*20", ref rlt, ref ab, ref ab) == 1;
|
||||
}
|
||||
public string teststr() {
|
||||
int addr = dcEvent_zyx.Instance.TestGameFun("-1", "14*1*2", ref rlt, ref ab, ref ab);//获取pchar地址
|
||||
NativeDllMethod.nativefun("2", addr.ToString(), ref ab, ref ab);//pchar装入ab结构体
|
||||
return cls_nativeCom.Instance.getUnmanagedString(ref ab);//ab结构体转string
|
||||
}
|
||||
public bool canPlay(int seat) {
|
||||
return !isEmptySeat(seat) && !isTiqianJiesuan_id(getUserId(seat));
|
||||
}
|
||||
unsafe public int yasuo(byte[] src, byte[] dst, int len, int sty) {
|
||||
|
||||
fixed (byte* p1 = src) {
|
||||
fixed (byte* p2 = dst) {
|
||||
// ABlock sdfsdf;
|
||||
// sdfsdf.pt=(int*)p1;
|
||||
// sdfsdf.len=len;
|
||||
// nativeCom.cls_nativeCom.Instance.
|
||||
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "21*" + sty.ToString() + "*" + ((int)p1).ToString() + "*" + ((int)p2).ToString() + "*" + len.ToString(), ref rlt, ref ab, ref ab);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
unsafe public void sendPack(object obj, int evt, int userId = -1) {
|
||||
|
||||
|
||||
byte[] data = cls_nativeCom.Instance.Serizeable_obj_withEvt(obj, evt);
|
||||
fixed (byte* bt = data) {
|
||||
|
||||
int i = (int)(int*)bt;
|
||||
dcEvent_zyx.Instance.TestGameFun("-1", "9*" + userId.ToString() + '*' + i.ToString() + '*' + data.Length,
|
||||
ref rlt, ref ab, ref ab);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否socket在线 不是玩家是否登录了游戏
|
||||
/// </summary>
|
||||
/// <param name="seat"></param>
|
||||
/// <returns></returns>
|
||||
public bool isOnline(int seat) {
|
||||
int id = getUserId(seat);
|
||||
MrWu.Debug.Debug.Info("玩家是否在线!!!");
|
||||
return false;
|
||||
/*
|
||||
if (id < 0) return false;
|
||||
return baseinfo.instance.exe.gamefun("-1", "4*" + id + "*3", ref rlt, ref ab, ref ab) != 1;
|
||||
*/
|
||||
}
|
||||
public bool isOnline_id(int id) {
|
||||
// int id=getUserId(seat);
|
||||
if (id < 0) return false;
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "4*" + id + "*3", ref rlt, ref ab, ref ab) != 1;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否空座位
|
||||
/// </summary>
|
||||
/// <param name="seat"></param>
|
||||
/// <returns></returns>
|
||||
public bool isEmptySeat(int seat) {
|
||||
return getUserId(seat) < 0;
|
||||
}
|
||||
public bool isSifang { get { return dcEvent_zyx.Instance.TestGameFun("-1", "13*6*-1", ref rlt, ref ab, ref ab) != -1; } }
|
||||
|
||||
public int getSifangInfo(int sty) {
|
||||
return dcEvent_zyx.Instance.TestGameFun("-1", "13*6*2*" + sty.ToString(), ref rlt, ref ab, ref ab);
|
||||
}
|
||||
//---------
|
||||
|
||||
public void log(string str, bool isError = false) {
|
||||
if(isError)
|
||||
MrWu.Debug.Debug.Error(str);
|
||||
else
|
||||
MrWu.Debug.Debug.Log(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getSeatCnts { get { return dcEvent_zyx.Instance.TestGameFun("-1", "6*-1*-1*6", ref rlt, ref ab, ref ab); } }
|
||||
//--------
|
||||
public void savePaiju() {
|
||||
dcEvent_zyx.Instance.TestGameFun("-1", "15", ref rlt, ref ab, ref ab);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
195
base/mjComEvent_sub.cs
Normal file
195
base/mjComEvent_sub.cs
Normal file
@ -0,0 +1,195 @@
|
||||
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<ABlock>(int.Parse(dts[0]), ref ablockTmp,(int*)&ablockTmp);
|
||||
ABlock ablockTmp1= new ABlock();
|
||||
myCom_zyx.Instance.getDataOfStruct<ABlock>(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<ABlock>(, 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<ABlock>(, 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<ABlock>(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<ABlock>(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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
339
base/mj_.cs
Normal file
339
base/mj_.cs
Normal file
@ -0,0 +1,339 @@
|
||||
using System;
|
||||
using nativeCom;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using MrWu.Configuration;
|
||||
using System.Xml;
|
||||
using Game.Data;
|
||||
|
||||
public class mj_ : mj {
|
||||
|
||||
public static mj_ instance;
|
||||
|
||||
protected virtual int playerCnt {
|
||||
get {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public virtual void hufan_ut(){
|
||||
//hpr fangpaonew fanidx pk.zjpos;
|
||||
int hpr;
|
||||
int fangpaonew;
|
||||
int zjpos;
|
||||
|
||||
int[] fangpaos = new int[]{
|
||||
-1,0,1,2,3,10,11,12,13
|
||||
};
|
||||
|
||||
for(int i=0;i<playerCnt+1;i++){ //胡牌人
|
||||
hpr = i-1;
|
||||
for(int j=0;j<playerCnt;j++){ //庄家
|
||||
zjpos = j;
|
||||
int len = fangpaos.Length;
|
||||
for(int k=0;k<len;k++){ //放炮人
|
||||
fangpaonew = fangpaos[k];
|
||||
tr_pack_dapai pack = new tr_pack_dapai();
|
||||
tr_pack_dapai.init(ref pack);
|
||||
Tr_faninfo fan = new Tr_faninfo();
|
||||
Tr_faninfo.init(ref fan);
|
||||
setfanidx();
|
||||
int mlen = fanidx.Length;
|
||||
|
||||
//calFan_hupai(ref pk,
|
||||
//cal_hupai(ref pack,ref fan,hpr,fangpaonew,11,1111,)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//int[count][idx][id]
|
||||
|
||||
/// <summary>
|
||||
/// 排列组合 根据几个获取数组
|
||||
/// </summary>
|
||||
public int[][] pailiezuhe_count(int count){
|
||||
int[][] duilie = new int[count][];
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以idx开头的数组
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
public int[] pailiezuhe_startIdx(int StartIdx,int count){
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Startidx开头的第x个
|
||||
/// </summary>
|
||||
/// <param name="idx"></param>
|
||||
/// <param name="StratIdx"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <returns></returns>
|
||||
public int pailiezhuhe_startIdx_idx(int idx,int StratIdx,int count){
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected MemoryStream gzObj;
|
||||
|
||||
/// <summary>
|
||||
/// 解析麻将子游戏规则
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
public virtual void setZyxGz(ref tcls_mem_dll_agame now) { }
|
||||
|
||||
/// <summary>
|
||||
/// 获取规则
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="gz"></param>
|
||||
unsafe protected void getGz(int address, out Tr_MJGZ gz) {
|
||||
ABlock ab = new ABlock();
|
||||
myCom_zyx.Instance.getDataOfStruct<ABlock>(address, ref ab, (int*)&ab);
|
||||
IntPtr ptr = new IntPtr((int)ab.pt + 100);
|
||||
gz = (Tr_MJGZ)Marshal.PtrToStructure(ptr, typeof(Tr_MJGZ));
|
||||
}
|
||||
|
||||
unsafe protected void getGz(int address, ref ABlock ab, out Tr_MJGZ gz) {
|
||||
IntPtr ptr = new IntPtr((int)ab.pt + 100);
|
||||
gz = (Tr_MJGZ)Marshal.PtrToStructure(ptr, typeof(Tr_MJGZ));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置规则
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
unsafe public override void setGz(ref tcls_mem_dll_agame now, int memoryAddress) {
|
||||
MrWu.Debug.Debug.Info("读取规则!");
|
||||
|
||||
//解析通用规则
|
||||
if (now.isLibrary == 0) { //测试取测试的
|
||||
//now.gz = Form2.fmSub.gzTest;
|
||||
log("读取测试规则!");
|
||||
return;
|
||||
}
|
||||
|
||||
//第一步硬盘读文件
|
||||
if (gzObj == null) {
|
||||
string gzPath = funs.instance.getGzPath();
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(gzPath);
|
||||
Object tmp = (Tr_MJGZ)Configuration.LoadConfiguration(typeof(Tr_MJGZ), doc.DocumentElement);
|
||||
|
||||
// MrWu.Debug.Debug.Log("反序列化:");
|
||||
//Object tmp = baseFuntion.DeSerizeable(gzPath);
|
||||
// MrWu.Debug.Debug.Log("反序列化之后!");
|
||||
gzObj = baseFuntion.Serizeable(tmp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
now.gz = (Tr_MJGZ)baseFuntion.DeSerizeable(gzObj);
|
||||
|
||||
if (now.gzcs_big != null) {
|
||||
|
||||
string stt = "";
|
||||
int len = now.gzcs_big.Length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
stt += now.gzcs_big[i];
|
||||
};
|
||||
|
||||
MrWu.Debug.Debug.Info("通用规则:" + stt);
|
||||
|
||||
//牌类型
|
||||
now.gz.StyOf_Pai = (sbyte)now.gzcs_big[0];//tyGz[0].charToInt();
|
||||
//1表示不能吃 2可以吃
|
||||
now.gz.Not_Chi = to0(now.gzcs_big[1], now.gz.Not_Chi);
|
||||
//2电脑喜欢杠
|
||||
now.gz.Fan_GangPai = to0(now.gzcs_big[2], now.gz.Fan_GangPai);
|
||||
//3必须自摸
|
||||
if (now.gzcs_big[3] != 0) {
|
||||
if (now.gzcs_big[3] == 1)
|
||||
now.gz.StyOf_HuPai = 2;
|
||||
else if (now.gzcs_big[3] == 2)
|
||||
now.gz.StyOf_HuPai = 1;
|
||||
else
|
||||
now.gz.StyOf_HuPai = 0;
|
||||
}
|
||||
|
||||
//4吃就清一色
|
||||
if (now.gzcs_big[4] != 0) {
|
||||
if (now.gzcs_big[4] == 1)
|
||||
now.gz.chijiuqys = 1;
|
||||
else if (now.gzcs_big[4] == 2)
|
||||
now.gz.chijiuqys = 0;
|
||||
else
|
||||
now.gz.chijiuqys = 11;
|
||||
}
|
||||
|
||||
|
||||
now.gz.chijiuqys = (sbyte)now.gzcs_big[4];//.charToInt();
|
||||
//5听功能
|
||||
now.gz.TingStyle_ = getLast(now.gzcs_big[5], now.gz.TingStyle_);// (sbyte)(tyGz[5].charToInt() - 1);
|
||||
//6牌墙蹲高
|
||||
now.gz.dungaoCnt = (sbyte)now.gzcs_big[6];//.charToInt();
|
||||
//8风可成阙
|
||||
now.gz.ChiXi = getLast(now.gzcs_big[8], now.gz.ChiXi);// (sbyte)(tyGz[8].charToInt() - 1);
|
||||
//9箭可成阙
|
||||
now.gz.ChiYuan = getLast(now.gzcs_big[9], now.gz.ChiYuan);// (sbyte)(tyGz[9].charToInt() - 1);
|
||||
//10加倍次数
|
||||
//log("通用规则加倍次数:" + now.gz.jiabeiCnt + "," + now.gzcs_big[10]);
|
||||
now.gz.jiabeiCnt = Tojiabei(now.gzcs_big[10], now.gz.jiabeiCnt);// tyGz[10].charToInt();
|
||||
|
||||
//11前多少张可以加倍
|
||||
now.gz.jiabeichupaicnt = Tojiabei(now.gzcs_big[11], now.gz.jiabeichupaicnt);
|
||||
|
||||
//12听后看牌
|
||||
now.gz.tinghoukanpai = getLast(now.gzcs_big[12], now.gz.tinghoukanpai);// (sbyte)(tyGz[12].charToInt() - 1);
|
||||
} else {
|
||||
log("没有找到通用规则!");
|
||||
}
|
||||
|
||||
|
||||
//解析前25个通用规则
|
||||
if (now.gzcs_friend != null) {
|
||||
|
||||
int len = now.gzcs_friend.Length;
|
||||
|
||||
string stt = "";
|
||||
for(int i=0;i<len;i++){
|
||||
stt += now.gzcs_friend[i];
|
||||
}
|
||||
|
||||
MrWu.Debug.Debug.Info("朋友房规则:" + stt);
|
||||
|
||||
//德国场
|
||||
now.gz.fanjing968[0] = (sbyte)now.gzcs_friend[0];
|
||||
//1表示不能吃 2可以吃
|
||||
now.gz.Not_Chi = to0(now.gzcs_friend[1], now.gz.Not_Chi);
|
||||
//2电脑喜欢杠
|
||||
now.gz.Fan_GangPai = to0(now.gzcs_friend[2], now.gz.Fan_GangPai);
|
||||
//3必须自摸
|
||||
if (now.gzcs_friend[3] != 0) {
|
||||
if (now.gzcs_friend[3] == 1)
|
||||
now.gz.StyOf_HuPai = 2;
|
||||
else if (now.gzcs_friend[3] == 2)
|
||||
now.gz.StyOf_HuPai = 1;
|
||||
else
|
||||
now.gz.StyOf_HuPai = 0;
|
||||
}
|
||||
|
||||
//4吃就清一色
|
||||
if (now.gzcs_friend[4] != 0) {
|
||||
if (now.gzcs_friend[4] == 1)
|
||||
now.gz.chijiuqys = 1;
|
||||
else if (now.gzcs_friend[4] == 2)
|
||||
now.gz.chijiuqys = 0;
|
||||
else
|
||||
now.gz.chijiuqys = 11;
|
||||
}
|
||||
|
||||
//5听功能
|
||||
now.gz.TingStyle_ = to0(now.gzcs_friend[5], now.gz.TingStyle_);
|
||||
//6无效
|
||||
//7*
|
||||
//8风成阙
|
||||
now.gz.ChiXi = getLast(now.gzcs_friend[8], now.gz.ChiXi);
|
||||
//9箭成阙
|
||||
now.gz.ChiYuan = getLast(now.gzcs_friend[9], now.gz.ChiYuan);
|
||||
//10加倍次数
|
||||
now.gz.jiabeiCnt = Tojiabei(now.gzcs_friend[10], now.gz.jiabeiCnt);// tyGz[10].charToInt();
|
||||
//11前多少张可以加倍
|
||||
now.gz.jiabeichupaicnt = Tojiabei(now.gzcs_friend[11], now.gz.jiabeichupaicnt);
|
||||
//12听后看牌
|
||||
now.gz.tinghoukanpai = getLast(now.gzcs_friend[12], now.gz.tinghoukanpai);// (sbyte)(tyGz[12].charToInt()
|
||||
//13*
|
||||
//14屁胡
|
||||
if (now.gzcs_friend[14] != 0) {
|
||||
if (now.gzcs_friend[14] == 1) {
|
||||
now.gz.pingHu_1fan[0] = 0;
|
||||
now.gz.pingHu_1fan[1] = 0;
|
||||
} else if (now.gzcs_friend[14] == 2) {
|
||||
now.gz.pingHu_1fan[0] = 4;
|
||||
now.gz.pingHu_1fan[1] = 4;
|
||||
} else if (now.gzcs_friend[14] == 3) {
|
||||
now.gz.pingHu_1fan[0] = 4;
|
||||
now.gz.pingHu_1fan[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//16庄家
|
||||
if (now.gzcs_friend[16] != 0) {
|
||||
if (now.gzcs_friend[16] == 1) {
|
||||
now.gz.lunzhuang_ = 0;
|
||||
} else if (now.gzcs_friend[16] == 2) {
|
||||
now.gz.lunzhuang_ = 1;
|
||||
now.gz.lunzhuang_zjhp = 0;
|
||||
} else if (now.gzcs_friend[16] == 3) {
|
||||
now.gz.lunzhuang_ = 1;
|
||||
now.gz.lunzhuang_zjhp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
log("没找到子游戏规则!");
|
||||
}
|
||||
|
||||
//解析后25个子游戏规则
|
||||
setZyxGz(ref now);
|
||||
|
||||
if (now.gz.fanjing968[0] == 0)
|
||||
now.gz.Open_JING = 0;
|
||||
|
||||
ABlock ab1 = new ABlock();
|
||||
myCom_zyx.Instance.getDataOfStruct<ABlock>(memoryAddress, ref ab1, (int*)&ab1);
|
||||
|
||||
int gzSize = Marshal.SizeOf(typeof(Tr_MJGZ));
|
||||
|
||||
//log("规则大小:" + gzSize +"自摸方式:" + now.gz.StyOf_HuPai + ",清一色:" + now.gz.chijiuqys);
|
||||
|
||||
byte[] bts = new byte[gzSize];
|
||||
byte[] gzdata = funs.instance.StructToBytes(now.gz);
|
||||
Buffer.BlockCopy(gzdata, 0, bts, 0, gzSize);
|
||||
funs.instance.memToNative_bytes(bts, ref ab1, 100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 0表示不生效 1表示可以 2表示不可以 装换成 0不可以 1可以
|
||||
/// </summary>
|
||||
protected sbyte to0(byte ch, int org) {
|
||||
//sbyte t_sty = ch.charToInt();
|
||||
if (ch == 1)
|
||||
return (sbyte)ch;
|
||||
if (ch == 0)
|
||||
return (sbyte)org;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取上一个 0无效返回原值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected sbyte getLast(byte ch, int org) {
|
||||
//sbyte t_sty = ch.charToInt();
|
||||
if (ch == 0)
|
||||
return (sbyte)org;
|
||||
return (sbyte)(ch - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加倍的转换 0无效 1不加 2加几次 转 0不加 >2加几次
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private sbyte Tojiabei(byte ch, int org) {
|
||||
//sbyte t_sty = ch.charToInt();
|
||||
if (ch == 0)
|
||||
return (sbyte)org;
|
||||
if (ch == 1)
|
||||
return 0;
|
||||
return (sbyte)ch;
|
||||
}
|
||||
}
|
||||
396
base/mj_base.cs
Normal file
396
base/mj_base.cs
Normal file
@ -0,0 +1,396 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.IO;
|
||||
using nativeCom;
|
||||
using zyxAdapter;
|
||||
using Game.Data;
|
||||
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct strDataChange{
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=8)]
|
||||
public int[] dowhat;//0
|
||||
public int askCnt;//1
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=1000)]
|
||||
public int[] ask;//2
|
||||
public int rltCnt;//3
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=1000)]
|
||||
public int[] rlt;//4
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=1000)]
|
||||
public sbyte[] ask_bts;//5
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=1000)]
|
||||
public byte[] rlt_bts;//6
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct Tr_Paixing_z1{
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=5)]
|
||||
public Tr_Que pq;
|
||||
public Tr_Dui dui;
|
||||
}
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct Tr_Paixing_z2{
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=7)]
|
||||
public Tr_Dui dui7;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct Tr_Paixing {
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=20)]
|
||||
public byte[] bak;
|
||||
public byte UseJing;
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=22)]
|
||||
public Tr_Pai[] Pai_StrAll; //全部牌,含杠第4张
|
||||
|
||||
public sbyte PaiCntAll; //全部牌数量
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=18)]
|
||||
public sbyte[] str_Pai; //手牌+零牌 居然没用上??? 1下标开始
|
||||
|
||||
public int TingCount;//听数量
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=17)]
|
||||
public TTing[] TingArr;
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=3)]
|
||||
public sbyte[] JingCnt; //正、副精,全部精
|
||||
|
||||
public int LX ;//-1不听 0听牌 >0胡牌[1平和 2七小队 3十三烂 4国士无双 8标准烂(147 258 369)]
|
||||
// 1: (pq: Tr_Ques; dui: Tr_Dui);
|
||||
// 2: (dui7: array[0..6] of Tr_Dui); //由大到小
|
||||
// //3十三烂
|
||||
// //4国士无双
|
||||
// //8标准烂 147 258 369
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct tcls_mem_dll_agame{//麻将参数----每次开局
|
||||
|
||||
public int a;
|
||||
public Tr_MJGZ gz;
|
||||
public sbyte isLibrary;//0exe测试 1网络DLL
|
||||
public sbyte isSifang;
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=50)]
|
||||
public byte[] gzcs_big; //前50个通用
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=50)]
|
||||
public byte[] gzcs_friend;//: array[0..49] of Byte;
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct tcls_mem_dll_main{//宿主麻将参数---初始化一次
|
||||
public int a;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct tcls_mem_dll {//麻将参数---初始化一次
|
||||
public int huFanCnt;
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=100)]
|
||||
public int[] huFan_idx;
|
||||
public int hufanCnt_changeBase; //0..99 哪些被DLL替换了 ********新增
|
||||
[MarshalAs(UnmanagedType.ByValArray,SizeConst=40)]
|
||||
public int[] hupan_dll_changeBase;
|
||||
static public void init(ref tcls_mem_dll t){
|
||||
t.huFan_idx=new int[100];
|
||||
t.hupan_dll_changeBase=new int[40];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
[StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Ansi/*,Pack=1*/)]
|
||||
public struct tcls_mem_dll_main_agame{//宿主麻将参数---每次开局
|
||||
public int a;
|
||||
public Tr_MJGZ gz;
|
||||
}
|
||||
|
||||
public class mjbase{
|
||||
public tcls_mem_dll cs_dll;//DLL参数
|
||||
public tcls_mem_dll_main cs_main;//主参数
|
||||
|
||||
private tcls_mem_dll_agame cs_dll_agame;//DLL参数
|
||||
public tcls_mem_dll_main_agame cs_main_agame;//主参数
|
||||
|
||||
public int[] fanidx;
|
||||
|
||||
/// <summary>
|
||||
/// 所有牌
|
||||
/// </summary>
|
||||
public static readonly byte[] paiAll = new byte[]{
|
||||
11,12,13,14,15,16,17,18,19,
|
||||
31,32,33,34,35,36,37,38,39,
|
||||
51,52,53,54,55,56,57,58,59,
|
||||
71,72,73,74,77,78,79
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 根据牌拿位置
|
||||
/// </summary>
|
||||
/// <param name="pai"></param>
|
||||
/// <returns></returns>
|
||||
public int getPaiIdx(int pai){
|
||||
int shi = pai / 10;
|
||||
if(shi < 7)
|
||||
return shi/2*9+pai%10-1;
|
||||
int len = paiAll.Length;
|
||||
for(int i=27;i<len;i++){
|
||||
if(paiAll[i] == pai)
|
||||
return i;
|
||||
}
|
||||
|
||||
log("大错误" + pai);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strDataChange dc=new strDataChange();
|
||||
ABlock ab_mjfun=new ABlock();
|
||||
unsafe int*[] intptr_dc=new int*[10];
|
||||
|
||||
/// <summary>
|
||||
/// 胡牌修正
|
||||
/// </summary>
|
||||
/// <param name="pk"></param>
|
||||
/// <param name="fan"></param>
|
||||
/// <param name="hpr"></param>
|
||||
/// <param name="fangpaonew"></param>
|
||||
/// <param name="lingpai"></param>
|
||||
unsafe public virtual void cal_hupai(ref tr_pack_dapai pk,ref Tr_faninfo fan,int hpr,int fangpaonew,int lingpai,int memoryAddress,int style/*0表示汇总前的修正 1表示汇总后的修正*/){
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算胡番 奖励番 及胡的类型
|
||||
/// </summary>
|
||||
/// <param name="pk"></param>
|
||||
/// <param name="px"></param>
|
||||
/// <param name="addr_pxz"></param>
|
||||
/// <param name="fan"></param>
|
||||
/// <param name="hpr"></param>
|
||||
/// <param name="fangpaonew"></param>
|
||||
/// <param name="lingpai"></param>
|
||||
unsafe public virtual void calFan_hupai(ref tr_pack_dapai pk,ref Tr_Paixing px,IntPtr addr_pxz,ref Tr_faninfo fan,int hpr,int fangpaonew,int lingpai,int memoryAddress){
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 补充小番种 100..199
|
||||
/// </summary>
|
||||
/// <param name="pk"></param>
|
||||
/// <param name="px"></param>
|
||||
/// <param name="fanIdx 番索引"></param>
|
||||
/// <param name="hpr 谁"></param>
|
||||
unsafe public virtual int calFan_world(ref tr_pack_dapai pk,ref Tr_Paixing px,int fanIdx,int hpr){
|
||||
int r= -4444; //这是取底层
|
||||
return r;
|
||||
if (fanIdx>99)r=0; //这是我要计算的
|
||||
|
||||
else
|
||||
//这是覆盖底层
|
||||
switch(r){
|
||||
case 20:r=0;
|
||||
case 34:r=0;
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public unsafe virtual void sendPackFunc(ref tr_pack_dapai pk,int address){}
|
||||
|
||||
/// <summary>
|
||||
/// AI出牌
|
||||
/// </summary>
|
||||
/// <param name="pk"></param>
|
||||
/// <returns></returns>
|
||||
public virtual int chupai(ref tr_pack_dapai pk){
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void log(string str){
|
||||
dcEvent_zyx.Instance.log(str);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置番idx
|
||||
/// </summary>
|
||||
public virtual void setfanidx(){
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置规则
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
public virtual void setGz(ref tcls_mem_dll_agame now,int memoryAddress){
|
||||
}
|
||||
|
||||
unsafe public int initDll_agame(ref tcls_mem_dll_main_agame cs_main_,ref tcls_mem_dll_agame cs_dll_,ref ABlock ab,int memoryAddress) {
|
||||
cs_main_agame=cs_main_;
|
||||
cs_dll_agame=cs_dll_;
|
||||
|
||||
//cs_dll_agame.gz = cs_main_.gz;
|
||||
|
||||
//log("设置西啊伤心啊上半场卡号");
|
||||
|
||||
setGz(//ref cs_main_agame.gz,
|
||||
ref cs_dll_agame,memoryAddress);
|
||||
|
||||
log("xxxss "+cs_dll_agame.gz.dungaoCnt+" "+ab.len+" "+cs_main_agame.gz.dungaoCnt+" "+cs_main_agame.gz.score_gang_jing[1]);
|
||||
funs.instance.memToNative_bytes(funs.instance.StructToBytes(cs_dll_agame),ref ab,0);
|
||||
//log("sdlkjf029384");
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsafe void fixpt(){
|
||||
|
||||
fixed(int* ppp=&dc.dowhat[0]){
|
||||
intptr_dc[0]=ppp;
|
||||
|
||||
}
|
||||
fixed(int* ppp=&dc.askCnt){
|
||||
intptr_dc[1]=ppp;
|
||||
|
||||
}
|
||||
fixed(int* ppp=&dc.ask[0]){
|
||||
intptr_dc[2]=ppp;
|
||||
|
||||
}
|
||||
fixed(int* ppp=&dc.rltCnt){
|
||||
intptr_dc[3]=ppp;
|
||||
|
||||
}
|
||||
fixed(int* ppp=&dc.rlt[0]){
|
||||
intptr_dc[4]=ppp;
|
||||
|
||||
}
|
||||
fixed(sbyte* ppp=&dc.ask_bts[0]){
|
||||
intptr_dc[5]=(int*)ppp;
|
||||
|
||||
}
|
||||
fixed(byte* ppp=&dc.rlt_bts[0]){
|
||||
intptr_dc[6]=(int*)ppp;
|
||||
|
||||
}
|
||||
}
|
||||
unsafe public int initDll(ref tcls_mem_dll_main cs_main_,ref tcls_mem_dll cs_dll_,ref ABlock ab,int addr_mj) {
|
||||
addr_mjfun=addr_mj;
|
||||
|
||||
dc.ask=new int[1000];
|
||||
dc.rlt=new int[1000];
|
||||
dc.dowhat=new int[8];
|
||||
dc.ask_bts=new sbyte[1000];
|
||||
dc.rlt_bts=new byte[1000];
|
||||
fixpt();
|
||||
ab_mjfun.pt=(int*)addr_mjfun;
|
||||
|
||||
cs_main=cs_main_;
|
||||
cs_dll=cs_dll_;
|
||||
setfanidx();
|
||||
|
||||
Buffer.BlockCopy(fanidx,0,cs_dll.huFan_idx,0,fanidx.Length<<2);
|
||||
cs_dll.huFanCnt=fanidx.Length;
|
||||
|
||||
funs.instance.memToNative_bytes(funs.instance.StructToBytes(cs_dll),ref ab,0);
|
||||
|
||||
// byte[] bt=funs.instance.StructToBytes(cs_dll);
|
||||
// int* addr=myCom_zyx.Instance.getPointerOfBytes(bt);
|
||||
// myCom_zyx.Instance.move2Process(addr,new IntPtr( ab.pt),bt.Length);
|
||||
|
||||
|
||||
mainDo("测试",new int[]{5,6},new sbyte[]{31,54});
|
||||
log("ceshi..."+getvalue_int(0)+" "+getvalue_byte(3));
|
||||
return cs_dll.huFanCnt;
|
||||
}
|
||||
|
||||
public int getvalue_int(int idx){
|
||||
return dc.rlt[idx];
|
||||
|
||||
}
|
||||
public int[] getvalue_intArr(int idx,int len){
|
||||
if (idx==-1)
|
||||
return dc.rlt;else
|
||||
{
|
||||
int[] r=new int[len];
|
||||
Array.Copy(dc.rlt,idx,r,0,len);
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
public byte getvalue_byte(int idx){
|
||||
return dc.rlt_bts[idx];
|
||||
|
||||
}
|
||||
public byte[] getvalue_byteArr(int idx,int len){
|
||||
if(idx==-1)return dc.rlt_bts;else
|
||||
{
|
||||
byte[] r=new byte[len];
|
||||
Array.Copy(dc.rlt_bts,idx,r,0,len);
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected int addr_mjfun;//宿主mjfun
|
||||
unsafe protected void mainDo(string str, int[] ask,sbyte[] bts){
|
||||
|
||||
int[] dow=new int[8];
|
||||
|
||||
switch(str){
|
||||
case "测试": dow[0]=0; break;
|
||||
case "门清": dow[0]=1; break;
|
||||
case "零牌": dow[0]=2; break;
|
||||
case "零牌类型": dow[0]=3; break;//零牌类型 0自摸 1放炮
|
||||
case "垃圾牌":dow[0]=10;break;
|
||||
case "剩余牌":dow[0]=11;break;
|
||||
case "钱娄子": dow[0]=50;break;
|
||||
case "临时番": dow[0]=51;break;
|
||||
case "上把庄家":dow[0]=52;break;
|
||||
case "庄家座位":dow[0]=53;break;
|
||||
case "庄家":dow[0]=54;break;
|
||||
|
||||
case "增加杠":dow[0]=55;break;
|
||||
case "删除杠":dow[0]=56;break;
|
||||
case "牌是否杠":dow[0]=57;break;
|
||||
}
|
||||
|
||||
Array.Copy(dow,dc.dowhat,dow.Length);
|
||||
if(ask!=null)
|
||||
Array.Copy(ask,dc.ask,ask.Length);
|
||||
if( bts!=null)
|
||||
Array.Copy(bts,dc.ask_bts,bts.Length);
|
||||
//
|
||||
ab_mjfun.sty=56;
|
||||
ab_mjfun.len=678;
|
||||
ABlock xb=new ABlock();
|
||||
xb.pt=null;
|
||||
string sx="";
|
||||
string rlt=null;//!!!
|
||||
tr_rltpchar sdfsdf=new tr_rltpchar ();
|
||||
//fixpt();
|
||||
int len=intptr_dc.Length;
|
||||
for(int i=0;i<len;i++)sx+= ((int)(int*)intptr_dc[i]).ToString()+'^';
|
||||
dcEvent_zyx.Instance.TestGameFun(
|
||||
// myCom_zyx.Instance. doMsgNative_(
|
||||
"1",
|
||||
//new int*[]{ intptr_dc[0],intptr_dc[1], intptr_dc[2],intptr_dc[3],intptr_dc[4],intptr_dc[5]}
|
||||
sx // intptr_dc
|
||||
,ref sdfsdf
|
||||
,ref ab_mjfun ,ref xb);
|
||||
|
||||
rlt=null;//!!!!
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
28
base/nativeComSub.cs
Normal file
28
base/nativeComSub.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
||||
namespace nativeCom{
|
||||
|
||||
public class myCom_zyx: cls_nativeCom{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user