void cCookManager::NetworkMsgParse( BYTE Protocol, void* pMsg, DWORD dwLength ) { switch(Protocol) { case MP_COOK_SYN: Cook_Syn(pMsg); break; case MP_COOK_CHEAT: { MSG_DWORD4* pmsg = (MSG_DWORD4*)pMsg; CPlayer* pPlayer = (CPlayer*)g_pUserTable->FindUser(pmsg->dwObjectID); int nCheck = 0; if(0<pmsg->dwData1 && pmsg->dwData1<5) nCheck++; if(0<=pmsg->dwData2 && pmsg->dwData2<=m_wMaxCookCount[pmsg->dwData1]) nCheck++; if(0<=pmsg->dwData3 && pmsg->dwData3<=m_wMaxEatCount[pmsg->dwData1]) nCheck++; if(0<=pmsg->dwData4 && pmsg->dwData4<=m_wMaxFireCount[pmsg->dwData1]) nCheck++; if(nCheck==4) { pPlayer->SetCookLevel((WORD)pmsg->dwData1); pPlayer->SetCookCount((WORD)pmsg->dwData2); pPlayer->SetEatCount((WORD)pmsg->dwData3); pPlayer->SetFireCount((WORD)pmsg->dwData4); MSG_DWORD4 msg; msg.Category = MP_COOK; msg.Protocol = MP_COOK_STATE; msg.dwObjectID = pPlayer->GetID(); msg.dwData1 = pPlayer->GetCookLevel(); msg.dwData2 = pPlayer->GetCookCount(); msg.dwData3 = pPlayer->GetEatCount(); msg.dwData4 = pPlayer->GetFireCount(); pPlayer->SendMsg(&msg, sizeof(msg)); } } break; default: break; } }
void cCookManager::Cook_Syn(void* pMsg) { WORD wResult = eCookError_None; MSG_COOK_SYN* pmsg = (MSG_COOK_SYN*)pMsg; CPlayer* pPlayer = (CPlayer*)g_pUserTable->FindUser(pmsg->dwObjectID); if(pPlayer) { // 스피드핵 체크 if(0 < pPlayer->GetLastCookTime()) { wResult=eCookError_InvaildState; goto COOK_NACK; } // 요리도구확인 WORD wCookUtilLevel = CheckCookUtil(pPlayer); if(!wCookUtilLevel) { wResult=eCookError_InvaildUtil; goto COOK_NACK; } // 레시피확인 stRecipeInfo* pRecipe = GetRecipeInfo(pmsg->dwRecipeIdx); if(!pRecipe) { wResult=eCookError_InvaildRecipe; goto COOK_NACK; } // 요리도구-레시피 레벨확인 if(wCookUtilLevel<eCOOKLEVEL3 && wCookUtilLevel<COOKMGR->GetCookLevelFromRecipe(pRecipe->dwRecipeIdx)) { wResult=eCookError_LowerUtil; goto COOK_NACK; } // 모닥불확인 CNpc* pFire = (CNpc*)g_pUserTable->FindUser(pmsg->dwFireNpcIdx); if(!pFire || eObjectKind_Npc!=pFire->GetObjectKind()) { wResult=eCookError_InvaildFire; goto COOK_NACK; } // 제작수량확인 if(pmsg->wMakeNum<1 || 99<pmsg->wMakeNum) { wResult=eCookError_InvaildMakeNum; goto COOK_NACK; } // 거리제한 VECTOR3 vHeroPos, vPlacePos; pPlayer->GetPosition(&vHeroPos) ; pFire->GetPosition(&vPlacePos); float fDistance = CalcDistanceXZ(&vHeroPos, &vPlacePos); if(MAX_COOKING_DISTANCE < fDistance) { wResult = eCookError_OverDistance; goto COOK_NACK; } CItemSlot* pInvenSlot = pPlayer->GetSlot(eItemTable_Inventory); if(0 == ITEMMGR->GetTotalEmptySlotNum(pInvenSlot, pPlayer)) { wResult = eCookError_InvenFull; goto COOK_NACK; } // 요리재료확인 및 소모 if(!CheckIngredients(pPlayer, pRecipe, pmsg->wMakeNum)) { wResult = eCookError_NeedIngredient; goto COOK_NACK; } // 숙련도확인 및 증가 WORD wCookCount = pPlayer->GetCookCount(); WORD wAddPoint = 0; if(pPlayer->GetCookLevel() == GetCookLevelFromRecipe(pRecipe->dwRecipeIdx)) { WORD wExpertPointMin = (WORD)pRecipe->dwExpertPointMin; WORD wExpertPointMax = (WORD)pRecipe->dwExpertPointMax; if(pPlayer->GetCookCount() < wExpertPointMin) { wResult = eCookError_LowerExpertPoint; goto COOK_NACK; } if(wExpertPointMax < wCookCount) wAddPoint = 0; else if(wExpertPointMax <= wCookCount+pmsg->wMakeNum) wAddPoint = wExpertPointMax - wCookCount; else wAddPoint = pmsg->wMakeNum; if(wCookCount+wAddPoint < COOKMGR->GetMaxCookCount(pPlayer->GetCookLevel())) pPlayer->SetCookCount(wCookCount + wAddPoint); else pPlayer->SetCookCount(COOKMGR->GetMaxCookCount(pPlayer->GetCookLevel())); } Cooking_Update(pPlayer); Cooking_Log(pPlayer->GetID(), eCookingLog_CookCount, pRecipe->dwRecipeIdx, wCookCount, wAddPoint, pPlayer->GetCookCount()); DWORD* pPlayerIdx = new DWORD; if(pPlayerIdx) { *pPlayerIdx = pPlayer->GetID(); pPlayer->SetLastCookTime(gCurTime); m_CookerList.Add(pPlayerIdx, *pPlayerIdx); } MSG_DWORD2 msgAck; msgAck.Category = MP_COOK; msgAck.Protocol = MP_COOK_ACK; msgAck.dwObjectID = pPlayer->GetID(); msgAck.dwData1 = pRecipe->dwRecipeIdx; msgAck.dwData2 = pmsg->wMakeNum; pPlayer->SendMsg(&msgAck, sizeof(msgAck)); MSG_DWORD4 msg; msg.Category = MP_COOK; msg.Protocol = MP_COOK_STATE; msg.dwObjectID = pPlayer->GetID(); msg.dwData1 = pPlayer->GetCookLevel(); msg.dwData2 = pPlayer->GetCookCount(); msg.dwData3 = pPlayer->GetEatCount(); msg.dwData4 = pPlayer->GetFireCount(); pPlayer->SendMsg(&msg, sizeof(msg)); return; } COOK_NACK: MSG_DWORD msg; msg.Category = MP_COOK; msg.Protocol = MP_COOK_NACK; msg.dwObjectID = pPlayer->GetID(); msg.dwData = wResult; PACKEDDATA_OBJ->QuickSend( pPlayer, &msg, sizeof( msg ) ); }