Beispiel #1
0
unsigned long MGetMZFileChecksum(const char* pszFileName) 
{
	MZFile mzf;
	if(!mzf.Open(pszFileName)) 
		return 0;

	char* pBuffer = NULL;
	int nLen = mzf.GetLength();
	pBuffer = new char[mzf.GetLength()+1];
	pBuffer[nLen] = 0;
	mzf.Read(pBuffer, nLen);
	mzf.Close();

	unsigned long nChecksum = MGetMemoryChecksum(pBuffer,nLen);
	delete pBuffer;
	return nChecksum;
}
Beispiel #2
0
bool ZMapDesc::LoadSmokeDesc(const char* pFileName)
{
	MXmlDocument	Data;
	Data.Create();

	MZFile mzf;

	if( !mzf.Open( pFileName, g_pFileSystem ))
	{
		return false;
	}

	char* buffer;
	buffer	= new char[mzf.GetLength() + 1];
	mzf.Read( buffer, mzf.GetLength() );
	buffer[mzf.GetLength()] = 0;

	if( !Data.LoadFromMemory(buffer) )
	{
		delete buffer;
		return false;
	}

	delete buffer;
	mzf.Close();

	MXmlElement root, child;
	char TagName[256];
	char Attribute[256];
	root = Data.GetDocumentElement();
	int iCount = root.GetChildNodeCount();	

	ZMapSmokeDummy* pMapSmoke = NULL;

	char drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT];

	for( int i = 0 ; i < iCount; ++i )
	{
		child		= root.GetChildNode(i);
		child.GetTagName( TagName );
		if( TagName[0] == '#' )
		{
			continue;
		}

		child.GetAttribute( Attribute, "NAME" );

		_splitpath(Attribute,drive,dir,fname,ext);
		
		pMapSmoke = m_SmokeDummyMgr.Get( string( fname ) );

		if( pMapSmoke ) {

			if( child.GetAttribute( Attribute, "DIRECTION" )) {

				if(pMapSmoke->m_SmokeType == ZMapSmokeType_ST) {

//					static rmatrix _mrot = RGetRotY(180) * RGetRotX(90);
//					((ZMapSmokeST*)pMapSmoke)->m_vSteamDir = pMapSmoke->m_vDir * _mrot;
					((ZMapSmokeST*)pMapSmoke)->m_vSteamDir = pMapSmoke->m_vDir;
				}
				
				D3DXMATRIX RotMat;
				rvector dir = rvector( 0,1,0 );
				int theta;
				sscanf( Attribute, "%d", &theta );
				D3DXMatrixRotationAxis( &RotMat, &rvector(0,0,1), ((float)theta*D3DX_PI/180) );
				dir = dir * RotMat;
					
				pMapSmoke->m_vDir = dir;
			}

			if( child.GetAttribute( Attribute, "LIFE" )) {

				float fLife=0.f;
				sscanf( Attribute, "%f", &fLife );
				pMapSmoke->m_fLife = fLife;
			}

			if( child.GetAttribute( Attribute, "TOGGLEMINTIME" )) {

				float fToggleMinTime=0.f;
				sscanf( Attribute, "%f", &fToggleMinTime );
				pMapSmoke->m_fToggleMinTime = fToggleMinTime;
			}

			if( child.GetAttribute( Attribute, "POWER" )) {

				float power=0.f;
				sscanf( Attribute, "%f", &power );
				pMapSmoke->m_fPower = power;
			}

			if(child.GetAttribute( Attribute, "DELAY" ) ) {

				int delay=0; 
				sscanf( Attribute, "%d", &delay );
				pMapSmoke->m_nDelay = delay;
			}

			if(child.GetAttribute( Attribute, "SIZE" ) ) {

				float _size=0;
				sscanf( Attribute, "%f", &_size );
				pMapSmoke->m_fSize = _size;
			}

			if(child.GetAttribute( Attribute, "COLOR" ) ) {

				int r,g,b;
				sscanf( Attribute, "%d,%d,%d", &r,&g,&b );
				pMapSmoke->m_dwColor = D3DCOLOR_ARGB(0,min(r,255),min(g,255),min(b,255));
			}
		}
	}

	return true;
}
Beispiel #3
0
bool MQuestScenarioCatalogue::ReadXml(MZFileSystem* pFileSystem,const char* szFileName)
{
	MXmlDocument	xmlIniData;
	xmlIniData.Create();

	char *buffer;
	MZFile mzf;

	if(pFileSystem) {
		if(!mzf.Open(szFileName,pFileSystem))  {
			if(!mzf.Open(szFileName))  {
				xmlIniData.Destroy();
				return false;
			}
		}
	} 
	else  {

		if(!mzf.Open(szFileName)) {

			xmlIniData.Destroy();
			return false;
		}
	}

	buffer = new char[mzf.GetLength()+1];
	buffer[mzf.GetLength()] = 0;

	mzf.Read(buffer,mzf.GetLength());

	if(!xmlIniData.LoadFromMemory(buffer)) {
		xmlIniData.Destroy();
		return false;
	}

	delete[] buffer;
	mzf.Close();


	MXmlElement rootElement, chrElement, attrElement;
	char szTagName[256];

	rootElement = xmlIniData.GetDocumentElement();
	int iCount = rootElement.GetChildNodeCount();

	for (int i = 0; i < iCount; i++) {

		chrElement = rootElement.GetChildNode(i);
		chrElement.GetTagName(szTagName);

		if (szTagName[0] == '#') continue;

		if (!_stricmp(szTagName, MTOK_SPECIAL_SCENARIO)) {
			ParseSpecialScenario(chrElement);
		}
		else if (!_stricmp(szTagName, MTOK_STANDARD_SCENARIO))
		{
			ParseStandardScenario(chrElement);
		}

	}

	xmlIniData.Destroy();

	return true;

}
Beispiel #4
0
//////////////////////////////////////////////////////////////////////////
//	InitEnv
//////////////////////////////////////////////////////////////////////////
void ZEmblemList::InitEnv( char* pFileName_ )
{
	MXmlDocument	Data;
	Data.Create();

	MZFile mzf;
	if( !mzf.Open( pFileName_, g_pFileSystem ))
	{
		return;
	}
	char* buffer;
	buffer	= new char[mzf.GetLength() + 1];
	mzf.Read( buffer, mzf.GetLength() );
	buffer[mzf.GetLength()] = 0;

	if( !Data.LoadFromMemory(buffer) )
	{
		delete buffer;
		return;
	}
	delete buffer;
	mzf.Close();

	MXmlElement root, child;
	char TagName[256];
	char Attribute[256];
	root = Data.GetDocumentElement();
	int iCount = root.GetChildNodeCount();	

	for( int i = 0 ; i < iCount; ++i )
	{
		child		= root.GetChildNode(i);
		child.GetTagName( TagName );
		if( TagName[0] == '#' )
		{
			continue;
		}
		child.GetAttribute( Attribute, "NAME" );
		mEmblemMapItor	= mEmblemMap.find( Attribute );
		if( mEmblemMapItor	!= mEmblemMap.end() )
		{
			ZClothEmblem* p		= mEmblemMapItor->second;
			
			if( child.GetAttribute( Attribute, "DIRECTION" ))
			{
				D3DXMATRIX RotMat;
				rvector dir = rvector( 0,1,0 );
				int theta;
				sscanf( Attribute, "%d", &theta );
				D3DXMatrixRotationAxis( &RotMat, &rvector(0,0,1), ((float)theta*D3DX_PI/180) );
				dir = dir*RotMat;
				//p->SetBaseWind( dir );
				p->GetWndGenerator()->SetWindDirection( dir );
			}

			if( child.GetAttribute( Attribute, "POWER" ))
			{
				float power;
				sscanf( Attribute, "%f", &power );
				p->GetWndGenerator()->SetWindPower( power );
			}
			
			MXmlElement dummy;
			int iDummyNum = child.GetChildNodeCount();
			for( int j = 0 ; j < iDummyNum; ++j )
			{
				dummy = child.GetChildNode( j );
				dummy.GetTagName( TagName );
				if( TagName[0] == '#' )
				{
					continue;
				}
				if( stricmp( TagName, "RESTRICTION" ) == 0 )
				{
					sRestriction* rest = new sRestriction;
					int iValue = 0;
					float fValue = 0.f;
					if( dummy.GetAttribute( Attribute, "AXIS" ))
					{
						sscanf( Attribute, "%d", &iValue );
						rest->axis	=(RESTRICTION_AXIS)iValue;
					}				
					if( dummy.GetAttribute( Attribute, "POSITION") )
					{
						sscanf( Attribute, "%f", &fValue );
						rest->position = fValue;
					}
					if( dummy.GetAttribute(Attribute, "COMPARE") )
					{
						sscanf( Attribute, "%d", &iValue );
						rest->compare =(RESTRICTION_COMPARE)iValue;
					}
					p->AddRestriction( rest );
				}
				else if( stricmp( TagName, "WINDTYPE" ) == 0 )
				{
					int iValue = 0;
					if( dummy.GetAttribute( Attribute, "TYPE" ) )
					{
						sscanf( Attribute, "%d", &iValue );
						p->GetWndGenerator()->SetWindType( (WIND_TYPE) iValue );
					}
					if( dummy.GetAttribute( Attribute, "DELAY" ))
					{
						sscanf( Attribute, "%d", &iValue );
						p->GetWndGenerator()->SetDelayTime( iValue );
					}
				}
			}
		}
	}

	for( list<ZClothEmblem*>::iterator iter = begin(); iter != end(); ++iter )
	{
		// 처음 몇 프레임을 계산하고 시작한다..
		for( int i = 0 ; i < 100; ++i )
			(*iter)->update();
	}
}
Beispiel #5
0
bool MQuestItemDescManager ::ReadXml( MZFileSystem* pFileSystem, const char* szFileName )
{
	if( (0== pFileSystem) || (0 == szFileName) )
		return false;

	MXmlDocument	xmlIniData;
	xmlIniData.Create();

	//	<-----------------
	char *buffer;
	MZFile mzf;

	if(pFileSystem) 
	{
		if(!mzf.Open(szFileName,pFileSystem)) 
		{
			if(!mzf.Open(szFileName)) 
			{
				xmlIniData.Destroy();
				return false;
			}
		}
	} 
	else 
	{
		if(!mzf.Open(szFileName))
		{
			xmlIniData.Destroy();
			return false;
		}
	}

	buffer = new char[mzf.GetLength()+1];
	buffer[mzf.GetLength()] = 0;
	mzf.Read(buffer,mzf.GetLength());

	if(!xmlIniData.LoadFromMemory(buffer))
	{
		xmlIniData.Destroy();
		return false;
	}
	delete[] buffer;
	mzf.Close();
	//	<------------------

	MXmlElement rootElement, chrElement, attrElement;
	char szTagName[256];

	rootElement = xmlIniData.GetDocumentElement();
	int iCount = rootElement.GetChildNodeCount();

	for (int i = 0; i < iCount; i++)
	{
		chrElement = rootElement.GetChildNode(i);
		chrElement.GetTagName(szTagName);
		if (szTagName[0] == '#') continue;

		if (!stricmp(szTagName, MQICTOK_ITEM))
		{
			ParseQuestItem(chrElement);
		}
	}

	xmlIniData.Destroy();

	return true;
}
Beispiel #6
0
bool ZSoundEngine::LoadResource(char* pFileName)
{
	MXmlDocument Data;

	MZFile mzf;
	if(!mzf.Open(pFileName, m_pZFileSystem)) return false;

	char *buffer;
	buffer=new char[mzf.GetLength()+1];
	mzf.Read(buffer,mzf.GetLength());
	buffer[mzf.GetLength()]=0;

	Data.Create();
	if(!Data.LoadFromMemory(buffer))
	{
		delete buffer;
		return false;
	}
	delete buffer;
	mzf.Close();


	MXmlElement root, chr, attr;

	char szSoundName[256];
	char szSoundFileName[256];


	root		= Data.GetDocumentElement();
	int iCount	= root.GetChildNodeCount();

	for( int i = 0 ; i < iCount; ++i )
	{
		chr		= root.GetChildNode(i);
		chr.GetTagName( szSoundName );
		if( szSoundName[0] == '#' ) continue;

		chr.GetAttribute( szSoundName, "name" );
		strcpy( szSoundFileName, SOUNDEFFECT_DIR );
		strcat( szSoundFileName, szSoundName );
		strcat( szSoundFileName, ".wav" );

		char szType[64] = "";
		chr.GetAttribute(szType, "type", "3d");


		float min = ZDEF_MINDISTANCE;
		float max = ZDEF_MAXDISTANCE;
		float fTemp;
		if( chr.GetAttribute( &fTemp, "MINDISTANCE" )) min = fTemp;
		if( chr.GetAttribute( &fTemp, "MAXDISTANCE" )) max = fTemp;

		bool bLoop = false;
		chr.GetAttribute(&bLoop, "loop");

		float fDefaultVolume = 1.0f;
		chr.GetAttribute(&fDefaultVolume, "volume", 1.0f);

		unsigned long int nFlags=0;

		if (bLoop) nFlags |= RSOUND_LOOP_NORMAL;
		else nFlags |= RSOUND_LOOP_OFF;

		if (!stricmp(szType, "2d"))
		{
			OpenSound(szSoundFileName, RSOUND_2D | nFlags);

			if (!IS_EQ(fDefaultVolume, 1.0f))
			{
				RBaseSoundSource* pSoundSource = GetSoundSource(szSoundFileName, RSOUND_]2D);
				if (pSoundSource)
				{
					SetDefaultVolume(pSoundSource, fDefaultVolume);
				}
			}
		}
bool ZConfiguration::LoadSystem(const char* szFileName)
{
	char			*buffer;
	MZFile			mzFile;
	MXmlDocument	xmlConfig;
	xmlConfig.Create();

	if( !mzFile.Open( szFileName, ZApplication::GetFileSystem())) 
	{
		xmlConfig.Destroy();
		return false;
	} 

	buffer = new char[ mzFile.GetLength()+1];
	buffer[mzFile.GetLength()]=0;
	mzFile.Read( buffer, mzFile.GetLength());

	mlog( "Load XML from memory : %s", FILENAME_SYSTEM );

	if( !xmlConfig.LoadFromMemory( buffer, GetLanguageID(m_Locale.strDefaultLanguage.c_str())) )
	{
		mlog( "- FAIL\n");

		xmlConfig.Destroy();
		return false;
	}
	delete[] buffer;
	mzFile.Close();
	mlog( "- SUCCESS\n");

	MXmlElement		parentElement = xmlConfig.GetDocumentElement();
	MXmlElement		serverElement, childElement;

	int iCount = parentElement.GetChildNodeCount();

	if (!parentElement.IsEmpty())
	{
		m_ServerList.clear();

		m_nServerCount = 0;
		while ( 1)
		{
			char szText[ 256];
			sprintf( szText, "%s%d", ZTOK_SERVER, m_nServerCount);
			if (parentElement.FindChildNode( szText, &serverElement))
			{
				char szServerIP[ 32];
				char szName[ 32];
				int nServerPort;
				int nServerType;
				serverElement.GetChildContents( szServerIP,		ZTOK_IP);
				serverElement.GetChildContents( &nServerPort,	ZTOK_PORT);
				serverElement.GetChildContents( &nServerType,	ZTOK_TYPE);
				serverElement.GetChildContents( szName,			ZTOK_NAME);

                ZSERVERNODE ServerNode;
				strcpy( ServerNode.szAddress, szServerIP);
				strcpy( ServerNode.szName, szName);
				ServerNode.nPort = nServerPort;
				ServerNode.nType = nServerType;

				m_ServerList.insert( map<int,ZSERVERNODE>::value_type( m_nServerCount, ServerNode));

				m_nServerCount++;
			}
			else
				break;
		}

		if (parentElement.FindChildNode(ZTOK_LOCALE_BAREPORT, &childElement))
		{
			childElement.GetChildContents( m_szBAReportAddr, ZTOK_ADDR);
			childElement.GetChildContents( m_szBAReportDir,  ZTOK_DIR);
		}

		if (parentElement.FindChildNode(ZTOK_LOCALE_XMLHEADER, &childElement))
		{
			childElement.GetContents(m_Locale.szXmlHeader);
		}

		if (parentElement.FindChildNode(ZTOK_SKIN, &childElement))
		{
			childElement.GetContents(m_szInterfaceSkinName);
		}

		if (parentElement.FindChildNode(ZTOK_LOCALE_DEFFONT, &childElement))
		{
			childElement.GetContents(m_Locale.szDefaultFont);
		}

		if (parentElement.FindChildNode(ZTOK_LOCALE_IME, &childElement))
		{
 			childElement.GetContents(&m_Locale.bIMESupport);

			MEvent::SetIMESupport( m_Locale.bIMESupport);
		}
		if (parentElement.FindChildNode(ZTOK_LOCALE_HOMEPAGE, &childElement))
		{
			childElement.GetChildContents( m_Locale.szHomepageUrl,		ZTOK_LOCALE_HOMEPAGE_URL);
			childElement.GetChildContents( m_Locale.szHomepageTitle,	ZTOK_LOCALE_HOMEPAGE_TITLE);
		}
		if (parentElement.FindChildNode(ZTOK_LOCALE_EMBLEM_URL, &childElement))
		{
			childElement.GetContents( m_Locale.szEmblemURL);
		}
		if (parentElement.FindChildNode(ZTOK_LOCALE_TEMBLEM_URL, &childElement))
		{
			childElement.GetContents( m_Locale.szTEmblemURL);
		}
		if (parentElement.FindChildNode(ZTOK_LOCALE_CASHSHOP_URL, &childElement))
		{
			childElement.GetContents( m_Locale.szCashShopURL);
		}
		if (parentElement.FindChildNode(ZTOK_LOCATOR_LIST, &childElement))
		{
			m_pLocatorList->ParseLocatorList(childElement);
		}
		if (parentElement.FindChildNode(ZTOK_TLOCATOR_LIST, &childElement))
		{
			m_pTLocatorList->ParseLocatorList(childElement);
		}
	}
	xmlConfig.Destroy();

	m_bIsComplete = true;
	return true;
}
bool ZConfiguration::LoadLocale(const char* szFileName)
{
	MXmlDocument	xmlLocale;
	MXmlElement		parentElement, serverElement, bindsElement;
	MXmlElement		childElement;
	MXmlElement		selectableLangsElem;

	char			*buffer;
	MZFile			mzFile;

	xmlLocale.Create();

	if( !mzFile.Open(szFileName, ZApplication::GetFileSystem())) 
	{
		xmlLocale.Destroy();
		return false;
	} 

	buffer = new char[ mzFile.GetLength()+1];
	buffer[mzFile.GetLength()]=0;
	mzFile.Read( buffer, mzFile.GetLength());

	mlog( "Load XML from memory : %s", szFileName);

	if( !xmlLocale.LoadFromMemory(buffer) )
	{
		mlog( "- FAIL\n");

		xmlLocale.Destroy();
		return false;
	}
	delete[] buffer;
	mzFile.Close();
	mlog( "- SUCCESS\n");

	parentElement = xmlLocale.GetDocumentElement();
	int iCount = parentElement.GetChildNodeCount();

	if (!parentElement.IsEmpty())
	{
		if( parentElement.FindChildNode(ZTOK_LOCALE, &childElement) )
		{
			char szCountry[ 16 ]	= "";
			char szLanguage[ 16 ]	= "";
			//int nMaxPlayers = 16;
			int nMaxPlayers = 127;

			childElement.GetChildContents( szCountry, ZTOK_LOCALE_COUNTRY );
			childElement.GetChildContents( szLanguage, ZTOK_LOCALE_LANGUAGE );
			childElement.GetChildContents( &nMaxPlayers, ZTOK_LOCALE_MAXPLAYERS);
			if (childElement.FindChildNode(ZTOK_LOCALE_SELECTABLE_LANGUAGES, &selectableLangsElem))
				ParseLocaleSelectableLanguages(selectableLangsElem);

			if( (0 == szCountry) || (0 == szLanguage) )
			{
				mlog( "config.xml - Country or Language is invalid.\n" );
				return false;
			}

			m_Locale.strCountry			= szCountry;
			m_Locale.strDefaultLanguage	= szLanguage;
			m_Locale.nMaxPlayers		= nMaxPlayers;

		    strcpy(m_Etc.szLanguage, szLanguage);
			mlog( "Country : KOR, Language : KOR\n", szCountry, szLanguage );
			//mlog( "Country : (%s), Language : (%s)\n", szCountry, szLanguage );
		}
	}
	xmlLocale.Destroy();

	return true;
}
bool MMatchEventFactoryManager::LoadEventListXML( MZFileSystem* pFileSystem, const string& strFileName )
{
	MXmlDocument	xmlIniData;
	xmlIniData.Create();

	//	<-----------------
	char *buffer;
	MZFile mzf;

	if(pFileSystem) 
	{
		if(!mzf.Open(strFileName.c_str(),pFileSystem)) 
		{
			if(!mzf.Open(strFileName.c_str())) 
			{
				xmlIniData.Destroy();
				return false;
			}
		}
	} 
	else 
	{
		if(!mzf.Open(strFileName.c_str()))
		{
			xmlIniData.Destroy();
			return false;
		}
	}

	buffer = new char[mzf.GetLength()+1];
	buffer[mzf.GetLength()] = 0;
	mzf.Read(buffer,mzf.GetLength());

	if(!xmlIniData.LoadFromMemory(buffer))
	{
		xmlIniData.Destroy();
		return false;
	}
	delete[] buffer;
	mzf.Close();
	//	<------------------

	MXmlElement rootElement, chrElement, attrElement;
	char szTagName[256];

	rootElement = xmlIniData.GetDocumentElement();
	int iCount = rootElement.GetChildNodeCount();

	for (int i = 0; i < iCount; i++)
	{
		chrElement = rootElement.GetChildNode(i);
		chrElement.GetTagName(szTagName);
		if (szTagName[0] == '#') continue;

		if (!stricmp(EL_LOCALE, szTagName))
		{
			ParseLocale( chrElement );
		}
	}

	xmlIniData.Destroy();
	return true;
}