//! 响应开始物品操作 GoodsAllPurposeOpt::eOptResult GoodsAllPurposeOpt::FinishOpt(void) { CPlayer *pPlayer = GetGame()->FindPlayer(m_OwnerGuid); if(NULL != pPlayer) { if(CanOpt(pPlayer)) { BOOL bPass = TRUE; //! 找到物品 for (DWORD i = 0; i < m_dwMaxPushNum; ++i) { if(NULL == pPlayer->FindGoodsByGuidInPack(m_arrGoodsGuid[i])) { bPass = FALSE; break; } } if(bPass) { //! 执行脚本 pPlayer->PlayerRunScript(m_szOnFinishScript); return eOR_Succeed; } else { memset(m_arrGoodsGuid, 0, sizeof(CGUID) * MAX_ALLPURPOSE_CONTAINER_SIZE); CMessage msg(MSG_S2C_GOODS_AllPurpose_RePop); DBWriteSet dbWriteSet; msg.GetDBWriteSet(dbWriteSet); dbWriteSet.AddToByteArray((DWORD)0xFFFFFFFF); msg.SendToPlayer(m_OwnerGuid, false); CMessage msgTxt(MSG_S2C_GOODS_AllPurpose_UpdateTxt); DBWriteSet TxtdbWriteSet; msgTxt.GetDBWriteSet(TxtdbWriteSet); TxtdbWriteSet.AddToByteArray(m_szText); msgTxt.SendToPlayer(m_OwnerGuid, false); return eOR_Failed; } } } return eOR_Lawless; }
//! 响应物品放入 GoodsAllPurposeOpt::eOptResult GoodsAllPurposeOpt::OnGoodsPut(const CGUID &GoodsGuid, DWORD dwIdx) { if(m_dwMaxPushNum > dwIdx) { CPlayer *pPlayer = GetGame()->FindPlayer(m_OwnerGuid); if(NULL != pPlayer) { if(CanOpt(pPlayer)) { //! 找到该物品 if(NULL != pPlayer->FindGoodsByGuidInPack(GoodsGuid)) { m_arrGoodsGuid[dwIdx] = GoodsGuid; //! 执行脚本 pPlayer->PlayerRunScript(m_szOnPushScript); CMessage msg(MSG_S2C_GOODS_AllPurpose_RePush); DBWriteSet dbWriteSet; msg.GetDBWriteSet(dbWriteSet); dbWriteSet.AddToByteArray(dwIdx); dbWriteSet.AddToByteArray(GoodsGuid); msg.SendToPlayer(m_OwnerGuid, false); return eOR_Succeed; } else { return eOR_Failed; } } } } return eOR_Lawless; }
//! 进行制作 BOOL GoodsTailorSystem::MakeGoods(const tagMakeInfo& MakeInfo) { CPlayer *pPlayer = GetGame()->FindPlayer(MakeInfo.PlayerGuid); if(NULL == pPlayer) return FALSE; //! 验证合法性 switch(MakeInfo.lType) { case eMT_FORM_GOODS: { CGoods *pGoods = pPlayer->FindGoodsByGuidInPack(MakeInfo.GoodsGuid); if(NULL == pGoods) return FALSE; } break; case eMT_FROM_NPC: { //! 地图判断 if(MakeInfo.RegionGuid != pPlayer->GetRegionGUID()) return FALSE; //! 距离判断 if(MakeInfo.lRadius < abs(LONG(pPlayer->GetPosX() - MakeInfo.fPosX)) || MakeInfo.lRadius < abs((LONG)(pPlayer->GetPosY() - MakeInfo.fPosY))) return FALSE; } break; default: return FALSE; } //! 开始制作 if(NULL == MakeInfo.pGsOneMakeTable) { assert(NULL != MakeInfo.pGsOneMakeTable); Log4c::Error(ROOT_MODULE,"%-18s %s",__FUNCTION__,GetText("GS_GOODS_83"));//发生不该出现的错误,物品制作配方对象为空! return FALSE; } DWORD dwResult = MakeInfo.pGsOneMakeTable->MakeGoods(pPlayer); //! 处理结果 if(eGTC_Succeed == dwResult) { switch(MakeInfo.lType) { case eMT_FORM_GOODS: { if(MakeInfo.bDelGoodsWhenFinish) { if(!pPlayer->DelGoods(MakeInfo.GoodsGuid, 1)) { //发生严重错误,物品制作已经完成,但消耗物品没有被删除成功,还有一种可能就是配置的消耗物中包含了触发制作的物品! Log4c::Error(ROOT_MODULE,"%-18s %s",__FUNCTION__,GetText("GS_GOODS_84")); } } } break; } } else { CMessage msg(MSG_S2C_MAKE_RESULT); msg.Add((BYTE)FALSE); msg.Add(dwResult); msg.SendToPlayer(pPlayer->GetExID(), false); } return (eGTC_Succeed == dwResult); }