Ejemplo n.º 1
0
void MemCacheServerHandler::SetEnbale(bool enable)
{
	m_bEnabled = enable;
	if (!enable)
	{
		Ini myini;
		if (myini.Open("MemErr_Plat.ini") == false)
		{
			//return;
		}
		myini.Write("MemCache", "MemCacheError",1);
		struct tm  tm_val; 
		time_t rawtime = 0; 
		time_t time_now = time ( &rawtime ); 
		tm_val = *localtime ( &rawtime ); 
		char time_str[128] = {0};
		sprintf(time_str,"%d-%d-%d-%d:%d:%d",tm_val.tm_year + 1900,tm_val.tm_mon +1,tm_val.tm_mday,tm_val.tm_hour,tm_val.tm_min,tm_val.tm_sec);
		myini.Write("MemCache", "ErrDate",time_str);
		myini.Save();
	}
}
Ejemplo n.º 2
0
BOOL AreaManager::Init( const CHAR *pszPathName )
{
__ENTER_FUNCTION

	AREA_FILE* pAreaFile = g_pSceneManager->FindAreaFile(pszPathName) ;
	if( pAreaFile==NULL )
	{//没有读到数据	
		pAreaFile = g_pSceneManager->FindEmptyAreaFile() ;
		if( pAreaFile==NULL )
		{
			Assert(FALSE) ;
			return FALSE ;
		}

		BOOL bResult;
		Ini iniArea;
		bResult = iniArea.Open( pszPathName );
		if ( !bResult )
		{
			Log::SaveLog( SERVER_LOGFILE, " AreaManager::Init can not open file;<filename=%s>", pszPathName );
			return FALSE;
		}

		CHAR szSection[128], szValue[128];
		if ( 0 != iniArea.ReadText( "area_info", "area_count", szValue, sizeof ( szValue ) ) )
		{
			
			pAreaFile->m_Count = (UINT)(atoi(szValue));
			m_uAreaCount = pAreaFile->m_Count ;
			if ( m_uAreaCount > 0 )
			{
				pAreaFile->m_pArea = new Area[pAreaFile->m_Count] ;
				if( pAreaFile->m_pArea==NULL )
				{
					Assert(FALSE) ;
					return FALSE ;
				}

				UINT i;
				for ( i = 0; i < m_uAreaCount; i++ )
				{
					Area *pArea = &(pAreaFile->m_pArea[i]);
					sprintf( szSection, "area%u", i );

					if ( 0 == iniArea.ReadText( szSection, "guid", szValue, sizeof ( szValue ) ) )
						break;
					pArea->m_uAreaID	= (UINT)atoi( szValue );

					if ( 0 == iniArea.ReadText( szSection, "script_id", szValue, sizeof ( szValue ) ) )
						break;
					pArea->m_uScriptID		= (UINT)atoi( szValue );

					if ( 0 == iniArea.ReadText( szSection, "left", szValue, sizeof ( szValue ) ) )
						break;
					pArea->m_rcArea.m_fLeft	= (FLOAT)atof( szValue );

					if ( 0 == iniArea.ReadText( szSection, "top", szValue, sizeof ( szValue ) ) )
						break;
					pArea->m_rcArea.m_fTop	= (FLOAT)atof( szValue );

					if ( 0 == iniArea.ReadText( szSection, "right", szValue, sizeof ( szValue ) ) )
						break;
					pArea->m_rcArea.m_fRight	= (FLOAT)atof( szValue );

					if ( 0 == iniArea.ReadText( szSection, "bottom", szValue, sizeof ( szValue ) ) )
						break;
					pArea->m_rcArea.m_fBottom	= (FLOAT)atof( szValue );

				}

				strncpy( pAreaFile->m_szFileName, pszPathName, _MAX_PATH-1 ) ;
			}
		}
		iniArea.Close();
	}

	//设置事件区数据
	for( INT i=0; i<pAreaFile->m_Count; i++ )
	{
		Area *pArea = &(pAreaFile->m_pArea[i]);
		m_pScene->RegisterArea(pArea);
	}


	return TRUE;

__LEAVE_FUNCTION

	return FALSE;
}