Ejemplo n.º 1
0
bool init_attrs(const CAttr _attr_array[], uint32 _array_len, CUtlMap<int, int>& _attr_type_table, CUtlMap<CUtlSymbol, int>& _attr_name_table)
{
    SetDefLessFunc(_attr_type_table);
    SetDefLessFunc(_attr_name_table);

    for (uint32 i = 0; i < _array_len; i++)
    {
        int keyIndex = _attr_type_table.Find(_attr_array[i].attr_type);
        if (_attr_type_table.IsValidIndex(keyIndex))
        {
            Log.Error("[init_attrs] Init Attr Key Error:%d", _attr_array[i].attr_type);
            return false;
        }
        _attr_type_table.Insert(_attr_array[i].attr_type, i);

        CUtlSymbol symbol(_attr_array[i].attr_name.c_str());
        int nameIndex = _attr_name_table.Find(symbol);
        if (_attr_name_table.IsValidIndex(nameIndex))
        {
            Log.Error("[init_attrs] Init Attr Name Error:%s", _attr_array[i].attr_name.c_str());
            return false;
        }
        _attr_name_table.Insert(symbol, _attr_array[i].attr_type);
    }
    return true;
}
Ejemplo n.º 2
0
void Draw_DecalSetName( int decal, char *name )
{
	while ( decal >= g_DecalLookup.Count() )
	{
		MEM_ALLOC_CREDIT();
		int idx = g_DecalLookup.AddToTail();
		g_DecalLookup[idx] = g_DecalDictionary.InvalidIndex();
	}

	FileNameHandle_t fnHandle = g_pFileSystem->FindOrAddFileName( name );
	int lookup = g_DecalDictionary.Find( fnHandle );
	if ( lookup == g_DecalDictionary.InvalidIndex() )
	{
		DecalEntry entry;
#ifdef _DEBUG
		int len = strlen(name) + 1;
		entry.m_pDebugName = new char[len];
		memcpy( entry.m_pDebugName, name, len );
#endif
		entry.material = GL_LoadMaterial( name, TEXTURE_GROUP_DECAL );
		entry.index = decal;

		lookup = g_DecalDictionary.Insert( fnHandle, entry );
	}
	else
	{
		g_DecalDictionary[lookup].index = decal;
	}

	g_DecalLookup[decal] = lookup;
}
Ejemplo n.º 3
0
std::string get_attr_name(int type, const CAttr _attr_array[], CUtlMap<int, int>& _attr_type_table)
{
    int index = _attr_type_table.Find(type);
    if (!_attr_type_table.IsValidIndex(index)) {
        return "";
    }
    return _attr_array[_attr_type_table[index]].attr_name;
}
Ejemplo n.º 4
0
int get_attr_type(std::string name, CUtlMap<CUtlSymbol, int>& _attr_name_table)
{
    CUtlSymbol symbol(name.c_str());
    int index = _attr_name_table.Find(symbol);
    if (!_attr_name_table.IsValidIndex(index)) {
        return 0;
    }
    return _attr_name_table[index];
}
Ejemplo n.º 5
0
bool CNameTextMgr::_AddText(char* szString, CUtlMap<CUtlSymbol, CUtlSymbol>& vec)
{
	CUtlSymbol symbol(szString);
	int index = vec.Find(symbol);
	if(vec.IsValidIndex(index))
	{
		LOGGER_ERROR("[NameText] Error:%s", szString);
		return false;
	}
	vec.Insert(symbol, symbol);
	return true;
}
Ejemplo n.º 6
0
// called from cl_parse.cpp
// find the server side decal id given it's name.
// used for save/restore
int Draw_DecalIndexFromName( char *name, bool *found )
{
	Assert( found );

	FileNameHandle_t fnHandle = g_pFileSystem->FindOrAddFileName( name );
	int lookup = g_DecalDictionary.Find( fnHandle );
	if ( lookup == g_DecalDictionary.InvalidIndex() )
	{
		if ( found )
		{
			*found = false;
		}
		return 0;
	}

	if ( found )
	{
		*found = true;
	}
	return g_DecalDictionary[lookup].index;
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: this function will attempt to remap a key's value
// Input  : pszKey - the name of the key
//			pszInvalue - the original value
//			AllowNameRemapping - only do name remapping if this parameter is true.  
//				this is generally only false on the instance level.
// Output : returns true if the value changed
//			pszOutValue - the new value if changed
//-----------------------------------------------------------------------------
bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *pszOutValue, TNameFixup NameFixup )
{
	if ( RemapOperation.Count() == 0 )
	{
		RemapOperation.SetLessFunc( &CUtlType_LessThan );
		RemapOperation.Insert( ivAngle, REMAP_ANGLE );
		RemapOperation.Insert( ivTargetDest, REMAP_NAME );
		RemapOperation.Insert( ivTargetSrc, REMAP_NAME );
		RemapOperation.Insert( ivOrigin, REMAP_POSITION );
		RemapOperation.Insert( ivAxis, REMAP_ANGLE );
		RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
	}

	if ( !m_InstanceClass )
	{
		return false;
	}

	GDinputvariable *KVVar = m_InstanceClass->VarForName( pszKey );
	if ( !KVVar )
	{
		return false;
	}

	GDIV_TYPE	KVType = KVVar->GetType();
	int			KVRemapIndex = RemapOperation.Find( KVType );
	if ( KVRemapIndex == RemapOperation.InvalidIndex() )
	{
		return false;
	}

	strcpy( pszOutValue, pszInValue );

	switch( RemapOperation[ KVRemapIndex ] )
	{
		case REMAP_NAME:
			if ( KVType != ivInstanceVariable )
			{
				RemapNameField( pszInValue, pszOutValue, NameFixup );
			}
			break;

		case REMAP_POSITION:
			{
				Vector	inPoint( 0.0f, 0.0f, 0.0f ), outPoint;

				sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z );
				VectorTransform( inPoint, m_InstanceMat, outPoint );
				sprintf( pszOutValue, "%g %g %g", outPoint.x, outPoint.y, outPoint.z );
			}
			break;
			
		case REMAP_ANGLE:
			if ( m_InstanceAngle.x != 0.0f || m_InstanceAngle.y != 0.0f || m_InstanceAngle.z != 0.0f )
			{
				QAngle		inAngles( 0.0f, 0.0f, 0.0f ), outAngles;
				matrix3x4_t angToWorld, localMatrix;

				sscanf ( pszInValue, "%f %f %f", &inAngles.x, &inAngles.y, &inAngles.z );

				AngleMatrix( inAngles, angToWorld );
				MatrixMultiply( m_InstanceMat, angToWorld, localMatrix );
				MatrixAngles( localMatrix, outAngles );

				sprintf( pszOutValue, "%g %g %g", outAngles.x, outAngles.y, outAngles.z );
			}
			break;

		case REMAP_ANGLE_NEGATIVE_PITCH:
			if ( m_InstanceAngle.x != 0.0f || m_InstanceAngle.y != 0.0f || m_InstanceAngle.z != 0.0f )
			{
				QAngle		inAngles( 0.0f, 0.0f, 0.0f ), outAngles;
				matrix3x4_t angToWorld, localMatrix;

				sscanf ( pszInValue, "%f", &inAngles.x );	// just the pitch
				inAngles.x = -inAngles.x;

				AngleMatrix( inAngles, angToWorld );
				MatrixMultiply( m_InstanceMat, angToWorld, localMatrix );
				MatrixAngles( localMatrix, outAngles );

				sprintf( pszOutValue, "%g", -outAngles.x );	// just the pitch
			}
			break;
	}

	return ( strcmpi( pszInValue, pszOutValue ) != 0 );
}