public MarryPartyResult MarryPartyCreate(GameClient client, int partyType, long startTime) { if (!MarryLogic.IsVersionSystemOpenOfMarriage()) { return(MarryPartyResult.NotOpen); } MarryPartyConfigData configData = GetMarryPartyConfigData(partyType); if (null == configData) { return(MarryPartyResult.InvalidParam); } MarriageData marryData = client.ClientData.MyMarriageData; if (marryData.nSpouseID < 0 || marryData.byMarrytype < 0) { return(MarryPartyResult.NotMarry); } int husbandRoleID = 0; int wifeRoleID = 0; string husbandName = ""; string wifeName = ""; if (1 == marryData.byMarrytype) { husbandRoleID = client.ClientData.RoleID; husbandName = client.ClientData.RoleName; wifeRoleID = marryData.nSpouseID; wifeName = MarryLogic.GetRoleName(marryData.nSpouseID); } else { husbandRoleID = marryData.nSpouseID; husbandName = MarryLogic.GetRoleName(marryData.nSpouseID); wifeRoleID = client.ClientData.RoleID; wifeName = client.ClientData.RoleName; } // 必须先添加,以防夫妻重复举行婚宴。。。想不通为什么找我 MarryPartyData partyData = m_MarryPartyDataCache.AddParty(client.ClientData.RoleID, partyType, startTime, husbandRoleID, wifeRoleID, husbandName, wifeName); if (partyData == null) { return(MarryPartyResult.AlreadyRequest); } MarryPartyResult result = MarryPartyResult.Success; byte[] byteData = null; TCPProcessCmdResults dbResult = Global.RequestToDBServer3(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_DB_MARRY_PARTY_ADD, string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", client.ClientData.RoleID, partyType, startTime, husbandRoleID, wifeRoleID, husbandName, wifeName), out byteData, client.ServerId ); if (TCPProcessCmdResults.RESULT_FAILED == dbResult || null == byteData || byteData.Length <= 6) { result = MarryPartyResult.AlreadyRequest; } if (result == MarryPartyResult.Success) { // 检查举办所需金币是否足够 if (configData.PartyCost > Global.GetTotalBindTongQianAndTongQianVal(client)) { result = MarryPartyResult.NotEnoughMoney; } if (configData.PartyCost > 0) { // 扣除举办所需金币 if (Global.SubBindTongQianAndTongQian(client, configData.PartyCost, "举办婚宴") == false) { result = MarryPartyResult.NotEnoughMoney; } } } if (result != MarryPartyResult.Success) { if (dbResult != TCPProcessCmdResults.RESULT_FAILED) { try { Global.SendAndRecvData((int)TCPGameServerCmds.CMD_DB_MARRY_PARTY_REMOVE, string.Format("{0}", client.ClientData.RoleID), client.ServerId ); } catch (Exception) { } } m_MarryPartyDataCache.RemoveParty(client.ClientData.RoleID); return(result); } Int32 length = BitConverter.ToInt32(byteData, 0); MarryPartyData dbPartyData = DataHelper.BytesToObject <MarryPartyData>(byteData, 6, length - 2); m_MarryPartyDataCache.SetPartyTime(partyData, dbPartyData.StartTime); SendMarryPartyList(client, partyData); //lock (MarryPartyNPCShowMutex) //{ // if (MarryPartyNPCShow == false) // { // // TODO: add npc // MarryPartyNPCShow = true; // } //} return(result); }
public MarryPartyResult MarryPartyCreate(GameClient client, int partyType, long startTime) { MarryPartyResult result2; if (!MarryLogic.IsVersionSystemOpenOfMarriage()) { result2 = MarryPartyResult.NotOpen; } else { MarryPartyConfigData configData = this.GetMarryPartyConfigData(partyType); if (null == configData) { result2 = MarryPartyResult.InvalidParam; } else { MarriageData marryData = client.ClientData.MyMarriageData; if (marryData.nSpouseID < 0 || marryData.byMarrytype < 0) { result2 = MarryPartyResult.NotMarry; } else { int husbandRoleID; string husbandName; int wifeRoleID; string wifeName; if (1 == marryData.byMarrytype) { husbandRoleID = client.ClientData.RoleID; husbandName = client.ClientData.RoleName; wifeRoleID = marryData.nSpouseID; wifeName = MarryLogic.GetRoleName(marryData.nSpouseID); } else { husbandRoleID = marryData.nSpouseID; husbandName = MarryLogic.GetRoleName(marryData.nSpouseID); wifeRoleID = client.ClientData.RoleID; wifeName = client.ClientData.RoleName; } MarryPartyData partyData = this.m_MarryPartyDataCache.AddParty(client.ClientData.RoleID, partyType, startTime, husbandRoleID, wifeRoleID, husbandName, wifeName); if (partyData == null) { result2 = MarryPartyResult.AlreadyRequest; } else { MarryPartyResult result = MarryPartyResult.Success; byte[] byteData = null; TCPProcessCmdResults dbResult = Global.RequestToDBServer3(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10188, string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}", new object[] { client.ClientData.RoleID, partyType, startTime, husbandRoleID, wifeRoleID, husbandName, wifeName }), out byteData, client.ServerId); if (TCPProcessCmdResults.RESULT_FAILED == dbResult || byteData == null || byteData.Length <= 6) { result = MarryPartyResult.AlreadyRequest; } if (result == MarryPartyResult.Success) { if (configData.PartyCost > Global.GetTotalBindTongQianAndTongQianVal(client)) { result = MarryPartyResult.NotEnoughMoney; } if (configData.PartyCost > 0) { if (!Global.SubBindTongQianAndTongQian(client, configData.PartyCost, "举办婚宴")) { result = MarryPartyResult.NotEnoughMoney; } } } if (result != MarryPartyResult.Success) { if (dbResult != TCPProcessCmdResults.RESULT_FAILED) { try { Global.SendAndRecvData <string>(10189, string.Format("{0}", client.ClientData.RoleID), client.ServerId, 0); } catch (Exception) { } } this.m_MarryPartyDataCache.RemoveParty(client.ClientData.RoleID); result2 = result; } else { int length = BitConverter.ToInt32(byteData, 0); MarryPartyData dbPartyData = DataHelper.BytesToObject <MarryPartyData>(byteData, 6, length - 2); this.m_MarryPartyDataCache.SetPartyTime(partyData, dbPartyData.StartTime); this.SendMarryPartyList(client, partyData, -1); result2 = result; } } } } } return(result2); }