Add support for EmptyBlocks
MODIFY
generator/csv/fields.csv
generator/csv/fields.csv
@@ -591,11 +591,11 @@ Database,switches,f,Array<Switch>,0x17,,1,0,RPG::Switchs
Database,variables,f,Array<Variable>,0x18,,1,0,RPG::Variables
Database,commonevents,f,Array<CommonEvent>,0x19,,1,0,RPG::CommonEvent
Database,version,f,DatabaseVersion,0x1A,0,0,0,Indicates version of database. When 1 the database was converted to RPG Maker 2000 v1.61
-Database,commoneventD2,f,,0x1B,,0,1,Duplicated? - Not used - RPG2003
-Database,commoneventD3,f,,0x1C,,0,1,Duplicated? - Not used - RPG2003
+Database,commoneventD2,f,EmptyBlock,0x1B,,1,1,Duplicated? - Not used - RPG2003
+Database,commoneventD3,f,EmptyBlock,0x1C,,1,1,Duplicated? - Not used - RPG2003
Database,battlecommands,f,BattleCommands,0x1D,,1,1,RPG::BattleCommand - RPG2003
Database,classes,f,Array<Class>,0x1E,,1,1,RPG::Class - RPG2003
-Database,classD1,f,,0x1F,,0,1,Duplicated? - Not used - RPG2003
+Database,classD1,f,EmptyBlock,0x1F,,1,1,Duplicated? - Not used - RPG2003
Database,battleranimations,f,Array<BattlerAnimation>,0x20,,1,1,RPG::BattlerAnimation - RPG2003
Encounter,troop_id,f,Ref<Troop>,0x01,0,0,0,Integer
MapInfo,name,f,String,0x01,'',0,0,String. Note: Map ID 0 used to be game title but it should be ignored (TreeCtrl dummy editor dumped data); always use RPG_RT.ini GameTitle instead

MODIFY
generator/generate.py
generator/generate.py
@@ -41,6 +41,8 @@ def lcf_type(field, prefix=True):
return "SIZE"
if field.type == "DatabaseVersion":
return "DATABASE_VERSION"
+ if field.type == "EmptyBlock":
+ return "EMPTY"
return "TYPED"
def cpp_type(ty, prefix=True):
@@ -50,6 +52,9 @@ def cpp_type(ty, prefix=True):
if ty == "DatabaseVersion":
return 'int32_t'
+ if ty == "EmptyBlock":
+ return 'void'
+
m = re.match(r'Array<(.*):(.*)>', ty)
if m:
return 'std::vector<%s>' % cpp_type(m.group(1), prefix)
@@ -124,6 +129,11 @@ def filter_structs_without_codes(structs):
yield struct
def filter_unused_fields(fields):
+ for field in fields:
+ if field.type and field.type != "EmptyBlock":
+ yield field
+
+def filter_unwritten_fields(fields):
for field in fields:
if field.type:
yield field
@@ -368,6 +378,7 @@ def main(argv):
env.filters["pod_default"] = pod_default
env.filters["struct_has_code"] = filter_structs_without_codes
env.filters["field_is_used"] = filter_unused_fields
+ env.filters["field_is_written"] = filter_unwritten_fields
env.filters["num_flags"] = num_flags
env.filters["flag_size"] = flag_size
env.filters["flag_set"] = flag_set

MODIFY
generator/templates/reader.tmpl
generator/templates/reader.tmpl
#define LCF_CURRENT_STRUCT {{ struct_name }}
LCF_STRUCT_FIELDS_BEGIN()
-{%- for field in fields[struct_name]|field_is_used %}
+{%- for field in fields[struct_name]|field_is_written %}
LCF_STRUCT_{{ field|lcf_type }}_FIELD({{ field.type|cpp_type }}, {{ field.name }}, {{field.presentifdefault}}, {{field.is2k3}}),
{%- endfor %}
LCF_STRUCT_FIELDS_END()

MODIFY
src/generated/ldb_database.cpp
src/generated/ldb_database.cpp
Binary files a/src/generated/ldb_database.cpp and b/src/generated/ldb_database.cpp differ

MODIFY
src/reader_struct.h
src/reader_struct.h
@@ -454,6 +454,36 @@ struct DatabaseVersionField : public TypedField<S,T> {
}
};
+/**
+ * EmptyField class template.
+ */
+
+template <typename S>
+struct EmptyField : public Field<S> {
+
+ using Field<S>::Field;
+
+ void ReadLcf(S& obj, LcfReader& stream, uint32_t length) const { }
+ void WriteLcf(const S& obj, LcfWriter& stream) const { }
+ int LcfSize(const S& obj, LcfWriter& stream) const {
+ //This is always an "empty block"
+ return 0;
+ }
+ void WriteXml(const S& obj, XmlWriter& stream) const { }
+ void BeginXml(S& obj, XmlReader& stream) const { }
+ void ParseXml(S& obj, const std::string& data) const { }
+
+ bool IsDefault(const S& a, const S& b) const {
+ if (this->present_if_default) {
+ return false;
+ }
+ return true;
+ }
+
+};
+
+
+
/**
* SizeField class template.
*/
@@ -781,6 +811,14 @@ private:
, IS2K3 \
) \
+#define LCF_STRUCT_EMPTY_FIELD(T, REF, PRESENTIFDEFAULT, IS2K3) \
+ new EmptyField<RPG::LCF_CURRENT_STRUCT>( \
+ LCF_CHUNK_SUFFIX::BOOST_PP_CAT(Chunk, LCF_CURRENT_STRUCT)::REF \
+ , BOOST_PP_STRINGIZE(REF) \
+ , PRESENTIFDEFAULT \
+ , IS2K3 \
+ ) \
+
#define LCF_STRUCT_SIZE_FIELD(T, REF, PRESENTIFDEFAULT, IS2K3) \
new SizeField<RPG::LCF_CURRENT_STRUCT, T>( \
&RPG::LCF_CURRENT_STRUCT::REF \

Add support for EmptyBlocks