public bool ChooseRole(string role_name) { if (role_name == null) { LogSystem.LogError("Role Name Is Empty!"); return(false); } if (0 == role_name.Length) { LogSystem.Log("sendChooseRole packet role name is empty!"); return(false); } byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1]; Array.Copy(System.Text.Encoding.Default.GetBytes(role_name), name, role_name.Length); StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length); ar.WriteInt8(GlobalClineMsgId.CLIENT_CHOOSE_ROLE);//消息ID //unsigned short wsName[OUTER_OBJNAME_LENGTH + 1]; // 名称 //unsigned char nVerify[16]; // 校验码 //char strInfo[1]; ar.WriteUnicodeLen(role_name, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2);//玩家名 byte[] verify = new byte[16]; fxVerify.GetChooseRoleVerify(role_name, ref verify); ar.WriteUserDataNoLen(verify); //检验码 ar.WriteInt8(0); //附加信息 return(m_sender.Send(ar.GetData(), ar.GetLength())); }
public bool DeleteRole(string role_name) { if (role_name == null) { //Log.TraceError("Role Name Is Empty!"); return(false); } if (0 == role_name.Length) { //Log.Trace("DeleteRole role name is empty!"); return(false); } //byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1]; //Array.Copy(System.Text.Encoding.Default.GetBytes(role_name), name, role_name.Length); StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length); ar.WriteInt8(GlobalClineMsgId.CLIENT_DELETE_ROLE);//消息ID //unsigned short wsName[OUTER_OBJNAME_LENGTH + 1]; // 名称 ar.WriteUnicodeLen(role_name, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2);//玩家名 return(m_sender.Send(ar.GetData(), ar.GetLength())); }
public bool ChooseRole(string role_name) { if (role_name == null) { //Log.TraceError("Role Name Is Empty!"); return(false); } if (0 == role_name.Length) { //Log.Trace("sendChooseRole packet role name is empty!"); return(false); } //byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1]; //Array.Copy(System.Text.Encoding.Default.GetBytes(role_name), name, role_name.Length); StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length); ar.WriteInt8(GlobalClineMsgId.CLIENT_CHOOSE_ROLE);//消息ID //unsigned short wsName[OUTER_OBJNAME_LENGTH + 1]; // 名称 //unsigned char nVerify[4]; // 校验码 //char strInfo[1]; ar.WriteUnicodeLen(role_name, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2);//玩家名 //byte[] verify = new byte[4]; //校验码4个字节,对消息加密获取验证码 byte[] data = new byte[256]; int index = 0; //序号,名字加入校验 MsgEncode.WriteInt32(ref data, ref index, (uint)MsgEncode.Instance.Serial); MsgEncode.WriteUnicodeLen(ref data, ref index, role_name, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2); byte[] verify = MsgEncode.Instance.Encode(data, index, 4); ar.WriteUserDataNoLen(verify); //检验码 ar.WriteInt8(0); //附加信息 MsgEncode.Instance.MsgSerial++; return(m_sender.Send(ar.GetData(), ar.GetLength())); }
public bool CreateRole(ref VarList args) { try { if ((args.GetCount() < 2) || (args.GetType(1) != VarType.WideStr)) { LogSystem.Log("arguments error"); return(false); } string roleName = args.GetWideStr(1); //role name byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1]; Array.Copy(System.Text.Encoding.Default.GetBytes(roleName), name, roleName.Length); //verify // byte[] verify = new byte[16]; StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length); ar.WriteInt8(GlobalClineMsgId.CLIENT_CREATE_ROLE); ar.WriteInt32(args.GetInt(0)); ar.WriteUnicodeLen(roleName, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2); ///ar.WriteUserDataNoLen(verify); ar.WriteUInt16((uint)(args.GetCount() - 2)); ///ar.WriteInt32(); if (!AddMsgVarList(ar, args, 2, args.GetCount())) { return(false); } return(m_sender.Send(ar.GetData(), ar.GetLength())); } catch (System.Exception ex) { LogSystem.LogError(ex); return(false); } }
public bool CreateRole(ref VarList args) { try { if ((args.GetCount() < 2) || (args.GetType(1) != VarType.WideStr)) { //Log.Trace("arguments error"); return(false); } string roleName = args.GetWideStr(1); //role name //byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1]; //Array.Copy(System.Text.Encoding.Default.GetBytes(roleName), name, roleName.Length); //verify byte[] verify = new byte[4]; //校验码4个字节,对消息加密获取验证码 byte[] varify = MsgEncode.Instance.Encode(ref args, 4); StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length); ar.WriteInt8(GlobalClineMsgId.CLIENT_CREATE_ROLE); ar.WriteInt32(args.GetInt(0)); ar.WriteUnicodeLen(roleName, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2); ar.WriteInt16(1); ar.WriteInt8(2); ar.WriteInt32(args.GetInt(2)); //ar.WriteUserDataNoLen(verify); ar.WriteUserDataNoLen(varify); ar.WriteInt8(0); return(m_sender.Send(ar.GetData(), ar.GetLength())); } catch (System.Exception ex) { Log.TraceExcep(ref ex); return(false); } }