Example #1
0
void FCSCard::User2Perl(const char *String)
{
	SetFlipped(User2PerlFlippedStatus(String));
	SetCardNumber(User2PerlCardNumber(String));
	SetSuit(User2PerlSuit(String));
}
Example #2
0
void CDBCard::Load(long msgid, BYTE* msgBuf, long& msgBufPos)
{
	// 解析消息
	CDBEntityManager::DBCardMapItr itr = GetGame()->GetDBEntityManager()->GetDBCardMap().find(GetExID());

	char szGuid[128];
	GetExID().tostring(szGuid);

	if(itr != GetGame()->GetDBEntityManager()->DBCardMapEnd())
	{
		WORD attrNum = _GetWordFromByteArray(msgBuf, msgBufPos);

		for(int i=0; i<(int)attrNum; i++)
		{
			// add one card data
			_GetWordFromByteArray(msgBuf, msgBufPos);
			DB_CARD_ATTR_TYPE attrType = (DB_CARD_ATTR_TYPE)_GetLongFromByteArray(msgBuf, msgBufPos);
			switch(attrType)
			{
			case DB_CARD_ATTR_SZ_CARDNUMBER:
				{
					char num[1024];
					_GetStringFromByteArray(msgBuf, msgBufPos, num);
					SetCardNumber(num, strlen(num));
				}
				break;
			case DB_CARD_ATTR_SZ_CARDTYPE:
				{
					char num[1024];
					_GetStringFromByteArray(msgBuf, msgBufPos, num);
					SetCardType(num, strlen(num));
				}
				break;
			case DB_CARD_ATTR_SZ_SELLERACCOUNT:
				{
					char num[1024];
					_GetStringFromByteArray(msgBuf, msgBufPos, num);
					SetSellerAccount(num, strlen(num));
				}
				break;
			case DB_CARD_ATTR_LONG_SELLERID:
				{
					CGUID value;
					_GetBufferFromByteArray(msgBuf, msgBufPos, value);
					SetSellerID(value);
				}
				break;
			case DB_CARD_ATTR_SZ_BUYERACCOUNT:
				{
					char num[1024];
					_GetStringFromByteArray(msgBuf, msgBufPos, num);
					SetCardNumber(num, strlen(num));
				}
				break;
			case DB_CARD_ATTR_LONG_BUYERID:
				{
					CGUID value;
					_GetBufferFromByteArray(msgBuf, msgBufPos, value);
					SetBuyerID(value);
				}
				break;
			case DB_CARD_ATTR_DWORD_PRICE:
				{
					DWORD value = _GetDwordFromByteArray(msgBuf, msgBufPos);
					SetPrice(value);
				}
				break;
			case DB_CARD_ATTR_DWORD_CHARGEPRICE:
				{
					DWORD value = _GetDwordFromByteArray(msgBuf, msgBufPos);
					SetChargePrice(value);
				}
				break;
			case DB_CARD_ATTR_DWORD_CARDSTATE:
				{
					DWORD value = _GetDwordFromByteArray(msgBuf, msgBufPos);
					SetCardState(value);
				}
				break;
			case DB_CARD_ATTR_DWORD_CARDTIME:
				{
					DWORD value = _GetDwordFromByteArray(msgBuf, msgBufPos);
					SetCardTime(value);
				}
				break;
			case DB_CARD_ATTR_DWORD_STARTTIME:
				{
					DWORD value = _GetDwordFromByteArray(msgBuf, msgBufPos);
					SetStartTime(value);
				}
				break;
			case DB_CARD_ATTR_DWORD_SERIALNUMBER:
				{
					DWORD value = _GetDwordFromByteArray(msgBuf, msgBufPos);
					SetSerialNumber(value);
				}
				break;
			}
		}

		CCard *pCard = new CCard;

		if( !pCard) 
		{
			return;
		}

		GetGame()->GetDBEntityManager()->CDBCardToCCard(this, pCard);

		// 返回0为真。
		if( CCardsHandler::getInstance()->InsertCard(pCard) )
		{
			return;
		}
		
		
		////AddLogText("DB2W[%d] : DB_OPER_LOAD_CARD, CardID[%s]...OK!", msgid, szGuid);

		return;
	}

//	//AddLogText("DB2W[%d] : DB_OPER_LOAD_CARD, CardID[%s]...FAILED!", msgid, szGuid);
}