UINT16 CMoneyTree::RockMoney(UINT32& dwGetCoin, UINT8 byGuideFlag, DT_MONEY_TREE_DATA_CLI& stMoneyTreeInfo, UINT16 &wGetCoinRate2) { UINT32 dwCostGold = 0; //心情时间 UINT16 wTotalRockNum = CVipPropMgr::Instance()->GetIncNum(EVINF_MONEYTREE, m_poOwner->GetDT_PLAYER_BASE_DATA().byVipLevel); stMoneyTreeInfo.wTotalCanRockNum = wTotalRockNum; stMoneyTreeInfo.wVipExtNum = CVipPropMgr::Instance()->GetIncNum(EVINF_MONEYTREE, m_poOwner->GetDT_PLAYER_BASE_DATA().byVipLevel); UINT16 wMoodKeepTime = CMoneyTreePropMgr::Instance()->GetMoodKeepTime(); //未引导 if(m_poOwner->CKGuide( EGF_ROCKMONEY)) { //引导,不判断次数及元宝,给心情1 m_stDT_MONEY_TREE_DATA.byMoodValue = 1; dwGetCoin = CMoneyTreeBasePropMgr::Instance()->GetProduceCoin(m_poOwner->GetLevel(), m_stDT_MONEY_TREE_DATA.byMoodValue); //m_poOwner->GetDT_PLAYER_BASE_DATA().qwCoin += dwGetCoin; m_poOwner->AddCoin(dwGetCoin, CRecordMgr::EACT_GUIDEROCKMONEY, m_stDT_MONEY_TREE_DATA.byMoodValue, m_stDT_MONEY_TREE_DATA.wRockNum); m_stDT_MONEY_TREE_DATA.qwRockTime = SDTimeSecs(); m_stDT_MONEY_TREE_DATA.wRockNum++; } //已引导 else { //客户端指引重试,直接返回数据,不判断次数及元宝,也不增加铜币 if(1 == byGuideFlag) { dwGetCoin = CMoneyTreeBasePropMgr::Instance()->GetProduceCoin(m_poOwner->GetLevel(), m_stDT_MONEY_TREE_DATA.byMoodValue); GetDT_MONEY_TREE_DATA_CLI(stMoneyTreeInfo, wGetCoinRate2); return ERR_ROCK_MONEY_TREE::ID_SUCCESS; } //今天 if(IsToday(m_stDT_MONEY_TREE_DATA.qwRockTime)) { //已不可再摇 if(m_stDT_MONEY_TREE_DATA.wRockNum >= wTotalRockNum) { return ERR_ROCK_MONEY_TREE::ID_USE_OUT_NUM; } else { //判断元宝 dwCostGold = CMoneyTreeBasePropMgr::Instance()->GetRockNeedGold(m_poOwner, m_stDT_MONEY_TREE_DATA.wRockNum); if(m_poOwner->GetDT_PLAYER_BASE_DATA().qwGold < dwCostGold) { return ERR_COMMON::ID_GOLD_NOT_ENOUGH; } //判断心情值保持期 INT64 dnGap = SDTimeSecs() - m_stDT_MONEY_TREE_DATA.qwMoodStartTime; if(dnGap < 0)//异常 { m_stDT_MONEY_TREE_DATA.qwMoodStartTime = 0; m_stDT_MONEY_TREE_DATA.byMoodValue = 0; } //已过保持期,重置 else if(dnGap >= wMoodKeepTime) { m_stDT_MONEY_TREE_DATA.qwMoodStartTime = 0; m_stDT_MONEY_TREE_DATA.byMoodValue = 0; } dwGetCoin = CMoneyTreeBasePropMgr::Instance()->GetProduceCoin(m_poOwner->GetLevel(), m_stDT_MONEY_TREE_DATA.byMoodValue); } } //不是今天,则重置摇钱值 else { m_stDT_MONEY_TREE_DATA.wRockNum = 0; m_stDT_MONEY_TREE_DATA.byMoodValue = 0; //判断元宝 dwCostGold = CMoneyTreeBasePropMgr::Instance()->GetRockNeedGold(m_poOwner, m_stDT_MONEY_TREE_DATA.wRockNum); if(m_poOwner->GetDT_PLAYER_BASE_DATA().qwGold < dwCostGold) { return ERR_COMMON::ID_GOLD_NOT_ENOUGH; } dwGetCoin = CMoneyTreeBasePropMgr::Instance()->GetProduceCoin(m_poOwner->GetLevel(), m_stDT_MONEY_TREE_DATA.byMoodValue); } //扣除元宝,给收获铜币 //m_poOwner->GetDT_PLAYER_BASE_DATA().qwGold -= dwCostGold; //m_poOwner->GetDT_PLAYER_BASE_DATA().qwCoin += dwGetCoin; m_poOwner->DecGold(dwCostGold, CRecordMgr::EDGT_ROCKMONEY, m_stDT_MONEY_TREE_DATA.byMoodValue, m_stDT_MONEY_TREE_DATA.wRockNum); m_poOwner->AddCoin(dwGetCoin, CRecordMgr::EACT_ROCKMONEY, m_stDT_MONEY_TREE_DATA.byMoodValue, m_stDT_MONEY_TREE_DATA.wRockNum); //随机赋值心情值 if(RandomReseed(100) < CMoneyTreePropMgr::Instance()->GetMoneyTreeMoodRate(m_stDT_MONEY_TREE_DATA.byMoodValue)) { UINT8 byMoodValue = m_stDT_MONEY_TREE_DATA.byMoodValue + 1; if(CMoneyTreePropMgr::Instance()->IsExist(byMoodValue)) { m_stDT_MONEY_TREE_DATA.byMoodValue++; } m_stDT_MONEY_TREE_DATA.qwMoodStartTime = SDTimeSecs();//命中则重置心情值保质期 } m_stDT_MONEY_TREE_DATA.qwRockTime = SDTimeSecs(); m_stDT_MONEY_TREE_DATA.wRockNum++; CPlayerMedal* poPlayerMedal = m_poOwner->GetPlayerMedal(); if ( NULL != poPlayerMedal) { poPlayerMedal->CheckMedalBySmallType(EMST_ROCK_MONEY); } } //SetSaveState(ESS_WANT_SAVE); //记录已引导 m_poOwner->AddGuideRecord( EGF_ROCKMONEY); GetDT_MONEY_TREE_DATA_CLI(stMoneyTreeInfo, wGetCoinRate2); return ERR_ROCK_MONEY_TREE::ID_SUCCESS; }
u32 GenerateBytes ( u8 *block, u32 blockLen, RANDOM_STRUCT *randStruct ) { u32 available; u8 auxbuff[PRNG_MOD_BLEN]; mpz_t zaux; u32 return_code = PRNG_NO_ERROR; if (randStruct == NULL) return PRNG_NOT_INIT; /* Is the prng seeded? */ if (randStruct->bytesNeeded) return PRNG_NOT_SEEDED; /* Initializations */ mpz_init_set_ui (zaux, 0L); if (!randStruct->maxNoOutputBlocks) { /* max no. of output blocks exceeded; we need to reseed */ return_code = RandomReseed (randStruct); /* If return_code is PRNG_NO_DATA_TO_RESEED, return output anyway * but forward return code */ } else randStruct->maxNoOutputBlocks--; /* There may be output available from previous output generation */ available = randStruct->outputAvailable; /* Generate and copy prng output */ while (blockLen > available) { /* copy prng output (if any) to user buffer */ memcpy ((u8 *)block, (u8 *)&randStruct->output[SHA1_DIGESTSIZE-available], available); block += available; blockLen -= available; /* * generate new output */ /* In FIPS 186 apdx 3.1, prng output is G(state + optional_user_input) * Here, optional_user_input = 0. * To avoid Blaichenbacher's attack, there is NO reduction modulo q * on the output. */ /* transform prng state (zstate) into byte array */ WORD2BYTE (auxbuff, randStruct->zstate, PRNG_MOD_BLEN); /* Compute randStruct->output = G(state); */ sha1G (randStruct, auxbuff); /* randStruct->output now contains the PRNG output */ available = SHA1_DIGESTSIZE; /* * update prng state */ /* transform output into mpz_t number */ BYTE2WORD (zaux, randStruct->output, SHA1_DIGESTSIZE); /* update state: new state S_{i+1} = H(Si+ti) + S_i + 1 */ mpz_add (zaux, zaux, randStruct->zstate); mpz_add (randStruct->zstate, zaux, one); mpz_mod (randStruct->zstate, randStruct->zstate, two2pow); } /* copy last chunk of prng output to user buffer */ memcpy ((u8 *)block, (u8 *)&randStruct->output[SHA1_DIGESTSIZE-available], blockLen); randStruct->outputAvailable = available - blockLen; /* Zeroize sensitive information */ memset (auxbuff, 0, PRNG_MOD_BLEN); mpz_clear (zaux); available = 0; return (return_code); }