X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=addon.c;h=0b342ce99ad3f063dea66034423edde0877a2b10;hb=d3021395f97b2ae244835c6656008386c8874343;hp=4d1e90342c0f35b6fb87081af3730c6af3fe2f4d;hpb=abc4dcca885e5a0bc45322c60b040841f69bbc58;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/addon.c b/addon.c index 4d1e903..0b342ce 100644 --- a/addon.c +++ b/addon.c @@ -7,16 +7,40 @@ #include "steam.h" #include "workshop.h" -static u32 addon_count( enum addon_type type ){ - return addon_system.registry_type_counts[ type ]; +static u32 addon_count( enum addon_type type, u32 ignoreflags ){ + if( ignoreflags ){ + u32 typecount = 0, count = 0; + for( u32 i=0; typecountalias.type == type ){ + typecount ++; + + if( reg->flags & ignoreflags ) + continue; + + count ++; + } + } + + return count; + } + else + return addon_system.registry_type_counts[ type ]; } + /* these kind of suck, oh well. */ -static addon_reg *get_addon_from_index(enum addon_type type, u32 index){ - u32 count = 0; - for( u32 i=0; countalias.type == type ){ + typecount ++; + + if( reg->flags & ignoreflags ) + continue; + if( index == count ) return reg; @@ -230,6 +254,7 @@ static addon_reg *addon_alloc_reg( PublishedFileId_t workshop_id, } addon_reg *reg = &addon_system.registry[ addon_system.registry_count ]; + reg->flags = 0; reg->metadata_len = 0; reg->cache_id = 0; reg->state = k_addon_state_indexed; @@ -535,8 +560,8 @@ static int addon_get_content_folder( addon_reg *reg, vg_str *folder ){ static u16 addon_cache_fetch( enum addon_type type, u32 reg_index ){ addon_reg *reg = NULL; - if( reg_index < addon_count( type ) ){ - reg = get_addon_from_index( type, reg_index ); + if( reg_index < addon_count( type, 0 ) ){ + reg = get_addon_from_index( type, reg_index, 0 ); if( reg->cache_id ) return reg->cache_id; } @@ -554,8 +579,8 @@ static u16 addon_cache_alloc( enum addon_type type, u32 reg_index ){ struct addon_cache_entry *new_entry = vg_pool_item( &cache->pool, new_id ); addon_reg *reg = NULL; - if( reg_index < addon_count( type ) ) - reg = get_addon_from_index( type, reg_index ); + if( reg_index < addon_count( type, 0 ) ) + reg = get_addon_from_index( type, reg_index, 0 ); if( new_entry ){ if( new_entry->reg_ptr ) @@ -683,7 +708,7 @@ static void addon_cache_load_loop(void){ vg_info( "process cache load request (%u#%u, reg:%u)\n", type, id, entry->reg_index ); - if( entry->reg_index >= addon_count(type) ){ + if( entry->reg_index >= addon_count(type,0) ){ /* should maybe have a different value for this case */ entry->state = k_addon_cache_state_none; SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); @@ -693,7 +718,7 @@ static void addon_cache_load_loop(void){ SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); /* continue with the request */ - addon_reg *reg = get_addon_from_index( type, entry->reg_index ); + addon_reg *reg = get_addon_from_index( type, entry->reg_index, 0 ); entry->reg_ptr = reg; vg_str folder;