27 #ifndef ICB_PX_LINKED_DATA_FILE_H 28 #define ICB_PX_LINKED_DATA_FILE_H 30 #include "engines/icb/common/px_rcutypes.h" 31 #include "engines/icb/common/px_common.h" 32 #include "engines/icb/common/px_clu_api.h" 33 #include "engines/icb/debug.h" 35 #include "common/endian.h" 40 #define PX_LINKED_DATA_FILE_ERROR (0xffffffff) 42 #define ORDER_PRESERVED_FLAG 1 43 #define NO_NAMES_FLAG 2 44 #define SUPPRESS_OUTPUT 4 // Suppress printing of output 50 uint32 name_hash_value;
56 uint32 number_of_items;
68 return (FROM_LE_32(file->number_of_items));
71 static inline uint32 GetHeaderVersion(
LinkedDataFile *file) {
return (FROM_LE_32(file->header.version)); }
73 static inline int32 OrderPreserved(
LinkedDataFile *file) {
return (FROM_LE_32(file->flags) & (ORDER_PRESERVED_FLAG)); }
75 static inline int32 NameSearchable(
LinkedDataFile *file) {
return (!OrderPreserved(file)); }
77 static uint32 Fetch_item_number_by_hash(
LinkedDataFile *file,
const uint32 hash);
78 static uint32 Fetch_item_number_by_name(
LinkedDataFile *file,
const char *name);
80 static void *Fetch_item_by_number(
LinkedDataFile *file, uint32 number);
82 static void *Fetch_item_by_name(
LinkedDataFile *file,
const char *name);
84 static void *Fetch_items_name_by_number(
LinkedDataFile *file, uint32 number);
86 static void *Try_fetch_item_by_name(
LinkedDataFile *file,
const char *);
89 static void *Try_fetch_item_by_script_name(
LinkedDataFile *file,
const char *name);
93 inline void *LinkedDataObject::Fetch_item_by_number(
LinkedDataFile *file, uint32 number) {
95 assert(number < FROM_LE_32(file->number_of_items));
97 return (((uint8 *)&file->header) + FROM_LE_32(file->list[number].data_offset));
101 inline void *LinkedDataObject::Fetch_items_name_by_number(
LinkedDataFile *file, uint32 number) {
103 assert(number < FROM_LE_32(file->number_of_items));
105 return (((uint8 *)&file->header) + FROM_LE_32(file->list[number].name_offset));
110 inline uint32 LinkedDataObject::Fetch_item_number_by_name(
LinkedDataFile *file,
const char *name) {
113 if (!NameSearchable(file)) {
114 Fatal_error(
"This file is not searchable by name and was created as such (name %s)", name);
117 hash = EngineHashString(name);
119 return Fetch_item_number_by_hash(file, hash);
123 inline void *LinkedDataObject::Fetch_item_by_name(
LinkedDataFile *file,
const char *name) {
126 search = Try_fetch_item_by_name(file, name);
129 Fatal_error(
"pxLinked_data_file::Fetch_item_by_name Object %s not found", name);
139 inline void *LinkedDataObject::Try_fetch_item_by_name(
LinkedDataFile *file,
const char *name) {
143 search = Fetch_item_number_by_name(file, name);
145 if (search == PX_LINKED_DATA_FILE_ERROR)
148 return Fetch_item_by_number(file, search);
152 inline void *LinkedDataObject::Try_fetch_item_by_hash(
LinkedDataFile *file, uint32 hash) {
156 search = Fetch_item_number_by_hash(file, hash);
158 if (search == PX_LINKED_DATA_FILE_ERROR)
161 return Fetch_item_by_number(file, search);
164 inline void *LinkedDataObject::Try_fetch_item_by_script_name(
LinkedDataFile *file,
const char *name) {
168 if (strstr((
const char *)((uint8 *)&file->header) + FROM_LE_32(file->list[search].name_offset), (
const char *)name))
169 return (((uint8 *)&file->header) + FROM_LE_32(file->list[search].data_offset));
172 }
while (search < FROM_LE_32(file->number_of_items));
Definition: px_linkeddatafile.h:64
Definition: px_linkeddatafile.h:53
Definition: px_common.h:100
Definition: px_linkeddatafile.h:46