5 #include "vg/vg_steam_ugc.h"
6 #include "addon_types.h"
7 #include "vg/vg_mem_pool.h"
12 typedef struct addon_reg addon_reg
;
13 typedef struct addon_cache_entry addon_cache_entry
;
14 typedef struct addon_alias addon_alias
;
18 PublishedFileId_t workshop_id
;
19 char foldername
[ ADDON_FOLDERNAME_MAX
];
22 #define ADDON_REG_HIDDEN 0x1
28 u8 metadata
[512]; /* vg_msg buffer */
36 k_addon_state_indexed
,
37 k_addon_state_indexed_absent
/* gone but not forgotten */
44 /* deffered: updates in main thread */
45 u32 registry_type_counts
[k_addon_type_max
];
48 struct addon_cache_entry
{
50 addon_reg
*reg_ptr
; /* TODO: only use reg_index? */
52 vg_pool_node poolnode
;
54 enum addon_cache_state
{
55 k_addon_cache_state_none
,
56 k_addon_cache_state_loaded
,
57 k_addon_cache_state_load_request
64 void *items
; /* the real data */
67 cache
[k_addon_type_max
];
68 SDL_SpinLock sl_cache_using_resources
;
72 static void addon_system_init( void );
73 static u32
addon_count( enum addon_type type
, u32 ignoreflags
);
74 static addon_reg
*get_addon_from_index( enum addon_type type
, u32 index
,
76 static u32
get_index_from_addon( enum addon_type type
, addon_reg
*a
);
77 static int addon_get_content_folder( addon_reg
*reg
, vg_str
*folder
, int async
);
79 /* scanning routines */
80 static u32
addon_match( addon_alias
*alias
);
81 static int addon_alias_eq( addon_alias
*a
, addon_alias
*b
);
82 static void addon_alias_uid( addon_alias
*alias
, char buf
[ADDON_UID_MAX
] );
83 static int addon_uid_to_alias( const char *uid
, addon_alias
*alias
);
84 static void invalidate_addon_alias( addon_alias
*alias
);
85 static void addon_mount_content_folder( enum addon_type type
,
86 const char *base_folder
,
87 const char *content_ext
);
88 static void addon_mount_workshop_items(void);
89 static void async_addon_reg_update( void *data
, u32 size
);
90 static addon_reg
*addon_mount_local_addon( const char *folder
,
92 const char *content_ext
);
93 static u16
addon_cache_fetch( enum addon_type type
, u32 reg_index
);
94 static u16
addon_cache_alloc( enum addon_type type
, u32 reg_index
);
95 static void *addon_cache_item( enum addon_type type
, u16 id
);
96 static void *addon_cache_item_if_loaded( enum addon_type type
, u16 id
);
97 static void async_addon_setstate( void *data
, u32 size
);
98 static void addon_cache_load_loop(void);
99 static u16
addon_cache_create_viewer( enum addon_type type
, u16 reg_id
);
101 static void addon_cache_watch( enum addon_type type
, u16 cache_id
);
102 static void addon_cache_unwatch( enum addon_type type
, u16 cache_id
);
103 static u16
addon_cache_create_viewer_from_uid( enum addon_type type
,
104 char uid
[ADDON_UID_MAX
] );