up network version
[carveJwlIkooP6JGAAIwe30JlM.git] / addon.c
diff --git a/addon.c b/addon.c
index 0b342ce99ad3f063dea66034423edde0877a2b10..6f60311c52980fefdcb9c76f97bc82f8a76ded4f 100644 (file)
--- a/addon.c
+++ b/addon.c
@@ -368,7 +368,7 @@ static addon_reg *addon_mount_local_addon( const char *folder,
       if( (reg->alias.type == type) && (reg->foldername_hash == folder_hash) ){
          if( !strcmp( reg->alias.foldername, folder_name ) ){
             reg->state = k_addon_state_indexed;
-            return NULL;
+            return reg;
          }
       }
    }
@@ -429,7 +429,12 @@ static addon_reg *addon_mount_local_addon( const char *folder,
  * Check all subscribed items
  */
 static void addon_mount_workshop_items(void){
+   if( skaterift.demo_mode ){
+      vg_info( "Won't load workshop items in demo mode\n" );
+      return;
+   }
    if( !steam_ready ) return;
+
    /*
     * Steam workshop scan
     */
@@ -522,16 +527,30 @@ static void addon_mount_content_folder( enum addon_type type,
 /*
  * write the full path of the addon's folder into the vg_str
  */
-static int addon_get_content_folder( addon_reg *reg, vg_str *folder ){
+static int addon_get_content_folder( addon_reg *reg, vg_str *folder, int async){
    if( reg->alias.workshop_id ){
-      vg_async_item *call = 
-         vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
-      struct async_workshop_filepath_info *info = call->payload;
+      struct async_workshop_filepath_info *info = NULL;
+      vg_async_item *call = NULL;
+
+      if( async ){
+         call = vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
+         info = call->payload;
+      }
+      else 
+         info = alloca( sizeof(struct async_workshop_filepath_info) );
+
       info->buf = folder->buffer;
       info->id = reg->alias.workshop_id;
       info->len = folder->len;
-      vg_async_dispatch( call, async_workshop_get_filepath );
-      vg_async_stall(); /* too bad! */
+
+      if( async ){
+         vg_async_dispatch( call, async_workshop_get_filepath );
+         vg_async_stall(); /* too bad! */
+      }
+      else {
+         async_workshop_get_filepath( info, 0 );
+      }
+
       if( info->buf[0] == '\0' ){
          vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
                      reg->alias.workshop_id );
@@ -723,7 +742,7 @@ static void addon_cache_load_loop(void){
 
             vg_str folder;
             vg_strnull( &folder, path_buf, 4096 );
-            if( addon_get_content_folder( reg, &folder ) ){
+            if( addon_get_content_folder( reg, &folder, 1 ) ){
                if( addon_cache_load_request( type, id, reg, folder ) ){
                   vg_async_call( async_addon_setstate, 
                                  entry, k_addon_cache_state_loaded );