void vmf_load_all_instances( vmf_map *map, vdf_node *vmf )
{
+ char nextvmf[ 512 ];
+ const char *base = kv_get( vmf, "csr_path", "" );
+
vdf_foreach( vmf, "entity", ent )
{
if( !strcmp( kv_get( ent, "classname", "" ), "func_instance" ))
{
// Entity is in use if file is specified, if not just ignore the entity.
- const char *path = kv_get( ent, "file", "" );
- if( strcmp( path, "" ) )
+ const char *path = kv_get( ent, "file", NULL );
+
+ if( path )
{
- if( (ent->user1 = vmf_init_subvmf( map, path )))
+ // Make relative path real
+ strcpy( nextvmf, base );
+ csr_downlvl( nextvmf );
+ strcat( nextvmf, path );
+
+ if( (ent->user1 = vmf_init_subvmf( map, nextvmf )))
{
ent->user1 --;
ent->user = VMF_FLAG_IS_INSTANCE;
strcpy( inst->name, subvmf );
if( (inst->root = vdf_open_file( subvmf )) )
- {
+ {
+ vdf_kv_append( inst->root, "csr_path", subvmf );
+
// Recursive load other instances
vmf_load_all_instances( map, inst->root );
return id+1;
return NULL;
}
+ vdf_kv_append( map->root, "csr_path", path );
+
// Prepare instances
vmf_load_all_instances( map, map->root );