Exemplo n.º 1
0
void  XElement::GetIntList(CTSTR lpName, List<int> &IntList) const
{
    assert(lpName);

    IntList.Clear();

    for(DWORD i=0; i<SubItems.Num(); i++)
    {
        if(!SubItems[i]->IsData()) continue;

        XDataItem *item = static_cast<XDataItem*>(SubItems[i]);
        if(item->strName.CompareI(lpName))
        {
            CTSTR lpValue = item->strData;

            if( (*LPWORD(lpValue) == 'x0') ||
                (*LPWORD(lpValue) == 'X0') )
            {
                IntList << tstring_base_to_uint(lpValue+2, NULL, 16);
            }
            else if(scmpi(lpValue, TEXT("true")) == 0)
                IntList << 1;
            else if(scmpi(lpValue, TEXT("false")) == 0)
                IntList << 0;
            else
                IntList << tstring_base_to_uint(lpValue, NULL, 0);
        }
    }
}
Exemplo n.º 2
0
BOOL GetVersionText(
	LPCWSTR /* IN */ szModulePath,
	LPCSTR /* IN */ szBlock,
	LPWSTR /* OUT */ szText, 
	DWORD /* IN  */ dwMaxTextLen
	)
{
	// Copying version information to buffer
	UINT iDataLength=GetFileVersionInfoSizeW(szModulePath,NULL);
	if (iDataLength<2)
		return FALSE;
	BYTE* pData=new BYTE[iDataLength+2];
	if (pData==NULL)
		return FALSE;

	if (!GetFileVersionInfoW(szModulePath,NULL,iDataLength,pData))
	{
		delete[] pData;
		return FALSE;
	}
	
	VOID* pTranslations,* pProductVersion=NULL;
	WCHAR szTranslation[200];
	
	
	// Checking first translation block
	if (!VerQueryValueW(pData,L"VarFileInfo\\Translation",&pTranslations,&iDataLength))
	{
		delete[] pData;
		return FALSE;
	}
	swprintf_s(szTranslation,200,L"\\StringFileInfo\\%04X%04X\\%S",LPWORD(pTranslations)[0],LPWORD(pTranslations)[1],szBlock);
	
	
	
	if (!VerQueryValueW(pData,szTranslation,&pProductVersion,&iDataLength))
	{
		// Checking english if nothing else does not found
		swprintf_s(szTranslation,200,L"\\StringFileInfo\\040904b0\\%S",szBlock);
		
		if (!VerQueryValueW(pData,szTranslation,&pProductVersion,&iDataLength))
		{
			delete[] pData;
			return FALSE;
		}
	}


	
	// Copying information from pProductVersion to szText
	wcscpy_s(szText,dwMaxTextLen,(LPCWSTR)pProductVersion);
	
	delete[] pData;
	return TRUE;
}
Exemplo n.º 3
0
int   XElement::GetInt(CTSTR lpName, int def) const
{
    assert(lpName);

    XDataItem *item = GetDataItem(lpName);
    if(item)
    {
        CTSTR lpValue = item->strData;

        if( (*LPWORD(lpValue) == 'x0') ||
            (*LPWORD(lpValue) == 'X0') )
        {
            return tstring_base_to_uint(lpValue+2, NULL, 16);
        }
        else if(scmpi(lpValue, TEXT("true")) == 0)
            return 1;
        else if(scmpi(lpValue, TEXT("false")) == 0)
            return 0;
        else
            return tstring_base_to_uint(lpValue, NULL, 0);
    }

    return def;
}
Exemplo n.º 4
0
BOOL ConfigFile::GetColorList(CTSTR lpSection, CTSTR lpKey, List<Color4> &ColorList)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j,k;
    BOOL bFoundKey = 0;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    for(k=0; k<key.ValueList.Num(); k++)
                    {
                        TSTR strValue = key.ValueList[k];
                        if(*strValue == '{')
                        {
                            Color4 ret;

                            ret.x = float(tstof(++strValue));

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.y = float(tstof(++strValue));

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.z = float(tstof(++strValue));

                            if(!(strValue = schr(strValue, ',')))
                                ret.w = 0.0f;
                            else
                                ret.w = float(tstof(++strValue));
                            ColorList << ret;
                        }
                        else if(*strValue == '[')
                        {
                            Color4 ret;

                            ret.x = float(tstoi(++strValue))/255.0f;

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.y = float(tstoi(++strValue))/255.0f;

                            if(!(strValue = schr(strValue, ',')))
                                break;
                            ret.z = float(tstoi(++strValue))/255.0f;

                            if(!(strValue = schr(strValue, ',')))
                                ret.w = 0.0f;
                            else
                                ret.w = float(tstoi(++strValue))/255.0f;

                            ColorList << ret;
                        }
                        else if( (*LPWORD(strValue) == 'x0') ||
                            (*LPWORD(strValue) == 'X0') )
                        {
                            ColorList << RGBA_to_Vect4(tstring_base_to_int(strValue+2, NULL, 16));
                        }
                    }

                    bFoundKey = 1;
                }
            }
        }
    }

    return bFoundKey;
}
Exemplo n.º 5
0
Color4 ConfigFile::GetColor(CTSTR lpSection, CTSTR lpKey)
{
    assert(lpSection);
    assert(lpKey);

    DWORD i,j;

    for(i=0; i<Sections.Num(); i++)
    {
        ConfigSection &section = Sections[i];
        if(scmpi(lpSection, section.name) == 0)
        {
            for(j=0; j<section.Keys.Num(); j++)
            {
                ConfigKey &key = section.Keys[j];
                if(scmpi(lpKey, key.name) == 0)
                {
                    TSTR strValue = key.ValueList[0];
                    if(*strValue == '{')
                    {
                        Color4 ret;

                        ret.x = float(tstof(++strValue));

                        if(!(strValue = schr(strValue, ',')))
                            break;
                        ret.y = float(tstof(++strValue));

                        if(!(strValue = schr(strValue, ',')))
                            break;
                        ret.z = float(tstof(++strValue));

                        if(!(strValue = schr(strValue, ',')))
                        {
                            ret.w = 1.0f;
                            return ret;
                        }
                        ret.w = float(tstof(++strValue));

                        return ret;
                    }
                    else if(*strValue == '[')
                    {
                        Color4 ret;

                        ret.x = (float(tstoi(++strValue))/255.0f)+0.001f;

                        if(!(strValue = schr(strValue, ',')))
                            break;
                        ret.y = (float(tstoi(++strValue))/255.0f)+0.001f;

                        if(!(strValue = schr(strValue, ',')))
                            break;
                        ret.z = (float(tstoi(++strValue))/255.0f)+0.001f;

                        if(!(strValue = schr(strValue, ',')))
                        {
                            ret.w = 1.0f;
                            return ret;
                        }
                        ret.w = (float(tstoi(++strValue))/255.0f)+0.001f;

                        return ret;
                    }
                    else if( (*LPWORD(strValue) == 'x0') ||
                        (*LPWORD(strValue) == 'X0') )
                    {
                        return RGBA_to_Vect4(tstring_base_to_int(strValue+2, NULL, 16));
                    }
                }
            }
        }
    }

    return Color4(0.0f, 0.0f, 0.0f, 0.0f);
}
Exemplo n.º 6
0
int _stdcall MWECompiler(LPBYTE lpSCDT, int sizeSCDT) {
	int substitutions = 0;
	DWORD common[] = {	0x01130000, 0x01144012, 0x01154013, 0x01164014, 0x01174015, 0x01184016, 0x01194017, 0x011B4018,
						0x011D4019, 0x01224020, 0x011A4112, 0x011C4113, 0x011E4114, 0x01204115, 0x01214116, 0x01234117,
						0x011F4118, 0x01254119, 0x01284120, 0x01294212, 0x01274213, 0x012B4214, 0x012C4215, 0x012D4216,
						0x01304217, 0x012E4218, 0x012F4219, 0x01324220, 0x40194312, 0x41174115, 0x42144213, 0x42174216,
						0x00004312, 0x40120000, 0x41144016, 0x10D40000, 0x110D10D5, 0x10FD110E, 0x10F310FC, 0x00000000 };
	bool ten = false;
	for(int i = 0; i < sizeSCDT; i++) {
		if (ten = (!lpSCDT[i] && lpSCDT[i + 1]==0x10) ? 0 < (i += 4) : ten) {
			if (lpSCDT[i]) continue;
			else ten = false;
		}
		for(LPWORD j = LPWORD(&common[35])+1; j < LPWORD(&common[39]); j++) {
			if (*LPWORD(lpSCDT + i) == *j) {
				i += 2;
				if (lpSCDT[i]==0x2C && lpSCDT[i + 1]==0x20 && lpSCDT[i + 2]==0x6F)	i += 3;
				if (lpSCDT[i]==0x20 && lpSCDT[i + 1]==0x6F)							i += 2;
				i += lpSCDT[i] + 1;
			}
		}
		if (!lpSCDT[i] && lpSCDT[i + 1]==0x10) i += 2;
		for(LPDWORD j = LPDWORD(&common[1]); j < LPDWORD(&common[29]); j++) {
			bool exist = false;
			for(LPWORD k = LPWORD(&common[33])+1; k < LPWORD(&common[35]); k++) {
				if (*LPWORD(j) == *k) exist = true;
			}
			if ( !exist && *LPWORD(lpSCDT + i) == *(LPWORD(j) - 1)) {
				for(LPWORD k = LPWORD(&common[28])+1; k < LPWORD(&common[33]); k++) {
					if (*LPWORD(j) == *k && *LPDWORD(lpSCDT + i - 4) == 0x30303030) {
						for(int n = sizeof(DWORD); n > 0; n--) {
							char buffer[12];	// 11 is maximum available length of int value.
							_itoa_s(i, buffer, 12, 10);
							int length = strlen(buffer) + 1;
							if (n < length) lpSCDT[i - n] = buffer[length - n - 1];
							else lpSCDT[i - n] = 0x30;
						}
					}
				}
				*LPWORD(lpSCDT + i) = *LPWORD(j);
				substitutions++;
			}
		}
	}
	return substitutions;
}
Exemplo n.º 7
0
BYTE* dataparser2(LPCWSTR pStr,DWORD* pdwDataLength)
{
	if (pStr[0]=='\0')
		return NULL;
	
	BYTE* pData=new BYTE[10];
	BYTE* pDataPtr=pData;
	DWORD nAllocLen=10;

	// Removing spaces 
	while (*pStr==' ') pStr++;

	while (*pStr!='\0')
	{
		if (_1stcontain2nd(pStr,L"int"))
		{
			pStr+=3;
			int base=_getbase2(pStr,10);
			if (*pStr!='(')
				break;
			pStr++;
			
			_allocmore(pData,pDataPtr,nAllocLen,4);
			*((DWORD*)pDataPtr)=DWORD(_readnum(base,pStr));
			while (*pStr!=')' && *pStr!='\0') pStr++;
			if (*pStr==')') pStr++;
			pDataPtr+=4;
		}
		else if (_1stcontain2nd(pStr,L"dword"))
		{
			pStr+=5;
			int base=_getbase2(pStr,16);
			if (*pStr!='(')
				break;
			pStr++;
			
			_allocmore(pData,pDataPtr,nAllocLen,4);
			*((DWORD*)pDataPtr)=DWORD(_readnum(base,pStr));
			while (*pStr!=')' && *pStr!='\0') pStr++;
			if (*pStr==')') pStr++;
			pDataPtr+=4;
		}
		else if (_1stcontain2nd(pStr,L"word"))
		{
			pStr+=4;
			int base=_getbase2(pStr,16);
			if (*pStr!='(')
				break;
			pStr++;
			
			_allocmore(pData,pDataPtr,nAllocLen,2);
			*((WORD*)pDataPtr)=WORD(_readnum(base,pStr));
			while (*pStr!=')' && *pStr!='\0') pStr++;
			if (*pStr==')') pStr++;
			pDataPtr+=2;
		}
		else if (_1stcontain2nd(pStr,L"byte"))
		{
			pStr+=4;
			int base=_getbase2(pStr,16);
			if (*pStr!='(')
				break;
			pStr++;
			
			_allocmore(pData,pDataPtr,nAllocLen,1);
			*((BYTE*)pDataPtr)=BYTE(_readnum(base,pStr));
			while (*pStr!=')' && *pStr!='\0') pStr++;
			if (*pStr==')') pStr++;
			pDataPtr+=1;
		}
		else if (_1stcontain2nd(pStr,L"str"))
		{
			pStr+=3;
			if (*pStr!='(')
				break;
			pStr++;
			
			for (;*pStr!=')' && *pStr!='\0';pStr++)
			{
				_allocmore(pData,pDataPtr,nAllocLen,1);
				
				if (*pStr=='\\' && pStr[1]!='\0')
				{
					pStr++;
					switch (*pStr)
					{
					case '0':
						*(pDataPtr++)='\0';
						break;
					case 'n':
						*(pDataPtr++)='\n';
						break;
					case 'r':
						*(pDataPtr++)='\r';
						break;
					case 't':
						*(pDataPtr++)='\t';
						break;
					case 'b':
						*(pDataPtr++)='\b';
						break;
					case ')':
						*(pDataPtr++)=')';
						break;
					default:
						*(pDataPtr++)=BYTE(_readnum(16,pStr,2));;
						pStr--;
						break;
					}
				}
				else
					*(pDataPtr++)=W2Ac(*pStr);
			}
			if (*pStr==')') pStr++;
		}
		else if (_1stcontain2nd(pStr,L"oem"))
		{
			pStr+=3;
			if (*pStr!='(')
				break;
			pStr++;
			
			int iStart=DWORD(pDataPtr-pData);
			
			for (;*pStr!=')' && *pStr!='\0';pStr++)
			{
				_allocmore(pData,pDataPtr,nAllocLen,1);
				
				if (*pStr=='\\' && pStr[1]!='\0')
				{
					pStr++;
					switch (*pStr)
					{
					case '0':
						*(pDataPtr++)='\0';
						break;
					case 'n':
						*(pDataPtr++)='\n';
						break;
					case 'r':
						*(pDataPtr++)='\r';
						break;
					case 't':
						*(pDataPtr++)='\t';
						break;
					case 'b':
						*(pDataPtr++)='\b';
						break;
					case ')':
						*(pDataPtr++)=')';
						break;
					default:
						*(pDataPtr++)=BYTE(_readnum(16,pStr,2));;
						pStr--;
						break;
					}
				}
				else
					*(pDataPtr++)=W2Ac(*pStr);
			}
			CharToOemBuff(LPSTR(pData+iStart),LPSTR(pData+iStart),DWORD(pDataPtr-pData)-iStart);
			if (*pStr==')') pStr++;
		}
		else if (_1stcontain2nd(pStr,L"wstr") || _1stcontain2nd(pStr,L"uni"))
		{
			pStr+=3;
			while (*pStr!='(') pStr++;
			pStr++;
			
			for (;*pStr!=')' && *pStr!='\0';pStr++)
			{
				_allocmore(pData,pDataPtr,nAllocLen,2);
				
				if (*pStr=='\\' && pStr[1]!='\0')
				{
					pStr++;
					switch (*pStr)
					{
					case '0':
						*LPWORD(pDataPtr)=L'\0';
						break;
					case 'n':
						*LPWORD(pDataPtr)=L'\n';
						break;
					case 'r':
						*LPWORD(pDataPtr)=L'\r';
						break;
					case 't':
						*LPWORD(pDataPtr)=L'\t';
						break;
					case 'b':
						*LPWORD(pDataPtr)=L'\b';
						break;
					case ')':
						*LPWORD(pDataPtr)=L')';
						break;
					default:
						*LPWORD(pDataPtr)=WORD(_readnum(16,pStr,4));;
						pStr--;
						break;
					}
					pDataPtr+=2;
				}
				else
				{	
					*((WCHAR*)pDataPtr)=*pStr;
					pDataPtr+=2;
				}
			}
			if (*pStr==')') 
				pStr++;
		}
		else
		{
			_allocmore(pData,pDataPtr,nAllocLen,1);
			LPCWSTR pStrOld=pStr;
			*pDataPtr=_readnum(16,pStr,2);
			if (pStr==pStrOld)
			{
				*pdwDataLength=DWORD(pDataPtr-pData);
				return pData;
			}
			pDataPtr++;
		}
		while (*pStr==' ') pStr++;
	}
	*pdwDataLength=DWORD(pDataPtr-pData);
	return pData;
}
void	xrMU_Model::export_geometry		()
{
    // Declarator
    VDeclarator			D;
    D.set				(decl);

    // RT-check, BOX, low-point, frac-size
    Fbox			BB;
    BB.invalidate	();
    for (v_vertices_it vit=m_vertices.begin(); vit!=m_vertices.end(); vit++)
        BB.modify	((*vit)->P);

    Fvector			frac_low;
    float			frac_Ysize;
    BB.getcenter	(frac_low);
    frac_low.y	= BB.min.y;
    frac_Ysize		= BB.max.y - BB.min.y;

    // Begin building
    for (v_subdivs_it it=m_subdivs.begin(); it!=m_subdivs.end(); it++)
    {
        // Vertices
        {
            g_VB.Begin		(D);

            vecOGF_V&	verts	= it->ogf->vertices;
            for (u32 v_it=0; v_it<verts.size(); v_it++)
            {
                OGF_Vertex&		oV	= verts[v_it];

                // Position
                g_VB.Add	(&oV.P,3*sizeof(float));

                // Normal
                {
                    base_color_c	oV_c;
                    oV.Color._get(oV_c);
                    Fvector N	= oV.N;
                    N.add		(1.f);
                    N.mul		(.5f*255.f);
                    s32 nx		= iFloor(N.x);
                    clamp(nx,0,255);
                    s32 ny		= iFloor(N.y);
                    clamp(ny,0,255);
                    s32 nz		= iFloor(N.z);
                    clamp(nz,0,255);
                    s32 cc		= iFloor(oV_c.hemi*255.f);
                    clamp(cc,0,255);
                    u32	uN		= color_rgba(nx,ny,nz,cc);
                    g_VB.Add	(&uN,4);
                }

                // Tangent
                {
                    u32	uT		= color_rgba(oV.T.x,oV.T.y,oV.T.z,0);
                    g_VB.Add	(&uT,4);
                }

                // Binormal
                {
                    u32	uB		= color_rgba(oV.B.x,oV.B.y,oV.B.z,0);
                    g_VB.Add	(&uB,4);
                }

                // TC
                s16	tu,tv,frac,dummy;
                tu			= QC(oV.UV.begin()->x);
                tv			= QC(oV.UV.begin()->y);
                g_VB.Add	(&tu,2);
                g_VB.Add	(&tv,2);

                // frac
                float	f1	= (oV.P.y - frac_low.y)		/frac_Ysize;
                float	f2	= oV.P.distance_to(frac_low)/frac_Ysize;
                frac		= QC((f1+f2)/2.f);
                dummy		= 0;
                g_VB.Add	(&frac,	2);
                g_VB.Add	(&dummy,2);
            }

            g_VB.End		(&it->vb_id,&it->vb_start);
        }

        // Indices
        g_IB.Register	(LPWORD(&*it->ogf->faces.begin()),LPWORD(&*it->ogf->faces.end()),&it->ib_id,&it->ib_start);

        // SW
        if (it->ogf->progressive_test())
            g_SWI.Register	(&it->sw_id,&it->ogf->m_SWI);
    }
}