ZBmNumLabel* ZIDLResource::GetBmNumLabel(MXmlElement& element) { MXmlElement childElement; char szBuf[1024]; MWidget* pParentWidget; MListener* pListener; pListener = pParentWidget = GetParentWidget(element); ZBmNumLabel* pBmLabel = new ZBmNumLabel(MINT_ZBMNUMLABEL, pParentWidget, pListener); InsertWidget(element, pBmLabel); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if (GetCommonWidgetProperty(pBmLabel, childElement, szBuf)) continue; else if (!strcmp(szBuf, "FONTSIZE")) { pBmLabel->SetCharSize(GetSize(childElement)); } else if (!strcmp(szBuf, "BITMAP")) { MBitmap* pBitmap = GetBitmap(childElement); if (pBitmap != NULL) { pBmLabel->SetLabelBitmap(pBitmap); } } } return pBmLabel; }
void MMatchEventFactoryManager::ParseGameType( MXmlElement& chrElement, vector< EventGameType >& vGameType ) { EventGameType GameType; char szAttrName[ 128 ]; char szAttrValue[ 256 ]; const int nAttrCnt = chrElement.GetAttributeCount(); for( int i = 0; i < nAttrCnt; ++i ) { chrElement.GetAttribute( i, szAttrName, szAttrValue ); if( 0 == stricmp(EL_ORDER, szAttrName) ) { GameType.dwOrder = static_cast< DWORD >( atol(szAttrValue) ); continue; } if( 0 == stricmp(EL_TYPE, szAttrName) ) { GameType.GameType = static_cast< MMATCH_GAMETYPE >( atoi(szAttrValue) ); continue; } } vGameType.push_back( GameType ); }
ZCharacterViewList* ZIDLResource::GetCharacterViewList(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget = GetParentWidget(element); ZCharacterViewList* pWidget = new ZCharacterViewList("", pParentWidget, pParentWidget); InsertWidget(element, pWidget); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if(GetCommonWidgetProperty(pWidget, childElement, szBuf)) continue; if(!strcmp(szBuf, "ITEMWIDTH")){ int nWidth = 80; childElement.GetContents(&nWidth); pWidget->SetItemWidth(nWidth); } } return pWidget; }
ZPlayerSelectListBox* ZIDLResource::GetPlayerSelectListBox(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; // char szAttr[4096]; MWidget* pParentWidget = GetParentWidget(element); ZPlayerSelectListBox* pWidget = new ZPlayerSelectListBox("SelectPlayer", pParentWidget, pParentWidget); pWidget->SetListener(pWidget); InsertWidget(element, pWidget); int iCount = element.GetChildNodeCount(); bool bMode1 = false; for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if(GetCommonWidgetProperty(pWidget, childElement, szBuf)) continue; else if(!strcmp(szBuf, "MULTISELECT")) { pWidget->m_bMultiSelect = true; } } return pWidget; }
ZCharacterView* ZIDLResource::GetCharacterView(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget = GetParentWidget(element); ZCharacterView* pWidget = new ZCharacterView("", pParentWidget, pParentWidget); InsertWidget(element, pWidget); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); GetCommonWidgetProperty(pWidget, childElement, szBuf); if(!strcmp(szBuf, "VISIBLEEQUIPMENT")){ bool bVisibleEquipment = false; childElement.GetContents(&bVisibleEquipment); pWidget->SetVisibleEquipment(bVisibleEquipment); } } return pWidget; }
void MQuestScenarioCatalogue::ParseRewardItem(MXmlElement& element, MQuestScenarioInfo* pScenarioInfo) { char szAttrValue[256], szAttrName[64]; int nIndex = pScenarioInfo->nRewardItemCount; pScenarioInfo->nRewardItemCount++; int nAttrCount = element.GetAttributeCount(); for (int i = 0; i < nAttrCount; i++) { element.GetAttribute(i, szAttrName, szAttrValue); if (!_stricmp(szAttrName, MTOK_SCENARIO_TYPE)) { } else if (!_stricmp(szAttrName, MTOK_SCENARIO_ITEMID)) { pScenarioInfo->nRewardItemID[nIndex] = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_RATE)) { pScenarioInfo->fRewardItemRate[nIndex] = (float)atof(szAttrValue); } } }
bool RDummyList::Save(MXmlElement *pElement) { MXmlElement aDummyListElement = pElement->CreateChildElement(RTOK_DUMMYLIST); for (auto& Dummy : *this) { aDummyListElement.AppendText("\n\t\t"); char buffer[256]; MXmlElement aElement,aChild; aElement = aDummyListElement.CreateChildElement(RTOK_DUMMY); aElement.AddAttribute(RTOK_NAME, Dummy.Name.c_str()); aElement.AppendText("\n\t\t\t"); aChild=aElement.CreateChildElement(RTOK_POSITION); aChild.SetContents(Format(buffer, Dummy.Position)); aElement.AppendText("\n\t\t\t"); aChild=aElement.CreateChildElement(RTOK_DIRECTION); aChild.SetContents(Format(buffer, Dummy.Direction)); aElement.AppendText("\n\t\t"); } aDummyListElement.AppendText("\n\t"); return true; }
ZServerView* ZIDLResource::GetServerView(MXmlElement& element) { MXmlElement childElement; char szBuf[ 4096]; MWidget* pParentWidget = GetParentWidget( element); ZServerView* pWidget = new ZServerView( "", pParentWidget, pParentWidget); InsertWidget( element, pWidget); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof( szBuf)); childElement = element.GetChildNode( i); childElement.GetTagName( szBuf); GetCommonWidgetProperty( pWidget, childElement, szBuf); // if ( !strcmp( szBuf, "NAME")) // { // char szName[ 25]; // childElement.GetContents( szName); // pWidget->SetName( szName); // } } return pWidget; }
void MMatchEventFactoryManager::ParseEventPartTime( MXmlElement& chrElement, vector<EventPartTime>& EventPartTimeVec ) { EventPartTime ept; char szAttrName[ 128 ]; char szAttrValue[ 256 ]; const int nAttrCnt = chrElement.GetAttributeCount(); for( int i = 0; i < nAttrCnt; ++i ) { chrElement.GetAttribute( i, szAttrName, szAttrValue ); /* if( 0 == stricmp(EL_ORDER, szAttrName) ) { continue; } */ if( 0 == stricmp(EL_START_HOUR, szAttrName) ) { ept.btStartHour = static_cast< BYTE >( atoi(szAttrValue) ); continue; } if( 0 == stricmp(EL_END_HOUR, szAttrName) ) { ept.btEndHour = static_cast< BYTE >( atoi(szAttrValue) ); continue; } } #ifdef _DEBUG // 중복되는 범위가 있는지 검사. vector< EventPartTime >::iterator it, end; end = EventPartTimeVec.end(); for( it = EventPartTimeVec.begin(); it != end; ++it ) { if( (it->btStartHour <= ept.btStartHour) && (ept.btStartHour <= it->btEndHour) ) { ASSERT( 0 ); } if( (it->btStartHour <= ept.btEndHour) && (ept.btEndHour <= it->btEndHour) ) { ASSERT( 0 ); } } #endif EventPartTimeVec.push_back( ept ); }
bool ZGameTypeList::ParseGameTypeList( int nGameTypeNum, MXmlElement& element) { int iCount = element.GetChildNodeCount(); MXmlElement chrElement; char szTagName[256]; ZGameTypeConfig* pConfig = new ZGameTypeConfig; int nRoundCount = 0, nTimeLimitCount = 0, nMaxPlayersCount = 0; for (int i = 0; i < iCount; i++) { chrElement = element.GetChildNode(i); chrElement.GetTagName( szTagName); if ( szTagName[0] == '#') continue; if ( !stricmp( szTagName, "ROUNDS")) { if ( ParseRound( pConfig, chrElement)) pConfig->m_nDefaultRound = nRoundCount; nRoundCount++; } else if ( !stricmp( szTagName, "LIMITTIME")) { if ( ParseLimitTime( pConfig, chrElement)) pConfig->m_nDefaultLimitTime = nTimeLimitCount; nTimeLimitCount++; } else if ( !stricmp( szTagName, "MAXPLAYERS")) { if ( ParseMaxPlayers( pConfig, chrElement)) pConfig->m_nDefaultMaxPlayers = nMaxPlayersCount; nMaxPlayersCount++; } } m_GameTypeCfg.insert( m_GameTypeCfg.end(), MGAMETYPECFG::value_type( nGameTypeNum, pConfig)); return true; }
bool ZGameTypeList::ParseMaxPlayers( ZGameTypeConfig* pConfig, MXmlElement& element) { int nValue; char szStr[ 16]; bool selected = false; element.GetAttribute( &nValue, "player"); element.GetAttribute( szStr, "str"); element.GetAttribute( &selected, "default"); ZGameTypeConfigData* pCfgData = new ZGameTypeConfigData; pCfgData->m_nValue = nValue; strcpy( pCfgData->m_szString, szStr); pConfig->m_MaxPlayers.push_back( pCfgData); return selected; // Is default? }
void MQuestScenarioCatalogue::ParseNPCSetArray(MXmlElement& element, vector<int>& vec) { char szMaps[256]; memset(szMaps, 0, sizeof(szMaps)); MMatchQuest* pQuest = MMatchServer::GetInstance()->GetQuest(); element.GetContents(szMaps); int nLen = (int)strlen(szMaps); for (int i = 0; i < nLen; i += 4) { char szNPCSet[4]; memset(szNPCSet, 0, sizeof(szNPCSet)); for (int j = 0; j < 3; j++) { szNPCSet[j] = szMaps[i+j]; } // NPCSetCatalogue¿¡¼ ÇØ´ç NPCSet¸¦ ã´Â´Ù. MQuestNPCSetInfo* pNPCSetInfo = pQuest->GetNPCSetInfo(szNPCSet); if (pNPCSetInfo) { vec.push_back(pNPCSetInfo->nID); } else { // ¸Â´Â NPCSet°¡ ¾ø´Ù. _ASSERT(0); } } }
void MQuestScenarioCatalogue::ParseSacriItem(MXmlElement& element, MQuestScenarioInfo* pScenarioInfo) { char szAttrValue[256], szAttrName[64]; int nIndex = pScenarioInfo->nResSacriItemCount; pScenarioInfo->nResSacriItemCount++; int nAttrCount = element.GetAttributeCount(); for (int i = 0; i < nAttrCount; i++) { element.GetAttribute(i, szAttrName, szAttrValue); if (!_stricmp(szAttrName, MTOK_SCENARIO_ITEMID)) { pScenarioInfo->nResSacriItemID[nIndex] = atoi(szAttrValue); } } }
bool ZGameTypeList::ParseLimitTime( ZGameTypeConfig* pConfig, MXmlElement& element) { int nValue; char szStr[ 256]; bool selected = false; element.GetAttribute( &nValue, "sec"); element.GetAttribute( szStr, "str"); element.GetAttribute( &selected, "default"); ZGameTypeConfigData* pCfgData = new ZGameTypeConfigData; pCfgData->m_nValue = nValue; strcpy( pCfgData->m_szString, ZGetStringResManager()->GetStringFromXml(szStr)); pConfig->m_LimitTime.push_back( pCfgData); return selected; // Is default? }
bool MXmlElement::AppendChild(MXmlElement aChildElement) { MXmlDomElementPtr pElement; pElement = aChildElement.GetXmlDomNodePtr(); m_pDomNode->appendChild(pElement); return true; }
void MChannelRuleMgr::ParseRule(MXmlElement* pElement) { // Get Rule Node int nID = 0; pElement->GetAttribute(&nID, MTOK_CHANNELRULE_ATTR_ID); char szName[128]=""; pElement->GetAttribute(szName, MTOK_CHANNELRULE_ATTR_NAME); MChannelRule* pRule = new MChannelRule; pRule->Init(nID, szName); // Get Map Nodes MXmlElement childElement; char szTagName[256]=""; char szAttr[256]=""; int nCount = pElement->GetChildNodeCount(); for (int i=0; i<nCount; i++) { childElement = pElement->GetChildNode(i); childElement.GetTagName(szTagName); if (szTagName[0] == '#') continue; if (!_stricmp(szTagName, MTOK_CHANNELMAP)) { if (childElement.GetAttribute(szAttr, MTOK_CHANNELRULE_ATTR_NAME)) { pRule->AddMap(szAttr); } } else if (!_stricmp(szTagName, MTOK_CHANNELRULE_GAMETYPE)) { int nAttr = -1; if (childElement.GetAttribute(&nAttr, MTOK_CHANNELRULE_ATTR_ID)) { pRule->AddGameType(nAttr); } } } AddRule(pRule); }
void ZConfiguration::ParseLocaleSelectableLanguages(MXmlElement& selectableLangsElem) { char szTag[256]; char szLanguageID[256]; char szLanguageName[256]; MXmlElement elem; int numChild = selectableLangsElem.GetChildNodeCount(); for (int i=0; i<numChild; ++i) { elem = selectableLangsElem.GetChildNode(i); elem.GetTagName(szTag); if (strcmp(szTag, ZTOK_LOCALE_LANGUAGE) == 0) { bool bID = elem.GetAttribute(szLanguageID, "id"); bool bName = elem.GetAttribute(szLanguageName, "name"); _ASSERT(bID && bName); ZCONFIG_SELECTABLE_LANGUAGE langSelectable; langSelectable.strLanguage = szLanguageID; langSelectable.strLanguageName = szLanguageName; m_Locale.vecSelectableLanguage.push_back(langSelectable); } } }
ZScoreBoardFrame* ZIDLResource::GetScoreBoardFrame(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget; MListener* pListener; MBFrameLook* pFrameLook = NULL; pListener = pParentWidget = GetParentWidget(element); ZScoreBoardFrame* pFrame = new ZScoreBoardFrame("", pParentWidget, pListener); InsertWidget(element, pFrame); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if (GetCommonWidgetProperty(pFrame, childElement, szBuf)) continue; if (!strcmp(szBuf, "FRAMELOOK")) { char szItem[256]; memset(szItem, 0, sizeof(szItem)); childElement.GetContents(szItem); map<string, MBFrameLook*>::iterator itor = m_FrameLookMap.find(szItem); if (itor != m_FrameLookMap.end()) { pFrameLook = (MBFrameLook*)(*itor).second; pFrame->ChangeCustomLook((MFrameLook*)pFrameLook); } } } return pFrame; }
ZDuelTournamentRankingListBox* ZIDLResource::GetDuelTournamentRankingListBox( MXmlElement& element ) { MXmlElement childElement; char szBuf[4096]; // char szAttr[4096]; MWidget* pParentWidget = GetParentWidget(element); ZDuelTournamentRankingListBox* pWidget = new ZDuelTournamentRankingListBox("", pParentWidget, pParentWidget); InsertWidget(element, pWidget); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if(GetCommonWidgetProperty(pWidget, childElement, szBuf)) continue; } return pWidget; }
ZActionKey* ZIDLResource::GetActionKey(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget; MListener* pListener; pListener = pParentWidget = GetParentWidget(element); ZActionKey* pActionKey = (ZActionKey*)Mint::GetInstance()->NewWidget(MINT_ACTIONKEY, "", pParentWidget, pListener); InsertWidget(element, pActionKey); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if (GetCommonWidgetProperty(pActionKey, childElement, szBuf)) continue; /* if (!strcmp(szBuf, "EDITLOOK")) { char szItem[256]; memset(szItem, 0, sizeof(szItem)); childElement.GetContents(szItem); map<string, MBEditLook*>::iterator itor = m_EditLookMap.find(szItem); if (itor != m_EditLookMap.end()) { pActionKey->ChangeCustomLook((MBEditLook*)(*itor).second); } } */ } return pActionKey; }
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; }
ZMapListBox* ZIDLResource::GetMapListBox(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget; MListener* pListener; pListener = pParentWidget = GetParentWidget(element); ZMapListBox* pListBox = new ZMapListBox("", pParentWidget, pListener); InsertWidget(element, pListBox); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); GetCommonWidgetProperty(pListBox, childElement, szBuf); } return pListBox; }
ZStageInfoBox* ZIDLResource::GetStageInfoBox(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget = GetParentWidget(element); ZStageInfoBox* pWidget = new ZStageInfoBox("", pParentWidget, pParentWidget); InsertWidget(element, pWidget); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); if (GetCommonWidgetProperty(pWidget, childElement, szBuf)) continue; else if (!strcmp(szBuf, "STAGEINFOITEMLOOK")) { char szItem[256]; memset(szItem, 0, sizeof(szItem)); childElement.GetContents(szItem); map<string, MBListBoxLook*>::iterator itor = m_ListBoxLookMap.find(szItem); if (itor != m_ListBoxLookMap.end()) { MBListBoxLook* pListBoxLook = NULL; pListBoxLook = (*itor).second; // pWidget->ChangeCustomLook(pListBoxLook); pWidget->SetLook(pListBoxLook); } } } return pWidget; }
ZMeshView* ZIDLResource::GetMeshView(MXmlElement& element) { MXmlElement childElement; char szBuf[4096]; MWidget* pParentWidget = GetParentWidget(element); ZMeshView* pWidget = new ZMeshView("", pParentWidget, pParentWidget); InsertWidget(element, pWidget); int iCount = element.GetChildNodeCount(); for (int i = 0; i < iCount; i++) { memset(szBuf, 0, sizeof(szBuf)); childElement = element.GetChildNode(i); childElement.GetTagName(szBuf); GetCommonWidgetProperty(pWidget, childElement, szBuf); if (!strcmp(szBuf, "BUTTONLOOK")) { char szItem[256]; memset(szItem, 0, sizeof(szItem)); childElement.GetContents(szItem); map<string, MBButtonLook*>::iterator itor = m_ButtonLookMap.find(szItem); if (itor != m_ButtonLookMap.end()) { pWidget->ChangeCustomLook((MButtonLook*)(*itor).second); } pWidget->SetLook(true); } } return pWidget; }
void MMatchEventFactoryManager::ParseStartEndTime( MXmlElement& chrElement, SYSTEMTIME& stTime ) { memset( &stTime, 0, sizeof(stTime) ); char szAttrName[ 128 ]; char szAttrValue[ 256 ]; const int nAttrCnt = chrElement.GetAttributeCount(); for( int i = 0; i < nAttrCnt; ++i ) { chrElement.GetAttribute( i, szAttrName, szAttrValue ); if( 0 == stricmp(EL_YEAR, szAttrName) ) { stTime.wYear = static_cast< WORD >( atoi(szAttrValue) ); continue; } if( 0 == stricmp(EL_MONTH, szAttrName) ) { stTime.wMonth = static_cast< WORD >( atoi(szAttrValue) ); continue; } if( 0 == stricmp(EL_DAY, szAttrName) ) { stTime.wDay = static_cast< WORD >( atoi(szAttrValue) ); continue; } if( 0 == stricmp(EL_HOUR, szAttrName) ) { stTime.wHour = static_cast< WORD >( atoi(szAttrValue) ); continue; } } }
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 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 RMaterialList::Save(MXmlElement *pElement) { MXmlElement aMaterialListElement = pElement->CreateChildElement(RTOK_MATERIALLIST); { for(iterator i=begin();i!=end();i++) { aMaterialListElement.AppendText("\n\t\t"); RMATERIAL *pMaterial=*i; char buffer[256]; MXmlElement aElement,aChild; aElement=aMaterialListElement.CreateChildElement(RTOK_MATERIAL); aElement.AddAttribute(RTOK_NAME,pMaterial->Name.c_str()); aElement.AppendText("\n\t\t\t"); aChild=aElement.CreateChildElement(RTOK_DIFFUSE); aChild.SetContents(Format(buffer,pMaterial->Diffuse)); aElement.AppendText("\n\t\t\t"); aChild=aElement.CreateChildElement(RTOK_AMBIENT); aChild.SetContents(Format(buffer,pMaterial->Ambient)); aElement.AppendText("\n\t\t\t"); aChild=aElement.CreateChildElement(RTOK_SPECULAR); aChild.SetContents(Format(buffer,pMaterial->Specular)); aElement.AppendText("\n\t\t\t"); aChild=aElement.CreateChildElement(RTOK_DIFFUSEMAP); aChild.SetContents(pMaterial->DiffuseMap.c_str()); { MXmlElement aFlagElement; if((pMaterial->dwFlags & RM_FLAG_ADDITIVE) !=0) { aElement.AppendText("\n\t\t\t"); aElement.CreateChildElement(RTOK_ADDITIVE); } if((pMaterial->dwFlags & RM_FLAG_TWOSIDED) !=0) { aElement.AppendText("\n\t\t\t"); aElement.CreateChildElement(RTOK_TWOSIDED); } if((pMaterial->dwFlags & RM_FLAG_USEOPACITY) !=0) { aElement.AppendText("\n\t\t\t"); aElement.CreateChildElement(RTOK_USEOPACITY); } if((pMaterial->dwFlags & RM_FLAG_USEALPHATEST) !=0) { aElement.AppendText("\n\t\t\t"); aElement.CreateChildElement(RTOK_USEALPHATEST); } } aElement.AppendText("\n\t\t"); } aMaterialListElement.AppendText("\n\t"); } return true; }
void MQuestScenarioCatalogue::ParseMap(MXmlElement& element, MQuestScenarioInfo* pScenarioInfo) { char szTagName[128], szAttrValue[256], szAttrName[64]; int nAttrCount = element.GetAttributeCount(); int nDiceNum=0; for (int i = 0; i < nAttrCount; i++) { element.GetAttribute(i, szAttrName, szAttrValue); if (!_stricmp(szAttrName, MTOK_SCENARIO_DICE)) { nDiceNum = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_KEY_SECTOR)) { pScenarioInfo->Maps[nDiceNum-1].nKeySectorID = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_KEY_NPC)) { pScenarioInfo->Maps[nDiceNum-1].nKeyNPCID = atoi(szAttrValue); MMatchQuest* pQuest = MMatchServer::GetInstance()->GetQuest(); if (pQuest) { if (!pQuest->GetNPCInfo(MQUEST_NPC(pScenarioInfo->Maps[nDiceNum-1].nKeyNPCID))) { pScenarioInfo->Maps[nDiceNum-1].nKeyNPCID = 0; _ASSERT(0); // ÇØ´ç npc°¡ ¾ø´Ù. } } } else if (!_stricmp(szAttrName, MTOK_SCENARIO_BOSS)) { if (!_stricmp(szAttrValue, "true")) pScenarioInfo->Maps[nDiceNum-1].bKeyNPCIsBoss = true; else pScenarioInfo->Maps[nDiceNum-1].bKeyNPCIsBoss = false; } } int nDiceChildCount = element.GetChildNodeCount(); if ((nDiceNum <= 0) || (nDiceNum > SCENARIO_STANDARD_DICE_SIDES)) { nDiceNum = 1; // ÁÖ»çÀ§ ´«ÀÌ À߸øÀԷµǾî ÀÖ´Ù. _ASSERT(0); } MXmlElement chrElement; for (int k = 0; k < nDiceChildCount; k++) { chrElement = element.GetChildNode(k); chrElement.GetTagName(szTagName); if (szTagName[0] == '#') continue; if (!_stricmp(szTagName, MTOK_SCENARIO_NPCSET_ARRAY)) { ParseNPCSetArray(chrElement, pScenarioInfo->Maps[nDiceNum-1].vecNPCSetArray); } else if (!_stricmp(szTagName, MTOK_SCENARIO_JACO)) { ParseJaco(chrElement, &pScenarioInfo->Maps[nDiceNum-1]); } } }
void MQuestScenarioCatalogue::ParseJaco(MXmlElement& element, MQuestScenarioInfoMaps* pMap) { MQuestScenarioInfoMapJaco jaco; jaco.nNPCID = NPC_NONE; jaco.fRate = 0.0f; char szAttrValue[256], szAttrName[64], szTagName[128]; int nAttrCount = element.GetAttributeCount(); for (int i = 0; i < nAttrCount; i++) { element.GetAttribute(i, szAttrName, szAttrValue); if (!_stricmp(szAttrName, MTOK_SCENARIO_COUNT)) { pMap->nJacoCount = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_TICK)) { pMap->nJacoSpawnTickTime = atoi(szAttrValue) * 1000; } else if (!_stricmp(szAttrName, MTOK_SCENARIO_MIN_NPC)) { pMap->nJacoMinNPCCount = atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_MAX_NPC)) { pMap->nJacoMaxNPCCount = atoi(szAttrValue); } } int nChildCount = element.GetChildNodeCount(); MXmlElement chrElement; for (int k = 0; k < nChildCount; k++) { chrElement = element.GetChildNode(k); chrElement.GetTagName(szTagName); if (szTagName[0] == '#') continue; if (!_stricmp(szTagName, MTOK_SCENARIO_NPC)) { int nAttrCount = chrElement.GetAttributeCount(); MQuestScenarioInfoMapJaco jaco; jaco.nNPCID = NPC_NONE; jaco.fRate = 0.0f; for (int m = 0; m < nAttrCount; m++) { chrElement.GetAttribute(m, szAttrName, szAttrValue); if (!_stricmp(szAttrName, MTOK_SCENARIO_NPCID)) { jaco.nNPCID = (MQUEST_NPC)atoi(szAttrValue); } else if (!_stricmp(szAttrName, MTOK_SCENARIO_RATE)) { jaco.fRate = (float)atof(szAttrValue); } } pMap->vecJacoArray.push_back(jaco); } } }