Example #1
0
static bool LoadSubmeshData(MZFile& file, EluMesh& mesh)
{
	u32 nsubmesh; V(file.Read(nsubmesh));

	mesh.DrawProps.resize(nsubmesh);

	for (u32 i = 0; i < nsubmesh; ++i)
	{
		auto& dp = mesh.DrawProps[i];

		u32 mat; V(file.Read(mat));
		dp.material = mat;
		u16 idx; V(file.Read(idx));
		dp.indexBase = idx;
		u16 cnt; V(file.Read(cnt));
		dp.count = cnt;
		dp.vertexBase = 0;
		V(file.Seek(4));

		if (dp.material < 0)
		{
			if (mesh.DrawProps.size() == 1)
			{
				mesh.DrawProps.clear();
				return true;
			}

			mesh.DrawProps.erase(mesh.DrawProps.begin() + i);
			mesh.DrawProps.resize(mesh.DrawProps.size() - 1);
			--i;
		}
	}

	return true;
}
Example #2
0
static bool ReadSubindices(MZFile& file, std::vector<std::array<u16, 6>>& subindices)
{
	V(ReadVector(file, subindices));
	u32 size; V(file.Read(size));
	V(file.Seek((64 + 2) * size));
	return true;
}
Example #3
0
static bool SkipVector(MZFile& file)
{
	u32 size;
	V(file.Read(size));
	V(file.Seek(size * sizeof(T)));
	return true;
}
Example #4
0
static bool ReadMeshData(MZFile& file, EluMesh& mesh,
	const std::vector<std::array<u16, 6>>& subindices, const VertexData& vertexData)
{
	mesh.VertexCount = subindices.size();
	u32 idxcnt; V(file.Read(idxcnt));
	mesh.IndexCount = idxcnt;
	mesh.Indices = decltype(mesh.Indices){new u16[mesh.IndexCount]};
	V(file.Read(mesh.Indices.get(), mesh.IndexCount * sizeof(mesh.Indices[0])));

	auto MakeVector = [&](auto& vec) {
		vec = std::remove_reference_t<decltype(vec)>{
			new std::remove_reference_t<decltype(vec[0])>[subindices.size()]};
	};
	MakeVector(mesh.Positions);
	MakeVector(mesh.Normals);
	MakeVector(mesh.TexCoords);
	MakeVector(mesh.Tangents);

	for (size_t i = 0; i < subindices.size(); ++i)
	{
		mesh.Positions[i] = vertexData.Positions[subindices[i][0]];
		mesh.Normals[i] = vertexData.Normals[subindices[i][1]];

		auto& tx = vertexData.TexCoords[subindices[i][2]];
		mesh.TexCoords[i] = { tx.x, tx.y };

		mesh.Tangents[i] = vertexData.Tangents[subindices[i][4]];
	}

	return true;
}
Example #5
0
static bool ReadVector(MZFile& file, std::vector<T>& vec)
{
	u32 size;
	V(file.Read(size));
	vec.resize(size);
	V(file.Read(vec.data(), size * sizeof(vec[0])));
	return true;
}
Example #6
0
static bool ReadName(MZFile& file, EluMesh& mesh)
{
	u32 name_length{};
	V(file.Read(name_length));
	char name_buffer[256];
	V(file.Read(name_buffer, name_length));
	mesh.Name = name_buffer;
	return true;
}
Example #7
0
static bool ReadBisomething(MZFile& file)
{
	u32 bcount; V(file.Read(bcount));
	for (u32 i = 0; i < bcount; ++i)
	{
		u32 bi; V(file.Read(bi));
		V(file.Seek(8 * bi));
	}

	V(file.Seek(4));

	return true;
}
bool ZConfiguration::LoadGameTypeCfg(const char* szFileName)
{
	MXmlDocument xmlIniData;
	xmlIniData.Create();

	char			*buffer;
	MZFile			mzFile;
	if( !mzFile.Open(szFileName, ZApplication::GetFileSystem())) 
	{
		xmlIniData.Destroy();
		return false;
	} 

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

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

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

		xmlIniData.Destroy();
		delete []buffer;
		return false;
	}


	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, ZTOK_GAME_TYPE)) 
		{
			int nID = 0;
			chrElement.GetAttribute( &nID, "id");

			m_pGameTypeList->ParseGameTypeList( nID, chrElement);
		}
	}

	xmlIniData.Destroy();
	delete []buffer;

	return true;
}
Example #9
0
static bool LoadMesh5013(MZFile& file, EluMesh &mesh)
{
	V(ReadName(file, mesh));

	V(file.Seek(4));
	V(SkipVector<char>(file));
	V(ReadWorld(file, mesh));
	V(file.Seek(16));

	VertexData vertexData;
	V(ReadVertexData(file, mesh, vertexData, { Pos, Tex, SkipVecV3, Nor, Tan, SkipVecV3 }));

	V(ReadIndices(file));
	V(ReadBisomething(file));

	std::vector<std::array<u16, 6>> subindices;
	V(ReadSubindices(file, subindices));
	V(LoadSubmeshData(file, mesh));
	V(ReadMeshData(file, mesh, subindices, vertexData));

	V(file.Seek(2 * sizeof(v3)));

	return true;
}
Example #10
0
static bool ReadVertexData(MZFile& file, EluMesh& mesh, VertexData& data,
	const VertexAttributeOrder (&Order)[6])
{
	for (auto& Attribute : Order)
	{
		switch (Attribute)
		{
		case Pos: V(ReadVector(file, data.Positions)); break;
		case Nor: V(ReadVector(file, data.Normals)); break;
		case Tan: V(ReadVector(file, data.Tangents)); break;
		case Tex: V(ReadVector(file, data.TexCoords)); break;
		case Skip4: V(file.Seek(4)); break;
		case SkipVecV3: V(SkipVector<v3>(file)); break;
		}
	}

	return true;
}
Example #11
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;
}
Example #12
0
static bool ReadIndices(MZFile& file)
{
	u32 ntris;
	V(file.Read(ntris));
	if (ntris > 0)
	{
		V(file.Seek(4));
		V(file.Read(ntris));

		for (u32 i = 0; i < ntris; ++i)
		{
			u32 nverts;
			V(file.Read(nverts));
			V(file.Seek(12 * nverts + 2));
		}
	}

	V(SkipVector<v3>(file));
	V(file.Seek(4));

	return true;
}
Example #13
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();
	}
}
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;
}
Example #15
0
static bool LoadElu(LoaderState& State, const char* name)
{
	// HACK: Don't load shadowbox
	if (strstr(name, "shadowbox") != nullptr)
		return false;

	State.ObjectData.emplace_back();
	auto& dest = State.ObjectData.back();

	bool ReachedEnd = false;
	DEFER([&] { if (!ReachedEnd) State.ObjectData.pop_back(); });

	MZFile File;

	auto success = TryForEachPath(State.Paths, name, [&](auto& Path) {
		return File.Open(Path.c_str(), RealSpace2::g_pFileSystem);
	});
	if (!success)
	{
		MLog("LoadElu -- Failed to open elu file %s\n", name);
		return false;
	}

	EluHeader hdr;
	File.Read(hdr);

	dest.Meshes.reserve(hdr.meshCount);
	for (u32 i = 0; i < hdr.meshCount; ++i)
	{
		dest.Meshes.emplace_back();
		auto& Mesh = dest.Meshes.back();

		bool success{};

		switch (hdr.Version)
		{
		case 0x5012:
			success = LoadMesh5012(File, Mesh);
			break;
		case 0x5013:
			success = LoadMesh5013(File, Mesh);
			break;
		default:
			DMLog("Unknown mesh version %X\n", hdr.Version);
		}

		if (!success)
		{
			MLog("Failed to load mesh index %d version %x for elu %s\n", i, hdr.Version, name);
			return false;
		}

		dest.VertexCount += Mesh.VertexCount;
		dest.IndexCount += Mesh.IndexCount;

		DMLog("%s mesh %s %d vert %d index\n",
			name, Mesh.Name.c_str(), Mesh.VertexCount, Mesh.IndexCount);
		for (size_t j{}; j < Mesh.DrawProps.size(); ++j)
		{
			auto& dp = Mesh.DrawProps[j];
			DMLog("DrawProp %d: vb: %d, ib: %d, cnt: %d, mat: %d\n",
				j, dp.vertexBase, dp.indexBase, dp.count, dp.material);
		}
	}

	assert(File.Tell() == File.GetLength());

	DMLog("%s -- Meshes.size() = %d\n", name, dest.Meshes.size());

	dest.MaterialStart = State.Materials.size();
	if (!loadMaterial(State, (std::string{ name } +".xml").c_str()))
	{
		MLog("Failed to load material for elu %s\n", name);
		return false;
	}
	dest.Name = name;

	State.EluMap[dest.Name] = State.ObjectData.size() - 1;

	ReachedEnd = true;

	return true;
}
Example #16
0
static bool ReadWorld(MZFile& file, EluMesh& mesh)
{
	V(file.Read(mesh.World));
	return true;
}
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;
}
Example #18
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;

}
Example #19
0
bool MMapDesc::Initialize(MZFileSystem* pFileSystem, const char* szFileName)
{
	MXmlDocument	xmlIniData;	
	xmlIniData.Create();

	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;
		}
	}

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

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


	int iCount, num =0 ;
	MXmlElement		aParent, aChild;
	aParent = xmlIniData.GetDocumentElement();
	iCount = aParent.GetChildNodeCount();

	char szTagName[256]="";

	for (int i = 0; i < iCount; i++)
	{
		aChild = aParent.GetChildNode(i);
		aChild.GetTagName(szTagName);
		if(stricmp(szTagName,MMAP_MAP)==0)
		{
			if (szTagName[0] == '#') continue;
			
			aChild.GetAttribute(&m_MapVectors[num].nMapID, MMAP_ID);
			aChild.GetAttribute(m_MapVectors[num].szMapName , MMAP_NAME);
			aChild.GetAttribute(m_MapVectors[num].szMapImageName , MMAP_IMAGENAME);
			aChild.GetAttribute(m_MapVectors[num].szBannerName , MMAP_BANNERNAME);
			aChild.GetAttribute(&m_MapVectors[num].fExpRatio , MMAP_EXPRATIO);
			aChild.GetAttribute(&m_MapVectors[num].nMaxPlayers , MMAP_MAXPLAYERS);
			aChild.GetAttribute(&m_MapVectors[num].bOnlyDuelMap , MMAP_ONLYDUELMAP);
			
			num++;
		}
	}
    
	if(buffer)
	{
		delete[] buffer;
		buffer = NULL; 
	}

	return true;
}
Example #20
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;
}
Example #21
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);
				}
			}
		}
Example #22
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;
}
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;
}