X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=addon.h;fp=addon.h;h=768bede37bf8f10487aa4ca15658cfa2d71bb139;hb=02e009ae6e20938675277e9ce2f467e17b170cc7;hp=949a5d0678a29a10ec7cd76c0c9d4abac977aaba;hpb=cbeec2e44e93ab43ccde54c2dd9cd02f559ebef8;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/addon.h b/addon.h index 949a5d0..768bede 100644 --- a/addon.h +++ b/addon.h @@ -3,7 +3,7 @@ #include "skaterift.h" #include "vg/vg_steam_ugc.h" -#include "workshop_types.h" +#include "addon_types.h" #include "vg/vg_mem_pool.h" #include "world.h" @@ -14,22 +14,23 @@ /* 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; typedef struct addon_cache_entry addon_cache_entry; +typedef struct addon_alias addon_alias; + +struct addon_alias { + enum addon_type type; + PublishedFileId_t workshop_id; + char foldername[ ADDON_FOLDERNAME_MAX ]; +}; + struct { struct addon_reg{ - PublishedFileId_t workshop_id; - - enum workshop_file_type type; + addon_alias alias; + u32 foldername_hash; u8 metadata[512]; /* vg_msg buffer */ u32 metadata_len; - char foldername[ ADDON_FOLDERNAME_MAX ]; - u32 foldername_hash; u16 cache_id; enum addon_state{ @@ -43,7 +44,7 @@ struct { u32 registry_count; /* deffered: updates in main thread */ - u32 registry_type_counts[k_workshop_file_type_max]; + u32 registry_type_counts[k_addon_type_max]; struct addon_cache{ struct addon_cache_entry{ @@ -65,58 +66,35 @@ struct { void *items; /* the real data */ size_t stride; } - cache[k_workshop_file_type_max]; + cache[k_addon_type_max]; SDL_SpinLock sl_cache_using_resources; - - - -#if 0 - - - - /* caches */ - struct cache_board{ - struct player_board board; - - u32 reg_index; - addon_reg *reg_ptr; - vg_pool_node cachenode; - } - *boards; - vg_pool board_cache; - - struct cache_playermodel{ - struct player_model model; - - u32 reg_index; - addon_reg *reg_ptr; - vg_pool_node cachenode; - } - *playermodels; - vg_pool playermodel_cache; -#endif - } static addon_system; 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 u32 addon_count( enum addon_type type ); +static addon_reg *get_addon_from_index(enum addon_type type, u32 index); +static u32 get_index_from_addon( enum addon_type type, addon_reg *a ); static int addon_get_content_folder( addon_reg *reg, vg_str *folder ); /* scanning routines */ -VG_STATIC void addon_mount_content_folder( enum workshop_file_type type, +VG_STATIC void addon_mount_content_folder( enum addon_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, + enum addon_type type, const char *content_ext ); -static u16 addon_cache_fetch( enum workshop_file_type type, u32 reg_index ); -static u16 addon_cache_alloc( enum workshop_file_type type, u32 reg_index ); -static void *addon_cache_item( enum workshop_file_type type, u16 id ); -static void *addon_cache_item_if_loaded( enum workshop_file_type type, u16 id ); +static u16 addon_cache_fetch( enum addon_type type, u32 reg_index ); +static u16 addon_cache_alloc( enum addon_type type, u32 reg_index ); +static void *addon_cache_item( enum addon_type type, u16 id ); +static void *addon_cache_item_if_loaded( enum addon_type type, u16 id ); +static void async_addon_setstate( void *data, u32 size ); +static void addon_cache_load_loop(void); +static u16 addon_cache_create_viewer( enum addon_type type, u16 reg_id); + +static void addon_cache_watch( enum addon_type type, u16 cache_id ); +static void addon_cache_unwatch( enum addon_type type, u16 cache_id ); #endif /* ADDON_H */