コード例 #1
0
ファイル: DBPetItemInfo.cpp プロジェクト: jjiezheng/pap_full
BOOL DBPetItemInfo::Save(VOID* pSource)
{
	__ENTER_FUNCTION

	enum 
	{
		DB_PetPairData	=	1,
	};

	INT Result;

	SMUPool<PetProcreateItemSM>* pPoolPtr = static_cast<SMUPool<PetProcreateItemSM>*>(pSource);
	Assert(pPoolPtr);


	PetProcreateItem PetProItem;

	do
	{
		INT SmuCount = pPoolPtr->GetPoolMaxSize();
		
		if(SmuCount>MAX_PET_PROCREATE_ITEM_NUM)
			Assert(FALSE);

		INT UseStats;

		for(INT i = 0 ;i<SmuCount;i++)
		{
			PetProcreateItemSM*	pSMU = pPoolPtr->GetPoolObj(i);
			if(!pSMU)
			{
				Assert(pSMU);
				return FALSE;
			}

			UseStats =pSMU->GetUseStatus(SM_C_READ);
			pSMU->Lock(SM_C_READ);
			PetProcreateItem* pPetItem = &pSMU->m_PetProcreateItem;
			Assert(pPetItem);
			if(pPetItem == NULL)
			{
				pSMU->UnLock(SM_C_READ);
				Assert(FALSE);
			}

			if(pPetItem->IsInvalid() == TRUE && UseStats != PET_DELETE)
			{
				pSMU->UnLock(SM_C_READ);
				continue;
			}
			memcpy(&PetProItem,pPetItem,sizeof(PetProcreateItem));
			pSMU->m_SMUHead.UseStatus = PET_SAVED;
			pSMU->UnLock(SM_C_READ);
			
			//继续存储
			mInterface->Clear();
			CheckDBConnect("DBPetItemInfo");

			LONG_DB_QUERY* pQuery = GetLongInterQuery();
			if(!pQuery)
			{
				Assert(FALSE);
			}
			pQuery->Clear();

			CHAR PairDataList[20480] = {0};
			Binary2String(((CHAR*)pPetItem),sizeof(PetProcreateItem),
						   PairDataList);

			pQuery->Parse(SavePetItemInfo,
						  PairDataList,
						  i,
						  ((UseStats!=PET_DELETE)?1:0));

			ODBCBase::LongSave(&Result);

			//保存数据版本
			pQuery->Clear();
			pQuery->Parse(SavePetItemDataVersion,PETITEM_TABLE,PETPROCREATE_CURRENT_ITEM_VERSION,i);
			ODBCBase::LongSave(&Result);
		}

	}while(0);
	
	
	return TRUE;

	__LEAVE_FUNCTION

	return FALSE;
}
コード例 #2
0
ファイル: DBGuildInfo.cpp プロジェクト: brock7/TianLong
BOOL DBGuildInfo::Save(VOID* pSource)
{
	__ENTER_FUNCTION

	enum 
	{
		DB_GuildID	=	1,
		DB_GuildName,
		DB_Guildstat,
		DB_Chiefguid,
		DB_PCount,
		DB_UCount,
		DB_MUCount,
		DB_GPoint,
		DB_GuildMoney,
		DB_CityID,
		DB_Time,
		DB_Logvity,
		DB_Contribu,
		DB_Honor,
		DB_Indlvl,
		DB_Agrlvl,
		DB_Comlvl,
		DB_Deflvl,
		DB_Techlvl,
		DB_Amblvl,
		DB_Admin,
		DB_GuildDesc,
		DB_Chiefname,
		DB_Cname,
		DB_Glvl,
	};

	INT Result;
	
	SMUPool<GuildSMU>* pPoolPtr = static_cast<SMUPool<GuildSMU>*>(pSource);
	Assert(pPoolPtr);
	//保存工会数据

	GUILD_DB	SaveGuild;
	do
	{
		INT SmuCount = pPoolPtr->GetPoolMaxSize();
		if(SmuCount>MAX_GUILD_SIZE)
			Assert(FALSE);

		INT UseStats;
		for(INT i = 0 ;i<SmuCount;i++)
		{
			GuildSMU*	pSMU = pPoolPtr->GetPoolObj(i);
			if(!pSMU)
			{
				Assert(pSMU);
				return FALSE;
			}

			UseStats =pSMU->GetUseStatus(SM_C_READ);
		
			pSMU->Lock(SM_C_READ);
				GUILD_DB* pGuild = &(pSMU->m_GuildSM);
				if(pGuild == NULL)
				{
					pSMU->UnLock(SM_C_READ);
					Assert(FALSE);
				}
				
			memcpy(&SaveGuild,pGuild,sizeof(GUILD_DB));
			pSMU->m_SMUHead.UseStatus	= GUILD_SAVED;
			if(UseStats ==GUILD_DELETE)
			{
				pGuild->CleanUp();
			}

			pSMU->UnLock(SM_C_READ);

			if(SaveGuild.m_GuildID == INVALID_ID)
				continue;
				
			CHAR	AdminInfo[4096] = {0};
			
			Binary2String((CHAR*)(&SaveGuild.m_AdminLayout),
							sizeof(GUILD_ADMIN_t),
							AdminInfo);
			
			CHAR    GuildUser[MAX_LONG_COLUMN_BUFFER] = {0};

			Binary2String((CHAR*)(SaveGuild.m_aGuildUser),
						  sizeof(GUILDUSER_DB)*USER_ARRAY_SIZE,
						  GuildUser);
			
			
			LONG_DB_QUERY* pQuery = GetLongInterQuery();
			if(!pQuery)
			{
				Assert(FALSE);
			}
			pQuery->Clear();
			pQuery->Parse(SaveWorldGuildInfo,
						  SaveGuild.m_GuildID,
						  SaveGuild.m_GuildName,
						  SaveGuild.m_Status,
						  SaveGuild.m_ChieftainGUID,
						  SaveGuild.m_nProposerCount,
						  SaveGuild.m_UserCount,
						  SaveGuild.m_MaxUserSize,
						  SaveGuild.m_GuildPoint,
						  SaveGuild.m_GuildMoney,
						  SaveGuild.m_CityID,
						  SaveGuild.m_nTime,
						  SaveGuild.m_Longevity,
						  SaveGuild.m_Contribute,
						  SaveGuild.m_Honor,
						  SaveGuild.m_nIndustryLevel,
						  SaveGuild.m_nAgrLevel,
						  SaveGuild.m_nComLevel,
						  SaveGuild.m_nDefLevel,
						  SaveGuild.m_nTechLevel,
						  SaveGuild.m_nAmbiLevel,
						  AdminInfo,
						  SaveGuild.m_GuildDesc,
						  SaveGuild.m_GuildChiefName,
						  SaveGuild.m_GuildCreatorName,
						  SaveGuild.m_GuildLevel,
						  GuildUser,
						  ((UseStats!=GUILD_DELETE)?1:0) );

			if(!ODBCBase::LongSave(&Result))
				return FALSE;
		}

	}while(0);
	
	
	return TRUE;

	__LEAVE_FUNCTION

	return FALSE;
}