return 0xffffffff;
}
-static void addon_alias_uid( addon_alias *alias, char buf[76] ){
+/*
+ * Create a string version of addon alias in buf
+ */
+static void addon_alias_uid( addon_alias *alias, char buf[ADDON_UID_MAX] ){
if( alias->workshop_id ){
snprintf( buf, 128, "sr%03d-steam-"PRINTF_U64,
alias->type, alias->workshop_id );
}
}
+/*
+ * parse uid to alias. returns 1 if successful
+ */
+static int addon_uid_to_alias( char uid[ADDON_UID_MAX], addon_alias *alias ){
+/* 1
+ * 01234567890123
+ * sr&&&-@@@@@-#*
+ * | | |
+ * type | id
+ * |
+ * location
+ */
+ if( strlen(uid) < 13 ) return 0;
+ if( !((uid[0] == 's') && (uid[1] == 'r')) ) return 0;
+
+ char type[4];
+ memcpy( type, uid+2, 3 );
+ type[3] = '\0';
+ alias->type = atoi(type);
+
+ char location[6];
+ memcpy( location, uid+6, 5 );
+ location[5] = '\0';
+
+ if( !strcmp(location,"steam") )
+ alias->workshop_id = atoll( uid+12 );
+ else if( !strcmp(location,"local") )
+ vg_strncpy( uid+12, alias->foldername, 64, k_strncpy_always_add_null );
+ else
+ return 0;
+
+ return 1;
+}
+
static void addon_system_init( void ){
u32 reg_size = sizeof(addon_reg)*ADDON_MOUNTED_MAX;
addon_system.registry = vg_linear_alloc( vg_mem.rtmemory, reg_size );
return cache_id;
}
+static u16 addon_cache_create_viewer_from_uid( enum addon_type type,
+ char uid[ADDON_UID_MAX] ){
+ addon_alias q;
+ addon_uid_to_alias( uid, &q );
+ if( q.type != type ) return 0;
+
+ u32 reg_id = addon_match( &q );
+
+ if( reg_id == 0xffffffff ){
+ vg_warn( "We dont have the addon '%s' installed.\n", uid );
+ return 0;
+ }
+ else {
+ return addon_cache_create_viewer( type, reg_id );
+ }
+}
+
static void addon_cache_watch( enum addon_type type, u16 cache_id ){
if( !cache_id ) return;