All pastes #75211 Raw Edit

Something

public text v1 · immutable
#75211 ·published 2006-06-29 22:44 UTC
rendered paste body
int UTIL_FindOffsetDMap(datamap_t *dmap, const char *property)
{
	int ret = 0;
	int oldoffset = 0;
	static int offset = 0;
	static int indent = 0;
	char indents[256];

	Q_strcpy(indents,"");

	for (int i = 0; i < indent; i++)
	{
		Q_strcat(indents,"\t");
	}

	while (dmap)
	{
		char	classname[128];

		int headerbytes = Q_snprintf(classname, sizeof(classname), "%s%s\n", indents, dmap->dataClassName);

		for ( int i = 0; i < dmap->dataNumFields; i++ )
		{

			if (dmap->dataDesc[i].fieldName)
			{
				if (FStrEq(dmap->dataDesc[i].fieldName, property))
				{
					return dmap->dataDesc[i].fieldOffset[0] + offset;
				}
			}

			if (dmap->dataDesc[i].td)
			{
				datamap_t *dmap2 = dmap->dataDesc[i].td;
				oldoffset = offset;
				offset = dmap->dataDesc[i].fieldOffset[0];
				indent ++;
				ret = UTIL_FindOffsetDMap(dmap2, property);
				indent --;
				offset = oldoffset;
				if (ret > 0)
				{
					return ret;
				}
			}
		}
		dmap = dmap->baseMap; 
	}

	return 0;
}