102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
dttr_util_pkg.h
Go to the documentation of this file.
1
7
8#ifndef DTTR_UTIL_PKG_H
9#define DTTR_UTIL_PKG_H
10
11#include <stdbool.h>
12#include <stddef.h>
13#include <stdint.h>
14
15#include <dttr_core.h>
16#ifndef DTTR_SDK_ENABLE_UNSTABLE
17#error "Define DTTR_SDK_ENABLE_UNSTABLE before including dttr_util_pkg.h"
18#endif
19#include <dttr_pcdogs.h>
20
21#ifndef DTTR_UTIL_API
22#define DTTR_UTIL_API extern
23#endif
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
30#define DTTR_UTIL_PKG_DEFAULT_TOC_COUNT 138u
31
51
64
75
84
86
89 const DTTR_Util_PkgVisit *visit,
90 void *userdata
91);
92
96 int32_t toc_index,
97 const DTTR_PCDOGS_T_PKG_TOCEntry *entry,
98 void *userdata,
99 void **out_entry,
100 size_t *out_size,
101 DTTR_Util_PkgVisitStatus *out_status
102);
103
106 const DTTR_Core_Context *ctx,
107 int32_t toc_index,
108 const DTTR_PCDOGS_T_PKG_TOCEntry *entry,
109 void *entry_data,
110 void *userdata
111);
112
129
142
151
154
157 const DTTR_Core_Context *ctx,
158 const DTTR_Util_PkgWalkOptions *options,
159 DTTR_Util_PkgVisitor visitor,
160 void *userdata
161);
162
165
167#define DTTR_UTIL_PKG_VISIT_AS(FnSuffix, Kind, Type) \
168 static inline const Type *DTTR_Util_PkgVisit_As##FnSuffix( \
169 const DTTR_Util_PkgVisit *visit \
170 ) { \
171 return visit && visit->kind == (Kind) ? (const Type *)visit->ptr : NULL; \
172 }
173
177 LevelRuntimeData,
180)
183 MaterialEntry,
186)
189 SpriteContext,
192)
194 CollisionShape,
197)
198
199#ifdef __cplusplus
200}
201#endif
202
203#endif // DTTR_UTIL_PKG_H
void void * ctx
DTTR_Util_PkgVisitAction(* DTTR_Util_PkgVisitor)(const DTTR_Util_PkgVisit *visit, void *userdata)
Visitor called once per visit. Its return value steers traversal.
DTTR_UTIL_API const char * DTTR_Util_PkgVisitStatusName(DTTR_Util_PkgVisitStatus status)
Return a static log-friendly name such as ok or load failed.
#define DTTR_UTIL_PKG_VISIT_AS(FnSuffix, Kind, Type)
Define a typed accessor that returns visit->ptr only for the matching kind.
DTTR_PCDOGS_T_Material_Entry DTTR_UTIL_PKG_VISIT_COLLISION_SHAPE
DTTR_Util_PkgVisitKind
Values stored in DTTR_Util_PkgVisit.kind.
@ DTTR_UTIL_PKG_VISIT_TOC_ENTRY
@ DTTR_UTIL_PKG_VISIT_SCENE_NODE
@ DTTR_UTIL_PKG_VISIT_LEVEL_RUNTIME_DATA
@ DTTR_UTIL_PKG_VISIT_SPRITE_ENTRY
@ DTTR_UTIL_PKG_VISIT_MESH_NODE
@ DTTR_UTIL_PKG_VISIT_LOADED_ENTRY
@ DTTR_UTIL_PKG_VISIT_UNSUPPORTED
DTTR_Util_PkgVisitAction
Visitor actions that steer the next walk step.
@ DTTR_UTIL_PKG_VISIT_LOAD_AND_RECURSE
@ DTTR_UTIL_PKG_VISIT_RECURSE
@ DTTR_UTIL_PKG_VISIT_SKIP_SUBTREE
@ DTTR_UTIL_PKG_VISIT_STOP
@ DTTR_UTIL_PKG_VISIT_CONTINUE
DTTR_UTIL_API DTTR_Util_PkgWalkResult DTTR_Util_PkgWalk(const DTTR_Core_Context *ctx, const DTTR_Util_PkgWalkOptions *options, DTTR_Util_PkgVisitor visitor, void *userdata)
Walk live package structures and call the visitor for each visit.
bool(* DTTR_Util_PkgLoadEntryFn)(const DTTR_Core_Context *ctx, int32_t toc_index, const DTTR_PCDOGS_T_PKG_TOCEntry *entry, void *userdata, void **out_entry, size_t *out_size, DTTR_Util_PkgVisitStatus *out_status)
Load data for a TOC entry, reporting failures through out_status.
#define DTTR_UTIL_API
DTTR_UTIL_API DTTR_Util_PkgWalkOptions DTTR_Util_PkgWalk_DefaultOptions()
Return default options covering all known domains, entry loading included.
DTTR_Util_PkgWalkDomain
Bit flags for DTTR_Util_PkgWalkOptions.domains.
@ DTTR_UTIL_PKG_DOMAIN_ALL_KNOWN
@ DTTR_UTIL_PKG_DOMAIN_TOC
@ DTTR_UTIL_PKG_DOMAIN_COLLISION
@ DTTR_UTIL_PKG_DOMAIN_SPRITE
@ DTTR_UTIL_PKG_DOMAIN_MESH
@ DTTR_UTIL_PKG_DOMAIN_ENTRY
@ DTTR_UTIL_PKG_DOMAIN_LEVEL
@ DTTR_UTIL_PKG_DOMAIN_SCENE
@ DTTR_UTIL_PKG_DOMAIN_KNOWN_CHILDREN
@ DTTR_UTIL_PKG_DOMAIN_MATERIAL
void(* DTTR_Util_PkgFreeEntryFn)(const DTTR_Core_Context *ctx, int32_t toc_index, const DTTR_PCDOGS_T_PKG_TOCEntry *entry, void *entry_data, void *userdata)
Release entry data produced by the matching load callback.
DTTR_UTIL_PKG_VISIT_MATERIAL_ENTRY
DTTR_Util_PkgVisitStatus
Status values reported by visits and the final walk result.
@ DTTR_UTIL_PKG_STATUS_UNRESOLVED_SYMBOL
@ DTTR_UTIL_PKG_STATUS_OK
@ DTTR_UTIL_PKG_STATUS_INVALID_ARGUMENT
@ DTTR_UTIL_PKG_STATUS_LOAD_FAILED
@ DTTR_UTIL_PKG_STATUS_DECODE_UNSUPPORTED
@ DTTR_UTIL_PKG_STATUS_UNKNOWN_ENTRY_KIND
@ DTTR_UTIL_PKG_STATUS_BOUNDS_INVALID
Concrete runtime level-data block carried by Level_Data* APIs.
Package TOC entry used by the package table. Size-lane aliases share this storage.
Pointers last only for the visit unless PCDOGS documents a longer lifetime.
DTTR_Util_PkgVisitKind kind
const void * loaded_entry_base
const DTTR_Util_PkgVisit * parent
DTTR_Util_PkgVisitStatus status
const DTTR_PCDOGS_T_PKG_TOCEntry * toc_entry
Walk options. Start from DTTR_Util_PkgWalk_DefaultOptions() for defaults.
const DTTR_PCDOGS_T_PKG_TOCEntry * toc_entries
DTTR_Util_PkgLoadEntryFn load_entry
DTTR_Util_PkgFreeEntryFn free_entry
Non-fatal per-entry failures keep traversal moving.
DTTR_Util_PkgVisitStatus status