qboolean ParseEntity(void)
{
	epair_t        *e;


	/* dummy check */
	if(!GetToken(qtrue))
		return qfalse;
	if(strcmp(token, "{"))
		Error("ParseEntity: { not found");
	if(numEntities == MAX_MAP_ENTITIES)
		Error("numEntities == MAX_MAP_ENTITIES");

	/* create new entity */
	mapEnt = &entities[numEntities];
	numEntities++;

	/* parse */
	while(1)
	{
		if(!GetToken(qtrue))
			Error("ParseEntity: EOF without closing brace");
		if(!EPAIR_STRCMP(token, "}"))
			break;
		e = ParseEPair();
		e->next = mapEnt->epairs;
		mapEnt->epairs = e;
	}

	/* return to sender */
	return qtrue;
}
qboolean KeyExists(const entity_t * ent, const char *key)
{
	epair_t        *ep;

	/* walk epair list */
	for(ep = ent->epairs; ep != NULL; ep = ep->next)
	{
		if(!EPAIR_STRCMP(ep->key, key))
			return qtrue;
	}

	/* no match */
	return qfalse;
}
const char     *ValueForKey(const entity_t * ent, const char *key)
{
	epair_t        *ep;


	/* dummy check */
	if(ent == NULL)
		return "";

	/* walk epair list */
	for(ep = ent->epairs; ep != NULL; ep = ep->next)
	{
		if(!EPAIR_STRCMP(ep->key, key))
			return ep->value;
	}

	/* if no match, return empty string */
	return "";
}
void SetKeyValue( entity_t *ent, const char *key, const char *value ){
	epair_t *ep;


	/* check for existing epair */
	for ( ep = ent->epairs; ep != NULL; ep = ep->next )
	{
		if ( !EPAIR_STRCMP( ep->key, key ) ) {
			free( ep->value );
			ep->value = copystring( value );
			return;
		}
	}

	/* create new epair */
	ep = safe_malloc( sizeof( *ep ) );
	ep->next = ent->epairs;
	ent->epairs = ep;
	ep->key = copystring( key );
	ep->value = copystring( value );
}