bool MEmblemMgr::CreateCache() { TCHAR szEmblemPath[MAX_PATH]=""; TCHAR szPath[MAX_PATH]=""; if(GetMyDocumentsPath(szPath)) { strcpy_safe(szEmblemPath, szPath); strcat_safe(szEmblemPath, GUNZ_FOLDER); CreatePath(szEmblemPath); strcat_safe(szEmblemPath, MPATH_EMBLEMFOLDER); CreatePath(szEmblemPath); strcat_safe(szEmblemPath, MPATH_EMBLEMFILE); } else { return false; } MXmlDocument xmlDoc; xmlDoc.Create(); bool bResult = xmlDoc.SaveToFile(szEmblemPath); xmlDoc.Destroy(); return bResult; }
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; }
bool MCharacterDescManager::Read(const char* szFileName) { MXmlDocument xmlIniData; xmlIniData.Create(); if (!xmlIniData.LoadFromFile(szFileName)) { xmlIniData.Destroy(); return false; } MXmlElement rootElement, chrElement, attrElement; char szTemp[256]; char szName[256]; rootElement = xmlIniData.GetDocumentElement(); int iCount = rootElement.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { chrElement = rootElement.GetChildNode(i); chrElement.GetTagName(szTemp); if (szTemp[0] == '#') continue; if (!strcmp(szTemp, "CHARACTER")) { int id = -1; memset(szName, 0, 256); chrElement.GetAttribute(&id, "id"); chrElement.GetAttribute(szName, "name"); MCharacterDesc* pCharacterDesc = new MCharacterDesc(id, szName); MCharacterBasicAttr basic_attr; if (chrElement.FindChildNode("BasicAttr", &attrElement)) { attrElement.GetAttribute(&basic_attr.nSTR, "str"); attrElement.GetAttribute(&basic_attr.nCON, "con"); attrElement.GetAttribute(&basic_attr.nDEX, "dex"); attrElement.GetAttribute(&basic_attr.nAGI, "agi"); attrElement.GetAttribute(&basic_attr.nINT, "int"); attrElement.GetAttribute(&basic_attr.nCHA, "cha"); } pCharacterDesc->SetDesc(&basic_attr); insert(value_type(id, pCharacterDesc)); } } xmlIniData.Destroy(); return true; }
/// MAP이라는 Element의 ID가 bird인 항목을 찾아 HEIGHT와 WIDTH를 /// 500으로 변환하고 new.xml로 저장한다. void Sample2() { MXmlDocument aXml; aXml.Create(); if (!aXml.LoadFromFile("sample1.xml")) return; int iCount, i; char szBuf1[65535], szBuf2[65535]; MXmlElement aParent, aChild; aParent = aXml.GetDocumentElement(); iCount = aParent.GetChildNodeCount(); for (i = 0; i < iCount; i++) { aChild = aParent.GetChildNode(i); aChild.GetTagName(szBuf1); if (szBuf1[0] == '#') continue; if (!strcmp(szBuf1, "MAP")) { aChild.GetAttribute(szBuf2, "ID"); if (!strcmp(szBuf2, "bird")) { aParent = aChild; if (aParent.FindChildNode("WIDTH", &aChild)) { sprintf(szBuf1, "%d", 500); aChild.SetContents(szBuf1); } if (aParent.FindChildNode("HEIGHT", &aChild)) { sprintf(szBuf1, "%d", 500); aChild.SetContents(szBuf1); } } } } aXml.SaveToFile("new.xml"); aXml.Destroy(); printf("Done!!!\n"); }
// xml 파일 만들기 예제 void Sample3() { MXmlDocument aXml; aXml.Create(); aXml.CreateProcessingInstruction(); MXmlElement aRootElement; MXmlElement aElement; MXmlElement aChildElement; aRootElement = aXml.CreateElement("XML"); aXml.AppendChild(aRootElement); aRootElement = aXml.GetDocumentElement(); /// text aRootElement.AppendText("\n\t"); aElement = aXml.CreateElement("TEST"); aRootElement.AppendChild(aElement); aElement.AddAttribute("id", "1"); aElement.AddAttribute("map", "bird"); /// text aElement.AppendText("\n\t\t"); aChildElement = aXml.CreateElement("CHILD"); aChildElement.AddAttribute("attr", 500); aChildElement.SetContents("자식 노드"); aElement.AppendChild(aChildElement); /// text aElement.AppendText("\n\t"); /// text aXml.GetDocumentElement().AppendText("\n"); aXml.SaveToFile("new2.xml"); printf("Done!!!\n"); }
bool MMapDesc::Initialize(const char* szFileName) { MXmlDocument xmlIniData; xmlIniData.Create(); if (!xmlIniData.LoadFromFile(szFileName)) { 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; _ASSERT( 0 <= num && num < MMATCH_MAP_COUNT); 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++; } } return true; }
bool MQuestScenarioCatalogue::ReadXml(const char* szFileName) { MXmlDocument xmlIniData; xmlIniData.Create(); if (!xmlIniData.LoadFromFile(szFileName)) { xmlIniData.Destroy(); 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, MTOK_SPECIAL_SCENARIO)) { ParseSpecialScenario(chrElement); } else if (!_stricmp(szTagName, MTOK_STANDARD_SCENARIO)) { ParseStandardScenario(chrElement); } } xmlIniData.Destroy(); return true; }
bool MQuestItemDescManager ::ReadXml( const char* szFileName ) { if( 0 == szFileName ) return false; MXmlDocument xmlIniData; xmlIniData.Create(); if (!xmlIniData.LoadFromFile(szFileName)) { xmlIniData.Destroy(); 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, MQICTOK_ITEM)) { ParseQuestItem(chrElement); } } xmlIniData.Destroy(); return true; }
bool MAgentConfig::LoadFromXML(const char* pszFileName) { MXmlDocument xmlConfig; MXmlElement parentElement, childElement; MXmlElement serverElement; xmlConfig.Create(); if (!xmlConfig.LoadFromFile(pszFileName)) { xmlConfig.Destroy(); return false; } parentElement = xmlConfig.GetDocumentElement(); int iCount = parentElement.GetChildNodeCount(); if (!parentElement.IsEmpty()) { if (parentElement.FindChildNode(ATOK_AGENTCONFIG, &serverElement)) { serverElement.GetChildContents(m_szName, ATOK_NAME); serverElement.GetChildContents(&m_nMaxClient, ATOK_MAXCLIENT); if (serverElement.FindChildNode(ATOK_ADDRESS, &childElement)) { childElement.GetAttribute(m_szIP, ATOK_ATTR_IP); childElement.GetAttribute(&m_nTCPPort, ATOK_ATTR_TCPPORT); childElement.GetAttribute(&m_nUDPPort, ATOK_ATTR_UDPPORT); } if (serverElement.FindChildNode(ATOK_MATCHSERVERADDRESS, &childElement)){ childElement.GetAttribute(m_szMatchServerIP, ATOK_ATTR_IP); childElement.GetAttribute(&m_nMatchServerTCPPort, ATOK_ATTR_TCPPORT); } } } xmlConfig.Destroy(); return true; }
bool MMatchEventFactoryManager::LoadEventListXML( const string& strFileName ) { MXmlDocument xmlIniData; xmlIniData.Create(); if (!xmlIniData.LoadFromFile(strFileName.c_str())) { xmlIniData.Destroy(); return false; } MXmlElement rootElement, chrElement, attrElement; char szTagName[256]; rootElement = xmlIniData.GetDocumentElement(); int iCount = rootElement.GetChildNodeCount(); m_LoadEventSize = 0; 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; }
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; }
bool MEmblemMgr::LoadCache() { MXmlDocument xmlDoc; xmlDoc.Create(); if (!xmlDoc.LoadFromFile(GetEmblemDataFile())) { xmlDoc.Destroy(); return false; } MXmlElement rootElement,emblemElement,childElement; char szTagName[256]; rootElement = xmlDoc.GetDocumentElement(); int iCount = rootElement.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { emblemElement = rootElement.GetChildNode(i); emblemElement.GetTagName(szTagName); if (szTagName[0] == '#') continue; if (!strcmp(szTagName, MTOK_EMBLEM)) { int nCLID = -1; char szURL[256]=""; int nChecksum = -1; time_t tmLastUsed = 0; int nEmblemChildCount = emblemElement.GetChildNodeCount(); MXmlElement chrElement; for (int j = 0; j < nEmblemChildCount; j++) { chrElement = emblemElement.GetChildNode(j); chrElement.GetTagName(szTagName); if (szTagName[0] == '#') continue; if (!strcmp(szTagName, MTOK_EMBLEM_CLID)) { chrElement.GetContents(&nCLID); } else if (!strcmp(szTagName, MTOK_EMBLEM_URL)) { chrElement.GetContents(szURL); } else if (!strcmp(szTagName, MTOK_EMBLEM_CHECKSUM)) { chrElement.GetContents(&nChecksum); } } if ((nCLID != -1) && (szURL[0] != 0) && (nChecksum != -1)) { emblemElement.GetChildContents((int*)&tmLastUsed, MTOK_EMBLEM_TIMELASTUSED); // 없어도 로드되게 RegisterEmblem(nCLID, szURL, nChecksum, tmLastUsed); } } } xmlDoc.Destroy(); return true; }
/// GLOBAL이라는 Element를 찾아서 Child Element의 내용을 읽는다. void Sample1() { int iCount, i; char szBuf[65535]; MXmlDocument aXml; MXmlElement aParent, aChild; MXmlNode aNode; SServConfig aConfig; memset(&aConfig, 0, sizeof(aConfig)); aXml.Create(); if (!aXml.LoadFromFile("sample1.xml")) return; aParent = aXml.GetDocumentElement(); if (aParent.FindChildNode("GLOBAL", &aChild)) { aParent = aChild; iCount = aParent.GetChildNodeCount(); for (i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); aChild = aParent.GetChildNode(i); aChild.GetTagName(szBuf); if (szBuf[0] == '#') continue; if (!strcmp(szBuf, "SERVERNAME")) { aChild.GetContents(aConfig.ServerName); } else if (!strcmp(szBuf, "LOCATION")) { aChild.GetContents(aConfig.Location); } else if (!strcmp(szBuf, "DESCRIPTION")) { aChild.GetContents(aConfig.Desc); } else if (!strcmp(szBuf, "ADMINNAME")) { aChild.GetContents(aConfig.AdminName); } else if (!strcmp(szBuf, "ADMINEMAIL")) { aChild.GetContents(aConfig.AdminEMail); } } printf("ServerName = %s\n", aConfig.ServerName); printf("Location = %s\n", aConfig.Location); printf("Description = %s\n", aConfig.Desc); printf("AdminName = %s\n", aConfig.AdminName); printf("AdminEMail = %s\n", aConfig.AdminEMail); printf("Done!!!\n\n"); } aXml.Destroy(); }
bool MEmblemMgr::SaveCache() { list<MEmblemNode*> sortedQueue; for (MEmblemMap::iterator i=m_EmblemMap.begin(); i!=m_EmblemMap.end(); i++) { MEmblemNode* pNode = (*i).second; sortedQueue.push_back(pNode); } sortedQueue.sort(CompareEmblem); MXmlDocument xmlDoc; char szBuf[256]=""; xmlDoc.Create(); xmlDoc.CreateProcessingInstruction(); MXmlElement rootElement; rootElement=xmlDoc.CreateElement("XML"); xmlDoc.AppendChild(rootElement); int nCount = 0; for (list<MEmblemNode*>::iterator i=sortedQueue.begin(); i!=sortedQueue.end(); i++) { MEmblemNode* pNode = (*i); rootElement.AppendText("\n\t"); MXmlElement emblemElement = rootElement.CreateChildElement(MTOK_EMBLEM); emblemElement.AppendText("\n\t\t"); MXmlElement childElement; sprintf_safe(szBuf,"%u", pNode->GetCLID()); childElement = emblemElement.CreateChildElement(MTOK_EMBLEM_CLID); childElement.SetContents(szBuf); emblemElement.AppendText("\n\t\t"); childElement = emblemElement.CreateChildElement(MTOK_EMBLEM_URL); childElement.SetContents(pNode->GetURL()); emblemElement.AppendText("\n\t\t"); sprintf_safe(szBuf,"%u", pNode->GetChecksum()); childElement = emblemElement.CreateChildElement(MTOK_EMBLEM_CHECKSUM); childElement.SetContents(szBuf); emblemElement.AppendText("\n\t\t"); sprintf_safe(szBuf, "%u", (unsigned int)pNode->GetTimeLastUsed()); childElement = emblemElement.CreateChildElement(MTOK_EMBLEM_TIMELASTUSED); childElement.SetContents(szBuf); emblemElement.AppendText("\n\t"); if (++nCount >= 1000) break; } rootElement.AppendText("\n"); bool bResult = xmlDoc.SaveToFile(GetEmblemDataFile()); xmlDoc.Destroy(); SetSaveFlag(false); sortedQueue.clear(); return bResult; }
////////////////////////////////////////////////////////////////////////// // 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 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; }
bool MSpawnManager::ReadSpawnPosition(char* pszMapFile) { MXmlDocument aXml; aXml.Create(); if (!aXml.LoadFromFile(pszMapFile)) { aXml.Destroy(); return false; } char szBuf[65535]; ZeroMemory(szBuf, 65535); MXmlElement aRoot; aRoot = aXml.GetDocumentElement(); int nTotalRead = 0; int nSpawnListCount = aRoot.GetChildNodeCount(); for (int i=0; i<nSpawnListCount; i++) { MXmlElement aSpawnList = aRoot.GetChildNode(i); aSpawnList.GetTagName(szBuf); if (szBuf[0] == '#') continue; if (!stricmp(szBuf, MTOK_SPAWNPOSITIONLIST)) { int nSpawnCount = aSpawnList.GetChildNodeCount(); for (int j=0; j<nSpawnCount; j++) { MXmlElement aSpawn = aSpawnList.GetChildNode(j); aSpawn.GetTagName(szBuf); if (szBuf[0] == '#') continue; if (!strcmp(szBuf, MTOK_SPAWNPOSITION)) { char szSpawnName[128]; ZeroMemory(szSpawnName, 128); rvector Pos; if (!aSpawn.GetAttribute(szSpawnName, MTOK_NAME)) continue; int nFieldCount = aSpawn.GetChildNodeCount(); for (int k=0; k<nFieldCount; k++) { MXmlElement aField = aSpawn.GetChildNode(k); aField.GetTagName(szBuf); if (szBuf[0] == '#') continue; if (!stricmp(szBuf, MTOK_POSITION)) { aField.GetContents(szBuf); sscanf(szBuf, "%f %f %f", &Pos.x, &Pos.y, &Pos.z); } } MSpawnData* pSpawnData = FindSpawnByName(szSpawnName); if (pSpawnData) { LOG("Duplicated spawn name '%s' found in '%s' file", szSpawnName, pszMapFile); } else { AddSpawnData(szSpawnName, Pos); nTotalRead++; } } } } // SPAWNLIST } aXml.Destroy(); LOG("Read %d spawn position in map '%s'", nTotalRead, pszMapFile); return true; }
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; }
bool ZConfiguration::SaveToFile(const char *szFileName, const char* szHeader) { char buffer[256]; MXmlDocument xmlConfig; xmlConfig.Create(); xmlConfig.CreateProcessingInstruction(szHeader); MXmlElement aRootElement; aRootElement=xmlConfig.CreateElement("XML"); aRootElement.AppendText("\n\t"); xmlConfig.AppendChild(aRootElement); // Check FirstTime Loading // Server { MXmlElement serverElement=aRootElement.CreateChildElement(ZTOK_SERVER); serverElement.AppendText("\n\t\t"); MXmlElement aElement; aElement = serverElement.CreateChildElement(ZTOK_IP); aElement.SetContents(m_szServerIP); serverElement.AppendText("\n\t\t"); aElement = serverElement.CreateChildElement(ZTOK_PORT); sprintf(buffer,"%d",m_nServerPort); aElement.SetContents(buffer); serverElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Skin { MXmlElement skinElement=aRootElement.CreateChildElement(ZTOK_SKIN); skinElement.SetContents(m_szInterfaceSkinName); skinElement.AppendText(""); } aRootElement.AppendText("\n\n\t"); // Video { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_VIDEO); parentElement.AppendText("\n\t\t"); MXmlElement aElement; aElement = parentElement.CreateChildElement(ZTOK_VIDEO_WIDTH); char temp[256]; sprintf(temp, "%d", m_Video.nWidth); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_HEIGHT); sprintf(temp, "%d", m_Video.nHeight); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_COLORBITS); sprintf(temp, "%d", m_Video.nColorBits); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_GAMMA); sprintf(temp, "%d", m_Video.nGamma); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_FULLSCREEN); if(m_Video.bFullScreen==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_REFLECTION); if(m_Video.bReflection==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_LIGHTMAP); if(m_Video.bLightMap==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_DYNAMICLIGHT); if(m_Video.bDynamicLight==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_SHADER); if(m_Video.bShader==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_CHARTEXLEVEL); sprintf(temp, "%d", m_Video.nCharTexLevel); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_MAPTEXLEVEL); sprintf(temp, "%d", m_Video.nMapTexLevel); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_EFFECTLEVEL); sprintf(temp, "%d", m_Video.nEffectLevel); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_VIDEO_TEXTUREFORMAT); sprintf(temp, "%d", m_Video.nTextureFormat); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_MOVINGPICTURE_RESOLUTION); sprintf(temp, "%d", m_MovingPicture.iResolution); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_MOVINGPICTURE_FILESIZE); sprintf(temp, "%d", m_MovingPicture.iFileSize); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement("NHARDWARETNL"); sprintf(temp, "%s", m_Video.bTerrible ? "true" : "false" ); aElement.SetContents(temp); parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Audio { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_AUDIO); parentElement.AppendText("\n\t\t"); MXmlElement aElement; char temp[256]; aElement = parentElement.CreateChildElement(ZTOK_AUDIO_BGM_MUTE); if(m_Audio.bBGMMute==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_BGM_VOLUME); sprintf(temp, "%f", m_Audio.fBGMVolume ); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_EFFECT_MUTE); if(m_Audio.bEffectMute==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_EFFECT_VOLUME); sprintf(temp, "%f", m_Audio.fEffectVolume); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_3D_SOUND); sprintf(temp, "%d", m_Audio.b3DSound); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_8BITSOUND); if(m_Audio.b8BitSound==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_INVERSE); if(m_Audio.bInverse==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_HWMIXING); if(m_Audio.bHWMixing==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_HITSOUND); if(m_Audio.bHitSound==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_AUDIO_NARRATIONSOUND); if(m_Audio.bNarrationSound==true) strcpy(temp, "true"); else strcpy(temp, "false"); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement( ZTOK_AUDIO_CUSTOMMUSIC ); if( m_Audio.bCustomMusic ) strcpy( temp, "true" ); else strcpy( temp, "false" ); aElement.SetContents( temp ); parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Mouse { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_MOUSE); parentElement.AppendText("\n\t\t"); MXmlElement aElement; aElement = parentElement.CreateChildElement(ZTOK_MOUSE_SENSITIVITY); char temp[256]; // 버그리포트 => 옵션->키보드->마우스->마우스 감도에서 최하로 설정했을때 마우스가 안움직인다. // 최소인 0바로전 값이 0.0135f이기때문에 이값보다 낮으면 0.0125f로 세팅 20090313 by kammir /*if(m_Mouse.fSensitivity < 0.01f) m_Mouse.fSensitivity = 0.0125f;*/ m_Mouse.fSensitivity = ValidateMouseSensitivityInFloat(m_Mouse.fSensitivity); sprintf(temp, "%f", m_Mouse.fSensitivity); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_MOUSE_INVERT); if(m_Mouse.bInvert==true) strcpy(temp, "TRUE"); else strcpy(temp, "FALSE"); aElement.SetContents(temp); parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Joystick { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_JOYSTICK); parentElement.AppendText("\n\t\t"); MXmlElement aElement; aElement = parentElement.CreateChildElement(ZTOK_JOYSTICK_SENSITIVITY); char temp[256]; sprintf(temp, "%f", m_Joystick.fSensitivity); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_JOYSTICK_INVERT); if(m_Joystick.bInvert==true) strcpy(temp, "TRUE"); else strcpy(temp, "FALSE"); aElement.SetContents(temp); parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Control { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_KEYBOARD); for(int i=0; i<ZACTION_COUNT; i++){ char szItemName[256]; strcpy(szItemName, m_Keyboard.ActionKeys[i].szName); _strupr(szItemName); if(szItemName[0]!=0){ parentElement.AppendText("\n\t\t"); MXmlElement aElement; aElement = parentElement.CreateChildElement(szItemName); char temp[256]; sprintf(temp, "%d", m_Keyboard.ActionKeys[i].nVirtualKey); aElement.SetContents(temp); aElement.SetAttribute("alt",m_Keyboard.ActionKeys[i].nVirtualKeyAlt); } } parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Macro // if( parentElement.FindChildNode(ZTOK_MACRO, &childElement) ) { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_MACRO); parentElement.AppendText("\n\t\t"); MXmlElement aElement; char* _temp[ZCONFIG_MACRO_MAX] = { ZTOK_MACRO_F1, ZTOK_MACRO_F2, ZTOK_MACRO_F3, ZTOK_MACRO_F4, ZTOK_MACRO_F5, ZTOK_MACRO_F6, ZTOK_MACRO_F7, ZTOK_MACRO_F8, }; for(int i=0;i<ZCONFIG_MACRO_MAX;i++) { aElement = parentElement.CreateChildElement( _temp[i] ); aElement.SetContents(m_Macro.szMacro[i]); parentElement.AppendText("\n\t\t"); } parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Etc { MXmlElement parentElement=aRootElement.CreateChildElement(ZTOK_ETC); MXmlElement aElement; // Network port parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_NETWORKPORT1); char temp[256]; sprintf(temp, "%d", m_Etc.nNetworkPort1); aElement.SetContents(temp); parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_NETWORKPORT2); sprintf(temp, "%d", m_Etc.nNetworkPort2); aElement.SetContents(temp); // Boost parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_BOOST); sprintf(temp, "%s", m_Etc.bBoost?"TRUE":"FALSE"); aElement.SetContents(temp); // 언어 선택 #ifdef _MULTILANGUAGE parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_LANGUAGE); sprintf(temp, "%s", GetSelectedLanguage()); aElement.SetContents(temp); #ifdef LOCALE_NHNUSA //NHNUSA는 config.xml에 의존하지 않으므로 언어변경후 재시작을 위해서 언어설정을 별도로 보존해둔다 g_LanguageSettingForNHNUSA.SetLanguageSetting( GetSelectedLanguageIndex()); #endif #endif //_MULTILANGUAGE // Reject normal chat parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_REJECT_NORMALCHAT); sprintf(temp, "%s", m_Etc.bRejectNormalChat?"TRUE":"FALSE"); aElement.SetContents(temp); // Reject team chat parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_REJECT_TEAMCHAT); sprintf(temp, "%s", m_Etc.bRejectTeamChat?"TRUE":"FALSE"); aElement.SetContents(temp); // Reject clan chat parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_REJECT_CLANCHAT); sprintf(temp, "%s", m_Etc.bRejectClanChat?"TRUE":"FALSE"); aElement.SetContents(temp); // Reject whisper parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_REJECT_WHISPER); sprintf(temp, "%s", m_Etc.bRejectWhisper?"TRUE":"FALSE"); aElement.SetContents(temp); // Reject invite parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_REJECT_INVITE); sprintf(temp, "%s", m_Etc.bRejectInvite?"TRUE":"FALSE"); aElement.SetContents(temp); // crosshair parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_CROSSHAIR); sprintf(temp, "%d", m_Etc.nCrossHair); aElement.SetContents(temp); // FrameLimit parentElement.AppendText("\n\t\t"); aElement = parentElement.CreateChildElement(ZTOK_ETC_FRAMELIMIT_PERSECOND); sprintf(temp, "%d", m_Etc.nFrameLimit_perSecond); aElement.SetContents(temp); parentElement.AppendText("\n\t"); } aRootElement.AppendText("\n\n\t"); // Bind : 봉인 /* aRootElement.AppendText("\n\t"); MXmlElement bindsElement=aRootElement.CreateChildElement(ZTOK_BINDS); for(ZHOTKEYS::iterator i=m_HotKeys.begin();i!=m_HotKeys.end();i++) { bindsElement.AppendText("\n\t\t"); MXmlElement bind=bindsElement.CreateChildElement(ZTOK_BIND); ZHOTKEY *photkey=(*i).second; bind.SetContents(photkey->command.c_str()); char buffer[256]; bind.SetAttribute(ZTOK_KEY,GetKeyName(photkey->nVirtKey,buffer)); bind.SetAttribute(ZTOK_KEY_CTRL,photkey->nModifier & MOD_CONTROL ? 1 : 0); bind.SetAttribute(ZTOK_KEY_ALT,photkey->nModifier & MOD_ALT ? 1 : 0); bind.SetAttribute(ZTOK_KEY_SHIFT,photkey->nModifier & MOD_SHIFT ? 1 : 0); } bindsElement.AppendText("\n\t"); */ aRootElement.AppendText("\n"); // LANGID LangID = LANG_KOREAN; /* Korean : 이거 정말 하드코딩 박기 싫었는디... 쩝... -_-;;; */ //#ifdef LOCALE_JAPAN // LangID = LANG_JAPANESE; /* Japanese */ //#elif LOCALE_US // LangID = LANG_ENGLISH; /* International */ //#elif LOCALE_BRAZIL // LangID = LANG_PORTUGUESE; /* Brazil */ //#elif LOCALE_INDIA // LangID = LANG_ENGLISH; /* India */ //#endif return xmlConfig.SaveToFile(szFileName); }
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 ZConfiguration::LoadConfig(const char* szFileName) { MXmlDocument xmlConfig; MXmlElement parentElement, serverElement, bindsElement; MXmlElement childElement; mlog( "Load Config from file : %s", szFileName ); xmlConfig.Create(); if (!xmlConfig.LoadFromFile(szFileName)) { mlog( "- FAIL\n"); xmlConfig.Destroy(); return false; } mlog( "- SUCCESS\n"); parentElement = xmlConfig.GetDocumentElement(); int iCount = parentElement.GetChildNodeCount(); if (!parentElement.IsEmpty()) { if (parentElement.FindChildNode( ZTOK_SERVER, &serverElement)) { serverElement.GetChildContents( m_szServerIP, ZTOK_IP); serverElement.GetChildContents( &m_nServerPort, ZTOK_PORT); } if (parentElement.FindChildNode(ZTOK_VIDEO, &childElement)) { childElement.GetChildContents(&m_Video.nWidth, ZTOK_VIDEO_WIDTH); childElement.GetChildContents(&m_Video.nHeight, ZTOK_VIDEO_HEIGHT); childElement.GetChildContents(&m_Video.nColorBits, ZTOK_VIDEO_COLORBITS); childElement.GetChildContents(&m_Video.bFullScreen, ZTOK_VIDEO_FULLSCREEN); childElement.GetChildContents(&m_Video.nGamma, ZTOK_VIDEO_GAMMA); childElement.GetChildContents(&m_Video.bReflection, ZTOK_VIDEO_REFLECTION ); childElement.GetChildContents(&m_Video.bLightMap, ZTOK_VIDEO_LIGHTMAP ); childElement.GetChildContents(&m_Video.bDynamicLight, ZTOK_VIDEO_DYNAMICLIGHT ); childElement.GetChildContents(&m_Video.bShader, ZTOK_VIDEO_SHADER ); childElement.GetChildContents(&m_Video.nCharTexLevel, ZTOK_VIDEO_CHARTEXLEVEL ); childElement.GetChildContents(&m_Video.nMapTexLevel, ZTOK_VIDEO_MAPTEXLEVEL ); RBspObject::SetTextureRenderOnOff(m_Video.nMapTexLevel != 7); childElement.GetChildContents(&m_Video.nEffectLevel, ZTOK_VIDEO_EFFECTLEVEL ); childElement.GetChildContents(&m_Video.nTextureFormat, ZTOK_VIDEO_TEXTUREFORMAT ); childElement.GetChildContents(&m_Video.bTerrible, "NHARDWARETNL"); childElement.GetChildContents(&m_MovingPicture.iResolution, ZTOK_MOVINGPICTURE_RESOLUTION ); childElement.GetChildContents(&m_MovingPicture.iFileSize, ZTOK_MOVINGPICTURE_FILESIZE ); } if (parentElement.FindChildNode(ZTOK_AUDIO, &childElement)) { childElement.GetChildContents(&m_Audio.bBGMEnabled, ZTOK_AUDIO_BGM_ENABLED); childElement.GetChildContents(&m_Audio.fBGMVolume, ZTOK_AUDIO_BGM_VOLUME); childElement.GetChildContents(&m_Audio.fEffectVolume, ZTOK_AUDIO_EFFECT_VOLUME); childElement.GetChildContents(&m_Audio.bBGMMute, ZTOK_AUDIO_BGM_MUTE); childElement.GetChildContents(&m_Audio.bEffectMute, ZTOK_AUDIO_EFFECT_MUTE); childElement.GetChildContents(&m_Audio.b8BitSound, ZTOK_AUDIO_8BITSOUND); childElement.GetChildContents(&m_Audio.bInverse, ZTOK_AUDIO_INVERSE); childElement.GetChildContents(&m_Audio.bHWMixing, ZTOK_AUDIO_HWMIXING); childElement.GetChildContents(&m_Audio.bHitSound, ZTOK_AUDIO_HITSOUND); childElement.GetChildContents(&m_Audio.bNarrationSound, ZTOK_AUDIO_NARRATIONSOUND); childElement.GetChildContents( &m_Audio.bCustomMusic, ZTOK_AUDIO_CUSTOMMUSIC ); //childElement.GetChildContents(&m_Audio.b3DSound, ZTOK_AUDIO_3D_SOUND); m_Audio.b3DSound = true; } if (parentElement.FindChildNode(ZTOK_MOUSE, &childElement)) { childElement.GetChildContents(&m_Mouse.fSensitivity, ZTOK_MOUSE_SENSITIVITY); childElement.GetChildContents(&m_Mouse.bInvert, ZTOK_MOUSE_INVERT); } if (parentElement.FindChildNode(ZTOK_JOYSTICK, &childElement)) { childElement.GetChildContents(&m_Joystick.fSensitivity, ZTOK_JOYSTICK_SENSITIVITY); childElement.GetChildContents(&m_Joystick.bInvert, ZTOK_JOYSTICK_INVERT); } if (parentElement.FindChildNode(ZTOK_KEYBOARD, &childElement)) { for(int i=0; i<ZACTION_COUNT; i++){ char szItemName[256]; strcpy(szItemName, m_Keyboard.ActionKeys[i].szName); _strupr(szItemName); MXmlNode keyNode; if (childElement.FindChildNode(szItemName, &keyNode)) { MXmlElement actionKeyElement = keyNode; const int ID_UNDEFINED = -2; int nKey; actionKeyElement.GetAttribute(&nKey,"alt",ID_UNDEFINED); // "alt"에 값이 없다면 ID_UNDEFINED 를 세팅 if(nKey!=ID_UNDEFINED) // "alt"에 값이 없다면 스킵 m_Keyboard.ActionKeys[i].nVirtualKeyAlt = nKey; actionKeyElement.GetContents(&m_Keyboard.ActionKeys[i].nVirtualKey); } } } if( parentElement.FindChildNode(ZTOK_MACRO, &childElement) ) { //char buf[8][256]; //childElement.GetChildContents(buf[0], ZTOK_MACRO_F1, 255); //childElement.GetChildContents(buf[1], ZTOK_MACRO_F2, 255); //childElement.GetChildContents(buf[2], ZTOK_MACRO_F3, 255); //childElement.GetChildContents(buf[3], ZTOK_MACRO_F4, 255); //childElement.GetChildContents(buf[4], ZTOK_MACRO_F5, 255); //childElement.GetChildContents(buf[5], ZTOK_MACRO_F6, 255); //childElement.GetChildContents(buf[6], ZTOK_MACRO_F7, 255); //childElement.GetChildContents(buf[7], ZTOK_MACRO_F8, 255); //for (int i = 0; i < 8; i++) //{ // strcpy(m_Macro.szMacro[i], ZGetStringResManager()->GetStringFromXml(buf[i])); //} // 여기선 읽기만 함. // string.xml을 읽은 후 다시 컨버팅 함. // config.xml에 있는 lcale정보로 string.xml의 국가를 결정하기 때문에 이 부분은 바로 처리할 수 없음. childElement.GetChildContents(m_Macro.szMacro[0], ZTOK_MACRO_F1, 255); childElement.GetChildContents(m_Macro.szMacro[1], ZTOK_MACRO_F2, 255); childElement.GetChildContents(m_Macro.szMacro[2], ZTOK_MACRO_F3, 255); childElement.GetChildContents(m_Macro.szMacro[3], ZTOK_MACRO_F4, 255); childElement.GetChildContents(m_Macro.szMacro[4], ZTOK_MACRO_F5, 255); childElement.GetChildContents(m_Macro.szMacro[5], ZTOK_MACRO_F6, 255); childElement.GetChildContents(m_Macro.szMacro[6], ZTOK_MACRO_F7, 255); childElement.GetChildContents(m_Macro.szMacro[7], ZTOK_MACRO_F8, 255); } if (parentElement.FindChildNode(ZTOK_ETC, &childElement)) { childElement.GetChildContents(&m_Etc.nNetworkPort1, ZTOK_ETC_NETWORKPORT1); childElement.GetChildContents(&m_Etc.nNetworkPort2, ZTOK_ETC_NETWORKPORT2); childElement.GetChildContents(&m_Etc.bBoost, ZTOK_ETC_BOOST); childElement.GetChildContents(&m_Etc.bRejectNormalChat, ZTOK_ETC_REJECT_NORMALCHAT); childElement.GetChildContents(&m_Etc.bRejectTeamChat, ZTOK_ETC_REJECT_TEAMCHAT); childElement.GetChildContents(&m_Etc.bRejectClanChat, ZTOK_ETC_REJECT_CLANCHAT); childElement.GetChildContents(&m_Etc.bRejectWhisper, ZTOK_ETC_REJECT_WHISPER); childElement.GetChildContents(&m_Etc.bRejectInvite, ZTOK_ETC_REJECT_INVITE); childElement.GetChildContents(&m_Etc.nCrossHair, ZTOK_ETC_CROSSHAIR); childElement.GetChildContents(&m_Etc.nFrameLimit_perSecond, ZTOK_ETC_FRAMELIMIT_PERSECOND); //m_Etc.szLanguage[0] = 0; #ifdef _MULTILANGUAGE #ifdef LOCALE_NHNUSA SetSelectedLanguageIndex( g_LanguageSettingForNHNUSA.GetLanguageSetting()); #else // 기본적으로는 게임내부 옵션에서 선택한 언어를 config에 저장했던 것을 로딩 childElement.GetChildContents( m_Etc.szLanguage, ZTOK_ETC_LANGUAGE, 32); #endif #endif //_MULTILANGUAGE } ValidateSelectedLanguage(); /* if (parentElement.FindChildNode(ZTOK_BINDS, &bindsElement)) { for(int i=0;i<bindsElement.GetChildNodeCount();i++) { char tagname[256]; MXmlElement bind=bindsElement.GetChildNode(i); bind.GetTagName(tagname); if(strcmp(tagname,ZTOK_BIND)==0) { char key[256],command[256]; int ctrl,alt,shift; bind.GetAttribute(key,ZTOK_KEY); bind.GetAttribute(&ctrl,ZTOK_KEY_CTRL); bind.GetAttribute(&alt,ZTOK_KEY_ALT); bind.GetAttribute(&shift,ZTOK_KEY_SHIFT); bind.GetContents(command); ZHOTKEY *photkey=new ZHOTKEY; photkey->nModifier=0; if(ctrl) photkey->nModifier|=MOD_CONTROL; if(alt) photkey->nModifier|=MOD_ALT; if(shift) photkey->nModifier|=MOD_SHIFT; photkey->nVirtKey=GetVirtKey(key); photkey->command=string(command); int nHotkeyID=MRegisterHotKey(photkey->nModifier,photkey->nVirtKey); m_HotKeys.insert(ZHOTKEYS::value_type(nHotkeyID,photkey)); } } } */ } //if( m_Video.bTerrible ) //{ // //m_Video.nCharTexLevel = 2; // //m_Video.nMapTexLevel = 2; // //m_Video.nEffectLevel = 2; // //m_Video.bDynamicLight = false; // //m_Video.bReflection = false; //} //else //{ // m_Video.bLightMap = false; // 최하위 버전이 아닐 경우 라이트 맵을 끄지 못한다 //} xmlConfig.Destroy(); 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; }
bool MSpawnManager::ReadSpawnData(char* pszSpawnFile) { MXmlDocument aXml; aXml.Create(); if (!aXml.LoadFromFile(pszSpawnFile)) { aXml.Destroy(); return false; } char szBuf[65535]; ZeroMemory(szBuf, 65535); MXmlElement aRoot; aRoot = aXml.GetDocumentElement(); int nTotalRead = 0; int nSpawnCount = aRoot.GetChildNodeCount(); for (int i=0; i<nSpawnCount; i++) { MXmlElement aSpawn = aRoot.GetChildNode(i); aSpawn.GetTagName(szBuf); if (szBuf[0] == '#') continue; if (!stricmp(szBuf, MTOK_SPAWNDATA)) { char szSpawnName[128]; ZeroMemory(szSpawnName, 128); if (!aSpawn.GetAttribute(szSpawnName, "name")) continue; int nObjectID = 0; int nMaxCount = 0; int nRespawnTime = 0; int nFieldCount = aSpawn.GetChildNodeCount(); for (int j=0; j<nFieldCount; j++) { MXmlElement aField = aSpawn.GetChildNode(j); aField.GetTagName(szBuf); if (szBuf[0] == '#') continue; if (!stricmp(szBuf, MTOK_OBJECTID)) aField.GetContents(&nObjectID); else if (!stricmp(szBuf, MTOK_MAXCOUNT)) aField.GetContents(&nMaxCount); else if (!stricmp(szBuf, MTOK_RESPAWNTIME)) aField.GetContents(&nRespawnTime); } MSpawnData* pSpawnData = FindSpawnByName(szSpawnName); if (pSpawnData) { pSpawnData->SetObjID(nObjectID); pSpawnData->SetMaxCount(nMaxCount); pSpawnData->SetRespawnTime(nRespawnTime); nTotalRead++; } else { LOG("SpawnData '%s' has no SpawnPosition. (%s)", szSpawnName, pszSpawnFile); } } } aXml.Destroy(); LOG("Read %d spawn data in file '%s'", nTotalRead, pszSpawnFile); return true; }
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 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; }
// 핫키는 봉인되었다. bool ZConfiguration::LoadHotKey(const char* szFileName) { MXmlDocument xmlConfig; MXmlElement parentElement, serverElement, bindsElement; MXmlElement childElement; xmlConfig.Create(); if (!xmlConfig.LoadFromFile(szFileName)) { xmlConfig.Destroy(); return false; } parentElement = xmlConfig.GetDocumentElement(); int iCount = parentElement.GetChildNodeCount(); if (!parentElement.IsEmpty()) { if (parentElement.FindChildNode(ZTOK_BINDS, &bindsElement)) { for(int i=0;i<bindsElement.GetChildNodeCount();i++) { char tagname[256]; MXmlElement bind=bindsElement.GetChildNode(i); bind.GetTagName(tagname); if(strcmp(tagname,ZTOK_BIND)==0) { char key[256],command[256]; bool ctrl,alt,shift; bind.GetAttribute(key,ZTOK_KEY); bind.GetAttribute(&ctrl,ZTOK_KEY_CTRL); bind.GetAttribute(&alt,ZTOK_KEY_ALT); bind.GetAttribute(&shift,ZTOK_KEY_SHIFT); bind.GetContents(command); ZHOTKEY *photkey=new ZHOTKEY; photkey->nModifier=0; if(ctrl) photkey->nModifier|=MOD_CONTROL; if(alt) photkey->nModifier|=MOD_ALT; if(shift) photkey->nModifier|=MOD_SHIFT; photkey->nVirtKey=GetVirtKey(key); photkey->command=string(command); int nHotkeyID=Mint::GetInstance()->RegisterHotKey(photkey->nModifier,photkey->nVirtKey); m_HotKeys.insert(ZHOTKEYS::value_type(nHotkeyID,photkey)); } } } } xmlConfig.Destroy(); return true; }