Elaztek Developer Hub
Blamite Game Engine - blam!  00453.06.08.26.0624.blamite
The core library for the Blamite Game Engine.
tag_io.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <Strings/components/diagnostics/errors/errors.h>
6 
7 #ifdef BLAM_EXPORTS
8 #define BLAM_EXT_API __declspec(dllexport)
9 #else
10 #define BLAM_EXT_API __declspec(dllimport)
11 #endif
12 
13 #ifndef BLAM
14 #define BLAM
15 #endif
16 
17 class BlamTagData;
18 
19 #pragma pack(push, 1)
20 struct tag_flags
21 {
22  bool is_placeable : 1;
23  bool flag1 : 1;
24  bool flag2 : 1;
25  bool flag3 : 1;
26  bool flag4 : 1;
27  bool flag5 : 1;
28  bool flag6 : 1;
29  bool flag7 : 1;
30 };
31 #pragma pack(pop)
32 
33 #pragma pack(push, 1)
34 struct tag_header {
35  char reserved0[0x24];
36  char tag_class[0x5];
39  char reserved3[0x11];
40  char blam_identifier_2[0x4] = {'b', 'l', 'a', 'm'};
45  char reserved4[0xC];
46  char engine_version[0x20];
47  char reserved5[0x10];
48 
49  void validate()
50  {
51  tag_class[0x4] = NULL;
52  engine_version[0x1F] = NULL;
53  }
54 };
55 #pragma pack(pop)
56 
57 namespace Blam::Content::Tags
58 {
67  //BLAM void AddExtraTagFolder(std::string tag_folder);
68 
74  BLAM void LoadReferencedTags(std::string tag_path);
75 
80 
94  BLAM BlamResult LoadTagFromFile(std::string tag_path, bool reload_if_already_loaded = true);
95 
111  BLAM BlamResult LoadTagFromMemoryBlock(char* address, int size, std::string tag_path, bool reload_if_already_loaded = true);
112 
120  BLAM BlamResult SaveTag(std::string tag_path);
121 
129  BLAM bool TagNeedsPostprocess(BlamTagData* tag_data);
130 
143  BLAM void TagPostprocess(BlamTagData* tag_data);
144 
148  BLAM void TagScriptPostprocess(BlamTagData* tag_data);
149 
158  BLAM BlamTagData* CloneTag(BlamTagData* original_tag_data);
159 
166  BLAM std::string GetLastLoadingTagPath();
167 }
tag_block::entry_size
int entry_size
The size of each block entry.
Definition: tags.h:253
Blam::Settings::Config::GetEngineConfiguration
BLAM BlamConfigurationFile * GetEngineConfiguration()
Retrieves the main engine configuration file.
Definition: config.cpp:60
tag_io.h
tag_flags::flag4
bool flag4
Definition: tag_io.h:26
Blam::Content::Tags::SaveTag
BLAM BlamResult SaveTag(std::string tag_path)
Saves a tag data to a file.
Definition: tag_io.cpp:769
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:181
Blam::Content::Tags::TagScriptPostprocess
BLAM void TagScriptPostprocess(BlamTagData *tag_data)
Definition: tag_postprocess.cpp:272
tag_header::tag_class
char tag_class[0x5]
Definition: tag_io.h:36
tag_block::entry_data_address
void * entry_data_address
The address of the blocks' entry data.
Definition: tags.h:255
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
Blam::Content::Tags::GetFieldSize
BLAM int GetFieldSize(BlamTagFieldType type)
Retrieves the standard field size of a plugin field type.
Definition: fields.cpp:96
tag_block< void >
BlamProjectInfo::allow_user_tag_overrides
bool allow_user_tag_overrides
Definition: project_info.h:28
tag_flags::is_placeable
bool is_placeable
Definition: tag_io.h:22
LoadTagDataSection
void * LoadTagDataSection(int offset, int size, std::ifstream *tag_file)
Loads a tag data section from a file.
Definition: tag_io.cpp:85
logger.h
tag_reference::GetTagPath
std::string GetTagPath()
Retrieves the path of the tag that this tagref refers to.
Definition: tag_reference.cpp:57
tag_header::flags
tag_flags flags
Definition: tag_io.h:37
BlamEngineDataFolder::Tags
@ Tags
Directory used for reading engine tags. Defaults to ./tags/
tag_header::script_name_size
uint32_t script_name_size
Definition: tag_io.h:44
version_data.h
Blam::Content::Tags::GetLoadedTags
BLAM std::vector< BlamTagData * > * GetLoadedTags()
Retrieves the list of loaded tag data.
Definition: tags.cpp:157
BlamTagData::path
char path[256]
The tag's path.
Definition: tags.h:145
tag_header::reserved5
char reserved5[0x10]
Definition: tag_io.h:47
BlamTagData::script_id
std::string script_id
Definition: tags.h:151
FixupClonedTagData
bool FixupClonedTagData(void *tag_address, int size, void *original_tag_address)
Definition: tag_io.cpp:269
Blam::Content::Tags::LoadTagFromFile
BLAM BlamResult LoadTagFromFile(std::string tag_path, bool reload_if_already_loaded=true)
Loads a tag from the engine's tag directory (default is '.
Definition: tag_io.cpp:319
tag_reference::data_size
int data_size
The size of tagref_address.
Definition: tags.h:298
field_reference::referenced_field_type
BlamTagFieldType referenced_field_type
Definition: tags.h:458
project.h
BuildTagDataSection
std::vector< char > BuildTagDataSection(void *section_data, int size, int start_offset)
Prepares a tag data section for saving.
Definition: tag_io.cpp:706
Blam::Content::Tags::GetTagClass
BLAM_EXT_API BlamTagClass * GetTagClass(std::string id)
Retrieves a tag class that matches the given string.
Definition: tagclass.cpp:72
USER_DATA_PATH
#define USER_DATA_PATH(path)
Macro to quickly access a user data folder.
Definition: config.h:41
Blam::Content::Tags::TagNeedsPostprocess
BLAM bool TagNeedsPostprocess(BlamTagData *tag_data)
Checks if a given tag requires additional post-processing.
Definition: tag_postprocess.cpp:108
tag_header::blam_identifier_2
char blam_identifier_2[0x4]
Definition: tag_io.h:40
BLAM
#define BLAM
Definition: tag_io.h:14
tag_header::reserved3
char reserved3[0x11]
Definition: tag_io.h:39
tag_flags::flag5
bool flag5
Definition: tag_io.h:27
tag_header::script_name_offset
uint64_t script_name_offset
Definition: tag_io.h:43
uint64_t
unsigned long long uint64_t
Definition: stdint.h:18
tag_header::fieldset_version
uint32_t fieldset_version
Definition: tag_io.h:42
Blam::Content::Project::GetCurrentProjectInfo
BLAM BlamProjectInfo GetCurrentProjectInfo()
Definition: project.cpp:7
Blam::Content::Tags::GetLastLoadingTagPath
BLAM std::string GetLastLoadingTagPath()
Retrieves the tag path of the most recent tag that started loading.
Definition: tag_io.cpp:854
LoadTagDataSection__New
bool LoadTagDataSection__New(void *tag_address, int size, int header_size)
Definition: tag_io.cpp:221
ENGINE_VERSION
#define ENGINE_VERSION
Definition: version_data.h:32
BlamTagData::SetTagPath
bool SetTagPath(std::string new_path)
Updates the tag path.
Definition: BlamTagData.cpp:39
tag_header
Definition: tag_io.h:34
BlamTagData::uses_global_script
bool uses_global_script
Definition: tags.h:155
Blam::Content::Tags::CloneTag
BLAM BlamTagData * CloneTag(BlamTagData *original_tag_data)
Creates a copy of a tag in memory.
Definition: tag_io.cpp:826
NULL
Add a fourth parameter to bake specific font ranges NULL
Definition: README.txt:57
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:206
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:34
tag_block::entry_count
int entry_count
The number of entries within the tag block.
Definition: tags.h:256
TagOrigin::Clone
@ Clone
Indicates the tag was created by cloning the data of an existing tag.
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:207
Blam::Content::Tags::TagPostprocess
BLAM void TagPostprocess(BlamTagData *tag_data)
Performs any required post-processing for a given tag.
Definition: tag_postprocess.cpp:152
tag_reference
Structure representing a tag reference.
Definition: tags.h:289
field_reference
Structure representing a field reference.
Definition: tags.h:455
tag_header::reserved4
char reserved4[0xC]
Definition: tag_io.h:45
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:205
Blam::Content::Tags::LoadTagFromMemoryBlock
BLAM BlamResult LoadTagFromMemoryBlock(char *address, int size, std::string tag_path, bool reload_if_already_loaded=true)
Loads a tag from a block of memory.
Definition: tag_io.cpp:527
tag_flags::flag2
bool flag2
Definition: tag_io.h:24
uint32_t
unsigned int uint32_t
Definition: stdint.h:17
Blam::Content::Tags::GetTagData
BLAM BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: tags.cpp:81
Blam::Content::Tags::ResolveAllTagReferences
BLAM void ResolveAllTagReferences()
Attempts to resolve all tag references within all loaded tags.
Definition: tags.cpp:73
BlamProjectInfo
Definition: project_info.h:5
tag_flags
Definition: tag_io.h:20
tag_header::engine_version
char engine_version[0x20]
Definition: tag_io.h:46
LoadSectionTagReferences
void LoadSectionTagReferences(char *address, int size, std::string tag_path)
Attempts to resolve any tag references within the given tag data section.
Definition: tag_io.cpp:28
TagOrigin::Memory
@ Memory
Indicates the tag originated from the engine's memory.
engine_definitions.h
tag_reference::data_is_tag
bool data_is_tag
Whether or not tagref_address points to tag data, or the tag's path.
Definition: tags.h:296
data_reference::data_address
void * data_address
The address of the referenced data.
Definition: tags.h:346
Blam::Content::Tags::LoadReferencedTags
BLAM void LoadReferencedTags(std::string tag_path)
Adds an additional folder to search when attempting to load a tag.
Definition: tag_io.cpp:60
fields.h
data_reference
Structure representing a data reference.
Definition: tags.h:342
tag_reference::HasReference
bool HasReference()
Checks if a tag reference has a tag specified or not.
Definition: tag_reference.cpp:81
tag_header::blamite_identifier_byte
bool blamite_identifier_byte
Definition: tag_io.h:38
tag_flags::flag6
bool flag6
Definition: tag_io.h:28
tag_flags::flag1
bool flag1
Definition: tag_io.h:23
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:210
tag_flags::flag7
bool flag7
Definition: tag_io.h:29
data_reference::data_size
int data_size
The size of the referenced data.
Definition: tags.h:347
field_reference::file_offset
uint32_t file_offset
Definition: tags.h:460
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:132
tagclass.h
tag_header::validate
void validate()
Definition: tag_io.h:49
config.h
tag_flags::flag3
bool flag3
Definition: tag_io.h:25
tags.h
BlamTagData::origin
TagOrigin origin
The origin of the tag.
Definition: tags.h:147
TagOrigin::BinaryFile
@ BinaryFile
Indicates the tag originated from a binary file.
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:125
tag_reference::tagref_address
void * tagref_address
The address of the tagref data.
Definition: tags.h:295
BlamUserDataFolder::Tags
@ Tags
Directory storing user-created tags. Defaults to {DataRoot}/tags/.
field_reference::field_address
void * field_address
Definition: tags.h:459
BlamTagData::size
int size
The size of the tag's data in memory.
Definition: tags.h:133
tag_reference::ResolveReference
bool ResolveReference()
Attempts to resolve a tag reference.
Definition: tag_reference.cpp:9
tag_header::reserved0
char reserved0[0x24]
Definition: tag_io.h:35
tag_header::plugin_revision
uint32_t plugin_revision
Definition: tag_io.h:41
loading_tag_path
std::string loading_tag_path
Definition: tag_io.cpp:19
BlamTagClass
Class representing a tag class.
Definition: tags.h:202
BlamTagData::tag_class
std::string tag_class
The tag's short class name.
Definition: tags.h:146