more refactors..
[carveJwlIkooP6JGAAIwe30JlM.git] / addon.h
diff --git a/addon.h b/addon.h
index d28db0c1d4ca647fd11fbf753e91aaf5673414d2..7db6588515526217f779ba8e8b7cdbfcc59af58b 100644 (file)
--- a/addon.h
+++ b/addon.h
@@ -1,11 +1,23 @@
 #ifndef ADDON_H
 #define ADDON_H
 
-#include "workshop.h"
+#include "common.h"
+#include "vg/vg_steam_ugc.h"
 #include "workshop_types.h"
-#define ADDON_MOUNTED_MAX 128
+#include "vg/vg_mem_pool.h"
+
+#include "world.h"
+#include "player.h"
+
 #define ADDON_FOLDERNAME_MAX 64
 
+/* total count that we have knowledge of */
+#define ADDON_MOUNTED_MAX 128
+
+/* in memory and loaded stuffs */
+#define CACHE_BOARD_MAX  10
+#define CACHE_PLAYER_MAX 10
+
 typedef struct addon_reg addon_reg;
 struct {
    struct addon_reg{
@@ -31,6 +43,35 @@ struct {
 
    /* deffered: updates in main thread */
    u32 registry_type_counts[k_workshop_file_type_max]; 
+
+   /* caches */
+   struct cache_board{
+      enum cache_board_state{
+         k_cache_board_state_none,
+         k_cache_board_state_loaded,
+         k_cache_board_state_load_request
+      }
+      state;
+      struct player_board board;
+      u32 reg_index;
+      addon_reg *reg_ptr;
+
+      vg_pool_node cachenode;
+   }
+   *boards;
+   vg_pool board_cache;
+
+   struct cache_playermodel{
+      enum cache_board_state state;
+      struct player_model model;
+      u32 reg_index;
+      addon_reg *reg_ptr;
+      vg_pool_node cachenode;
+   }
+   *playermodels;
+   vg_pool playermodel_cache;
+
+   SDL_SpinLock sl_cache;
 }
 static addon_system;
 
@@ -38,12 +79,16 @@ static void addon_system_init( void );
 static u32 addon_count( enum workshop_file_type type );
 static addon_reg *get_addon_from_index(enum workshop_file_type type, u32 index);
 static u32 get_index_from_addon( enum workshop_file_type type, addon_reg *a );
+static int addon_get_content_folder( addon_reg *reg, vg_str *folder );
 
 /* scanning routines */
-VG_STATIC void addon_mount_local_folder( enum workshop_file_type type,
-                                         const char *base_folder, 
-                                         const char *content_ext );
+VG_STATIC void addon_mount_content_folder( enum workshop_file_type type,
+                                           const char *base_folder, 
+                                           const char *content_ext );
 VG_STATIC void addon_mount_workshop_items(void);
 VG_STATIC void async_addon_reg_update( void *data, u32 size );
+VG_STATIC addon_reg *addon_mount_local_addon( const char *folder,
+                                              enum workshop_file_type type,
+                                              const char *content_ext );
 
 #endif /* ADDON_H */