Change battle_commands type to vector<int32_t> and initialize it correctly
MODIFY
generator/csv/fields.csv
generator/csv/fields.csv
@@ -33,7 +33,7 @@ Actor,state_ranks,t,UInt8,0x47,,Integer
Actor,state_ranks,f,Vector<UInt8>,0x48,,Array - Short
Actor,attribute_ranks,t,UInt8,0x49,,Integer
Actor,attribute_ranks,f,Vector<UInt8>,0x4A,,Array - Short
-Actor,battle_commands,f,Vector<Ref<BattleCommand:UInt32>>,0x50,,Array - RPG::BattleCommand - RPG2003
+Actor,battle_commands,f,Vector<Ref<BattleCommand:Int32>>,0x50,,Array - RPG::BattleCommand - RPG2003
Sound,name,f,String,0x01,'',String
Sound,volume,f,Integer,0x03,100,Integer
Sound,tempo,f,Integer,0x04,100,Integer
@@ -122,7 +122,7 @@ Class,state_ranks,t,UInt8,0x47,,Integer
Class,state_ranks,f,Vector<UInt8>,0x48,,Array - Short
Class,attribute_ranks,t,UInt8,0x49,,Integer
Class,attribute_ranks,f,Vector<UInt8>,0x4A,,Array - Short
-Class,battle_commands,f,Vector<Ref<BattleCommand:UInt32>>,0x50,,Array - Uint32
+Class,battle_commands,f,Vector<Ref<BattleCommand:Int32>>,0x50,,Array - Uint32
CommonEvent,name,f,String,0x01,'',String
CommonEvent,trigger,f,Enum<CommonEvent_Trigger>,0x0B,0,Integer
CommonEvent,switch_flag,f,Boolean,0x0C,False,Flag
@@ -946,7 +946,7 @@ SaveActor,skills,f,Vector<Int16>,0x34,,short[]
SaveActor,equipped,f,Vector<Int16>,0x3D,,short[5]
SaveActor,current_hp,f,Integer,0x47,-1,int
SaveActor,current_sp,f,Integer,0x48,-1,int
-SaveActor,battle_commands,f,Vector<Ref<BattleCommand:UInt32>>,0x50,,array of (uncompressed) int32
+SaveActor,battle_commands,f,Vector<Ref<BattleCommand:Int32>>,0x50,,array of (uncompressed) int32
SaveActor,status_size,f,Integer,0x51,0,?
SaveActor,status,f,Vector<Int16>,0x52,,array of short
SaveActor,changed_class,f,Boolean,0x53,False,bool

MODIFY
generator/generate.py
generator/generate.py
@@ -32,6 +32,7 @@ cpp_types = {
'UInt16': 'uint16_t',
'UInt32': 'uint32_t',
'Int16': 'int16_t',
+ 'Int32': 'int32_t',
'String': 'std::string',
}

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

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

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

MODIFY
src/generated/rpg_actor.h
src/generated/rpg_actor.h
Binary files a/src/generated/rpg_actor.h and b/src/generated/rpg_actor.h differ

MODIFY
src/generated/rpg_class.h
src/generated/rpg_class.h
Binary files a/src/generated/rpg_class.h and b/src/generated/rpg_class.h differ

MODIFY
src/generated/rpg_saveactor.h
src/generated/rpg_saveactor.h
Binary files a/src/generated/rpg_saveactor.h and b/src/generated/rpg_saveactor.h differ

MODIFY
src/reader_lcf.cpp
src/reader_lcf.cpp
@@ -145,6 +145,22 @@ void LcfReader::Read<int16_t>(std::vector<int16_t> &buffer, size_t size) {
}
}
+template <>
+void LcfReader::Read<int32_t>(std::vector<int32_t> &buffer, size_t size) {
+ buffer.clear();
+ size_t items = size / 4;
+ for (unsigned int i = 0; i < items; ++i) {
+ int32_t val;
+ Read(&val, 4, 1);
+ SwapByteOrder(val);
+ buffer.push_back(val);
+ }
+ if (size % 4 != 0) {
+ Seek(size % 4, FromCurrent);
+ buffer.push_back(0);
+ }
+}
+
template <>
void LcfReader::Read<uint32_t>(std::vector<uint32_t> &buffer, size_t size) {
buffer.clear();
@@ -299,3 +315,8 @@ void LcfReader::SwapByteOrder(int16_t& s)
{
SwapByteOrder((uint16_t&) s);
}
+
+void LcfReader::SwapByteOrder(int32_t& s)
+{
+ SwapByteOrder((uint32_t&) s);
+}

MODIFY
src/reader_lcf.h
src/reader_lcf.h
@@ -234,6 +234,13 @@ private:
*/
static void SwapByteOrder(uint16_t &us);
+ /**
+ * Converts a 32bit signed integer to/from little-endian.
+ *
+ * @param us integer to convert.
+ */
+ static void SwapByteOrder(int32_t &us);
+
/**
* Converts a 32bit unsigned integer to/from little-endian.
*

MODIFY
src/rpg_setup.cpp
src/rpg_setup.cpp
@@ -46,11 +46,11 @@ void RPG::SaveActor::Setup(int actor_id) {
equipped.push_back(actor.initial_equipment.accessory_id);
current_hp = 0;
current_sp = 0;
- battle_commands = actor.battle_commands;
+ battle_commands.resize(7, -1);
status_size = 0;
status.clear();
changed_class = false;
- class_id = actor.class_id;
+ class_id = -1;
row = -1;
two_weapon = actor.two_weapon;
lock_equipment = actor.lock_equipment;

MODIFY
src/writer_lcf.cpp
src/writer_lcf.cpp
@@ -91,6 +91,17 @@ void LcfWriter::Write<int16_t>(const std::vector<int16_t>& buffer) {
Write(*it);
}
+template <>
+void LcfWriter::Write<int32_t>(const std::vector<int32_t>& buffer) {
+ std::vector<int32_t>::const_iterator it;
+ for (it = buffer.begin(); it != buffer.end(); it++) {
+ int32_t val = *it;
+ SwapByteOrder(val);
+ // Write<int> writes a compressed integer
+ Write(&val, 4, 1);
+ }
+}
+
template <>
void LcfWriter::Write<uint32_t>(const std::vector<uint32_t>& buffer) {
std::vector<uint32_t>::const_iterator it;
@@ -147,3 +158,8 @@ void LcfWriter::SwapByteOrder(int16_t& s)
{
SwapByteOrder((uint16_t&) s);
}
+
+void LcfWriter::SwapByteOrder(int32_t& s)
+{
+ SwapByteOrder((uint32_t&) s);
+}

MODIFY
src/writer_lcf.h
src/writer_lcf.h
@@ -115,6 +115,13 @@ private:
*/
static void SwapByteOrder(uint16_t &us);
+ /**
+ * Converts a 32bit signed integer to/from little-endian.
+ *
+ * @param us integer to convert.
+ */
+ static void SwapByteOrder(int32_t &us);
+
/**
* Converts a 32bit unsigned integer to/from little-endian.
*

Change battle_commands type to vector<int32_t> and initialize it correctly