Support RPG::Terms 0x1/0x3 defaulting semantics
RPG::Terms 0x3 if empty string will be present in a 2k database
but not a 2k3 database. This appears a one-off situation so it
is hacked in for now..
MODIFY
generator/csv/fields.csv
generator/csv/fields.csv
@@ -377,7 +377,7 @@ State,sp_change_max,f,Int32,0x41,0,0,0,Integer
State,sp_change_val,f,Int32,0x42,0,0,0,Integer
State,sp_change_map_steps,f,Int32,0x43,0,0,0,Integer
State,sp_change_map_val,f,Int32,0x44,0,0,0,Integer
-Terms,encounter,f,String,0x01,'',0,0,String
+Terms,encounter,f,String,0x01,'',1,0,String
Terms,special_combat,f,String,0x02,'',1,0,String
Terms,escape_success,f,String,0x03,'',1,0,String
Terms,escape_failure,f,String,0x04,'',1,0,String

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

MODIFY
src/reader_struct.cpp
src/reader_struct.cpp
@@ -118,7 +118,7 @@ void Struct<S>::WriteLcf(const S& obj, LcfWriter& stream) {
<< " after " << last
<< " in struct " << name
<< std::endl;
- if (!field->present_if_default && field->IsDefault(obj, ref)) {
+ if (!field->isPresentIfDefault(db_is2k3) && field->IsDefault(obj, ref)) {
continue;
}
stream.WriteInt(field->id);
@@ -143,7 +143,7 @@ int Struct<S>::LcfSize(const S& obj, LcfWriter& stream) {
continue;
}
//printf("%s\n", field->name);
- if (!field->present_if_default && field->IsDefault(obj, ref)) {
+ if (!field->isPresentIfDefault(db_is2k3) && field->IsDefault(obj, ref)) {
continue;
}
result += LcfReader::IntSize(field->id);

MODIFY
src/reader_struct.h
src/reader_struct.h
#include "rpg_treemap.h"
#include "rpg_rect.h"
#include "rpg_savepicture.h"
+#include "rpg_terms.h"
#include "data.h"
// Forward declarations
@@ -305,6 +306,15 @@ struct Field {
virtual void BeginXml(S& obj, XmlReader& stream) const = 0;
virtual void ParseXml(S& obj, const std::string& data) const = 0;
+ bool isPresentIfDefault(bool db_is2k3) const {
+ if (std::is_same<S,RPG::Terms>::value && db_is2k3 && (id == 0x3 || id == 0x1)) {
+ //Special case - only known fields that are 2k specific and not
+ //written to a 2k3 db if defaulted.
+ return false;
+ }
+ return present_if_default;
+ }
+
Field(int id, const char* name, bool present_if_default, bool is2k3) :
name(name), id(id), present_if_default(present_if_default), is2k3(is2k3) {}
};

Support RPG::Terms 0x1/0x3 defaulting semantics

RPG::Terms 0x3 if empty string will be present in a 2k database
but not a 2k3 database. This appears a one-off situation so it
is hacked in for now..