Exemplo n.º 1
0
MSXML2::IXMLDOMDocument2Ptr CXmlBase::GetXmlDocPtrByStream(CComBSTR bstrXml
	, CString strXmlPathFile)
{
	CString str(_T(""));
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocument2Ptr pDoc;

	//载入到xml文档结构中
	hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
	if (FAILED(hr))
	{
		//WRITELOG("END, FAILED TO INVOKE pDoc.CreateInstance");
		return NULL;
	}

	pDoc->async = VARIANT_FALSE; //加载方式为“同步”
	pDoc->validateOnParse = VARIANT_FALSE; //文档结构有错误时,停止解析。

	if (VARIANT_FALSE == pDoc->loadXML(bstrXml.m_str))
	{
		//WRITELOG("END, FAILED TO INVOKE pDoc->loadXML");
		return NULL;
	}

	if (!strXmlPathFile.IsEmpty())
	{
		if (S_OK != pDoc->save((LPCTSTR)strXmlPathFile))
		{
			//WRITELOG("END, FAILED TO INVOKE pDoc->save");
		}
	}
	return pDoc;
}
Exemplo n.º 2
0
MSXML2::IXMLDOMDocument2Ptr CXmlBase::GetXmlDocPtrByFile(LPCTSTR lpszXmlPathFile
	, LPCTSTR lpszNamespace)
{
	CComBSTR bstrXml;
	CString str(_T(""));
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocument2Ptr pDoc;

	//载入到xml文档结构中
	hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
	if (FAILED(hr))
	{
//		WRITELOG("END, FAILED TO INVOKE pDoc.CreateInstance");
		return NULL;
	}

	pDoc->async = VARIANT_TRUE; //加载方式为“同步”
	pDoc->validateOnParse = VARIANT_FALSE; //文档结构有错误时,停止解析。

	if (VARIANT_FALSE == pDoc->load(lpszXmlPathFile))
	{
		//WRITELOG("END, FAILED TO INVOKE pDoc->load(%s)", strXmlPathFile);
		return NULL;
	}

	if (lpszNamespace != NULL)
	{
		hr = pDoc->setProperty("SelectionLanguage", "XPath");
		if (FAILED(hr)) return NULL;
		hr = pDoc->setProperty("SelectionNamespaces", lpszNamespace);
		if (FAILED(hr)) return NULL;
	}

	return pDoc;
}
Exemplo n.º 3
0
MSXML2::IXMLDOMNodePtr CXmlBase::InsertEnterAndTabs(MSXML2::IXMLDOMNodePtr pParentNode, MSXML2::IXMLDOMNodePtr pNode, int nLevel)
{
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
	MSXML2::IXMLDOMTextPtr pTabsText = NULL;
	MSXML2::IXMLDOMNodePtr pTabsNode = NULL;
	MSXML2::IXMLDOMElementPtr pElement = NULL;
	CString strText(_T("")), strTabs(_T(""));
	CComBSTR bstrText;

	if (nLevel < 0 
		|| pParentNode == NULL) return NULL;

	if(pNode == NULL)nLevel = 0;

	for (int i=0; i<nLevel; i++)
	{
		strTabs += _T("\t");
	}
	strText.Format(_T("%s%s"), _T("\r\n"), (LPCTSTR)strTabs);
	bstrText = _bstr_t(strText).GetBSTR();

	try
	{
		pDoc = pParentNode->GetownerDocument();
		if (pDoc == NULL) return NULL;

		pTabsText = pDoc->createTextNode((LPCTSTR)strText);
		if (pTabsText == NULL) return NULL;
		CComVariant varNode = pNode.GetInterfacePtr();
		pTabsNode = pParentNode->insertBefore(pTabsText, varNode);


		//hr = pDoc->raw_createTextNode(bstrText.m_str, &pTabsText);
		//if (FAILED(hr) || pTabsText == NULL) return NULL;
		//pElement = pTabsText;
		//pTabsNode = pParentNode->appendChild(pElement);

		//pTabsNode = pDoc->createTextNode((LPCTSTR)strText);  
		//if (pTabsNode == NULL) return NULL;
		//pNode = pNode->appendChild(pTabsNode);
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("创建xml节点发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox(NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pTabsNode;
}
Exemplo n.º 4
0
BOOL CXmlBase::SetNameSpace(MSXML2::IXMLDOMDocument2Ptr& pDoc, LPCTSTR lpszNameSpace)
{
	HRESULT hr = S_OK;
	if (lpszNameSpace == NULL 
		|| pDoc == NULL) return FALSE;
	
	hr = pDoc->setProperty("SelectionLanguage", "XPath");
	if (FAILED(hr)) return FALSE;
	hr = pDoc->setProperty("SelectionNamespaces", lpszNameSpace);
	if (FAILED(hr)) return FALSE;
	return TRUE;
}
Exemplo n.º 5
0
MSXML2::IXMLDOMDocument2Ptr CXmlBase::CreateXmlDocPtr(void)
{
	::CoInitialize(NULL);
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
	HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
	if (FAILED(hr))
	{
		return NULL;
	}

	pDoc->async = VARIANT_FALSE; //加载方式为“同步”
	pDoc->validateOnParse = VARIANT_FALSE; //文档结构有错误时,停止解析。
	//pDoc->preserveWhiteSpace = VARIANT_TRUE;
	return pDoc;
}
void CWordManager::WordEditorInsertActiveElement(void)
{
	CElementManager & em = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->ElementManager;
	LPCTSTR strElementName = getLastElementName();

	//load element
	int element_index = em.ElementIdFromName(strElementName);
	MSXML2::IXMLDOMElementPtr active_element = 
		em.CreateEmptyElement(element_index);

	
	//load document
	MSXML2::IXMLDOMDocument2Ptr doc;
	doc.CreateInstance(_T("Msxml2.DOMDocument"));
	em.LoadSkeletonDTD((MSXML2::IXMLDOMDocumentPtr &) doc);
	
	//insert element to chapter and document
	doc->documentElement->
		appendChild(em.CreateEmptyElement(ELID_CHAPTER))->
			appendChild(active_element);


	//configure by dialog
	if (CSkeletonDoc::EditActiveElement(active_element))
	{
		//transform and generate
		CAElTransform transform(active_element);

		transform.DoAllTransnformations();

#ifdef _DEBUG
		MSXML2::IXMLDOMParseErrorPtr err = doc->validate();

		if (err->errorCode != S_OK)
		{
			AfxMessageBox(err->reason);
			AfxMessageBox(active_element->selectSingleNode("output")->xml);
		}
#endif
	
		GenerateXMLStringToWordEditor(active_element->xml);
	}

	
	
	active_element.Release();
	doc.Release();
}
Exemplo n.º 7
0
	MSXML2::IXMLDOMDocument2Ptr setupXMLParser(char *path)
	{
		HRESULT hr;
		MSXML2::IXMLDOMDocument2Ptr xmlDoc;
		
		hr = CoInitialize(NULL);
		hr = xmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);
		if (FAILED(hr)) return NULL;

		if (xmlDoc->load(path) != VARIANT_TRUE) return NULL;

		hr = xmlDoc->setProperty("SelectionNamespaces", "xmlns:r='http://www.collada.org/2005/11/COLLADASchema'");
		hr = xmlDoc->setProperty("SelectionLanguage", "XPath");

		return xmlDoc;
	}
Exemplo n.º 8
0
//取得指定xpath的节点
MSXML2::IXMLDOMNodePtr CXmlBase::GetNodePtr(LPCTSTR lpszXPath 
	, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	if (pDoc == NULL || lpszXPath == NULL) return NULL;
	CComBSTR bstrText = _bstr_t(lpszXPath).GetBSTR();
	return pDoc->selectSingleNode(bstrText.m_str);
}
Exemplo n.º 9
0
//设置指定xpath的节点值
BOOL CXmlBase::SetNodeValue(LPCTSTR lpszValue, LPCTSTR lpszXPath 
	, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	if (pDoc == NULL || lpszXPath == NULL) return FALSE;
	MSXML2::IXMLDOMNodeListPtr pNodeList = pDoc->selectNodes(lpszXPath);
	long lCnt = pNodeList->Getlength();
	if (lCnt == 0) return FALSE;
	MSXML2::IXMLDOMNodePtr pNode = pNodeList->Getitem(0);
	return SetNodeValue(lpszValue, pNode);
}
Exemplo n.º 10
0
	void readGeometry(dae_reader_t *reader, MSXML2::IXMLDOMDocument2Ptr xmlDoc)
	{
		MSXML2::IXMLDOMNodeListPtr nodeList;
		nodeList = xmlDoc->selectNodes("/r:COLLADA/r:library_geometries/r:geometry");
		int count = nodeList->length;

		for (int i = 0; i < count; i++)
		{
			MSXML2::IXMLDOMNodePtr node = nodeList->Getitem(i);
			readMesh(reader, node);
		}
	}
Exemplo n.º 11
0
void CShootManagerSys::LoadShootSolutionSector(int iSector, LPCTSTR szFilename)
{
	if(iSector >= m_ShootSolutionSectorArray.Num())		return;
	
	int i;
	MSXML2::IXMLDOMDocument2Ptr pDoc;
	pDoc.CreateInstance(__uuidof(DOMDocument40));
	pDoc->load((_variant_t)szFilename);
	
	
	// 성공한 슛부터 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListSuccess = pDoc->selectNodes(L"root/success");
	for(i=0; i<pNodeListSuccess->Getlength(); i++)
	{
		MSXML2::IXMLDOMNodePtr pNodeSuccess = pNodeListSuccess->Getitem(i);
		
		CShootSolution Solution;
		Solution.Create(pNodeSuccess, true, this);
		m_ShootSolutionSectorArray[iSector].first.push_back(Solution);
	}

	MSXML2::IXMLDOMNodeListPtr pNodeListFail = pDoc->selectNodes(L"root/fail");
	for(i=0; i<pNodeListFail->Getlength(); i++)
	{
		MSXML2::IXMLDOMNodePtr pNodeFail = pNodeListFail->Getitem(i);

		CShootSolution Solution;
		Solution.Create(pNodeFail, false, this);
		m_ShootSolutionSectorArray[iSector].second.push_back(Solution);
	}

	pDoc.Release();			
}
Exemplo n.º 12
0
MSXML2::IXMLDOMNodePtr CXmlBase::CreateRootNode(MSXML2::IXMLDOMDocument2Ptr pDoc
	, LPCTSTR lpszRootText)
{
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMElementPtr pElement = NULL;
	MSXML2::IXMLDOMNodePtr pNode = NULL;
	CComBSTR bstrRootText = _bstr_t("root").GetBSTR();

	if (pDoc == NULL) return NULL;

	if (lpszRootText != NULL)
		bstrRootText = lpszRootText;

	if (bstrRootText.Length() == 0) return NULL;

	try
	{
		//hr = pDoc->raw_createElement(bstrRootText.m_str, &pElement);
		//if (FAILED(hr) || pElement == NULL) return NULL;
		//pNode = pElement;
		pNode = pDoc->createNode(NODE_ELEMENT, bstrRootText.m_str, _T(""));
		if (pNode == NULL) return NULL;
		//hr = pDoc->raw_appendChild(pNode, NULL);
		//if (FAILED(hr)) return NULL;
		pNode = pDoc->appendChild(pNode);
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("创建xml根节点发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox( NULL, str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pNode;
}
Exemplo n.º 13
0
MSXML2::IXMLDOMNodePtr CXmlBase::InsertNode( MSXML2::IXMLDOMNodePtr pParentNode , MSXML2::IXMLDOMNodePtr pNodeBack , LPCTSTR lpszNodeText )
{
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
	MSXML2::IXMLDOMElementPtr pElement = NULL;
	MSXML2::IXMLDOMNodePtr pNode = NULL;
	CComBSTR bstrNodeText = _bstr_t("node").GetBSTR();

	if (pParentNode == NULL 
		|| lpszNodeText == NULL) return NULL;

	bstrNodeText = lpszNodeText;
	if (bstrNodeText.Length() == 0) return NULL;

	try
	{
		pDoc = pParentNode->GetownerDocument();
		if (pDoc == NULL) return NULL;
		//hr = pDoc->raw_createElement(bstrNodeText.m_str, &pElement);
		//if (FAILED(hr) || pElement == NULL) return NULL;
		pNode = pDoc->createNode(NODE_ELEMENT, bstrNodeText.m_str, _T(""));
		if (pNode == NULL) return NULL;
		CComVariant varNode = pNodeBack.GetInterfacePtr();
		pNode = pParentNode->insertBefore(pNode, varNode);
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("插入xml节点发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox(NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pNode;
}
Exemplo n.º 14
0
MSXML2::IXMLDOMNodePtr CXmlBase::CreateXmlTitle(MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	MSXML2::IXMLDOMProcessingInstructionPtr pi = NULL;
	MSXML2::IXMLDOMNodePtr pNode = NULL;

	if (pDoc == NULL) return NULL;
	try
	{
		pi = pDoc->createProcessingInstruction(_T("xml")
			, _T("version=\"1.0\" encoding=\"UTF-8\""));
		if (pi == NULL) return NULL;
		
		pNode = pi;
		if (NULL == (pNode = pDoc->appendChild(pNode)))
		{
			pi.Release();
			pNode.Release();
			return NULL;
		}
		pi.Release();
		//pNode.Release();
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("创建xml头发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox( NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pNode;
}
Exemplo n.º 15
0
void CShootManagerSys::LoadShootSolutionSector(int iSector, SFullName nameFile)
{
	if(iSector >= m_ShootSolutionSectorArray.Num())		return;
	
	int i;
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
	DFileGPack packFile;
	packFile.Open(nameFile);
	CFileSys::LoadBinaryXML(pDoc, packFile.GetFile(), packFile.GetSize());
	packFile.Close();

	// 성공한 슛부터 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListSuccess = pDoc->selectNodes(L"root/success");
	for(i=0; i<pNodeListSuccess->Getlength(); i++)
	{
		MSXML2::IXMLDOMNodePtr pNodeSuccess = pNodeListSuccess->Getitem(i);
		
		CShootSolution Solution;
		Solution.Create(pNodeSuccess, true, this);
		Solution.SetSectorIndex(iSector);
		m_ShootSolutionSectorArray[iSector].first.push_back(Solution);
	}
	
	MSXML2::IXMLDOMNodeListPtr pNodeListFail = pDoc->selectNodes(L"root/fail");
	for(i=0; i<pNodeListFail->Getlength(); i++)
	{
		MSXML2::IXMLDOMNodePtr pNodeFail = pNodeListFail->Getitem(i);
		
		CShootSolution Solution;
		Solution.Create(pNodeFail, false, this);
		Solution.SetSectorIndex(iSector);
		m_ShootSolutionSectorArray[iSector].second.push_back(Solution);
	}
	
	CFileSys::UnloadXML(pDoc);
}
Exemplo n.º 16
0
MSXML2::IXMLDOMNodeListPtr CXmlBase::GetNodeListPtr(LPCTSTR lpszXPath
	, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	MSXML2::IXMLDOMNodeListPtr pNodeList;
	CComBSTR bstrText;
	
	if (lpszXPath == NULL)
	{
		return NULL;
	}
	if (pDoc == NULL)
	{
		return NULL;
	}
	bstrText = _bstr_t(lpszXPath).GetBSTR();
	pNodeList = pDoc->selectNodes(bstrText.m_str);
	return pNodeList;
}
Exemplo n.º 17
0
	void getAxisOrientation(dae_reader_t *reader, MSXML2::IXMLDOMDocument2Ptr xmlDoc)
	{
		MSXML2::IXMLDOMNodePtr node = xmlDoc->selectSingleNode("/r:COLLADA/r:asset/r:up_axis");

		reader->x = 0;
		reader->y = 1;
		reader->z = 2;

		if (node != NULL)
		{
			string orientation = node->text;

			if (orientation[0] == 'Y')
			{
				reader->z = 1;
				reader->y = 2;
			}
		}
	}
Exemplo n.º 18
0
MSXML2::IXMLDOMDocument2Ptr ValidateConfigXML()
{
	wchar_t moduleFileName[MAX_PATH] = {0};
	if(0 == GetModuleFileNameW(GetModuleHandle(_T("TestConnectSdk.dll")/*"TestConnectAPITool.dll"*/), moduleFileName, MAX_PATH))
		throw Workshare::Exception(_T("Failed to obtain the filename of the current module"));
	CStdStringW schemaUrl;
	schemaUrl.Format(L"res://%s/ConnectAPITestTool.xsd", moduleFileName);

	MSXML2::IXMLDOMDocument2Ptr spConfigSchema;
	HRESULT hr = spConfigSchema.CreateInstance(__uuidof(MSXML2::DOMDocument60));
	if(FAILED(hr))
		throw Workshare::ClassNotFoundException(_T("Msxml2.DOMDocument.6.0"), _T("Failed to create an XML dom object."));
	if(VARIANT_TRUE != spConfigSchema->load(schemaUrl.c_str()))
		ThrowMSXMLParseError(spConfigSchema->parseError, _T("Failed to load 'ConnectAPITestTool.xsd'."));

	MSXML2::IXMLDOMSchemaCollection2Ptr spSchemaCollection;
	hr = spSchemaCollection.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60));
	if(FAILED(hr))
		throw Workshare::ClassNotFoundException(_T("Msxml2.XMLSchemaCache.6.0"), _T("Failed to create an XML schema collection."));
	hr = spSchemaCollection->add(L"", spConfigSchema.GetInterfacePtr());
	if(S_OK != hr)
		throw Workshare::Exception(_T("Failed to add 'ConnectAPITestTool.xsd' to schema collection."));

	MSXML2::IXMLDOMDocument2Ptr spConfigXML;
	hr = spConfigXML.CreateInstance(__uuidof(MSXML2::DOMDocument60));
	if(FAILED(hr))
		throw Workshare::ClassNotFoundException(_T("Msxml2.DOMDocument.6.0"), _T("Failed to create an XML dom object."));
	spConfigXML->async = VARIANT_FALSE;
	spConfigXML->resolveExternals = VARIANT_FALSE;
	spConfigXML->validateOnParse = VARIANT_FALSE;
	spConfigXML->schemas = spSchemaCollection.GetInterfacePtr();
	if(VARIANT_TRUE != spConfigXML->load(L"ConnectAPITestTool.xml"))
		ThrowMSXMLParseError(spConfigXML->parseError, _T("Failed to load 'ConnectAPITestTool.xml'."));

	MSXML2::IXMLDOMParseErrorPtr spError = spConfigXML->validate();
	if(S_OK != spError->errorCode)
		ThrowMSXMLParseError(spError, _T("Failed to validate 'ConnectAPITestTool.xml'."));

	return spConfigXML;
}
Exemplo n.º 19
0
MSXML2::IXMLDOMNodePtr CXmlBase::GetRootNodePtr(MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	MSXML2::IXMLDOMElementPtr pRoot;
	MSXML2::IXMLDOMNodePtr pNode;
	HRESULT hr = NULL;
	
	if (pDoc == NULL)
	{
		//WRITELOG("END, pDoc为空"); return NULL;
	}

	hr = pDoc->get_documentElement(&pRoot);
	if (FAILED(hr) || NULL == pRoot)
	{
//		WRITELOG("END, pDoc取得根节点失败");
		return NULL;
	}
	pNode = pRoot;
	return pNode;
}
Exemplo n.º 20
0
//设置指定xpath的节点属性
BOOL CXmlBase::SetAttrValue(LPCTSTR lpszValue, LPCTSTR lpszAttrName, LPCTSTR lpszXPath 
	, MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	MSXML2::IXMLDOMNodePtr pNode = NULL;
	MSXML2::IXMLDOMNodeListPtr pNodeList = NULL;
	long lCnt = 0;
	if (pDoc == NULL || lpszXPath == NULL) return FALSE;
	try
	{
		pNodeList = pDoc->selectNodes(lpszXPath);
		lCnt = pNodeList->Getlength();
		if (lCnt == 0) return FALSE;
		pNode = pNodeList->Getitem(0);
	}
	catch (_com_error e)
	{
		::MessageBox(NULL, e.ErrorMessage(), NULL, MB_OK|MB_ICONERROR);
		return FALSE;
	}
	return SetAttrValue(lpszValue, lpszAttrName, pNode);
}
Exemplo n.º 21
0
void CShootManagerSys::LoadShootSolutionSet(SFullName nameFile)
{
	int i;
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
	
	DFileGPack packFile;
	packFile.Open(nameFile);
	CFileSys::LoadBinaryXML(pDoc, packFile.GetFile(), packFile.GetSize());
	packFile.Close();
	
	// 시뮬레이터에서 사용하는 거리 범위들을 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListDistance;
	MSXML2::IXMLDOMNodePtr pNodeDistance;
	float fDistance;
	pNodeListDistance = pDoc->selectNodes(L"root/distance_range/distance");
	for(i=0; i<pNodeListDistance->Getlength(); i++)
	{
		pNodeDistance = pNodeListDistance->Getitem(i);
		_bstr_t distance = pNodeDistance->GetnodeTypedValue();
		sscanf((LPCTSTR)distance, "%f", &fDistance);
		m_DistanceList.push_back(fDistance);
	}
	
	
	// 시뮬레이터에서 사용하는 각도 범위들을 로드한다.
	// 여기서 각도는 (골대 - 슈터) 와 양의 z 축 사이의 각도를 말한다.
	// degree 로 저장되어 있으므로 Angle 로 변환시킨다.
	MSXML2::IXMLDOMNodeListPtr pNodeListAngle;
	MSXML2::IXMLDOMNodePtr pNodeAngle;
	float fDegree;
	int iAngle;
	pNodeListAngle = pDoc->selectNodes(L"root/angle_range/degree");
	for(i=0; i<pNodeListAngle->Getlength(); i++)
	{
		pNodeAngle = pNodeListAngle->Getitem(i);
		_bstr_t degree = pNodeAngle->GetnodeTypedValue();
		sscanf((LPCTSTR)degree, "%f", &fDegree);
		iAngle = Degree2Angle(fDegree);					// degree 에서 Angle 로 변환한다.
		m_AngleList.push_back(iAngle);
	}
	
	// 전체 섹터 개수를 계산하고 여기에 맞게 메모리를 생성한다.
	int iNumSector = m_DistanceList.size() * (m_AngleList.size() + 1) + 6;
	for(i=0; i<iNumSector; i++)
	{
		ShootSolutionSector *pShootSolutionSector = new (m_ShootSolutionSectorArray) ShootSolutionSector;
	}
	
	// 각 섹터별로 섹터안의 Shoot Solution 들을 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListSector = pDoc->selectNodes(L"root/sector");
	MSXML2::IXMLDOMNodePtr pNodeSector;
	MSXML2::IXMLDOMNodePtr pNodeIndex;
	MSXML2::IXMLDOMNodePtr pNodePath;
	for(i=0; i<pNodeListSector->Getlength(); i++)
	{
		pNodeSector = pNodeListSector->Getitem(i);
		pNodeIndex = pNodeSector->selectSingleNode(L"index");
		pNodePath = pNodeSector->selectSingleNode(L"path");
		_bstr_t index = pNodeIndex->GetnodeTypedValue();
		_bstr_t path = pNodePath->GetnodeTypedValue();
		
		SString strName = (LPCTSTR)path;

		DCutPath(strName);
		DCutFileExt(strName);
		strName[strName.Len()-3] = 'b';
		
		int iIndex = atoi((LPCTSTR)index);
		LoadShootSolutionSector(iIndex, SFullName("simulator",strName));

	//	int iIndex = atoi((LPCTSTR)index);
	//	SString sFilePath = szFilename;
	//	sFilePath = DGetPathOnly(sFilePath);
	//	sFilePath += "\\";
	//	sFilePath += (LPCTSTR)path;
		//		sFilePath.Format("%s\\%s\\%s", g_szCurrentPath, g_szSimulatorPath, (LPCTSTR)path);
		
	//	LoadShootSolutionSector(iIndex, (LPCTSTR)sFilePath);
	}
	
	CFileSys::UnloadXML(pDoc);	
}
Exemplo n.º 22
0
CRDPConfig::CRDPConfig(const char *configFile)
{
	// Local variables and initializations
	HRESULT	hResult = S_OK;
	char	cNodeType;

	// set the defaults
	mConfigError = false;	// TODO - check for config error - report in Capture Fail
	mDrive = "C:";
	mRoot = "/DATA";		// NOTE: don't use backslash in file names
	mInfoDrive = "C:";
	mInfoRoot = "/xampp/htdocs/RDP_Data";
	mInfoFile = "messages.log";
	mMsgLogDrive = "C:";
	mMsgLogRoot = "/xampp/htdocs/RDP_Data";
	mMsgLogFile = "messages.log";
	mTestDataDrive = "C:";
	mTestDataRoot = "/DATA/TestData";
	//mTestDataEnabled = false;
	mDebugLevel = -1;

	mMSSListenerPort = 65000;
	mDrive = "C:";
	mRoot = "\\DATA\\";
	mLeadInSize = 21;
	mDataBlockSize = 150;
	mLeadOutSize = 0;
	mNoOfCards = 2;
	mNoOfPortsPerCard = 4;

	// Read the XML file and update the config values

	// Initialize the COM library
	hResult = CoInitialize(NULL);
	if (FAILED(hResult))
	{
		MsgLog::Error("RDPConfig module - Failed to initialize COM environment");
		return;
	}

	// Main try block for MSXML DOM operations
	try
	{
		// MSXML COM smart pointers
		// Use the Dccument2 class to enable schema validation
		MSXML2::IXMLDOMDocument2Ptr spDocInput;
		MSXML2::IXMLDOMNodePtr spNodeTemp;
		MSXML2::IXMLDOMElementPtr spElemTemp;
		MSXML2::IXMLDOMAttributePtr spAttrTemp;
		MSXML2::IXMLDOMNodeListPtr spNLChildren;

		// Create the COM DOM Document object
		hResult = spDocInput.CreateInstance(__uuidof(DOMDocument));

		if FAILED(hResult)
		{
			MsgLog::Error("RDPConfig module - Failed to create Document instance");
			return;
		}

		// Load the document synchronously
		spDocInput->async = VARIANT_FALSE;

		// Load input document. MSXML default for load is to
		// validate while parsing.
		hResult = spDocInput->load(configFile);

		// Check for load, parse, or validation errors
		if( hResult != VARIANT_TRUE)
		{
			MsgLog::Error("Parsing error reading config file %s", configFile);
			return;
		} else {
			MsgLog::Info("Config file %s opened successfully", configFile);
		}

		// Get document element
		spElemTemp = spDocInput->documentElement;
		if (Debug::Enabled(Debug::CONFIG))
			std::cout<<std::endl<<"Document Element name:  "<<spElemTemp->nodeName<<std::endl;

		// Walk through children of document element
		// and process according to type
		spNodeTemp = spElemTemp->firstChild;

		// TODO more checking needed for the config file
		while (spNodeTemp != NULL)
		{
			// Process node depending on type
			cNodeType = spNodeTemp->nodeType;
			switch (cNodeType)
			{
				// Comment Node
				case NODE_COMMENT:
					if (Debug::Enabled(Debug::CONFIG))
						std::cout<<"Comment Node:" << std::endl << "  "<<_bstr_t(spNodeTemp->nodeValue)<<std::endl;
					break;
				// Element Node
				case NODE_ELEMENT:
				{
					std::string	tempString;
					spElemTemp = (IXMLDOMElementPtr) spNodeTemp;
					std::string node = (const char *)spElemTemp->nodeName;
					Debug::PrintLine(Debug::CONFIG, "Processing %s", node.c_str());

					// A note on processing attributes
					// MSXML doesn't support the hasAttribute method,
					// so we'll try to get the Attribute node, then its value.
					// eg
					// spAttrTemp = spElemTemp->getAttributeNode("Attribute1");
					// if (spAttrTemp != NULL)	// test if "get" was successful
					//    ...

					if (node == "MSS") {
						spAttrTemp = spElemTemp->getAttributeNode("PORT");
						if (spAttrTemp != NULL) {
							mMSSListenerPort = (u_short)strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
							Debug::PrintLine(Debug::CONFIG, "  PORT Value:  %d", mMSSListenerPort);
						}
					} else if (node == "DISK") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  DRIVE:  %s", mDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  ROOT:  %s", mRoot.c_str());
						}
					} else if (node == "INFO") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mInfoDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  INFO DRIVE:  %s", mInfoDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mInfoRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mInfoRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  INFO ROOT:  %s", mInfoRoot.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("FILE");
						if (spAttrTemp != NULL) {
							mInfoFile = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  INFO FILE:  %s", mInfoFile.c_str());
						}
					} else if (node == "MSGLOG") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mMsgLogDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG DRIVE:  %s", mMsgLogDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mMsgLogRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mMsgLogRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG ROOT:  %s", mMsgLogRoot.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("FILE");
						if (spAttrTemp != NULL) {
							mMsgLogFile = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG FILE:  %s", mMsgLogFile.c_str());
						}
					} else if (node == "TESTDATA") {
						spAttrTemp = spElemTemp->getAttributeNode("DRIVE");
						if (spAttrTemp != NULL) {
							mTestDataDrive = (char *)_bstr_t(spAttrTemp->nodeValue);
							Debug::PrintLine(Debug::CONFIG, "  TESTDATA DRIVE:  %s", mTestDataDrive.c_str());
						}
						spAttrTemp = spElemTemp->getAttributeNode("ROOT");
						if (spAttrTemp != NULL) {
							mTestDataRoot = (char *)_bstr_t(spAttrTemp->nodeValue);
							FixPath(mTestDataRoot);	// replace all backslashes \ with forward slashes /
							Debug::PrintLine(Debug::CONFIG, "  MSGLOG ROOT:  %s", mTestDataRoot.c_str());
						}
						//spAttrTemp = spElemTemp->getAttributeNode("ENABLED");
						//if (spAttrTemp != NULL) {
						//	tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
						//	std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
						//	mTestDataEnabled = (tempString == "YES");
						//}
					} else if (node == "DEBUG") {
						spAttrTemp = spElemTemp->getAttributeNode("LEVEL");
						if (spAttrTemp != NULL) {
							mDebugLevel = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
							Debug::PrintLine(Debug::CONFIG, "  DEBUG LEVEL:  %d", mDebugLevel);
						}
					} else if (node == "FIBREOPTICINTERFACE") {
						MSXML2::IXMLDOMNodePtr spChildNode = spNodeTemp->firstChild;
						int	noOfCards = 2;	// default to 2 cards
						int noOfPortsPerCard = 4;	// default to 4 ports per card

						while (spChildNode != NULL)
						{
							if (spChildNode->nodeType == NODE_ELEMENT)
							{
								MSXML2::IXMLDOMElementPtr spChildElem = (IXMLDOMElementPtr) spChildNode;
								std::string nodeName = (const char *)spChildNode->nodeName;
								Debug::PrintLine(Debug::CONFIG, "    Processing %s", nodeName.c_str());
								//Debug::PrintLine(Debug::CONFIG, "    Processing %s", (const char *)spChildNode->nodeName);
								if (nodeName == "HARDWARE")
								{
									// eg <HARDWARE CARDS="2" PORTS="4"/>
									spAttrTemp = spChildElem->getAttributeNode("CARDS");
									if (spAttrTemp != NULL) {
										noOfCards = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("PORTS");
									if (spAttrTemp != NULL) {
										noOfPortsPerCard = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
								} else if (nodeName == "FORMAT")
								{
									// eg <FORMAT LEADIN="21" DATABLOCK="150" LEADOUT="0"/>
									spAttrTemp = spChildElem->getAttributeNode("LEADIN");
									if (spAttrTemp != NULL) {
										mLeadInSize = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
										if (mLeadInSize < 0) mConfigError = true;
									}
									spAttrTemp = spChildElem->getAttributeNode("DATABLOCK");
									if (spAttrTemp != NULL) {
										mDataBlockSize = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
										if (mDataBlockSize < 0) mConfigError = true;
									}
									spAttrTemp = spChildElem->getAttributeNode("LEADOUT");
									if (spAttrTemp != NULL) {
										mLeadOutSize = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
										if (mLeadOutSize < 0) mConfigError = true;
									}
									if (mLeadInSize+mDataBlockSize+mLeadOutSize > Global::MAX_IQ_SAMPLES) mConfigError = true;
								} else if (nodeName == "DEVICE")
								{
									// eg <DEVICE CARD="0" PORT="2" ID="sfm_0_sfpdp_2" READ="YES" WRITE="NO"/>
									int			card, port, fibre;
									bool		bRead, bWrite;
									std::string	id;

									spAttrTemp = spChildElem->getAttributeNode("CARD");
									if (spAttrTemp != NULL) {
										card = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("PORT");
									if (spAttrTemp != NULL) {
										port = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("FIBRE");
									// TODO check that fibre value runs from 0 up to n
									if (spAttrTemp != NULL) {
										fibre = strtol((char *)_bstr_t(spAttrTemp->nodeValue), NULL, 0);
									}
									spAttrTemp = spChildElem->getAttributeNode("ID");
									if (spAttrTemp != NULL) {
										id = (char *)_bstr_t(spAttrTemp->nodeValue);
									}
									spAttrTemp = spChildElem->getAttributeNode("READ");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										bRead = (tempString == "YES");
									}
									spAttrTemp = spChildElem->getAttributeNode("WRITE");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										bWrite = (tempString == "YES");
									}
									Debug::PrintLine(Debug::CONFIG, "\tCARD = %d", card);
									Debug::PrintLine(Debug::CONFIG, "\tPORT = %d", port);
									Debug::PrintLine(Debug::CONFIG, "\tFIBRE = %d", fibre);
									Debug::PrintLine(Debug::CONFIG, "\tid = %s", id.c_str());
									Debug::PrintLine(Debug::CONFIG, "\tRead? = %s", (bRead)?"Yes":"No");
									Debug::PrintLine(Debug::CONFIG, "\tWrite? = %s", (bWrite)?"Yes":"No");
									if ( (card >= 0) && (card < Global::MAX_CARDS)		// card is 0..max-1 ?
										&& (port >= 0) && (port < Global::MAX_PORTS)	// port is 0..max-1 ?
										&& (bRead || bWrite)							// either reader or writer or both ?
										) {
										CDevice	device(card, port, bRead, bWrite, fibre, id);
										mDevice.push_back(device);
									}
								} else if (nodeName == "PROCESSING")
								{
									// eg	<PROCESSING HEADERCRCCHECK="YES"
									//			DATACRCCHECK="YES"
									//			HEADERMARK="7FACE0FF"
									//		/>
									std::string	mark;

									spAttrTemp = spChildElem->getAttributeNode("HEADERCRCCHECK");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										mHeaderCRCCheck = (tempString == "YES");
									}
									spAttrTemp = spChildElem->getAttributeNode("DATACRCCHECK");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										std::transform(tempString.begin(), tempString.end(), tempString.begin(), std::toupper);
										mDataCRCCheck = (tempString == "YES");
									}
									spAttrTemp = spChildElem->getAttributeNode("HEADERMARK");
									if (spAttrTemp != NULL) {
										tempString = (char *)_bstr_t(spAttrTemp->nodeValue);
										if (tempString.length() != 8) {
											MsgLog::Error("HEADERMARK conversion error - %s", tempString.c_str());
											mConfigError = true;
										} else {
											//tempString = 
											for (int i = 0; i < sizeof(DWORD); i++) {
												int	val;
												std::string s = tempString.substr(2*i, 2);
												if (Global::FromString(val, s, std::hex)) {
													val &= 0xFF;
													Global::headerBOM1.c[i] = val;
													Global::headerBOM2.c[sizeof(DWORD) - i - 1] = val;
												} else {
													mConfigError = true;
													MsgLog::Error("HEADERMARK conversion error - %s", tempString.c_str());
												}
											}
										}
									}
									Debug::PrintLine(Debug::CONFIG, "\tHEADERCRCCHECK? = %s", (mHeaderCRCCheck)?"Yes":"No");
									Debug::PrintLine(Debug::CONFIG, "\tDATACRCCHECK? = %s", (mDataCRCCheck)?"Yes":"No");
									Debug::PrintLine(Debug::CONFIG, "\tHeader Word = 0x%02x%02x%02x%02x",
										Global::headerBOM1.c[0], Global::headerBOM1.c[1], Global::headerBOM1.c[2], Global::headerBOM1.c[3]);
								}
							}
							spChildNode = spChildNode->nextSibling;	// Get the next child of the Document Element
							//Debug::PrintLine(Debug::CONFIG, "\tlength of mDevice is %d", mDevice.size());
						}
						mNoOfCards = ( (noOfCards > 0) && (noOfCards <= Global::MAX_CARDS) ) ? noOfCards : 2;
						mNoOfPortsPerCard = ( (noOfPortsPerCard > 0) && (noOfPortsPerCard <= Global::MAX_PORTS) ) ? noOfPortsPerCard : 4;
						Debug::PrintLine(Debug::CONFIG, "Number of cards = %d", mNoOfCards);
						Debug::PrintLine(Debug::CONFIG, "Number of ports per card = %d", mNoOfPortsPerCard);
					} else {
						if (Debug::Enabled(Debug::CONFIG))
							std::cout << "Ignoring element:      " << spElemTemp->nodeName << std::endl;
					}
				}

				// Everything else allowed by the schema
				default:
					// Skip unexpected processing instructions
					// and white space text nodes
					break;
			} // End of switch block

			spNodeTemp = spNodeTemp->nextSibling;	// Get the next child of the Document Element

		} // End of while block
	} // End of try block
	catch (_com_error &e)	// Catch COM exceptions
	{
		std::cerr << "COM Error" << std::endl;
		std::cerr << "Message = " << e.ErrorMessage() << std::endl;
		return;
	}

	CoUninitialize();

	Debug::SetLevel(mDebugLevel);
}
Exemplo n.º 23
0
bool Engine::LoadContent()
{
	// Setup our SpriteBatch.
	m_pSpriteBatch = new DirectX::SpriteBatch(d3dContext_);

	m_pFont->Initialize(d3dDevice_, std::wstring(L"Calibri18.spritefont"));
	m_pSprite->Initialize(d3dDevice_, std::wstring(L"Test.dds"), 10.0f, 10.0f); 
	
	m_textToDisplay = Text();
	m_textToDisplay.Initialize(std::wstring(L"Sarah"), DirectX::SimpleMath::Vector2(200.0f, 200.0f));

	try
	{
		MSXML2::IXMLDOMDocument2Ptr xmlDoc;
		HRESULT hr = xmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER);

		teamStats.InitializeTeam("Players.xml");

		// Make sure the file was loaded correctly before trying to load the players.
		if (xmlDoc->load("Players.xml") == VARIANT_TRUE)
		{
			//xmlDoc->setProperty("SelectionLanguage", "XPath");
			//teamStats.LoadPlayers(xmlDoc);
		}


		if (xmlDoc->load("input.xml") != VARIANT_TRUE)
		{
			DXTRACE_MSG("Unable to load input.xml\n");

			xmlDoc->save("input.xml");
			//xmlDoc->
		}
		else
		{
			DXTRACE_MSG("XML was successfully loaded \n");

			xmlDoc->setProperty("SelectionLanguage", "XPath");
			MSXML2::IXMLDOMNodeListPtr wheels = xmlDoc->selectNodes("/Car/Wheels/*");
			DXTRACE_MSG("Car has %u wheels\n", wheels->Getlength());
		
			DXTRACE_MSG(wheels->Getitem(0)->text);

			//ptr->

			MSXML2::IXMLDOMNodePtr node;
			node = xmlDoc->createNode(MSXML2::NODE_ELEMENT, ("Engine"), (""));
			node->text = ("Engine 1.0");
			xmlDoc->documentElement->appendChild(node);
			hr = xmlDoc->save("output.xml");

			if (SUCCEEDED(hr))
			{
				DXTRACE_MSG("output.xml successfully saved\n");
			}
		}
	}
	catch (_com_error &e)
	{
		DXTRACE_MSG(e.ErrorMessage());
	}










	return true;
}
Exemplo n.º 24
0
bool CGameApp::Init()
{	
// plasma 2005.07.06 - 디버그 모드에선 그냥 직접 읽고, 릴리즈 모드에선 pak 파일에서 추출해서 사용한다.
#ifdef _DEBUG
//	if( !g_TextManager.Load("text_data/text.dat") ) 
	if( !g_TextManager.LoadPack("text.dat", "text_data") ) 
	{
		MessageBox( NULL, "Text.Dat load fail", "Error", MB_OK );
	}
#else
	if( !g_TextManager.LoadPack("text.dat", "text_data") ) 
	{
		MessageBox( NULL, "Text.Dat load fail", "Error", MB_OK );
	}
#endif
	
	// Create game all systems.
	m_pGSystem  = new CSystemWin32Imp;
	m_pGSystem->Init(m_pProcessInfo);

	// 2003/11/19 by impurity create xml system
	MSXML2::IXMLDOMDocument2Ptr pDoc = NULL;
//#ifdef _DEBUG
//	CFileSys::ConvertBinaryXML("script\\window.xml","script\\window.bml");
//	FILE* fIn;
//	if(NULL!=(fIn=fopen("script\\window.bml","rb")))
//	{
//		CFileSys::LoadBinaryXML(pDoc, fIn);
//	}	
//	fclose( fIn );
//#else 
	DFileGPack packFile;
	packFile.Open(SFullName("script","window.bml"));
	CFileSys::LoadBinaryXML(pDoc, packFile.GetFile(), packFile.GetSize());
	packFile.Close();
//#endif
	
	
	MSXML2::IXMLDOMNodePtr pNode = NULL;
	
	if(pNode=pDoc->selectSingleNode(L"./root/window/bitperpixel"))
	{
		m_DisplayMode.iBitPerPixel = (short)pNode->GetnodeTypedValue();
	}
	else
	{
		m_DisplayMode.iBitPerPixel = 16;
	}
	
	m_DisplayMode.iDeviceType = 0;
	
	//if(pNode=pDoc->selectSingleNode(L"./root/window/fullmode"))
	//{
	//	m_DisplayMode.iFullScreen = (bool)pNode->GetnodeTypedValue();
	//	((CProcessInfoWin32Imp *)m_pProcessInfo)->m_bFullScreen = true;
	//}
	//else
	{
		m_DisplayMode.iFullScreen = false;
		((CProcessInfoWin32Imp *)m_pProcessInfo)->m_bFullScreen = false;
	}
	
	m_DisplayMode.iRefreshRate = 0;
	m_DisplayMode.iZBufferDepth = 32;
	
	if(pNode=pDoc->selectSingleNode(L"./root/window/width"))
	{
		m_DisplayMode.iWidth = (short)pNode->GetnodeTypedValue();
	}
	else
	{
		m_DisplayMode.iWidth = 800;
	}
	
	if(pNode=pDoc->selectSingleNode(L"./root/window/height"))
	{
		m_DisplayMode.iHeight = (short)pNode->GetnodeTypedValue();
	}
	else
	{
		m_DisplayMode.iHeight = 600;
	}
	
	CFileSys::UnloadXML(pDoc);
	


	m_pGameFactory = new CGameFactoryImp;
	// Register Game factory to Factory System.
	m_pGSystem->GetFactorySys()->RegisterGameFactory( m_pGameFactory );


	// 3d base initial.
	InitPhysics();

	CWindowSysWin32Imp* pWindowSysWin32Imp = (CWindowSysWin32Imp*)m_pGSystem->GetWindowSys();

	if( !m_pGSystem->GetGControlSys()->Create( pWindowSysWin32Imp->m_hWnd, 
		                                       m_DisplayMode ) )
	{
		// Device create error 
		DLogWriteSystem("Create Device Error");
		Shutdown();
	}

	int Xplus = GetSystemMetrics(SM_CXBORDER)*2*GetSystemMetrics(SM_CXFIXEDFRAME);
	int Yplus = GetSystemMetrics(SM_CYBORDER)*2*GetSystemMetrics(SM_CYFIXEDFRAME) +
				GetSystemMetrics(SM_CYCAPTION);
	SetWindowPos(pWindowSysWin32Imp->m_hWnd, HWND_NOTOPMOST, (GetSystemMetrics(SM_CXSCREEN)-m_DisplayMode.iWidth)/2,
				(GetSystemMetrics(SM_CYSCREEN)-m_DisplayMode.iHeight)/2
				, m_DisplayMode.iWidth+Xplus, m_DisplayMode.iHeight+Yplus, SWP_SHOWWINDOW);


	m_pGSystem->GetGControlSys()->GetDevice()->SetRenderState( D3DRS_AMBIENT, 0xAAAAAA );

	m_pGSystem->GetGControlSys()->SetTextureAutoCompress( true );
	DLogEnable(true);

	// 우선 모든 Layer 들을 생성한다.
	CResourceSysWin32Imp *pResourceSys = (CResourceSysWin32Imp *)m_pGSystem->GetResourceSys();
	pResourceSys->CreateLayerAll();
	pResourceSys->CreateTask(FACTORY_ID_TASK_FRAME_PLAYER);

	CFrameTask *pTask = (CFrameTask *)pResourceSys->GetTask(FACTORY_ID_TASK_FRAME_PLAYER);
	m_pGSystem->GetTaskSys()->PostTaskCommand(CTaskCommand::FRAMESYNC_PUSH_BACK, pTask);
	pWindowSysWin32Imp->SetWndProcTask(pTask);


	// insert only game layer to task.
	CQuickConnection::Instance.Initial();

	// 욕설 필터링을 작동한다.
	LoadCurses("curse.pak");

	// 2006.4.23 doo 메크로채팅 텍스트를 로드한다.
	g_pMacroChatFinder = new CMacroChat;
	g_pMacroChatFinder->Init();
	
	// Login Server 의 ip, port 를 저장한다.
	// 임시로 CQuickConnection 에서 ip, port 를 가져오도록 하였다.
	CInfoSys *pInfoSys = m_pGSystem->GetInfoSys();
	pInfoSys->SetLoginServerAddress((LPCTSTR)CQuickConnection::Instance.m_sServerAddr, CQuickConnection::Instance.m_iServerPort);	
	
	//m_pGSystem->GetInfoSys()->SetPPLName(SName("ppl_ting"));

	// Reject Popup
	CInfoSys::SGameIDInfo *pGameIDInfo;
	pGameIDInfo = m_pGSystem->GetInfoSys()->GetGameIDInfo();
	pGameIDInfo->bRejectPopup = false;
	pGameIDInfo->bObserverChar = false;

	CQuickConnection::Instance.m_nIsQuickMode = 1;
	CQuickConnection::Instance.m_nIsHost = 1;
	CQuickConnection::Instance.m_sServerAddr = "127.0.0.1";
	CQuickConnection::Instance.m_iServerPort = 10000;
	CQuickConnection::Instance.m_nIsFullCourt = 0;
	CQuickConnection::Instance.m_nFrameSpeedOn = 1;
	CQuickConnection::Instance.m_nHostPort = 10001;
	CQuickConnection::Instance.m_nPlayerOn = 1;
	CQuickConnection::Instance.m_sPlayMode = "auto";
	CQuickConnection::Instance.m_vecPos[0] = SVector(1,0,0);
	CQuickConnection::Instance.m_vecPos[1] = SVector(0,0,1);
	CQuickConnection::Instance.m_vecPos[2] = SVector(2,0,0);
	CQuickConnection::Instance.m_vecPos[3] = SVector(0,0,2);
	CQuickConnection::Instance.m_vecPos[4] = SVector(3,0,0);
	CQuickConnection::Instance.m_vecPos[5] = SVector(0,0,3);

	CQuickConnection::Instance.m_sConnectAddr = "127.0.0.1";
	CQuickConnection::Instance.m_sConnectionId = "c1test45";
	CQuickConnection::Instance.m_nClientPort = 10000;
	CQuickConnection::Instance.m_nCharID = 5;
	CQuickConnection::Instance.m_nCharType = 5;
	CQuickConnection::Instance.m_dwTeamID = 0;
	//CQuickConnection::Instance.m_dwMyId = 1;

	if( CQuickConnection::Instance.m_nIsQuickMode )
	{
		CFrameTask* pFrameTask = (CFrameTask*)pTask;
		// game render layer.
		CRenderLayer_Game* pRenderLayer = (CRenderLayer_Game *)pResourceSys->GetRenderLayer( FACTORY_ID_RENDERLAYER_GAME );
		pFrameTask->PostRenderLayerCommand( CRenderLayerCommand::PUSH_BACK, pRenderLayer );
		pRenderLayer->ResourceLoad(m_pGSystem, NULL);

		// game logic layer.
		CLogicLayer* pLogicLayer = pResourceSys->GetLogicLayer( FACTORY_ID_LOGICLAYER_GAME );
		pFrameTask->PostLogicLayerCommand( CLogicLayerCommand::PUSH_BACK, pLogicLayer );

		// host logic layer.
		if( CQuickConnection::Instance.m_nIsHost )
		{
			pLogicLayer = pResourceSys->GetLogicLayer( FACTORY_ID_LOGICLAYER_HOST );
			CLogicLayer_Host* pHostLogicLayer = (CLogicLayer_Host*)pLogicLayer;
			pHostLogicLayer->InitHost(CQuickConnection::Instance.m_nHostPort, 1 );
			pFrameTask->PostLogicLayerCommand( CLogicLayerCommand::PUSH_BACK, pLogicLayer );
		}
		
		m_pGSystem->GetInfoSys()->LoadGameOption("game.cfg");
		
	}
	else // insert all layer to excute game.
	{
		// lobby layer.
//		CInterfaceLayer *pInterfaceLayer_Login = pResourceSys->GetInterfaceLayer(FACTORY_ID_INTERFACELAYER_CREATECHAR);
//		pTask->PostInterfaceLayerCommand(CInterfaceLayerCommand::PUSH_BACK, pInterfaceLayer_Login);
		
		// room layer.
	}

	// plasma 2005.07.06 - Resource Table
#ifdef _DEBUG
/*	CTableResource* pItemRsc = new CTableResource;
	std::vector<std::string> ItemCustomKey;
	ItemCustomKey.push_back("ItemCode");
	pItemRsc->SetCustomKey(ItemCustomKey);
	pItemRsc->Load("text_data/ItemShop.txt");
	CTableRscManager::Instance().AddTableResource( "item", pItemRsc );
		
	CTableResource* pSkillRsc = new CTableResource;
	std::vector<std::string> SkillCustomKey;
	SkillCustomKey.push_back("SkillNo");
	SkillCustomKey.push_back("Kind");
	pSkillRsc->SetCustomKey(SkillCustomKey);
	pSkillRsc->Load("text_data/skillshop.txt");
	CTableRscManager::Instance().AddTableResource( "skill", pSkillRsc );

	CTableResource* pTrainingRsc = new CTableResource;
	std::vector<std::string> TrainingCustomKey;
	TrainingCustomKey.push_back("TrainingNo");
	pTrainingRsc->SetCustomKey(TrainingCustomKey);
	pTrainingRsc->Load("text_data/TrainingShop.txt");
	CTableRscManager::Instance().AddTableResource( "training", pTrainingRsc );
*/
	CTableResource* pItemRsc = new CTableResource;
	std::vector<std::string> ItemCustomKey;
	ItemCustomKey.push_back("ItemCode");
	pItemRsc->SetCustomKey(ItemCustomKey);
	pItemRsc->LoadPack("text_data", "ItemShop.txt");
	CTableRscManager::Instance().AddTableResource( "item", pItemRsc );
		
	CTableResource* pSkillRsc = new CTableResource;
	std::vector<std::string> SkillCustomKey;
	SkillCustomKey.push_back("SkillNo");
	SkillCustomKey.push_back("Kind");
	pSkillRsc->SetCustomKey(SkillCustomKey);
	pSkillRsc->LoadPack("text_data", "skillshop.txt");
	CTableRscManager::Instance().AddTableResource( "skill", pSkillRsc );

	CTableResource* pTrainingRsc = new CTableResource;
	std::vector<std::string> TrainingCustomKey;
	TrainingCustomKey.push_back("TrainingNo");
	pTrainingRsc->SetCustomKey(TrainingCustomKey);
	pTrainingRsc->LoadPack("text_data", "TrainingShop.txt");
	CTableRscManager::Instance().AddTableResource( "training", pTrainingRsc );

#else
	CTableResource* pItemRsc = new CTableResource;
	std::vector<std::string> ItemCustomKey;
	ItemCustomKey.push_back("ItemCode");
	pItemRsc->SetCustomKey(ItemCustomKey);
	pItemRsc->LoadPack("text_data", "ItemShop.txt");
	CTableRscManager::Instance().AddTableResource( "item", pItemRsc );
		
	CTableResource* pSkillRsc = new CTableResource;
	std::vector<std::string> SkillCustomKey;
	SkillCustomKey.push_back("SkillNo");
	SkillCustomKey.push_back("Kind");
	pSkillRsc->SetCustomKey(SkillCustomKey);
	pSkillRsc->LoadPack("text_data", "skillshop.txt");
	CTableRscManager::Instance().AddTableResource( "skill", pSkillRsc );

	CTableResource* pTrainingRsc = new CTableResource;
	std::vector<std::string> TrainingCustomKey;
	TrainingCustomKey.push_back("TrainingNo");
	pTrainingRsc->SetCustomKey(TrainingCustomKey);
	pTrainingRsc->LoadPack("text_data", "TrainingShop.txt");
	CTableRscManager::Instance().AddTableResource( "training", pTrainingRsc );
#endif

	return true;
}
Exemplo n.º 25
0
void CShootManagerSys::LoadShootSolutionSet(LPCTSTR szFilename)
{
	int i;
	MSXML2::IXMLDOMDocument2Ptr pDoc;
	pDoc.CreateInstance(__uuidof(DOMDocument40));
	pDoc->load((_variant_t)szFilename);


	// 시뮬레이터에서 사용하는 거리 범위들을 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListDistance;
	MSXML2::IXMLDOMNodePtr pNodeDistance;
	float fDistance;
	pNodeListDistance = pDoc->selectNodes(L"root/distance_range/distance");
	for(i=0; i<pNodeListDistance->Getlength(); i++)
	{
		pNodeDistance = pNodeListDistance->Getitem(i);
		_bstr_t distance = pNodeDistance->GetnodeTypedValue();
		sscanf((LPCTSTR)distance, "%f", &fDistance);
		m_DistanceList.push_back(fDistance);
	}

	
	// 시뮬레이터에서 사용하는 각도 범위들을 로드한다.
	// 여기서 각도는 (골대 - 슈터) 와 양의 z 축 사이의 각도를 말한다.
	// degree 로 저장되어 있으므로 Angle 로 변환시킨다.
	MSXML2::IXMLDOMNodeListPtr pNodeListAngle;
	MSXML2::IXMLDOMNodePtr pNodeAngle;
	float fDegree;
	int iAngle;
	pNodeListAngle = pDoc->selectNodes(L"root/angle_range/degree");
	for(i=0; i<pNodeListAngle->Getlength(); i++)
	{
		pNodeAngle = pNodeListAngle->Getitem(i);
		_bstr_t degree = pNodeAngle->GetnodeTypedValue();
		sscanf((LPCTSTR)degree, "%f", &fDegree);
		iAngle = Degree2Angle(fDegree);					// degree 에서 Angle 로 변환한다.
		m_AngleList.push_back(iAngle);
	}

	// 전체 섹터 개수를 계산하고 여기에 맞게 메모리를 생성한다.
	int iNumSector = m_DistanceList.size() * (m_AngleList.size() + 1) + 6;
	for(i=0; i<iNumSector; i++)
	{
		ShootSolutionSector *pShootSolutionSector = new (m_ShootSolutionSectorArray) ShootSolutionSector;
	}

	// 각 섹터별로 섹터안의 Shoot Solution 들을 로드한다.
	MSXML2::IXMLDOMNodeListPtr pNodeListSector = pDoc->selectNodes(L"root/sector");
	MSXML2::IXMLDOMNodePtr pNodeSector;
	MSXML2::IXMLDOMNodePtr pNodeIndex;
	MSXML2::IXMLDOMNodePtr pNodePath;
	for(i=0; i<pNodeListSector->Getlength(); i++)
	{
		pNodeSector = pNodeListSector->Getitem(i);
		pNodeIndex = pNodeSector->selectSingleNode(L"index");
		pNodePath = pNodeSector->selectSingleNode(L"path");
		_bstr_t index = pNodeIndex->GetnodeTypedValue();
		_bstr_t path = pNodePath->GetnodeTypedValue();

		int iIndex = atoi((LPCTSTR)index);
		SString sFilePath = szFilename;
		sFilePath = DGetPathOnly(sFilePath);
		sFilePath += "\\";
		sFilePath += (LPCTSTR)path;
//		sFilePath.Format("%s\\%s\\%s", g_szCurrentPath, g_szSimulatorPath, (LPCTSTR)path);

		LoadShootSolutionSector(iIndex, (LPCTSTR)sFilePath);
	}

	pDoc.Release();		
}