void Struct<S>::WriteLcf(const std::vector<S>& vec, LcfWriter& stream) { int count = vec.size(); stream.WriteInt(count); for (int i = 0; i < count; i++) { IDReader::WriteID(vec[i], stream); TypeReader<S>::WriteLcf(vec[i], stream); } }
void RawStruct<RPG::EventCommand>::WriteLcf(const RPG::EventCommand& event_command, LcfWriter& stream) { stream.Write(event_command.code); stream.Write(event_command.indent); stream.WriteInt(stream.Decode(event_command.string).size()); stream.Write(stream.Decode(event_command.string)); int count = event_command.parameters.size(); stream.Write(count); for (int i = 0; i < count; i++) stream.Write(event_command.parameters[i]); }
void Struct<RPG::Save>::WriteLcf(const RPG::Save& obj, LcfWriter& stream) { RPG::Save ref = RPG::Save(); int last = -1; for (int i = 0; fields[i] != NULL; i++) { const Field<RPG::Save>* field = fields[i]; if (field->id < last) std::cerr << "field order mismatch: " << field->id << " after " << last << " in struct " << name << std::endl; printf("\n%s", field->name); if (field->IsDefault(obj, ref)) { printf(" -> default"); continue; } stream.WriteInt(field->id); stream.WriteInt(field->LcfSize(obj, stream)); field->WriteLcf(obj, stream); } // stream.WriteInt(0); // This last byte broke savegames }
void Struct<S>::WriteLcf(const S& obj, LcfWriter& stream) { S ref = S(); int last = -1; for (int i = 0; fields[i] != NULL; i++) { const Field<S>* field = fields[i]; if (field->id < last) std::cerr << "field order mismatch: " << field->id << " after " << last << " in struct " << name << std::endl; //printf("\n%s", field->name); if (field->IsDefault(obj, ref)) { //printf(" -> default"); continue; } stream.WriteInt(field->id); stream.WriteInt(field->LcfSize(obj, stream)); field->WriteLcf(obj, stream); } stream.WriteInt(0); }
int RawStruct<RPG::EventCommand>::LcfSize(const RPG::EventCommand& event_command, LcfWriter& stream) { int result = 0; result += LcfReader::IntSize(event_command.code); result += LcfReader::IntSize(event_command.indent); result += LcfReader::IntSize(event_command.string.size()); result += stream.Decode(event_command.string).size(); int count = event_command.parameters.size(); result += LcfReader::IntSize(count); for (int i = 0; i < count; i++) result += LcfReader::IntSize(event_command.parameters[i]); return result; }
void RawStruct<RPG::MoveCommand>::WriteLcf(const RPG::MoveCommand& ref, LcfWriter& stream) { stream.WriteInt(ref.command_id); switch (ref.command_id) { case RPG::MoveCommand::Code::switch_on: stream.Write(ref.parameter_a); break; case RPG::MoveCommand::Code::switch_off: stream.Write(ref.parameter_a); break; case RPG::MoveCommand::Code::change_graphic: stream.WriteInt(stream.Decode(ref.parameter_string).size()); stream.Write(ref.parameter_string); stream.Write(ref.parameter_a); break; case RPG::MoveCommand::Code::play_sound_effect: stream.WriteInt(stream.Decode(ref.parameter_string).size()); stream.Write(ref.parameter_string); stream.Write(ref.parameter_a); stream.Write(ref.parameter_b); stream.Write(ref.parameter_c); break; } }
void RawStruct<RPG::Rect>::WriteLcf(const RPG::Rect& ref, LcfWriter& stream) { stream.Write(ref.l); stream.Write(ref.t); stream.Write(ref.r); stream.Write(ref.b); }