yed
[carveJwlIkooP6JGAAIwe30JlM.git] / addon.c
diff --git a/addon.c b/addon.c
index 29b24a020ba59bf01fba14f3c3fc17f8d564d623..504904fac98c26546869ecc633033924eb7ef42e 100644 (file)
--- a/addon.c
+++ b/addon.c
@@ -4,6 +4,8 @@
 #include "addon.h"
 #include "vg/vg_msg.h"
 #include "steam.h"
+#include "workshop_types.h"
+#include "workshop.h"
 
 static u32 addon_count( enum workshop_file_type type ){
    return addon_system.registry_type_counts[ type ];
@@ -347,4 +349,35 @@ VG_STATIC void addon_mount_content_folder( enum workshop_file_type type,
    vg_dir_close(&dir);
 }
 
+static int addon_get_content_folder( addon_reg *reg, vg_str *folder ){
+   if( reg->workshop_id ){
+      vg_async_item *call = 
+         vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
+      struct async_workshop_filepath_info *info = call->payload;
+      info->buf = folder->buffer;
+      info->id = reg->workshop_id;
+      info->len = folder->len;
+      vg_async_dispatch( call, async_workshop_get_filepath );
+      vg_async_stall(); /* too bad! */
+      if( info->buf[0] == '\0' ){
+         vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
+                     reg->workshop_id );
+         return 0;
+      }
+      folder->i = strlen( folder->buffer );
+      return 1;
+   }
+   else{
+      folder->i = 0;
+      if( reg->type == k_workshop_file_type_board )
+         vg_strcat( folder, "boards/" );
+      else if( reg->type == k_workshop_file_type_world )
+         vg_strcat( folder, "maps/" );
+      else return 0;
+
+      vg_strcat( folder, reg->foldername );
+      return 1;
+   }
+}
+
 #endif /* ADDON_C */