int CheckAutoDivideMoney( ItemAttr *item, short int cn ) // 100000을 넘은 아이템 처리 { CItem *t = ItemUnit( *item ); if( !t ) return 0 ; if( t->GetItemKind() != IK_MONEY ) return 0; CHARLIST *ch = &connections[cn].chrlst; if( !ch ) return 0 ; if( item->attr[IATTR_DURATION] > MAX_MONEY ) { ItemAttr *new_item = SearchInv( ch ); if( !new_item ) { item->attr[IATTR_MUCH] = MAX_MONEY; } else { memcpy(new_item , item , sizeof( ItemAttr ) ); new_item->attr[IATTR_MUCH] = item->attr[IATTR_DURATION] - MAX_MONEY; item->attr[IATTR_MUCH] = MAX_MONEY; if( new_item->attr[IATTR_MUCH] > MAX_MONEY ) CheckAutoDivideMoney( new_item, cn ); return 1; } } return 0; }
CGoods *CPlayer::GetUpdateItem( UINT8 byAttr, UINT16 &wItemID ) { CItem *pItem = NULL; //if( EAST_HP==byAttr ) //{ // pItem=GetBag().GetGoodsItem( CSinglePramMgr::Instance()->GetStrengthenHeroHPItemID() ); // wItemID=CSinglePramMgr::Instance()->GetStrengthenHeroHPItemID(); //} //else //{ // pItem=GetBag().GetGoodsItem( CSinglePramMgr::Instance()->GetStrengthenHeroAttackItemID() ); // wItemID=CSinglePramMgr::Instance()->GetStrengthenHeroAttackItemID(); //} if( NULL == pItem ) { return NULL; } if( pItem->GetItemKind() != EIK_GOODS ) { return NULL; } return dynamic_cast<CGoods *>( pItem ); }
DWORD GetMoneyByItem( CHARLIST *ch ) { DWORD money=0; int type, num; CItem *t; for( int i=0; i<3; i++ ) for( int j=0; j<3; j++ ) for( int k=0; k<8; k++ ) { ItemAttr &item = ch->inv[i][j][k]; if( item.item_no ) { getItemIndex( item.item_no, type, num ); t = ItemUnit( type, num ); if( t && t->GetItemKind() == IK_MONEY ) { if( item.item_no == IN_COIN && item.attr[IATTR_MUCH] > 5) // 동전 { item.item_no = IN_COINS; // 돈 더미로 바꿈 } else if( item.item_no == IN_COINS && item.attr[IATTR_MUCH] <= 5 ) // 동전 더미 { item.item_no = IN_COIN; } money += item.attr[IATTR_MUCH]; } } } if( ch->handheld.item_no ) // 핸드 부분에 있는 돈 계산 { ItemAttr &item = ch->handheld; getItemIndex( item.item_no, type, num ); t = ItemUnit( type, num ); if( t && t->GetItemKind() == IK_MONEY ) { if( item.item_no == IN_COIN && item.attr[IATTR_MUCH] > 5) item.item_no = IN_COINS; else if( item.item_no == IN_COINS && item.attr[IATTR_MUCH] <= 5 ) item.item_no = IN_COIN; money += item.attr[IATTR_MUCH]; } } return money; }
ItemAttr *SearchItemOfInvByKind( int kind, CHARLIST *ch ) { int type, num; CItem * t; for( int i=0; i<3; i++ ) for( int j=0; j<3; j++ ) for( int k=0; k<8; k++ ) { ItemAttr &item = ch->inv[i][j][k]; if( item.item_no ) { getItemIndex( item.item_no, type, num ); t = ItemUnit( type, num ); if( t && t->GetItemKind() == kind ) return &item; } } return NULL; }
UINT16 CGoods::UseBox(DT_ITEM_DATA_LIST_CLI2& stBoxItemInfo) { SGoodsProp* pstGoodsProp = GetGoodsProp(); if(NULL == pstGoodsProp) { RETURN_OTHER_ERR; } SItemComposeProp* pstItemComposeProp = CItemComposePropMgr::Instance()->GetProp(pstGoodsProp->wKindID); if(NULL == pstItemComposeProp) { SYS_CRITICAL(_SDT("[%s: %d]: pstItemComposeProp is NULL!"), MSG_MARK); RETURN_OTHER_ERR; } CItemRateMap& mapComposeItem = pstItemComposeProp->mapComposeItem; if(0 == mapComposeItem.size()) { SYS_CRITICAL(_SDT("[%s: %d]: mapComposeItem[%d] is 0!"), MSG_MARK, pstGoodsProp->wKindID); RETURN_OTHER_ERR; } INT32 nGap = (INT32)(m_poOwner->GetBag().GetIdleSize()) - (INT32)(mapComposeItem.size()); if(nGap < 0) { //判断背包中是否存在该物品,若存在则可少使用一个格子 CBag& oBag = m_poOwner->GetBag(); for(CItemRateMapItr itr = mapComposeItem.begin(); itr != mapComposeItem.end(); itr++) { //只有物品有效,装备叠加数为1,则只找Goods if(oBag.GetGoodsItem(itr->first)) { nGap++; } } } //背包容量不足 if(nGap < 0) { return ERR_GOODS_USE::ID_BAG_FULL; } for(CItemRateMapItr itr = mapComposeItem.begin(); itr != mapComposeItem.end(); itr++) { //若是系统可以直接使用的物品,则使用 if(CItemMgr::Instance()->SysUseGoods(m_poOwner, itr->first, itr->second.wItemNum)) { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(itr->first, itr->second.wItemNum, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum]); } else { ECreateItemRet eRet; CItem* poItem = CItemMgr::Instance()->CreateItemIntoBag(m_poOwner, itr->first, itr->second.wItemNum, eRet, 0, CRecordMgr::EAIT_BOX, m_stDT_GOODS_DATA.wKindID); if(NULL == poItem) { //异常 SYS_CRITICAL(_SDT("[%s: %d]: CreateItemIntoBag failed[%d]!"), MSG_MARK, itr->first); } //装备没有叠加数,可以直接poEquip->GetDT_EQUIP_DATA_CLI(stEquip); if(EIK_EQUIP == poItem->GetItemKind()) { CEquip* poEquip = dynamic_cast<CEquip*>(poItem); if(NULL == poEquip) { //异常 continue; } stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum].byItemType = EIK_EQUIP; DT_EQUIP_DATA_CLI& stEquip = stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum].stItemInfo.stEquip ; poEquip->GetDT_EQUIP_DATA_CLI(stEquip); } else { //内部礼包,返回的是礼包的物品 SGoodsProp* pstGoodsProp = CGoodsPropMgr::Instance()->GetPropByPrimaryKey(itr->first); if((pstGoodsProp) && (EGMK_INNERBOX == pstGoodsProp->byMainKindID)) { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(poItem->GetItemKindID(), 1, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum]); } else { CItemMgr::Instance()->GetDT_ITEM_DATA_CLI2(itr->first, itr->second.wItemNum, stBoxItemInfo.astItemList[stBoxItemInfo.byItemNum]); } } } stBoxItemInfo.byItemNum++; } return ERR_GOODS_USE::ID_SUCCESS; }