Add CountField concept - for System party and menu
MODIFY
generator/csv/fields.csv
generator/csv/fields.csv
@@ -527,9 +527,9 @@ System,title_name,f,String,0x11,'',0,0,String
System,gameover_name,f,String,0x12,'',0,0,String
System,system_name,f,String,0x13,'',0,0,String
System,system2_name,f,String,0x14,'',0,1,String - RPG2003
-System,party,t,Int16,0x15,,0,0,Integer
+System,party,t,Count<Int16>,0x15,,0,0,Integer
System,party,f,Vector<Int16>,0x16,,1,0,Array - Short
-System,menu_commands,t,Int16,0x1A,,0,1,Integer - RPG2003
+System,menu_commands,t,Count<Int16>,0x1A,,0,1,Integer - RPG2003
System,menu_commands,f,Vector<Int16>,0x1B,,1,1,Array - Short - RPG2003
System,title_music,f,Music,0x1F,,0,0,RPG::Music
System,battle_music,f,Music,0x20,,0,0,RPG::Music

MODIFY
generator/generate.py
generator/generate.py
@@ -38,6 +38,9 @@ cpp_types = {
# Additional Jinja 2 functions
def lcf_type(field, prefix=True):
if field.size == True:
+ if re.match(r'Count<(.*)>', field.type):
+ return "COUNT"
+ else:
return "SIZE"
if field.type == "DatabaseVersion":
return "DATABASE_VERSION"
@@ -55,6 +58,10 @@ def cpp_type(ty, prefix=True):
if ty == "EmptyBlock":
return 'void'
+ m = re.match(r'Count<(.*)>', ty)
+ if m:
+ return cpp_type(m.group(1), prefix)
+
m = re.match(r'Array<(.*):(.*)>', ty)
if m:
return 'std::vector<%s>' % cpp_type(m.group(1), prefix)

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

MODIFY
src/reader_struct.h
src/reader_struct.h
@@ -523,6 +523,25 @@ struct SizeField : public Field<S> {
Field<S>(id, "", present_if_default, is2k3), ref(ref) {}
};
+
+/**
+ * CountField class template.
+ */
+template <class S, class T>
+struct CountField : public SizeField<S,T> {
+
+ using SizeField<S,T>::SizeField;
+
+ void WriteLcf(const S& obj, LcfWriter& stream) const {
+ int size = (obj.*(this->ref)).size();
+ TypeReader<int32_t>::WriteLcf(size, stream);
+ }
+ int LcfSize(const S& obj, LcfWriter& stream) const {
+ int size = (obj.*(this->ref)).size();
+ return LcfReader::IntSize(size);
+ }
+};
+
/**
* ID handling for Struct class.
*/
@@ -827,4 +846,12 @@ private:
, IS2K3 \
) \
+#define LCF_STRUCT_COUNT_FIELD(T, REF, PRESENTIFDEFAULT, IS2K3) \
+ new CountField<RPG::LCF_CURRENT_STRUCT, T>( \
+ &RPG::LCF_CURRENT_STRUCT::REF \
+ , LCF_CHUNK_SUFFIX::BOOST_PP_CAT(Chunk, LCF_CURRENT_STRUCT)::BOOST_PP_CAT(REF, _size) \
+ , PRESENTIFDEFAULT \
+ , IS2K3 \
+ ) \
+
#endif

Add CountField concept - for System party and menu